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:
co-authored by
Claude Opus 5.5
parent
b2f37f05b0
commit
1e93d30d1f
@@ -1,118 +0,0 @@
|
||||
export type BundleMeasurements = Readonly<{
|
||||
initialJsGzipBytes: number;
|
||||
lazyChunks: readonly Readonly<{ path: string; gzipBytes: number }>[];
|
||||
}>;
|
||||
|
||||
export type BundleThresholds = Readonly<{
|
||||
initialJsGzipBytes: number;
|
||||
lazyChunkGzipBytes: number;
|
||||
}>;
|
||||
|
||||
export function evaluateBundleBudget(
|
||||
measurements: BundleMeasurements,
|
||||
thresholds: BundleThresholds,
|
||||
) {
|
||||
const initialPassed =
|
||||
measurements.initialJsGzipBytes <= thresholds.initialJsGzipBytes;
|
||||
const lazyResults = measurements.lazyChunks.map((chunk) => ({
|
||||
...chunk,
|
||||
threshold: thresholds.lazyChunkGzipBytes,
|
||||
passed: chunk.gzipBytes <= thresholds.lazyChunkGzipBytes,
|
||||
}));
|
||||
return Object.freeze({
|
||||
initialPassed,
|
||||
lazyResults: Object.freeze(lazyResults),
|
||||
passed: initialPassed && lazyResults.every((chunk) => chunk.passed),
|
||||
});
|
||||
}
|
||||
|
||||
export type LabMetrics = Readonly<{
|
||||
lcpMs: number;
|
||||
cls: number;
|
||||
namedInteractionMs: number;
|
||||
}>;
|
||||
|
||||
export function evaluateLabBudget(
|
||||
report: Readonly<{
|
||||
context?: Readonly<Record<string, unknown>>;
|
||||
metrics: LabMetrics;
|
||||
}>,
|
||||
thresholds: LabMetrics,
|
||||
) {
|
||||
const requiredContext = [
|
||||
"runner",
|
||||
"browser",
|
||||
"viewport",
|
||||
"network",
|
||||
"cpu",
|
||||
"cache",
|
||||
"build",
|
||||
];
|
||||
const missingContext = requiredContext.filter(
|
||||
(field) => report.context?.[field] === undefined,
|
||||
);
|
||||
const results = {
|
||||
lcp: report.metrics.lcpMs <= thresholds.lcpMs,
|
||||
cls: report.metrics.cls <= thresholds.cls,
|
||||
namedInteraction:
|
||||
report.metrics.namedInteractionMs <= thresholds.namedInteractionMs,
|
||||
};
|
||||
return Object.freeze({
|
||||
missingContext: Object.freeze(missingContext),
|
||||
results: Object.freeze(results),
|
||||
passed: missingContext.length === 0 && Object.values(results).every(Boolean),
|
||||
});
|
||||
}
|
||||
|
||||
export function percentile75(values: readonly number[]): number | null {
|
||||
if (values.length === 0) return null;
|
||||
const sorted = [...values].sort((left, right) => left - right);
|
||||
return sorted[Math.ceil(sorted.length * 0.75) - 1];
|
||||
}
|
||||
|
||||
export type FieldMetrics = Readonly<{
|
||||
p75LcpMs: number | null;
|
||||
p75Cls: number | null;
|
||||
p75InpMs: number | null;
|
||||
}>;
|
||||
|
||||
export type FieldThresholds = Readonly<{
|
||||
p75LcpMs: number;
|
||||
p75Cls: number;
|
||||
p75InpMs: number;
|
||||
minimumEligibleSamples: number | null;
|
||||
}>;
|
||||
|
||||
export type FieldBudgetResult = Readonly<{
|
||||
status: "PASS" | "FAIL_THRESHOLD" | "FAIL_UNVERIFIED";
|
||||
passed: boolean;
|
||||
}>;
|
||||
|
||||
export function evaluateFieldBudget(
|
||||
report: Readonly<{ metrics: FieldMetrics; eligibleSamples: number }>,
|
||||
thresholds: FieldThresholds,
|
||||
): FieldBudgetResult {
|
||||
if (
|
||||
thresholds.minimumEligibleSamples === null ||
|
||||
report.eligibleSamples < thresholds.minimumEligibleSamples ||
|
||||
Object.values(report.metrics).some((value) => value === null)
|
||||
) {
|
||||
return Object.freeze({
|
||||
status: "FAIL_UNVERIFIED",
|
||||
passed: false,
|
||||
});
|
||||
}
|
||||
const metrics = report.metrics as Readonly<{
|
||||
p75LcpMs: number;
|
||||
p75Cls: number;
|
||||
p75InpMs: number;
|
||||
}>;
|
||||
const passed =
|
||||
metrics.p75LcpMs <= thresholds.p75LcpMs &&
|
||||
metrics.p75Cls <= thresholds.p75Cls &&
|
||||
metrics.p75InpMs <= thresholds.p75InpMs;
|
||||
return Object.freeze({
|
||||
status: passed ? "PASS" : "FAIL_THRESHOLD",
|
||||
passed,
|
||||
});
|
||||
}
|
||||
@@ -1,63 +0,0 @@
|
||||
export const PROMOTION_FORMULA = Object.freeze({
|
||||
MERGE_READY: Object.freeze([
|
||||
"FE-GATE-001",
|
||||
"FE-GATE-002",
|
||||
"FE-GATE-003",
|
||||
"FE-GATE-004",
|
||||
"FE-GATE-005",
|
||||
"FE-GATE-006",
|
||||
"FE-GATE-007",
|
||||
"FE-GATE-008",
|
||||
"FE-GATE-009",
|
||||
"FE-GATE-010",
|
||||
"FE-GATE-011",
|
||||
"FE-GATE-013",
|
||||
"FE-GATE-020",
|
||||
]),
|
||||
RELEASE_READY: Object.freeze([
|
||||
"FE-GATE-012",
|
||||
"FE-GATE-014",
|
||||
"FE-GATE-015",
|
||||
"FE-GATE-019",
|
||||
"FE-GATE-026",
|
||||
// FE-GATE-027. A candidate is only release-ready once it has been admitted
|
||||
// to a named environment; coherence alone never proved it belonged there.
|
||||
"FE-GATE-027",
|
||||
]),
|
||||
PROD_PROMOTION_READY: Object.freeze([
|
||||
"FE-GATE-016",
|
||||
"FE-GATE-021",
|
||||
"FE-GATE-022",
|
||||
"FE-GATE-023",
|
||||
"FE-GATE-024",
|
||||
"FE-GATE-025",
|
||||
]),
|
||||
FIELD_SLO_READY: Object.freeze(["FE-GATE-018"]),
|
||||
DOCUMENTATION_READY: Object.freeze(["FE-GATE-017"]),
|
||||
});
|
||||
|
||||
export type GateResult = "PASS" | "FAIL" | "UNVERIFIED";
|
||||
|
||||
export function evaluatePromotionReadiness(
|
||||
gateResults: Readonly<Record<string, GateResult>>,
|
||||
) {
|
||||
const allPass = (gateIds: readonly string[]) =>
|
||||
gateIds.every((gateId) => gateResults[gateId] === "PASS");
|
||||
|
||||
const mergeReady = allPass(PROMOTION_FORMULA.MERGE_READY);
|
||||
const releaseReady =
|
||||
mergeReady && allPass(PROMOTION_FORMULA.RELEASE_READY);
|
||||
const productionReady =
|
||||
releaseReady && allPass(PROMOTION_FORMULA.PROD_PROMOTION_READY);
|
||||
const fieldReady =
|
||||
productionReady && allPass(PROMOTION_FORMULA.FIELD_SLO_READY);
|
||||
const documentationReady = allPass(PROMOTION_FORMULA.DOCUMENTATION_READY);
|
||||
|
||||
return Object.freeze({
|
||||
MERGE_READY: mergeReady,
|
||||
RELEASE_READY: releaseReady,
|
||||
PROD_PROMOTION_READY: productionReady,
|
||||
FIELD_SLO_READY: fieldReady,
|
||||
DOCUMENTATION_READY: documentationReady,
|
||||
});
|
||||
}
|
||||
Reference in New Issue
Block a user