frontend-quality-gates / FE-GATE-017 / diagram-review (pull_request) Skipped
frontend-quality-gates / main / self-tests and removal drills (pull_request) Skipped
frontend-quality-gates / merge / static checks (pull_request) Successful in 1m9s
frontend-quality-gates / merge / tests (pull_request) Successful in 10m55s
frontend-quality-gates / merge / browser tests (pull_request) Successful in 5m11s
frontend-quality-gates / FE-GATE-014 / config-compatibility (pull_request) Skipped
frontend-quality-gates / FE-GATE-028 / manual-accessibility-review (pull_request) Skipped
frontend-quality-gates / FE-GATE-026 / lab-performance (pull_request) Skipped
frontend-quality-gates / FE-GATE-015 / immutable-release-candidate (pull_request) Skipped
frontend-quality-gates / external-vulnerability-provider (pull_request) Skipped
frontend-quality-gates / external-provenance-provider (pull_request) Skipped
frontend-quality-gates / promote-verified-immutable-candidate (pull_request) Skipped
frontend-quality-gates / deploy-promoted-release (pull_request) Skipped
frontend-quality-gates / FE-GATE-019 / hosting-header (pull_request) Skipped
frontend-quality-gates / FE-GATE-021 / runbook-boot-config (pull_request) Skipped
frontend-quality-gates / FE-GATE-022 / runbook-chunk-mismatch (pull_request) Skipped
frontend-quality-gates / FE-GATE-023 / runbook-api-degradation (pull_request) Skipped
frontend-quality-gates / FE-GATE-024 / runbook-telemetry (pull_request) Skipped
frontend-quality-gates / FE-GATE-025 / runbook-release-rollback (pull_request) Skipped
frontend-quality-gates / FE-GATE-018 / field-web-vitals (pull_request) Skipped
This reverts commitb489589403, reversing changes made to9e1cfd5975. 문제: main run 376(b4895894)의 `main / self-tests and removal drills` job에서 FE-GATE-030이 실패한다. browser-file-storage 제거 드릴 사본에서 tests/unit/test-evidence-source-rules.test.ts 6건이 모두 같은 이유로 떨어진다. scripts/check-test-evidence.ts의 missingForbidOnly가 playwright.capabilities.config.ts를 읽다 ENOENT로 죽는다. #55가 forbidOnly 검사를 전체 검사에서 fixture 모드까지 모든 모드로 옮겼다. 드릴은 그 설정 파일을 지우지만 config/repository-layout.json의 playwright-configs 목록에는 그대로 남는다. 이 job은 main 단계에만 있어 PR run에서는 돌지 않았다. 고른 방법: CI 매뉴얼 9.3대로 main을 먼저 초록으로 돌리려고 #55 병합 커밋을 통째로 되돌린다(git revert -m 1b4895894). 되돌린 트리는9e1cfd59트리(9b3237dd)와 같다. 버린 대안: 그 자리에서 고치기(없는 설정을 건너뛰거나, 드릴이 목록에서도 빼기)는 어느 쪽이 맞는지 판단과 검증이 필요해 main 빨강이 길어진다. 고침은 #55를 다시 올리는 PR에서 한다. 위험·한계: #55의 고침 12커밋(검사기 진단과 시험 빈틈)이 main에서 빠진다. 다시 올릴 때 이 드릴(FE-GATE-030, main 단계)을 PR 쪽에서 따로 돌리지 않으면 같은 일이 다시 난다. 검증: desktop 공유 잠금 아래 test:browser-file-storage-removal.b4895894트리(7536337a) 3회 모두 rc=1(64·69·53초). 3회차 로그에서 6건 실패, 6건 모두 run 376과 같은 ENOENT(playwright.capabilities.config.ts).9e1cfd59트리(9b3237dd, 이 커밋의 트리) 1회 rc=0(92초). 로그 desktop /tmp/claude-gates/fe-run376-b489-removal/, fe-run376-9e1c-removal/.
272 lines
8.5 KiB
TypeScript
272 lines
8.5 KiB
TypeScript
import { mkdir, readFile, stat } from "node:fs/promises";
|
|
|
|
import { optionalRecipesArtifactSchema } from "./contracts/release-artifacts.ts";
|
|
import {
|
|
measureOptionalRecipeBundle,
|
|
type OptionalRecipeBundleMeasurement,
|
|
} from "./lib/optional-recipe-bundle.ts";
|
|
import {
|
|
scanOptionalRecipeSources,
|
|
scanProductionBundle,
|
|
validateRecipeCatalog,
|
|
} from "./lib/optional-recipes.ts";
|
|
import { assertMatchesJsonSchema } from "./lib/json-schema.ts";
|
|
import { writeValidatedJsonArtifact } from "./lib/validated-json-artifact.ts";
|
|
|
|
type GateViolation = Readonly<{
|
|
ruleId: string;
|
|
path: string;
|
|
detail?: string;
|
|
}>;
|
|
|
|
type ReferenceRuntimeBundleInput = Readonly<{
|
|
recipeId: string;
|
|
sourceRoots: readonly string[];
|
|
bundleBudgetGzipBytes: number;
|
|
}>;
|
|
|
|
const argument = (name: string, fallback: string): string => {
|
|
const index = process.argv.indexOf(name);
|
|
return index === -1 ? fallback : (process.argv[index + 1] ?? fallback);
|
|
};
|
|
|
|
const catalogPath = argument(
|
|
"--catalog",
|
|
"config/recipes/frontend-capability-recipes.json",
|
|
);
|
|
const sourceRoot = argument("--source-root", "src");
|
|
const distRoot = argument("--dist-root", "dist");
|
|
const artifactPath = argument(
|
|
"--artifact",
|
|
"artifacts/quality/optional-recipes.json",
|
|
);
|
|
const requireDist = process.argv.includes("--require-dist");
|
|
|
|
const catalog = JSON.parse(
|
|
await readFile(catalogPath, "utf8"),
|
|
) as Record<string, unknown>;
|
|
const recipes = Array.isArray(catalog.recipes) ? catalog.recipes : [];
|
|
const packageDocument = JSON.parse(
|
|
await readFile("package.json", "utf8"),
|
|
) as Record<string, unknown>;
|
|
const catalogSchemaViolations: string[] = [];
|
|
try {
|
|
assertMatchesJsonSchema(
|
|
JSON.parse(
|
|
await readFile(
|
|
"config/schemas/recipes/frontend-capability-recipes.schema.json",
|
|
"utf8",
|
|
),
|
|
),
|
|
catalog,
|
|
"optional recipe catalog",
|
|
);
|
|
} catch {
|
|
catalogSchemaViolations.push("CATALOG_JSON_SCHEMA_INVALID");
|
|
}
|
|
const catalogViolations = [
|
|
...catalogSchemaViolations,
|
|
...validateRecipeCatalog(catalog, packageDocument),
|
|
];
|
|
const runtimeSourceViolations = (
|
|
await Promise.all(
|
|
recipes.flatMap((recipe: unknown) => {
|
|
if (!recipe || typeof recipe !== "object") return [];
|
|
const row = recipe as Record<string, unknown>;
|
|
const runtime = row.referenceRuntime;
|
|
if (!runtime || typeof runtime !== "object") return [];
|
|
const sourceRoots = (runtime as Record<string, unknown>).sourceRoots;
|
|
if (!Array.isArray(sourceRoots)) return [];
|
|
return sourceRoots
|
|
.filter(
|
|
(sourceRoot): sourceRoot is string =>
|
|
typeof sourceRoot === "string",
|
|
)
|
|
.map(async (sourceRoot) => ({
|
|
sourceRoot,
|
|
exists: await stat(sourceRoot)
|
|
.then(() => true)
|
|
.catch(() => false),
|
|
}));
|
|
}),
|
|
)
|
|
).filter(({ exists }) => !exists);
|
|
const {
|
|
inputs: referenceRuntimeBundleInputs,
|
|
violations: referenceRuntimeBundleConfigurationViolations,
|
|
} = referenceRuntimeBundleInputsFrom(recipes);
|
|
const referenceRuntimeBundles: OptionalRecipeBundleMeasurement[] = [];
|
|
const referenceRuntimeBundleMeasurementViolations: GateViolation[] = [];
|
|
for (const bundleInput of referenceRuntimeBundleInputs) {
|
|
try {
|
|
const measurement = await measureOptionalRecipeBundle(bundleInput);
|
|
referenceRuntimeBundles.push(measurement);
|
|
if (!measurement.passed) {
|
|
referenceRuntimeBundleMeasurementViolations.push({
|
|
ruleId: "REFERENCE_RUNTIME_BUNDLE_BUDGET_EXCEEDED",
|
|
path: measurement.recipeId,
|
|
detail:
|
|
`${measurement.gzipBytes} > ` +
|
|
`${measurement.bundleBudgetGzipBytes} gzip bytes`,
|
|
});
|
|
}
|
|
} catch (error) {
|
|
referenceRuntimeBundleMeasurementViolations.push({
|
|
ruleId: "REFERENCE_RUNTIME_BUNDLE_MEASUREMENT_FAILED",
|
|
path: bundleInput.recipeId,
|
|
detail: safeErrorSummary(error),
|
|
});
|
|
}
|
|
}
|
|
referenceRuntimeBundles.sort((left, right) =>
|
|
compareText(left.recipeId, right.recipeId),
|
|
);
|
|
const sourceViolations = await scanOptionalRecipeSources(sourceRoot);
|
|
const bundlePresent = await stat(`${distRoot}/.vite/manifest.json`)
|
|
.then(() => true)
|
|
.catch(() => false);
|
|
const bundleViolations = await scanProductionBundle(distRoot);
|
|
const violations: GateViolation[] = [
|
|
...catalogViolations.map((ruleId) => ({ ruleId, path: catalogPath })),
|
|
...runtimeSourceViolations.map(({ sourceRoot }) => ({
|
|
ruleId: "REFERENCE_RUNTIME_SOURCE_MISSING",
|
|
path: sourceRoot,
|
|
})),
|
|
...sourceViolations,
|
|
...bundleViolations.map((path) => ({
|
|
ruleId: "UNSELECTED_RECIPE_IN_PRODUCTION_BUNDLE",
|
|
path,
|
|
})),
|
|
...(requireDist && !bundlePresent
|
|
? [{ ruleId: "PRODUCTION_BUNDLE_MISSING", path: distRoot }]
|
|
: []),
|
|
...referenceRuntimeBundleConfigurationViolations,
|
|
...referenceRuntimeBundleMeasurementViolations,
|
|
];
|
|
const report = optionalRecipesArtifactSchema.parse({
|
|
schemaVersion: 1,
|
|
decisionId: "VD-10",
|
|
selectedCapabilities: [],
|
|
referenceRuntimes: recipes
|
|
.filter(
|
|
(recipe: unknown): recipe is Record<string, unknown> =>
|
|
Boolean(
|
|
recipe &&
|
|
typeof recipe === "object" &&
|
|
(recipe as Record<string, unknown>).referenceRuntime,
|
|
),
|
|
)
|
|
.map((recipe: Record<string, unknown>) => ({
|
|
id: recipe.id,
|
|
referenceRuntime: recipe.referenceRuntime,
|
|
})),
|
|
recipeCount: recipes.length,
|
|
productionRuntimeDependencies:
|
|
catalog.productionRuntimeDependencies ?? null,
|
|
referenceRuntimeBundleBudgets: referenceRuntimeBundles,
|
|
bundleStatus: bundlePresent
|
|
? bundleViolations.length === 0
|
|
? "PASS"
|
|
: "FAIL"
|
|
: "NOT_BUILT",
|
|
violations,
|
|
passed: violations.length === 0,
|
|
});
|
|
await mkdir("artifacts/quality", { recursive: true });
|
|
await writeValidatedJsonArtifact({
|
|
path: artifactPath,
|
|
schema: optionalRecipesArtifactSchema,
|
|
value: report,
|
|
});
|
|
|
|
if (violations.length > 0) {
|
|
process.stderr.write(
|
|
`Optional recipe contract failed:\n${violations
|
|
.map(
|
|
(violation) =>
|
|
`${violation.ruleId}: ${violation.path}` +
|
|
(violation.detail ? ` (${violation.detail})` : ""),
|
|
)
|
|
.join("\n")}\n`,
|
|
);
|
|
process.exit(1);
|
|
}
|
|
const referenceRuntimeBudgetStatus =
|
|
referenceRuntimeBundles.length > 0
|
|
? `, budgets=${referenceRuntimeBundles
|
|
.map(
|
|
(measurement) =>
|
|
`${measurement.recipeId}:${measurement.gzipBytes}/` +
|
|
measurement.bundleBudgetGzipBytes,
|
|
)
|
|
.join(",")} gzip bytes`
|
|
: "";
|
|
process.stdout.write(
|
|
`Optional recipes: PASS (${report.recipeCount} optional capabilities, ${report.referenceRuntimes.length} uncomposed reference runtimes, bundle=${report.bundleStatus}${referenceRuntimeBudgetStatus})\n`,
|
|
);
|
|
|
|
function referenceRuntimeBundleInputsFrom(
|
|
recipeRows: readonly unknown[],
|
|
): Readonly<{
|
|
inputs: readonly ReferenceRuntimeBundleInput[];
|
|
violations: readonly GateViolation[];
|
|
}> {
|
|
const inputs: ReferenceRuntimeBundleInput[] = [];
|
|
const violations: GateViolation[] = [];
|
|
for (const recipe of recipeRows) {
|
|
if (!recipe || typeof recipe !== "object") continue;
|
|
const row = recipe as Record<string, unknown>;
|
|
if (row.referenceRuntime === undefined) continue;
|
|
const recipeId =
|
|
typeof row.id === "string" ? row.id : "unknown-reference-runtime";
|
|
const runtime = row.referenceRuntime;
|
|
const sourceRoots =
|
|
runtime && typeof runtime === "object"
|
|
? (runtime as Record<string, unknown>).sourceRoots
|
|
: null;
|
|
if (
|
|
!Array.isArray(sourceRoots) ||
|
|
!sourceRoots.every(
|
|
(sourceRoot): sourceRoot is string =>
|
|
typeof sourceRoot === "string",
|
|
) ||
|
|
!Number.isSafeInteger(row.bundleBudgetGzipBytes) ||
|
|
(row.bundleBudgetGzipBytes as number) < 1
|
|
) {
|
|
violations.push({
|
|
ruleId: "REFERENCE_RUNTIME_BUNDLE_CONFIGURATION_INVALID",
|
|
path: recipeId,
|
|
});
|
|
continue;
|
|
}
|
|
inputs.push(
|
|
Object.freeze({
|
|
recipeId,
|
|
sourceRoots: Object.freeze([...sourceRoots]),
|
|
bundleBudgetGzipBytes: row.bundleBudgetGzipBytes as number,
|
|
}),
|
|
);
|
|
}
|
|
return Object.freeze({
|
|
inputs: Object.freeze(
|
|
inputs.sort((left, right) =>
|
|
compareText(left.recipeId, right.recipeId),
|
|
),
|
|
),
|
|
violations: Object.freeze(violations),
|
|
});
|
|
}
|
|
|
|
function safeErrorSummary(error: unknown): string {
|
|
const message =
|
|
error instanceof Error ? error.message : "unknown measurement failure";
|
|
return message
|
|
.split(/\r?\n/, 1)[0]
|
|
?.replaceAll(process.cwd(), ".")
|
|
.slice(0, 512) ?? "unknown measurement failure";
|
|
}
|
|
|
|
function compareText(left: string, right: string): number {
|
|
return left < right ? -1 : left > right ? 1 : 0;
|
|
}
|