Files
clean-architecture-frontend…/scripts/check-app-build-input.ts
DongHyeonka 411c9338c6
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
revert: 그룹 C 검사기 PR(#55)을 되돌려 main 제거 드릴을 살린다
This reverts commit b489589403, reversing
changes made to 9e1cfd5975.

문제: 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 1 b4895894). 되돌린 트리는
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/.
2026-11-19 13:20:00 +09:00

144 lines
5.6 KiB
TypeScript

import { readFile } from "node:fs/promises";
import path from "node:path";
import {
createFileSystemDeclarationSource,
type TopologyDeclarationSource,
} from "./generate-product-feature-index.ts";
/**
* scale-architecture.md §3 / §37. Build-input regression gate for deployable-app isolation.
*
* The app being built is the one recorded in `src/.generated/product-app.ts`.
* Its allowed features are exactly those owned (via their context) by that
* app's declarations. The gate fails when
* - a generated index imports a feature or declares a context outside that
* ownership set (e.g. a regression back to "import every src/features"),
* - the production bundle's module inventory contains a module of a feature
* the app does not own.
*/
export type AppBuildInputReport = Readonly<{
appId: string;
ownedContexts: readonly string[];
ownedFeatureDirectories: readonly string[];
generatedFeatureImports: readonly string[];
generatedContexts: readonly string[];
bundle: Readonly<{ checked: boolean; featureDirectories: readonly string[] }>;
violations: readonly string[];
}>;
const GENERATED = [
"src/.generated/product-feature-index.ts",
"src/.generated/product-context-index.ts",
"src/.generated/product-app.ts",
] as const;
function unique(values: Iterable<string>): string[] {
return [...new Set(values)].sort();
}
export async function inspectAppBuildInput(
root: string,
options: Readonly<{
source?: TopologyDeclarationSource;
bundleInventory?: string | null;
}> = {},
): Promise<AppBuildInputReport> {
const source = options.source ?? (await createFileSystemDeclarationSource(root));
const [featureIndex, contextIndex, appIndex] = await Promise.all(
GENERATED.map((file) => readFile(path.join(root, file), "utf8")),
);
const appId = /id:\s*"([^"]+)"/u.exec(appIndex ?? "")?.[1];
const violations: string[] = [];
if (!appId || !source.app(appId)) {
violations.push(`generated app ${appId ?? "<missing>"} is not a declared deployable app`);
}
const ownedContexts = appId ? source.contextsOf(appId).map((context) => context.id) : [];
const ownedFeatureDirectories = unique(
ownedContexts.flatMap((contextId) => source.featuresOf(contextId).map((feature) => feature.directory)),
);
const owned = new Set(ownedFeatureDirectories);
const featureDirectoriesIn = (text: string) =>
unique([...text.matchAll(/\.\.\/features\/([^/"']+)\//gu)].map((match) => match[1] as string));
const generatedFeatureImports = unique([
...featureDirectoriesIn(featureIndex ?? ""),
...featureDirectoriesIn(contextIndex ?? ""),
]);
for (const directory of generatedFeatureImports) {
if (!owned.has(directory)) {
violations.push(`generated index imports feature "${directory}" not owned by app ${appId}`);
}
}
const generatedContexts = unique(
[...(contextIndex ?? "").matchAll(/defineBoundedContextModule\(\{\s*id:\s*"([^"]+)"/gu)].map(
(match) => match[1] as string,
),
);
const ownedContextSet = new Set(ownedContexts);
for (const contextId of generatedContexts) {
if (!ownedContextSet.has(contextId)) {
violations.push(`generated index declares context "${contextId}" not owned by app ${appId}`);
}
}
let bundle: AppBuildInputReport["bundle"] = { checked: false, featureDirectories: [] };
const inventoryPath =
options.bundleInventory === undefined
? path.join(root, "artifacts/quality/vite-module-inventory.json")
: options.bundleInventory;
if (inventoryPath) {
const raw = await readFile(inventoryPath, "utf8").catch(() => null);
if (raw !== null) {
const inventory = JSON.parse(raw) as { chunks?: { modules?: string[] }[] };
const modules = (inventory.chunks ?? []).flatMap((chunk) => chunk.modules ?? []);
const featureDirectories = unique(
modules.flatMap((module) => {
const match = /^src\/features\/([^/]+)\//u.exec(module);
return match ? [match[1] as string] : [];
}),
);
bundle = { checked: true, featureDirectories };
for (const directory of featureDirectories) {
if (!owned.has(directory)) {
violations.push(`production bundle contains feature "${directory}" not owned by app ${appId}`);
}
}
}
}
return Object.freeze({
appId: appId ?? "",
ownedContexts: unique(ownedContexts),
ownedFeatureDirectories,
generatedFeatureImports,
generatedContexts,
bundle,
violations,
});
}
async function main(): Promise<void> {
// The bundle inventory is only meaningful right after a build of this tree;
// without `--require-bundle` the gate checks the generated indexes only, so a
// stale inventory from another build can never pass or fail it.
const requireBundle = process.argv.includes("--require-bundle");
const report = await inspectAppBuildInput(process.cwd(), requireBundle ? {} : { bundleInventory: null });
if (requireBundle && !report.bundle.checked) {
process.stderr.write("app build input: no production module inventory; run the build first\n");
process.exit(1);
}
for (const violation of report.violations) process.stderr.write(`FAIL ${violation}\n`);
process.stdout.write(
`app build input: app=${report.appId} contexts=${report.ownedContexts.length} ` +
`features=${report.ownedFeatureDirectories.length} generatedImports=${report.generatedFeatureImports.length} ` +
`bundle=${report.bundle.checked ? `${report.bundle.featureDirectories.length} feature dirs` : "not checked"} ` +
`${report.violations.length === 0 ? "PASS" : "FAIL"}\n`,
);
if (report.violations.length > 0) process.exitCode = 1;
}
if (import.meta.url === `file://${process.argv[1]}`) {
await main();
}