Files
clean-architecture-backend-…/docs/adr/ADR-MONGO-001-platform-boundary.md
T
DongHyeonka 74108497d4 docs(records): 기록과 ADR 맨 위에 한국어 머리 블록을 단다
문제: 설계서·계획서·납품 패키지·증거·학습 문서와 ADR이 기록이라는 표시
없이 지금 문서처럼 읽힌다. 상태 칸이 설계서 72개 중 40개, 계획서는
거의 없고, 있어도 Approved·확정·Accepted.처럼 값이 제각각이며 영어다.

고른 방법: docs/design, docs/history, docs/adr, docs/notification/adr의
.md 246개 맨 위에 같은 모양의 머리 블록을 단다. 칸은 상태·작성일·
요약(한국어 한 문장)·현재 정본, 대체됐으면 대체됨이다. 블록은 표시 줄
두 개로 감싸서 빼면 원문 바이트가 그대로 돌아온다(246개 모두 대조함).
- 종류는 폴더가 정하고 둘째 줄에 적는다(plans/evidence는 증거).
- 상태는 원래 상태 줄을 고정 어휘로 바꾼 값이다. 상태 줄이 없는
  설계서와 체크 상자가 다 표시되지 않은 계획서는 「확인 안 함」.
  capability-status.md 제거 표로 지운 것이 확인된 설계서 다섯은 「폐기」,
  2026-07-20 하네스 설계·계획과 production capability platform 설계는
  「대체됨」이다.
- 현재 정본은 구조 정리로 옮겨질 수 있는 src/messaging·src/grpc 대신
  docs/ 쪽 문서나 옮기지 않는 leaf README를 가리킨다.
docs/README.md에 「문서 수명과 언어」「기록 문서의 머리 블록」「문서와
코드를 같은 변경에서 고친다」를 더하고, 파생 서비스 안내에 머리 블록
충돌 가능성을 적었다.

버린 대안: H1 제목 아래에 블록을 두는 안은 보기에는 낫지만 빼는 규칙이
파일마다 달라져 원문 복원이 기계적이지 않다. 「종류」 칸을 따로 두는
안은 폴더와 같은 정보를 두 번 쓰게 한다.

위험·한계: 「확인 안 함」 설계서 38개, 계획서 51개는 지금 유효한지
아무도 판정하지 않았다. 요약은 제목·목표 줄을 보고 쓴 것이라 본문을
끝까지 읽지 않았다. 납품 패키지 셋의 MANIFEST.sha256는 이제 맞지 않는다
(납품 당시 바이트의 해시이고, 블록을 빼면 다시 맞는다). 리뷰 폴더에는
아직 머리 블록을 달지 않았다.

검증: 머리 블록을 뺀 내용과 HEAD 원본 246개 일치, check-work-docs.py
rc=0, --links docs·README.md·CLAUDE.md·AGENTS.md 깨진 링크 0.
2026-11-07 12:23:32 +09:00

4.1 KiB

결정 기록 본문은 결정한 때의 원문이다. 지금도 유효한지는 「상태」를, 지금 동작은 「현재 정본」을 읽는다.

  • 상태: 채택
  • 작성일: 2026-08-13
  • 요약: MongoDB 플랫폼의 경계를 정한 결정이다.
  • 현재 정본: docs/mongodb/repository-adaptation.md

ADR-MONGO-001 — MongoDB platform boundary

  • Status: Accepted
  • Date: 2026-08-13
  • Design source: docs/superpowers/specs/2026-08-11-mongodb-document-persistence-platform-design.md §1, §2 (D-01, D-04, D-05), §5, §6

Context

Two failure modes are common when a team wraps MongoDB.

The first is flattening: a shared CommonMongoRepository<T, ID> and a generic CRUD facade, which forces every collection to share an id strategy, a consistency profile and a query surface. MongoDB's single-document atomicity, aggregation model and change streams stop being reachable, and the first collection that needs something different gets a cast or a leaky generic.

The second is unrestricted exposure: the driver and runCommand available everywhere. Then any service can drop a collection, run an unbounded pipeline, or issue an admin command from a request thread, and no review catches it because there is nothing structural to catch.

Decision

The domain owns its documents; the platform owns the cross-cutting decisions. Four exposure planes:

Plane Contents Client
D1 Standard document persistence Spring Data repositories, typed queries, mapping manifest, atomic update primitives, optimistic revision Stable API V1, apiStrict=true
D2 Advanced document operations MongoTemplate, transactions/sessions, bulk, aggregation, keyset cursors, change streams Stable API V1, apiStrict=true
D3 Explicit Mongo capability Native BSON, time series, search/vector, CSFLE/QE, shard-aware operations Separate capability client
D4 Admin plane Collection, validator, index, migration, shard, repair Separate admin client and credential

Specifically:

  1. No CommonMongoRepository<T, ID>. Each aggregate declares its own repository.
  2. D1/D2 run on Stable API V1 with apiStrict=true, so a command outside the versioned API fails at development time instead of on the next server upgrade.
  3. D3 is not a raw-client escape. Every call passes a fixed admission order: capability registered → database profile → collection allowlist → operation name → timeout → consistency profile → result limit → trace → redaction → command category → admin-command refusal → execute.
  4. D4 is a separate client with a separate credential. No application-plane path reaches it; PolicyAwareMongoNativeGateway refuses admin-category commands regardless of capability.
  5. Advanced and Experimental capabilities are opt-in modules, never transitive dependencies of the Stable surface.

Consequences

Positive. MongoDB's semantics stay reachable. Misuse is refused structurally rather than reviewed for. A server upgrade cannot silently change D1/D2 behaviour. Admin operations have their own audit trail and credential.

Negative. Every operation needs a registered name and profile, so a new query is a small amount of configuration rather than zero. A genuinely new capability requires a registration before it can be used. Both are deliberate: the cost is paid once per operation, at review time.

Rejected alternative — "expose the driver, rely on code review." Review does not scale to every query in every service, and the operations that matter (unbounded pipeline, dropCollection, unanchored regex on user input) look unremarkable in a diff.

Repository adaptation

The design assumes 19 Gradle modules under modules/mongodb/. This repository's fail-closed registry declares exactly 19 leaf identities, so the modules became package boundaries inside :adapter:outbound:persistence-mongo, enforced by ArchUnit. See docs/mongodb/repository-adaptation.md.