diff --git a/.dependency-cruiser.json b/.dependency-cruiser.json index c48b20db..1bfd017d 100644 --- a/.dependency-cruiser.json +++ b/.dependency-cruiser.json @@ -320,27 +320,5 @@ "circular": true } } - ], - "options": { - "doNotFollow": { - "path": "node_modules" - }, - "exclude": { - "path": "^(dist|artifacts|tests/fixtures)" - }, - "enhancedResolveOptions": { - "exportsFields": [ - "exports" - ], - "conditionNames": [ - "import", - "require", - "node", - "default" - ] - }, - "tsConfig": { - "fileName": "tsconfig.app.json" - } - } + ] } diff --git a/docs/architecture/decisions/VD-01-typescript-lint-tooling.md b/docs/architecture/decisions/VD-01-typescript-lint-tooling.md index 408a0c7f..0da66728 100644 --- a/docs/architecture/decisions/VD-01-typescript-lint-tooling.md +++ b/docs/architecture/decisions/VD-01-typescript-lint-tooling.md @@ -50,7 +50,10 @@ architecture/security/type negative input으로 전환했다. 이는 7번 결정 - `check:types`는 app, Node scripts/config, tests project를 모두 검사한다. - TS invalid-call, invalid port, discriminated-union fixture는 실패해야 한다. -- ESLint와 dependency-cruiser는 TS/TSX architecture fixture를 검사한다. +- ESLint와 `check:architecture`의 import 그래프(`scripts/check-architecture.ts`)가 + TS/TSX architecture fixture를 검사한다. dependency-cruiser 18은 TypeScript 7을 + 해석하지 못해 0개 모듈을 검사하고 통과했으므로 실행하지 않는다(리뷰 12-05). + `.dependency-cruiser.json`은 이름만 남은 규칙 파일이고 그래프가 읽는다. - registry scanner는 TS registry의 required field, uniqueness와 reference를 검증한다. - browser security gate는 TSX의 금지된 raw HTML fixture를 거절한다. diff --git a/docs/architecture/frontend-platform-capability-review.md b/docs/architecture/frontend-platform-capability-review.md index 4df124ee..12281e55 100644 --- a/docs/architecture/frontend-platform-capability-review.md +++ b/docs/architecture/frontend-platform-capability-review.md @@ -65,7 +65,7 @@ P0/P1 acceptance와 P2 recipe 기본값은 `LOCAL_TEMPLATE_READY`다. 다만 실 | 영역 | 현재 판정 | 근거 | 필요한 다음 상태 | | --- | --- | --- | --- | | 부트·런타임 설정 | 준비됨 | `src/bootstrap`, runtime schema, release 검사 | 현 상태 유지, TS 전환 시 동일 게이트 유지 | -| 계층 의존 방향 | 준비됨 | dependency-cruiser + TS-aware static graph, unresolved/parse/layer/cycle negative fixture | 새 rule shape와 source extension도 같은 fail-closed graph에 추가 | +| 계층 의존 방향 | 준비됨 | TS-aware static graph(`scripts/check-architecture.ts`, 규칙 `.dependency-cruiser.json`), unresolved/parse/layer/cycle negative fixture. dependency-cruiser 자체는 TS 7을 해석하지 못해 실행하지 않음(12-05) | 새 rule shape와 source extension도 같은 fail-closed graph에 추가 | | application facade | 준비됨 | module-augmented feature input registry, typed output catalog, provider, production composition test | feature별 input contribution과 제거 gate 유지 | | REST HTTP client | 준비됨 + hardening delta | reference vertical의 path/search/body projection, attempt timeout/retry, abort/cleanup은 `COMPOSED` | auth fail-close/final invariant, total deadline, bounded decoder, status/media/CSRF/conditional/pagination은 `DESIGNED_NOT_IMPLEMENTED` | | Browser RPC 공통 계약/runtime | 준비됨/미조립 | V3 operation/profile registry, typed application port, bounded unary/server-stream lifecycle와 unavailable adapter는 `AVAILABLE_NOT_COMPOSED` | actual descriptor/generated client, protocol transport, proxy/provider/browser conformance | diff --git a/docs/architecture/layers.md b/docs/architecture/layers.md index ee660127..3bb072c3 100644 --- a/docs/architecture/layers.md +++ b/docs/architecture/layers.md @@ -92,8 +92,9 @@ application APIs augment the generic typed input registry. Concrete output ports are composed in bootstrap and stay hidden behind the application facade. Project-selected capabilities still implement the same output boundaries. -`check:architecture` keeps dependency-cruiser's report and adds the -authoritative TypeScript-aware graph below it: +`check:architecture` writes the TypeScript-aware graph below. It reads the rules +from `.dependency-cruiser.json` but does not run dependency-cruiser, which cannot +parse TypeScript 7 and checked zero modules (review 12-05): ```json { diff --git a/docs/architecture/overview.md b/docs/architecture/overview.md index 9c52370a..9f8579db 100644 --- a/docs/architecture/overview.md +++ b/docs/architecture/overview.md @@ -53,8 +53,9 @@ and exact input type. Route contracts/codecs, the route-input provider, and lazy runtime modules are separate modules so feature pages do not import the router that loads them. Expected application failures use the shared `Result`/`AppFailure` contract. -The architecture gate analyzes TS/TSX imports independently of -dependency-cruiser, rejects local JavaScript-family specifiers and executable +The architecture gate analyzes TS/TSX imports with its own graph (the rules +live in `.dependency-cruiser.json`; dependency-cruiser itself cannot parse +TypeScript 7 and does not run), rejects local JavaScript-family specifiers and executable JavaScript-family files, and fails on unresolved imports, parse failures, forbidden layer edges, or cycles. The remaining project-owned work includes selecting and verifying real hosting, identity, telemetry, vulnerability and diff --git a/docs/architecture/typescript-state-and-data-flow.md b/docs/architecture/typescript-state-and-data-flow.md index 32fa998f..b0ff4529 100644 --- a/docs/architecture/typescript-state-and-data-flow.md +++ b/docs/architecture/typescript-state-and-data-flow.md @@ -52,7 +52,9 @@ TypeScript 전환 목적은 확장자 변경이 아니라 이 계약을 컴파 1. ESLint가 product와 negative fixture의 `ts`/`tsx`를 모두 검사한다. 2. React Hooks 규칙을 추가하고 TypeScript/ESLint parser와 JSX accessibility 도구는 설치된 compiler/linter의 공식 peer 범위 안에서 선택한다. -3. dependency-cruiser의 extension과 resolver가 TS/TSX를 포함한다. +3. `check:architecture`의 import 그래프가 TS/TSX를 해석한다. 규칙은 + `.dependency-cruiser.json`에 있지만 dependency-cruiser는 실행하지 않는다. + TypeScript 7을 해석하지 못해 0개 모듈을 검사했기 때문이다(리뷰 12-05). 4. `scripts/check-registries.ts`가 TS/TSX를 검색한다. 5. `config/contracts/registry-governance.json`과 승인 baseline은 `.ts/.tsx` source 경로를 사용한다. diff --git a/docs/operations/ci-quality-gates.md b/docs/operations/ci-quality-gates.md index 89239eed..e7fc020e 100644 --- a/docs/operations/ci-quality-gates.md +++ b/docs/operations/ci-quality-gates.md @@ -115,9 +115,11 @@ MERGE_READY DOCUMENTATION_READY (off-chain) ``` -`check:architecture`는 dependency-cruiser 결과와 별도로 Babel parser/Node -resolver 기반 `staticImportGraph`를 `artifacts/quality/dependency-report.json`에 -기록한다. TS/TSX의 static, dynamic, type, CommonJS 및 JSDoc import를 검사하고, +`check:architecture`는 Babel parser/Node resolver 기반 `staticImportGraph`를 +`artifacts/quality/dependency-report.json`에 기록한다. 규칙은 +`.dependency-cruiser.json`에서 읽지만 dependency-cruiser는 실행하지 않는다. +dependency-cruiser 18은 TypeScript 7을 해석하지 못해 0개 모듈을 검사하고 +통과했다(리뷰 12-05). TS/TSX의 static, dynamic, type, CommonJS 및 JSDoc import를 검사하고, 로컬 source import에는 실제 TypeScript 확장자를 요구한다. 실행 source나 로컬 specifier에 `.js/.jsx/.mjs/.cjs`가 있거나 unresolved dependency, parse failure, error-severity layer violation, cycle 또는 지원하지 않는 architecture rule diff --git a/scripts/check-architecture.ts b/scripts/check-architecture.ts index 0683b130..2f79ed93 100644 --- a/scripts/check-architecture.ts +++ b/scripts/check-architecture.ts @@ -53,7 +53,6 @@ type GraphFixtureResult = Readonly<{ failures: string[]; }>; type DependencyResolution = Readonly<{ path?: string; reason: string }>; -type DependencyCruiserReport = Record; type TypeScriptOnlyPolicy = Readonly<{ checkedRoots: readonly string[]; exceptionsAllowed: false; @@ -111,27 +110,15 @@ function runPnpm(arguments_: string[]) { }); } -// Keep dependency-cruiser's report and checks. The second graph is authoritative -// for TypeScript 7 coverage because dependency-cruiser 18 cannot parse TS 7 yet. -const dependencyCruiser = runPnpm([ - "exec", - "depcruise", - "src", - "--config", - ".dependency-cruiser.json", - "--output-type", - "json", -]); +// 12-05 (D-11): this graph is the only architecture checker. dependency-cruiser +// 18 cannot parse TypeScript 7, so it cruised zero modules and still passed. +// .dependency-cruiser.json keeps its name and is read here as the rule file. const sourceGraph = await analyzeSourceGraph(sourceRoot, "src"); const typeScriptOnlyPolicy = await inspectTypeScriptOnlyPolicy(); const graphFixtureResult = await runGraphFixtureChecks(); -const dependencyReport = parseDependencyCruiserReport(dependencyCruiser.stdout); const graphErrors = blockingViolations(sourceGraph); -const dependencyCruiserReportValid = !( - "dependencyCruiserOutput" in dependencyReport -); -dependencyReport.staticImportGraph = { +const staticImportGraph = { analyzer: "babel-parser-node-resolver", modules: sourceGraph.modules, dependencies: sourceGraph.dependencies, @@ -162,25 +149,11 @@ dependencyReport.staticImportGraph = { await writeValidatedJsonArtifact({ path: qualityArtifact, schema: architectureDependencyReportArtifactSchema, - value: dependencyReport, + value: { staticImportGraph }, }); let architectureFailed = false; -if (!dependencyCruiserReportValid) { - architectureFailed = true; - process.stderr.write("dependency-cruiser returned an invalid JSON report\n"); -} - -if (dependencyCruiser.status !== 0) { - architectureFailed = true; - process.stderr.write( - (dependencyCruiser.error?.message ?? dependencyCruiser.stderr) || - dependencyCruiser.stdout || - "dependency-cruiser failed\n", - ); -} - for (const failure of sourceGraph.parseFailures) { architectureFailed = true; process.stderr.write( @@ -1186,17 +1159,3 @@ function isPathRule(value: unknown, allowCircular: boolean): value is PathRule { function isRecord(value: unknown): value is Record { return Boolean(value && typeof value === "object" && !Array.isArray(value)); } - -function parseDependencyCruiserReport( - output: string, -): DependencyCruiserReport { - try { - const report: unknown = JSON.parse(output); - if (!report || typeof report !== "object" || Array.isArray(report)) { - throw new Error("dependency-cruiser report must be a JSON object"); - } - return report as DependencyCruiserReport; - } catch { - return { summary: { errors: 1 }, dependencyCruiserOutput: output }; - } -} diff --git a/scripts/contracts/release-artifacts.ts b/scripts/contracts/release-artifacts.ts index 63c6f425..2d74a89c 100644 --- a/scripts/contracts/release-artifacts.ts +++ b/scripts/contracts/release-artifacts.ts @@ -979,33 +979,11 @@ const staticImportGraphSchema = z context.addIssue({ code: "custom", path: ["typeScriptOnlySourcePolicy", "passed"], message: "must agree with violations and summary" }); } }); -const dependencyCruiserSummarySchema = z - .object({ - violations: z.array(jsonObject), - error: z.int().nonnegative(), - warn: z.int().nonnegative(), - info: z.int().nonnegative(), - ignore: z.int().nonnegative(), - totalCruised: z.int().nonnegative(), - totalDependenciesCruised: z.int().nonnegative(), - }) - .catchall(z.json()); -export const architectureDependencyReportArtifactSchema = z.union([ - z - .object({ - modules: z.array(jsonObject), - summary: dependencyCruiserSummarySchema, - staticImportGraph: staticImportGraphSchema, - }) - .strict(), - z - .object({ - summary: z.object({ errors: z.literal(1) }).strict(), - dependencyCruiserOutput: z.string(), - staticImportGraph: staticImportGraphSchema, - }) - .strict(), -]); +// 12-05 (D-11): dependency-cruiser checked zero modules under TypeScript 7 and +// no longer runs; the report carries the import graph that enforces the rules. +export const architectureDependencyReportArtifactSchema = z + .object({ staticImportGraph: staticImportGraphSchema }) + .strict(); export const designSystemReportArtifactSchema = z .object({ diff --git a/tests/unit/architecture-report.test.ts b/tests/unit/architecture-report.test.ts new file mode 100644 index 00000000..a3137f67 --- /dev/null +++ b/tests/unit/architecture-report.test.ts @@ -0,0 +1,68 @@ +import { readFile } from "node:fs/promises"; + +import { describe, expect, it } from "vitest"; + +import { architectureDependencyReportArtifactSchema } from "../../scripts/contracts/release-artifacts.ts"; + +// 12-05 (D-11). dependency-cruiser cannot parse TypeScript 7, so it checked +// zero modules and passed while its report claimed a result. The import graph +// in check-architecture.ts is the only checker; the report carries only it. +const staticImportGraph = { + analyzer: "babel-parser-node-resolver", + modules: [], + dependencies: [], + unresolved: [], + parseFailures: [], + cycles: [], + violations: [], + summary: { + modules: 0, + typescriptModules: 0, + dependencies: 0, + localDependencies: 0, + unresolved: 0, + parseFailures: 0, + cycles: 0, + errors: 0, + typeScriptOnlyPolicyPassed: true, + nonTypeScriptExecutableSources: 0, + }, + fixtureChecks: { passed: true, checks: [], failures: [] }, + typeScriptOnlySourcePolicy: { + checkedRoots: ["src"], + exceptionsAllowed: false, + violations: [], + passed: true, + }, +}; + +describe("architecture dependency report", () => { + it("carries the import graph only", () => { + expect(architectureDependencyReportArtifactSchema.parse({ staticImportGraph })).toEqual({ + staticImportGraph, + }); + }); + + it("rejects a dependency-cruiser section", () => { + const cruiserSummary = { + violations: [], + error: 0, + warn: 0, + info: 0, + ignore: 0, + totalCruised: 0, + totalDependenciesCruised: 0, + }; + expect( + architectureDependencyReportArtifactSchema.safeParse({ + modules: [], + summary: cruiserSummary, + staticImportGraph, + }).success, + ).toBe(false); + }); + + it("does not run dependency-cruiser", async () => { + expect(await readFile("scripts/check-architecture.ts", "utf8")).not.toMatch(/depcruise/u); + }); +});