Files
clean-architecture-backend-…/CLAUDE.md
T
DongHyeonka 1400dc1506 feat!: 남은 리뷰 발견을 고치고 개발 매뉴얼과 기능 생성 명령을 더한다
문제: High·P1을 고친 뒤에도 P2·P3 약 90건이 남았다. 연결·구독·메시지
크기 상한이 없는 전송(WebSocket·gRPC·GraphQL deadline), 낙관적 충돌의
500, upsert 경쟁, Mongo 무제한 timeout, 샘플 목록 N+1, 갈라진 복사본
(TenantId 3벌, 이벤트 ID 문법 5곳, SQLState 표 2벌), 문서를 읽는 PR
테스트와 캐시를 막는 lane 설정 등이다. 새 기능을 어디에 어떤 순서로
만드는지 알려 주는 문서와 도구가 없었다. MinIO 공식 이미지가 사라져
객체 저장소 lane이 돌지 않았다.

방법: 영역별 묶음으로 실패 테스트를 먼저 쓰고 고쳤다. 고치는 중에 찾은
결함도 함께 고쳤다(durable operation id가 UUIDv4라 이벤트가 전부 DEAD,
S3 어댑터 생성·작은 chunk 읽기 실패, Redis 조건부 기록의 EVALSHA 권한).
MinIO는 pgsty/minio를 digest로 고정했다(Chainguard는 태그·실행 사용자·
mc 이미지 문제로 버림). docs/manual/에 작업 순서와 판단 지점을 쓰고,
scripts/new-feature.sh가 5개 leaf에 뼈대를 만든다. 생성→빌드→통과
왕복을 verifyFeatureScaffold가 mainCheck에서 본다. 묶음별 결과와
결정은 리뷰 README 14절에 있다.

위험·한계: 파생 서비스 동작이 바뀐다. JDBC batch 50 기본, 운영 jar에서
H2 제거, 트랜잭션 30초 제한, 격리 수준을 Hikari에서 고정, gRPC·
WebSocket·GraphQL 새 한도, correlation ID 규칙 밖이면 서버가 교체,
샘플 키 오류 코드 IDEMPOTENCY_KEY_INVALID. 새 leaf 두 개
(composition:durable-operation, adapter:inbound:messaging)와 새
마이그레이션(postgresql V20·V21, notification V11·V12, sample V8_1,
grpc-ledger V002)이 생긴다. V21 유일 인덱스는 기존 중복이 있으면
실패한다(runbook에 확인 쿼리).

검증: ci, mainCheck(생성 명령 왕복 포함), integrationCheck(MinIO 포함
전 컨테이너 lane), -p optional-platforms ci integrationCheck 통과.

Refs: docs/reviews/2026-11-01-maturity-review/README.md 14절
BREAKING CHANGE: JDBC batch 기본 켜짐, H2 운영 의존 제거, 트랜잭션
기본 제한 30초, gRPC·WebSocket·GraphQL 서버 한도 기본값 추가,
샘플 Idempotency-Key 오류 코드 변경.
2026-11-03 19:52:06 +09:00

10 KiB
Raw Blame History

CLAUDE.md

Repository guidance for the Java 21 + Spring Boot 4.0.8 Clean Architecture template.

Prime Directive

Preserve architecture before optimizing for speed. The following seven HARD-STOP conditions are a synchronized summary of the canonical local policy in AGENTS.md:

  1. domain-core gains framework, transport, database, or cloud dependencies.
  2. A controller directly uses a repository, Spring Data interface, or persistence entity.
  3. An inbound DTO leaks into application-core or domain-core.
  4. Business rules move into mappers, filters, configuration, settings, or controllers.
  5. Project dependencies violate src/config/architecture/modules.json or the Gradle dependency gate.
  6. Completion is claimed without the relevant verification or a named reason it could not run.
  7. A repository/corpus conclusion is made without evidence proportional to its scope and risk.

If this summary drifts from AGENTS.md, AGENTS.md wins and this summary must be resynchronized.

Gradle policy authorities

  • src/config/architecture/modules.json: every registered leaf identity, repository-relative source paths, Gradle paths and allowed production project dependency edges. There is no runtime membership list: what a composition root may take is its allowed_dependencies, and the direction gate refuses any other edge. The registry owns the leaf list and its size; no document restates the count, because a number written in prose drifts the moment a leaf is added.
  • src/settings.gradle: fail-closed registry validation, project inclusion, and directory mapping.
  • src/build-logic/: the architecture core (registry, direction and purity tasks), the conventions, and one test-lane mechanism (strictTestLanes). Feature-specific checks are the owning leaf's tests; a test that reads repository files declares them as that leaf's test inputs, and a test that compares a leaf with repository documents is a mainStage() lane (tag document-contract) in that leaf's mainCheck; a merge-blocking contract over non-document repository files is a pull-request lane whose inputs are exactly those files (app-bootstrap repository-contract). TEST/ARCHITECTURE lanes are cacheable; INTEGRATION/SYSTEM/PERFORMANCE and main-stage lanes rerun every time.
  • verifyEnvKeys stays an app-bootstrap task (owner decision 4); its implementation is build-logic's ca.config-contract. The src/build-tools/ included build was emptied and removed.
  • src/build.gradle: the root lifecycle (ci, mainCheck, integrationCheck, performanceCheck, releaseCheck and the named repository-wide gates). verifyStrictLaneStages --dry-run (pull request) fails when a non-explicitOnly strict lane is in no stage a workflow executes, or a folded workflow run: block splits an option off its command.

Commit policy is human-only: agents do not stage, commit, amend, or push implementation changes.

Proportional workflow

  • Low risk: work in the owning leaf, follow its nearest guidance, and run the focused check.
  • Medium risk: use the relevant Superpowers design, planning, TDD, debugging, and review workflows in proportion to the affected boundaries.
  • High risk: make architecture and behavior decisions explicit, use staged architecture/spec/quality review, and run architecture-wide verification authorized by the task.

Risk comes from change surface and runtime, security, data, or public-contract impact, not file count.

Module families

src/config/architecture/modules.json owns the complete leaf list. Root guidance summarizes families; the nearest src/**/CLAUDE.md owns local rules. No task enforces this any more: verifyDocumentedLeafCount was deleted along with the other documentation-drift parsers. A stated count that disagrees with the registry is a defect, not a build failure — so do not state one.

Family Responsibility Stable dependency direction
domain-core Pure domain model, invariants, events, ports Java stdlib and registered value-only contracts
application-core Commands, use cases, application policies, transaction ports domain-core, shared-contract
adapter:inbound:* HTTP, gRPC, GraphQL, WebSocket transport boundaries application/domain/shared contracts
adapter:outbound:persistence-* JPA/PostgreSQL and MongoDB persistence adapters application/domain/shared contracts as registered
adapter:outbound:* support, messaging, cache, notification, storage, file, HTTP client, identifier capabilities application/domain/shared and registered support edge
shared-contract Skeleton-wide operational contracts Java stdlib only
messaging:* Vendored messaging platform: a product with its own API, SPI, adapters and composition boundary, not a layer of this application messaging:* only — it depends on no domain-core, application-core, or shared-contract type
sample-portfolio Fixture/reference consumer registered runtime leaves; never a production dependency
app-bootstrap Spring Boot entrypoint and composition root registered runtime leaves

The messaging:* family is the one entry that is not a Clean Architecture layer, and it is listed so that the exception is stated rather than inferred from a directory. It is a vendored library — its own *-api leaves are its ports, its broker leaves are its adapters, its starter is its composition root — and the messaging module review (docs/reviews/2026-08-14-messaging-module-code-review.md MSG-023 §6.2) chose that layout deliberately over folding it into adapter:outbound:*. This application reaches it through the application-owned anti-corruption bridge in adapter:outbound:messaging (MSG-015). The canonical bridge is the only path: the legacy outbox append port and the legacy Kafka publishing seam were deleted (owner decision 7).

Never infer an individual leaf's Gradle path, allowed dependency, or test command from this table. Read its gradle_path and allowed_dependencies from src/config/architecture/modules.json; runtime composition is established by actual Gradle dependencies/auto-configuration, not a registry runtime_memberships field that does not exist.

Layer workflow

For a full use case, work in this order:

domain-core
  -> application-core
  -> adapter:outbound:* (or persistence/identifier)
  -> adapter:inbound:*
  -> app-bootstrap wiring

Layer-only work stays inside that registered leaf plus its tests. If a required fix crosses a layer or writable scope, stop and request context rather than expanding silently.

Testing

  • domain-core: pure JUnit unit tests.
  • application-core: use-case tests with hand-rolled fakes; no web or persistence context.
  • inbound adapters: focused transport slice/contract tests.
  • persistence adapters: mapping/port contract tests; use a real datastore only when vendor semantics require it.
  • other outbound adapters: port contract tests with fake external systems; no real network.
  • identifier: pure deterministic unit tests.
  • bootstrap/settings: binding, validation, wiring, and architecture tests.

From src/, read the owning leaf's gradle_path from config/architecture/modules.json and run ./gradlew <gradle-path>:test --console=plain. Architecture-wide commands:

./gradlew architectureCheck --console=plain
./gradlew :app-bootstrap:architectureTest --console=plain
./gradlew verifyPublicPathSnapshot --console=plain
./gradlew :app-bootstrap:verifyEnvKeys --console=plain

A leaf's check covers that leaf only — compile, its tests, Spotless, Checkstyle, Error Prone. Repository-wide questions have their own names: architectureCheck (dependency direction, purity of domain-core/shared-contract/application-*, Git-carryable sources, ArchUnit), qualityCheck (SpotBugs, FindSecBugs), configContractCheck (the environment contract), integrationCheck (the declared strict integration lanes; a lane that needs an input the build was not given is left out and named), performanceCheck (the declared performance lanes; main and nightly). ci (pull request) is leaf checks (API surfaces included, owner decision 20) + architectureCheck + qualityCheck, and the workflow also runs verifyStrictLaneStages --dry-run; mainCheck (main branch) is configContractCheck + qualificationCheck + the sample web contract + the public-path snapshot + the transport and messaging qualification lanes + every leaf's mainCheck (document-contract lanes, MinIO lanes); releaseCheck is the tag-only checks: release provenance and the public-path snapshot.

Test-writing rules (behavior-sentence names that assert what they promise, @DisplayName in Korean only when the name cannot say it (owner decision 5), given/when/then comments, one // when, one fake per port in the port owner's testFixtures, fake and adapter sharing one abstract contract test) are canonical in AGENTS.md.

Use public-path and env-key checks only when their surfaces changed. Full test, check or ci requires the controller's workflow authorization.

Capability modules

Optional features (JPA, Redis, Kafka, notification, Mongo, object storage, HTTP client, GraphQL, WebSocket, gRPC, file server) are modules that turn on when present and disappear when removed. A service selects them with one runtimeOnly line each in app-bootstrap/build.gradle; the template's default composition is the web inbound adapter, observability, the cores, and support/identifier. The seven completion criteria for a capability module are canonical in AGENTS.md.

Advisory and reporting

Use dependency-DAG/topological reasoning and 3–5 materially distinct alternatives when that many exist; use fewer when the option set is smaller. Judgment findings include falsifiable assumptions and counterarguments. Deterministic compile, dependency, secret, or failed-test findings use Rule → Evidence → Fix without manufactured debate.

Citation verification is profile-based: none for review-lite, blocking citations for review-standard, and all material citations for audit-deep/regulated. Durable reports are triggered by high risk, at least 3 blocking findings, an architecture decision, explicit user request, or the regulated profile. Otherwise a concise result is allowed.