Files
clean-architecture-backend-…/src/bootstrap/notification-platform/README.md
T
DongHyeonka 7b5b4c6983 fix(http)!: fileserver·notification HTTP와 bulk envelope를 공용 계약대로 답한다
문제: fileserver·notification의 HTTP 표면이 공용 계약(web AGENTS B8,
http-contract §1, manual 11)과 달랐다.
- fileserver batch는 part가 실패해도 success:true였고 결과를 data.results에
  넣었다. fullySucceeded()를 아무도 부르지 않았다. 계약끼리도 달랐다(web B8의
  BATCH_PARTIAL_FAILURE vs fileserver 계약의 200 + results[].error).
- BulkEnvelope.partial의 error.message가 영어 고정 문구였고, BulkItemResult는
  호출자 문구를 그대로 실었으며 null 키를 남겼다(mix-in 없음).
- Content-Range가 CORS 노출 목록에 없어 브라우저가 다운로드를 이어 받지 못했다.
- 알림 제출·template 게시의 모르는 channel·slot·locale이 details 없는
  BAD_PARAMETER였고(주석은 validation error), template 경로가 lowerCamel이 아닌
  /notification-templates였다.
- 전송 넷(raw·multipart·draft-12·tus)이 이름 없는 업로드에 "upload.bin"을
  지어 넣었다. 앱 정책 OriginalFilenamePolicy의 기본값은 "file"이라 업무 규칙이
  두 곳에 있었다(HARD-STOP 4).
- EnvelopeWireShapeTest는 http-contract §1의 증거로 쓰이는데 data null 키 생략,
  String → Envelope, unsorted page의 sort:null, 부분 실패 문구를 보지 않았다.

고른 방법:
- 리뷰 README 6절 ①대로 fileserver batch도 공용 bulk envelope다. 모두 성공 →
  success:true + results, 하나라도 실패 → success:false + BATCH_PARTIAL_FAILURE +
  part별 details(index, status, id, code, message). 성공한 part는 되돌리지 않는다.
  BatchUploadResponse는 쓰는 곳이 없어져 지웠다.
- BulkEnvelope.partial과 BulkItemResult.error(index, ApiErrorCode)는 category
  고정 문구를 쓴다. BulkItemResult에 null 생략 mix-in을 더했다.
- 알림 controller는 NotificationFieldRejection(VALIDATION_FAILED carrier, 필드를
  짚는 details 하나, 거절한 값은 싣지 않음)을 던진다. template 경로는
  /notificationTemplates다. 읽는 endpoint가 없어 201에 Location을 싣지 않고,
  manual 11 규칙에 그 경우를 적었다.
- 전송은 이름이 없으면 빈 이름을 넘기고 OriginalFilenamePolicy가 정한다.
- EnvelopeWireShapeTest에 빠진 넷을 더했다. EnvelopeTest의 when 둘인 시험을
  둘로 나눴다.
버린 대안: /notification-templates를 별칭으로 남기기 — 같은 자원의 경로가 둘이
되고 인가·공개 경로 스냅숏이 둘을 따로 봐야 한다.

위험·한계: batch를 읽는 client, 알림 template 경로를 쓰는 client와 배포
스크립트, BulkItemResult.error(index, code, message)를 부르던 코드가 바뀐다
(upgrade 안내 6·7·10·11·12, 14).

BREAKING CHANGE: fileserver batch 응답이 공용 bulk envelope가 됐다. 알림
template 경로가 /notificationTemplates다. 알림의 모르는 vocabulary 값은
VALIDATION_FAILED다. BulkItemResult.error는 ApiErrorCode를 받는다. 이름 없는
업로드의 표시 이름이 "file"이다. 할 일은 docs/upgrade/2026-11-round9-contracts.md.

Refs: RR9-03-01, RR9-03-02, RR9-03-09, RR9-03-13, RR9-03-21, RR9-05-09
2026-11-13 04:46:39 +09:00

4.5 KiB

composition:notification-platform — 알림 capability

  • Module ID: composition-notification-platform
  • Gradle path: :composition:notification-platform
  • Package: dev.caskeleton.composition.notification
  • 테스트: ./gradlew :composition:notification-platform:test --console=plain

제공하는 것

이 모듈 하나를 붙이면 알림 기능 전체가 들어온다.

composition:notification-platform
  ├─ NotificationApplicationCompositionAutoConfiguration  (use case 조립, `enabled` 조건)
  │    ├─ NotificationSubmissionConfiguration   접수·예약·취소·조회·템플릿 발행 use case
  │    ├─ NotificationDeliveryConfiguration     발송·재조정·lease 회수·ledger 투영·운영자 plane
  │    └─ NotificationCallbackConfiguration     provider 콜백 수집 + ProviderCallbackIngressBridge
  ├─ config/module-defaults/notification.yml (설정 기본값, support 로더가 읽음)
  ├─ adapter:outbound:notification      provider(SMTP·SES), 저장 외 런타임, NotificationPlatformAutoConfiguration
  ├─ adapter:outbound:persistence-notification  (runtimeOnly) 알림 entity·저장소·Flyway stream
  ├─ adapter:outbound:persistence-jpa   (runtimeOnly) DataSource·Flyway core·TransactionPort
  └─ adapter:inbound:web-notification   POST /notifications, POST /notificationTemplates,
                                        POST /internal/notification/callbacks/{provider}/{profile}
  • 조립 순서: 이 모듈의 root는 NotificationPlatformAutoConfiguration(outbound leaf) 뒤에 온다 (afterName).
  • 설정: config/module-defaults/notification.yml을 support의 ModuleDefaultsEnvironmentPostProcessor가 읽는다. 우선순위는 가장 낮다. 그래서 application*.yml, 환경 변수, 시스템 속성이 항상 이긴다. app-bootstrap은 이 파일을 모른다.
  • 저장소: 요청·발송·ledger 테이블과 migration은 adapter:outbound:persistence-notification에 있고, 그 테이블이 사는 관계형 플랫폼(DataSource, Flyway core stream, capability schema registry, TransactionPort)은 adapter:outbound:persistence-jpa다. 이 모듈이 둘 다 runtimeOnly로 가져오므로 (fileserver와 같은 한 줄 원칙) 따로 넣을 줄은 없다. APP_PERSISTENCE_JPA_ENABLED=false로 끄면 안 된다.

추가할 한 줄

// src/bootstrap/app/build.gradle
runtimeOnly project(':composition:notification-platform')       // 알림 (저장소·JPA 플랫폼 포함)

기본 조립에는 없다(src/bootstrap/app/build.gradle에 주석 처리된 줄로 있다). 이 줄을 지우면 use case 조립, provider 어댑터, HTTP 엔드포인트, 설정 기본값이 모두 함께 빠진다.

켜기와 끄기

모듈이 있으면 켜진다. app.notification.platform.enabled(APP_NOTIFICATION_PLATFORM_ENABLED, 기본 true)를 false로 줄 때만 꺼지고, 그때는 아무것도 바인딩하지 않는다. 켜진 상태에서는 아래 "항상" 키가 없으면 기동이 거부된다.

필요한 env 키

전체 목록과 타입·기본값은 docs/registries/env-keys.yaml의 APP_NOTIFICATION_*, SPRING_MAIL_* 행이 SSOT다. 켤 때 실제로 넣어야 하는 것:

언제 키
항상 데이터베이스 연결 env(APP_DATASOURCE_URL, APP_DATASOURCE_USERNAME, APP_DATASOURCE_PASSWORD)
항상 (키 7종과 각 키 id, 32바이트 이상 base64, 서로 달라야 함) APP_NOTIFICATION_PLATFORM_{CONTACT_ENCRYPTION,CONTACT_LOOKUP_HMAC,CALLBACK_SIGNING,PROVIDER_CREDENTIAL,PAYLOAD_ENCRYPTION,PROVIDER_REQUEST_LOOKUP_HMAC,CALLBACK_FINGERPRINT_HMAC}_KEY, 같은 이름 + _ID
SMTP provider APP_NOTIFICATION_PLATFORM_SMTP_ENABLED=true, APP_NOTIFICATION_PLATFORM_SMTP_SENDER_IDENTITY, SPRING_MAIL_HOST, SPRING_MAIL_PORT, SPRING_MAIL_USERNAME, SPRING_MAIL_PASSWORD
SES provider APP_NOTIFICATION_PLATFORM_SES_ENABLED=true, APP_NOTIFICATION_PLATFORM_SES_SENDER_IDENTITY, APP_NOTIFICATION_PLATFORM_SES_ACCESS_KEY_ID, APP_NOTIFICATION_PLATFORM_SES_CREDENTIAL_KEY_ID, APP_NOTIFICATION_PLATFORM_SES_REGION
provider 콜백 APP_NOTIFICATION_PLATFORM_CALLBACKS_ENABLED=true, SES는 APP_NOTIFICATION_PLATFORM_SES_ALLOWED_TOPIC_ARNS, 프록시 뒤라면 APP_SERVER_FORWARD_HEADERS_STRATEGY=native + server.tomcat.remoteip.internal-proxies(콜백 전용 프록시 목록은 없다)

나머지(발송 배치 크기, lease, 준비 상태 임계값 등)는 기본값으로 동작한다. 설명은 docs/notification/configuration-reference.md.