Boundary Rules
<discovered-domain-root> means the parent directory of a recursively
discovered domain manifest. It may be nested below paths.domains.
1. Rule Set (Hard Constraints)
BR-001: Client-to-Server Import Ban
- Rule: discovered domain
client/**에서 같은/다른 discovered domainserver/**import 금지 - Reason: 배포 경계/실행 환경 분리
BR-002: Server-to-Client Import Ban
- Rule: discovered domain
server/**에서 같은/다른 discovered domainclient/**import 금지 - Reason: 계층 역전 방지
BR-003: Shared Purity
- Rule:
<discovered-domain-root>/shared/**는 shared policy가 거부한 capability 의존 금지 - Default denied capabilities:
ui,database,runtime - Default classification preserves the existing React/Next, Prisma, Node runtime,
packages/ui,packages/db,packages/infra, and app-path behavior checkBoundaries.capabilities에서 dependency를 capability로 분류하고checkBoundaries.policy.shared.denyCapabilities에서 거부 정책을 설정한다.- Allow: capability가 거부되지 않은 pure contract/schema dependency
- Reason: 계약 계층의 순수성을 프로젝트별 stack에 맞게 강제
BR-004: Cross-Domain Access Policy
- Rule: 도메인 간 직접 내부 경로 import 금지
- Allow:
<other-discovered-domain-root>/shared/public또는 명시된 public API만 허용 - Reason: 내부 구현 은닉과 변경 안전성 확보
BR-005: App-to-Domain Public API Policy
- Rule:
apps/**에서<discovered-domain-root>/**를 import할 때 해당 도메인의 manifest에 선언된 public API만 허용 - Allow:
<discovered-domain-root>/client/public,server/public,shared/public또는 manifest에 명시된 public API - Reason: composition root인 앱이 도메인 내부 구현에 결합되는 것을 방지
BR-006: Declared Domain Dependency Policy
- Rule: 다른 도메인의 public API를 import하려면 대상 도메인이 소스 manifest의
dependsOn에 선언되어야 함 - Allow:
dependsOn에 선언된 도메인의 manifest public API - Reason: 실제 코드 의존성과 domain graph를 일치시켜 숨은 결합을 방지
2. Allow List
client -> sharedserver -> shareddomain -> other-domain public APIdomain -> declared dependency public APIapp -> domain public API
Compact single-layer layout
If exactly one manifest public API category is non-empty, direct files under that domain root are analyzed as that category's layer. This is a layout shortcut only; all existing layer and public API rules still apply. See ADR 0009.
Nested domain roots
Domain roots are discovered from the configured manifest filename at any depth
below paths.domains. BR-001 through BR-006 use the discovered root rather than
assuming paths.domains/<name>. Group directories have no boundary identity.
See ADR 0011.
3. Violation Output Format
CLI는 위반 시 아래 구조를 제공해야 한다.
[BOUNDARY_VIOLATION] BR-001
file: domains/order/client/use-order.ts
import: domains/order/server/order-service
line: 12
message: client layer cannot import server layer.
suggestion: move contract/type to shared or call via public API.
4. Exit Codes
0: 위반 없음1: 위반 존재2: 설정/manifest 파싱 오류3: 내부 실행 오류
5. Example Violations
Example A
- Source:
domains/product/client/list.ts - Import:
domains/product/server/repository.ts - Result: BR-001
Example B
- Source:
domains/auth/shared/types.ts - Import:
packages/ui/button - Result: BR-003
Example C
- Source:
domains/order/server/checkout.ts - Import:
domains/product/server/internal/stock.ts - Result: BR-004
Example D
- Source:
apps/web/src/checkout.ts - Import:
domains/order/server/internal/checkout.ts - Result: BR-005
Example E
- Source:
domains/order/server/checkout.ts - Import:
domains/billing/server/public.ts - Manifest:
order.dependsOndoes not includebilling - Result: BR-006