Files
clean-architecture-backend-…/docs/design/2026-09-19-multi-instance-runtime-contract.md
T
DongHyeonka 6a792b8144 refactor(layout)!: 옮긴 경로를 부르는 곳을 모두 새 배치에 맞춘다
문제: 앞 커밋이 Gradle 루트를 저장소 루트로 옮기고 계층 폴더를 묶었다.
빌드 스크립트·build-logic·시험·workflow·스크립트·문서가 아직 옛 배치
(Gradle 루트 = src/)를 가정해 빌드가 되지 않는다.

고른 방법:
- Gradle 경로와 registry id는 그대로 둔다(:app-bootstrap, :application-core,
  :composition:*). registry의 source_path만 새 폴더를 가리킨다. 폴더에 맞춘
  이름(:domain:core, :application:core)은 프로젝트 이름 core가 둘이 되어
  boot jar의 BOOT-INF/lib와 기본 capability가 겹치고, 파생 서비스의 모든
  project(':…') 줄을 바꾸게 한다.
- registry는 gradle/modules.json, 시험 이미지 목록은
  gradle/container-images.properties: 버전 카탈로그 옆, 빌드가 고정하는 것.
  config/는 코드 검사 도구 설정만 둔다.
- build-logic: settings·architecture 플러그인의 저장소 루트를 Gradle 루트로
  (getParentFile 제거). config contract의 파일 트리는 src/만 훑는다(루트를
  훑으면 docs·.claude/worktrees까지 줍는다).
- 빌드 스크립트: rootProject.projectDir.parentFile → rootProject.projectDir,
  rootProject.file('../…') → rootProject.file('…'), 옛 src 기준 include에
  src/를 붙인다. notification API surface의 application-notification 소스
  루트를 새 폴더로(놓치면 272개 타입이 surface에서 말없이 빠진다).
- 시험: 옛 src 기준 모듈 목록과 ../ 개수를 고친다. 없는 폴더를 말없이
  건너뛰던 목록(MessagingAuthority, NotificationPayloadAtRest 등)을 새
  폴더로, FileserverDocumentationCoverageTest는 Gradle 경로 → 폴더를
  registry로 찾는다. Docker 계약은 WORKDIR /build, 새 jar 경로.
- Docker: 빌드 context를 저장소 루트로, .dockerignore는 허용 목록으로 다시
  써서 전에 context였던 것만 들어가게 한다. compose의 build.context는 .,
  env_file은 ./.env.
- workflow: working-directory: src 기본값과 그것을 되돌리던 줄을 지운다.
- scripts: verify.sh, ci/*, bootstrap-local, new-feature,
  verify-feature-scaffold, mongo 검증, hooks, check-repo-layout 허용 목록.
  check-docs의 경로 검사는 build-logic/·gradle/로 시작하는 경로도 본다.
- 문서: AGENTS.md 지도, README 구조 표, leaf AGENTS.md의 cd src, gates·
  operate·결정 색인, src/bootstrap/AGENTS.md를 조립 계층 family 규칙으로
  다시 쓴다. 기록 문서(docs/design·history·reviews, 지난 upgrade 안내,
  capability-status 제거 표)는 머리 블록만 고친다. 파생 서비스용 안내
  docs/upgrade/2026-11-relayout.md를 더한다.

위험: bootRun working dir가 저장소 루트가 되어 .env와 상대 경로 설정이
루트 기준이다. 루트 .env는 compose 보간에도 읽힌다(upgrade 안내 5절).
파생 서비스는 태그 pre-relayout-2026-11까지 받은 뒤 이 묶음을 받는다.

검증: desktop에서 캐시 없이 scripts/verify.sh docs·pr·main·release,
compose smoke 18 lane, 빠른 시작(scripts/verify.sh app). 결과는 PR 본문.
구조 리뷰(arch-reviewer) 지적 5건을 반영했다.

BREAKING CHANGE: Gradle은 저장소 루트에서 돈다(cd src 없음). registry는
gradle/modules.json, 이미지 빌드 context는 저장소 루트다. 옛 경로 → 새 경로
표는 docs/upgrade/2026-11-relayout.md.
Refs: design-docs repo-structure/01-backend-layout.md 6.1절 가-2·가-3
2026-11-11 22:15:42 +09:00

4.0 KiB

기록 · 설계서 본문은 쓴 때의 원문이다. 지금 동작은 「현재 정본」을 읽는다.

  • 상태: 확인 안 함
  • 작성일: 2026-09-19
  • 요약: 가짜 조정 bean 없이 다중 인스턴스 런타임 계약을 세우는 설계다.
  • 현재 정본: src/bootstrap/app/README.md

Multi-instance Runtime Contract

Goal

Close tech-lead finding C2 without inventing placeholder coordination beans.

ca-skeleton.runtime.multi-instance-enabled must describe a runtime capability that the shipped composition can actually provide.

Current defect

StartupSafetyValidator treats multi-instance mode as a promise that five named beans exist:

  • distributedLockProvider
  • cacheStampedeProtection
  • outboxLeaderElection
  • distributedRateLimiter
  • migrationStartupRunner

Two names have no production definition at all. The unit test hides that by registering five plain Object beans, and the shipped distributed-lock system test had to register unrelated fake siblings just to prove the real JDBC lock composition.

The list also conflates unrelated concerns:

  • cache refresh coordination is explicitly optional efficiency, not a correctness lock;
  • edge rate limiting has its own transport/provider activation contract;
  • outbox owns its own SKIP LOCKED coordination when the outbox capability is enabled;
  • migration startup is not an instance-coordination provider.

Canonical meaning

multi-instance-enabled=true selects the cross-instance implementation of the application DistributedLockPort.

Therefore the runtime contract is:

  1. capability dependency validation requires JPA/relational persistence;
  2. persistence-jpa creates jdbcDistributedLock;
  3. bootstrap creates the primary distributedLockProvider decorator;
  4. StartupSafetyValidator verifies that the shipped distributed-lock provider exists and is a DistributedLockPort.

No other capability is implicitly enabled by this switch.

Capability-specific distributed guarantees remain capability-specific:

  • Redis edge rate limiting is required only when edge rate limiting is enabled and its provider is selected;
  • cache refresh coordination remains disabled unless a real CacheRefreshCoordinationPort implementation is explicitly composed in a future slice;
  • outbox coordination exists only with the outbox capability;
  • migration startup follows the migration setting.

Fail-closed behavior

When multi-instance mode is enabled but the distributed lock provider is absent or has the wrong type, startup fails through the existing ADAPTER_ENABLEMENT / exit-72 path.

The validator does not accept arbitrary bean names as evidence for unrelated capabilities.

Verification

  • unit: missing/wrong-type distributedLockProvider fails; correct typed provider passes;
  • system: real shipped H2/JPA composition starts with multi-instance enabled without any fake cache/rate-limit/outbox coordination beans, and exposes both jdbcDistributedLock and the metered distributedLockProvider;
  • existing JPA-off dependency failure remains;
  • app-bootstrap unit/system/architecture regressions stay green.

Verified result

  • the shipped system proof first failed exactly because the stale five-bean validator still required nonexistent sibling capabilities;
  • StartupSafetyValidator now validates only the real distributedLockProvider contract and requires the bean to implement DistributedLockPort;
  • name-only Object placeholders fail closed;
  • the fake five-bean unit fixture is removed;
  • the shipped H2/JPA composition starts with multi-instance mode enabled without fake cache, rate-limit, outbox, or migration siblings;
  • CapabilityDependencyValidator still requires JPA when multi-instance mode is enabled;
  • persistence-jpa distributed-lock tests: PASS;
  • app-bootstrap Spotless, full test, full systemTest and architectureTest: PASS;
  • stale phantom-bean contract scan: 0;
  • git diff --check: PASS.