diff --git a/.dependency-cruiser.json b/.dependency-cruiser.json index 60714add..6cb8b53f 100644 --- a/.dependency-cruiser.json +++ b/.dependency-cruiser.json @@ -336,16 +336,28 @@ }, { "name": "platform-kernel-is-product-neutral", - "comment": "scale-architecture.md §4. src/platform holds product-neutral primitives (budgets, execution, telemetry pipeline, validation, error envelopes). It never reaches up into a concrete feature, context, adapter, bootstrap or presentation module. Exception: src/platform/routing composes deployable-app descriptors by type. Owner: frontend-platform. Revisit if routing gains a product-specific import.", + "comment": "scale-architecture.md §4. src/platform holds product-neutral primitives (budgets, execution, telemetry pipeline, validation, error envelopes). It never reaches up into a concrete feature, context, adapter, bootstrap or presentation module. Exception: the one file src/platform/routing/context-route-module.ts, which platform-route-module-reads-only-descriptors limits to two descriptor files (REV-FE-0035: the exception used to cover the whole routing folder and every destination). Owner: frontend-platform. Revisit if routing gains a product-specific import.", "severity": "error", "from": { "path": "^src/platform/", - "pathNot": "^src/platform/routing/" + "pathNot": "^src/platform/routing/context-route-module\\.ts$" }, "to": { "path": "^src/(features|contexts|apps|adapters|bootstrap|presentation|application)/" } }, + { + "name": "platform-route-module-reads-only-descriptors", + "comment": "scale-architecture.md §4. src/platform/routing/context-route-module.ts composes deployable-app and bounded-context route descriptors, so it may read src/apps/deployable-app-module.ts and src/contexts/bounded-context-module.ts and no other features, contexts, apps, adapters, bootstrap, presentation or application module. The rule checks the target file, not whether the import is type-only. Presentation imports this file (app-router.tsx), so a wider exception would let presentation reach an adapter through it. Owner: frontend-platform. Revisit if routing needs another descriptor; name that file here instead of widening the folder.", + "severity": "error", + "from": { + "path": "^src/platform/routing/context-route-module\\.ts$" + }, + "to": { + "path": "^src/(features|contexts|apps|adapters|bootstrap|presentation|application)/", + "pathNot": "^src/(apps/deployable-app-module|contexts/bounded-context-module)\\.ts$" + } + }, { "name": "no-circular-dependencies", "comment": "A cycle makes the modules impossible to load or remove one at a time. Move the shared part into a lower module that both import.", diff --git a/CHANGELOG.md b/CHANGELOG.md index c57f666d..673e08b3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -84,6 +84,10 @@ Gitea runner에서 merge 단계를 초록으로 만들고, worker를 늘리지 - 옮기기 전: 그 타입 값을 직접 만들어 `createTelemetryPipeline`의 `budget.payload`에 넘기면 `check:types`가 `maxNodes`가 없다며 실패한다. - 옮기는 법: `{ ...DEFAULT_TELEMETRY_PAYLOAD_BUDGET, … }`로 만들거나 `maxNodes`를 적는다(기본 512). 양의 안전 정수가 아니면 `createTelemetryPipeline`이 `TypeError`를 던진다. - 옮긴 뒤 확인: `scripts/verify.sh script check:types`. +- `platform-kernel-is-product-neutral`의 예외가 `src/platform/routing/` 폴더 전체에서 `routing/context-route-module.ts` 한 파일로 좁아진다. 그 파일은 새 규칙 `platform-route-module-reads-only-descriptors`로 `src/apps/deployable-app-module.ts`·`src/contexts/bounded-context-module.ts`만 import한다(REV-FE-0035). + - 옮기기 전: `src/platform/routing/`의 다른 파일이 features·contexts·apps·adapters·bootstrap·presentation·application을 import하거나, `context-route-module.ts`가 그 두 파일 밖의 제품 모듈을 import하면 FE-GATE-010(`check:architecture`)이 실패한다. + - 옮기는 법: 그 파일을 제품 쪽(`src/apps`나 그 owner 곁)으로 옮긴다. routing에 descriptor가 정말 하나 더 필요하면 그 파일 이름을 새 규칙의 `to.pathNot`에 더한다. 폴더로 넓히지 않는다. + - 옮긴 뒤 확인: `scripts/verify.sh script check:architecture`. ### 보안·계약 변경 diff --git a/docs/architecture/layers.md b/docs/architecture/layers.md index f93d60ca..b013f25f 100644 --- a/docs/architecture/layers.md +++ b/docs/architecture/layers.md @@ -67,7 +67,8 @@ domain 코드는 feature 안(`src/features//domain`)에 있다. 최상위 do | `feature-and-app-roots-do-not-reach-adapters` | `src/features` 안에서 feature의 `adapters/` 폴더 밖에 있는 모든 파일(루트 파일과, `support/`처럼 계층이 아닌 모든 폴더), `src/contexts`, `src/apps`. 단 타입 전용인 `src/features/feature-adapter-contribution.ts`는 제외 | `src/adapters` | | `presentation-does-not-import-apps-or-contexts` | 범용 presentation과 feature presentation. 단 앱의 라우트 트리를 마운트하는 `src/presentation/routes/app-router.tsx`는 제외 | `src/apps`, `src/contexts` | | `observability-vendors-live-behind-adapters` | `src/adapters` 밖의 코드 | vendor telemetry SDK | -| `platform-kernel-is-product-neutral` | `src/platform`. 단 app descriptor를 타입으로 읽는 `routing/`은 제외 | features, contexts, apps, adapters, bootstrap, presentation, application | +| `platform-kernel-is-product-neutral` | `src/platform`. 단 app·context descriptor를 읽는 `routing/context-route-module.ts` 한 파일은 제외 | features, contexts, apps, adapters, bootstrap, presentation, application | +| `platform-route-module-reads-only-descriptors` | `src/platform/routing/context-route-module.ts` | features, contexts, apps, adapters, bootstrap, presentation, application. 단 `src/apps/deployable-app-module.ts`와 `src/contexts/bounded-context-module.ts`는 제외 | | `no-circular-dependencies` | `src` 전체 | import 순환 | `feature-and-app-roots-do-not-reach-adapters`가 있는 이유는 그래프가 간선을 @@ -114,8 +115,11 @@ kernel 말고 예외는 다음과 같다: - 앱을 import하는 `src/presentation/routes/app-router.tsx` (`presentation-does-not-import-apps-or-contexts`) - 디자인 시스템 facade(`design-system-is-reached-through-its-index`) -- 배포 단위 앱 타입을 읽는 `src/platform/routing` - (`platform-kernel-is-product-neutral`) +- 배포 단위 앱·context descriptor를 읽는 `src/platform/routing/context-route-module.ts` + (`platform-kernel-is-product-neutral`). 이 파일이 읽는 곳은 + `platform-route-module-reads-only-descriptors`가 descriptor 파일 둘로 + 묶는다. presentation이 이 파일을 import하므로, 폴더 전체나 다른 목적지를 + 풀면 그 파일을 거쳐 adapter에 닿는다 ## 어댑터 그룹의 공개 경계 diff --git a/docs/work/experts.md b/docs/work/experts.md index 9d824462..5b749d4b 100644 --- a/docs/work/experts.md +++ b/docs/work/experts.md @@ -61,6 +61,7 @@ | `src/presentation/{design-system,styles}/**`, `.storybook/**`, `tests/{storybook,visual}/**`, `docs/styling/**` | fe-design-system | 키보드·대비 → fe-a11y, 초기 청크 → fe-performance | | `src/**/*.tsx`, `src/features/**`, `src/application/**`, `src/presentation/adapters/**`, `src/adapters/{http,query-cache}/**`, `config/contracts/**` | fe-react | 자격 증명·저장소 → fe-security, 짝 백엔드 계약 → 백엔드 repo 세션(4절) | | `src/adapters/*/index.ts`, `src/adapters/platform/**`, `src/{contracts,contexts,apps,bootstrap}/**`, `src/features/*.ts`, `.dependency-cruiser.json`, `docs/architecture/layers.md`, `docs/reviews/adapters/INVENTORY.md` | fe-structure(판정은 `arch-reviewer`) | 번들 경계 → fe-performance, 런타임 설정 키 → fe-security | +| `src/platform/**` | fe-structure(판정은 `arch-reviewer`) | 예산·telemetry 값과 상한 → fe-performance, 판정이 거짓으로 통과 → fe-testing | | `tests/**`, `vitest.config.ts`, `playwright*.config.ts`, `config/testing/**`, `config/ci/ungated-tests.json` | fe-testing | 시험이 지키는 동작 → 그 분야 렌즈 | | `src/presentation/**`, `docs/accessibility/**` | fe-a11y | 대비·포커스 표시처럼 디자인 결정 → fe-ux | | `vite.config.ts`, `vite.service-worker.config.ts`, `config/{performance,scale}/**`, `config/hosting/cache-policy.json`, `src/adapters/service-worker/**`, `src/presentation/routes/**` | fe-performance | 예산·기준선 상향 → 소유자(5절) | diff --git a/scripts/check-architecture.ts b/scripts/check-architecture.ts index 250bc142..847ebcf8 100644 --- a/scripts/check-architecture.ts +++ b/scripts/check-architecture.ts @@ -857,6 +857,57 @@ async function runGraphFixtureChecks(): Promise { target === "src/contexts/customer/telemetry.ts", ), }, + // REV-FE-0035. The platform kernel exception used to cover all of + // src/platform/routing/ and every destination. Presentation imports + // routing, so a routing file re-exporting an adapter passed the graph. + { + name: "platform routing file re-export of a concrete adapter is rejected", + passed: blockingViolations(crossBoundaryGraph).some( + ({ rule, source, target }) => + rule === "platform-kernel-is-product-neutral" && + source === "src/platform/routing/re-export-adapter.ts" && + target === "src/adapters/telemetry/index.ts", + ), + }, + { + name: "platform route module import of a concrete adapter is rejected", + passed: blockingViolations(crossBoundaryGraph).some( + ({ rule, source, target }) => + rule === "platform-route-module-reads-only-descriptors" && + source === "src/platform/routing/context-route-module.ts" && + target === "src/adapters/telemetry/index.ts", + ), + }, + // Widening the route module's destinations to all of src/apps/ or + // src/contexts/ must fail here, not only an adapter import. + { + name: "platform route module import of a non-descriptor app module is rejected", + passed: blockingViolations(crossBoundaryGraph).some( + ({ rule, source, target }) => + rule === "platform-route-module-reads-only-descriptors" && + source === "src/platform/routing/context-route-module.ts" && + target === "src/apps/app-runtime.ts", + ), + }, + { + name: "platform route module descriptor imports are accepted", + passed: [ + "src/apps/deployable-app-module.ts", + "src/contexts/bounded-context-module.ts", + ].every( + (descriptor) => + crossBoundaryGraph.dependencies.some( + ({ source, target }) => + source === "src/platform/routing/context-route-module.ts" && + target === descriptor, + ) && + !blockingViolations(crossBoundaryGraph).some( + ({ source, target }) => + source === "src/platform/routing/context-route-module.ts" && + target === descriptor, + ), + ), + }, // 12-08 / 12-10: these import rules used to be regular expressions in // check-design-system.ts and realtime-boundaries.ts beside the graph. { diff --git a/src/platform/AGENTS.md b/src/platform/AGENTS.md index ee5b2508..caaf3eb0 100644 --- a/src/platform/AGENTS.md +++ b/src/platform/AGENTS.md @@ -4,12 +4,12 @@ ## 지킬 것 -- features·contexts·apps·adapters·bootstrap·presentation·application을 import하지 않는다(`platform-kernel-is-product-neutral`, 예외 `platform/routing/`). +- features·contexts·apps·adapters·bootstrap·presentation·application을 import하지 않는다(`platform-kernel-is-product-neutral`). 예외는 `routing/context-route-module.ts` 한 파일이고, 그 파일도 `src/apps/deployable-app-module.ts`·`src/contexts/bounded-context-module.ts` 두 파일만 읽는다(`platform-route-module-reads-only-descriptors`). 규칙은 파일만 보고 import가 타입 전용인지는 보지 않으니, 그 두 파일에서도 타입만 가져온다. - 확인하지 못한 판정은 `PASS`가 아니라 `UNVERIFIED`다. 상수 `true` 판정을 두지 않는다. - 모든 `src/` 폴더에 걸리는 규칙(adapter는 배럴로만, zod는 `src/contracts/zod.ts`로만, 아이콘 vendor·디자인 시스템·외부 계약 패키지·관측 vendor는 정해진 입구로만)은 루트 `AGENTS.md` 꼭 지킬 것과 `docs/architecture/layers.md`다. ## 검사 - 판정은 `check:architecture`(FE-GATE-010)다. 편집 직후 훅(N3)이 이 폴더 파일의 import를 같은 규칙에 대 본다. -- `test:coverage`(FE-GATE-005). 작업 중에는 `test:unit`으로 `tests/unit`만 돌린다 -- 돌리는 곳은 desktop이다(`scripts/verify.sh`). 테스트는 `tests/unit`에 둔다(`.claude/rules/tests.md`). +- `test:coverage`(FE-GATE-005)가 `tests/platform`도 돈다. 작업 중에는 `test:platform`으로 `tests/platform`과 `tests/architecture`를 돌린다. `src/platform/release`를 고쳤으면 `tests/release`도 돌아야 하니 `check:release-coherence`를 더 돌린다. 하위 폴더 몇 개만 볼 때는 `check:traffic`(execution·traffic·resilience), `check:observability`(errors·validation·telemetry), `check:topology`(cardinality·routing), `check:release-coherence`(release와 그 코드를 시험하는 `tests/release`)다. `test:unit`은 이 폴더 시험을 하나도 돌지 않는다. +- 돌리는 곳은 desktop이다(`scripts/verify.sh`). 테스트는 `tests/platform/<하위 폴더>/`에 두고, 하위 폴더 이름은 `src/platform/<하위 폴더>/`와 같다. jsdom을 쓰는 시험(`tests/platform/errors/failure-boundary.test.tsx`)도 여기 둔다. `.claude/rules/tests.md` 1번의 실행 환경별 폴더와 달리, 이 폴더 시험은 `test:platform`이 도는 `tests/platform`에 둔다(`docs/testing/taxonomy.md`의 `test:all` 문단). `tests/component`에 두면 `test:platform`과 `check:*`가 돌지 않는다. diff --git a/tests/fixtures/architecture/dependency-graph/cross-boundary/apps/app-runtime.ts b/tests/fixtures/architecture/dependency-graph/cross-boundary/apps/app-runtime.ts new file mode 100644 index 00000000..c232f9e0 --- /dev/null +++ b/tests/fixtures/architecture/dependency-graph/cross-boundary/apps/app-runtime.ts @@ -0,0 +1,3 @@ +// REV-FE-0035: an app module that is not a route descriptor. The route +// module must not read it even though it sits in src/apps/. +export const appRuntime = 1; diff --git a/tests/fixtures/architecture/dependency-graph/cross-boundary/apps/deployable-app-module.ts b/tests/fixtures/architecture/dependency-graph/cross-boundary/apps/deployable-app-module.ts new file mode 100644 index 00000000..0eaaf298 --- /dev/null +++ b/tests/fixtures/architecture/dependency-graph/cross-boundary/apps/deployable-app-module.ts @@ -0,0 +1,2 @@ +// REV-FE-0035: the app descriptor type src/platform/routing may read. +export type DeployableAppModule = Readonly<{ id: string }>; diff --git a/tests/fixtures/architecture/dependency-graph/cross-boundary/contexts/bounded-context-module.ts b/tests/fixtures/architecture/dependency-graph/cross-boundary/contexts/bounded-context-module.ts new file mode 100644 index 00000000..d38f7da1 --- /dev/null +++ b/tests/fixtures/architecture/dependency-graph/cross-boundary/contexts/bounded-context-module.ts @@ -0,0 +1,2 @@ +// REV-FE-0035: the context route descriptor type src/platform/routing may read. +export type BoundedContextRouteModule = Readonly<{ id: string }>; diff --git a/tests/fixtures/architecture/dependency-graph/cross-boundary/platform/routing/context-route-module.ts b/tests/fixtures/architecture/dependency-graph/cross-boundary/platform/routing/context-route-module.ts new file mode 100644 index 00000000..d3e24bff --- /dev/null +++ b/tests/fixtures/architecture/dependency-graph/cross-boundary/platform/routing/context-route-module.ts @@ -0,0 +1,12 @@ +// REV-FE-0035: the one routing file the platform kernel rule exempts. Its two +// descriptor type imports are accepted; any other product module (an adapter +// barrel, a non-descriptor app module) is rejected. +import type { DeployableAppModule } from "../../apps/deployable-app-module.ts"; +import type { BoundedContextRouteModule } from "../../contexts/bounded-context-module.ts"; + +export type ContextRouteModule = Readonly<{ + app: DeployableAppModule; + context: BoundedContextRouteModule; +}>; +export * from "../../adapters/telemetry/index.ts"; +export * from "../../apps/app-runtime.ts"; diff --git a/tests/fixtures/architecture/dependency-graph/cross-boundary/platform/routing/re-export-adapter.ts b/tests/fixtures/architecture/dependency-graph/cross-boundary/platform/routing/re-export-adapter.ts new file mode 100644 index 00000000..b6bb0f72 --- /dev/null +++ b/tests/fixtures/architecture/dependency-graph/cross-boundary/platform/routing/re-export-adapter.ts @@ -0,0 +1,3 @@ +// REV-FE-0035: another src/platform/routing file re-exporting a concrete +// adapter. Presentation imports routing, so this edge would reach the adapter. +export * from "../../adapters/telemetry/index.ts";