diff --git a/docs/manual/07-authorization.md b/docs/manual/07-authorization.md index aa629936..0dc62084 100644 --- a/docs/manual/07-authorization.md +++ b/docs/manual/07-authorization.md @@ -81,7 +81,8 @@ client가 같은 이름의 역할을 정의해도 이 서비스 권한이 되지 어디서든 ─▶ @SystemInvoked 유스케이스를 bean으로 등록 ──✗ (기동 실패) ``` -- 사용자 전송: 사용자가 보낸 요청이 들어오는 inbound adapter다(web·GraphQL·gRPC·WebSocket). +- 사용자 전송: 사용자가 보낸 요청이 들어오는 inbound adapter다(web·GraphQL·gRPC·WebSocket). STOMP + 클라이언트가 보낸 프레임마다 도는 inbound channel interceptor도 여기에 든다. - 시스템 호출자: broker 전달이나 시간(tick)이 깨우는 코드다. 사용자 요청은 여기로 들어오지 않는다. 시스템 호출자가 `@SystemInvoked` 유스케이스를 얻는 길은 아래 셋뿐이다. 이 표가 정본이고, 다른 문서는 이 @@ -102,16 +103,19 @@ client가 같은 이름의 역할을 정의해도 이 서비스 권한이 되지 | --- | --- | --- | | bean 금지 | `@SystemInvoked` 유스케이스가 bean이면 기동 실패. 호출자가 `new`로 만들어 혼자 들고 있는 것만 허용한다 | `src/composition/service-runtime/src/main/java/dev/caskeleton/composition/runtime/authorization/PermissionEnforcementGuard.java` | | 시스템 호출자만 | inbound adapter가 그 클래스에 의존하면 빌드 실패. `@SystemCaller(reason = "...")`를 단 클래스와 그 안에 중첩된 클래스만 예외 | `ONLY_SYSTEM_CALLERS_REACH_SYSTEM_INVOKED_USE_CASES`(`ApplicationBoundaryArchitectureTest`) | -| 표시 검사 | `@SystemCaller` 클래스와 그 안에 중첩된 클래스는 `..adapter.inbound.messaging..`·`..adapter.inbound.scheduler..`에만 있고, 사용자 전송 타입(controller·JAX-RS·GraphQL·STOMP mapping·gRPC·servlet)에 의존하지 않는다 | `SYSTEM_CALLERS_ARE_SYSTEM_DRIVEN_INBOUND_ADAPTERS`(같은 파일) | -| 전송 → 시스템 호출자 금지 | 사용자 전송 클래스가 `@SystemCaller`나, 그 클래스가 구현·상속하는 프로젝트 타입(작업의 인터페이스 등)에 의존하면 빌드 실패. 중간 클래스를 거쳐도 잡는다. 사용자 전송 클래스는 넷이다. ① 사용자 전송 패키지에 있는 클래스. ② 설정(`@Configuration`·`@AutoConfiguration`) 클래스 자신이 요청 처리기 타입(함수형 `RouterFunction`·`HandlerFunction`, `@RestController`·`@RequestMapping`, servlet·`Filter`·`HandlerInterceptor`, `WebSocketHandler`, GraphQL `DataFetcher`·`RuntimeWiringConfigurer`, gRPC `BindableService`·`ServerInterceptor` 등)에 의존하는 것. 요청 처리 코드를 설정에 직접 쓴 경우와 등록만 한 경우가 모두 든다. 함수형 route나 data fetcher를 람다로 쓰면 그 코드가 설정 클래스의 메서드로 컴파일되어 설정이 곧 endpoint다. 처리 코드를 다른 클래스에 두고 메서드 참조로 등록만 해도(`route().GET("/orders", orders::list)`) 설정은 route builder에 의존한다. 클래스 의존으로는 등록과 처리 코드를 가를 수 없어서 둘 다 사용자 전송으로 센다. ③ 설정 안에 중첩된 클래스 가운데 사용자 전송 타입에 의존하는 것. 중첩된 JAX-RS 자원·`@ServerEndpoint`도 여기서 잡힌다. 설정용 타입(`WebMvcConfigurer`·`WebSocketConfigurer`·STOMP broker 설정과 그 registry, CORS 설정, `RequestMethod`)에만 의존하는 중첩 클래스는 설정의 일부로 본다. ④ 그 밖의 클래스 가운데 사용자 전송 타입에 의존하는 것. 그래서 handler를 bean으로 등록하는 설정은 같은 클래스에서 `WebMvcConfigurer`(설정 필드를 읽는 익명 클래스여도)·CORS 설정·controller bean을 함께 만들어도 걸리지 않는다. 같은 클래스에 "지금 실행" route·data fetcher·interceptor를 쓰거나, route를 등록하거나, 안에 중첩한 endpoint가 작업을 부르면(설정의 메서드를 거쳐 불러도) 걸린다. route·data fetcher·interceptor 등록은 handler bean을 만드는 설정과 다른 설정에 둔다. 설정이 만드는 controller는 controller 자신이 검사받는다 | `USER_TRANSPORTS_DO_NOT_REACH_SYSTEM_CALLERS`(같은 파일) | +| 표시 검사 | `@SystemCaller` 클래스와 그 안에 중첩된 클래스는 `..adapter.inbound.messaging..`·`..adapter.inbound.scheduler..`에만 있고, 사용자 전송 타입(controller·JAX-RS·GraphQL·STOMP mapping과 channel interceptor·gRPC·servlet)에 의존하지 않는다 | `SYSTEM_CALLERS_ARE_SYSTEM_DRIVEN_INBOUND_ADAPTERS`(같은 파일) | +| 전송 → 시스템 호출자 금지 | 사용자 전송 클래스가 `@SystemCaller`나, 그 클래스가 구현·상속하는 프로젝트 타입(작업의 인터페이스 등)에 의존하면 빌드 실패. 중간 클래스를 거쳐도 잡는다. 사용자 전송 클래스는 넷이다. ① 사용자 전송 패키지에 있는 클래스. ② 설정(`@Configuration`·`@AutoConfiguration`) 클래스 자신이 요청 처리기 타입(함수형 `RouterFunction`·`HandlerFunction`, `@RestController`·`@RequestMapping`, servlet·`Filter`·`HandlerInterceptor`, `WebSocketHandler`, GraphQL `DataFetcher`·`RuntimeWiringConfigurer`, gRPC `BindableService`·`ServerInterceptor`, STOMP `ChannelInterceptor`·`ExecutorChannelInterceptor` 등)에 의존하는 것. 요청 처리 코드를 설정에 직접 쓴 경우와 등록만 한 경우가 모두 든다. channel interceptor를 구현한 설정은 프레임마다 자기 메서드가 돈다. interceptor를 `@Bean`으로 내놓는 설정은 route를 등록하는 설정과 같다. 함수형 route나 data fetcher를 람다로 쓰면 그 코드가 설정 클래스의 메서드로 컴파일되어 설정이 곧 endpoint다. 처리 코드를 다른 클래스에 두고 메서드 참조로 등록만 해도(`route().GET("/orders", orders::list)`) 설정은 route builder에 의존한다. 클래스 의존으로는 등록과 처리 코드를 가를 수 없어서 둘 다 사용자 전송으로 센다. ③ 설정 안에 중첩된 클래스 가운데 사용자 전송 타입에 의존하는 것. 중첩된 JAX-RS 자원·`@ServerEndpoint`, `configureClientInboundChannel`에서 등록하는 STOMP channel interceptor(익명 클래스여도, STOMP 헤더를 읽지 않아도)도 여기서 잡힌다. 설정용 타입(`WebMvcConfigurer`·`WebSocketConfigurer`·STOMP broker 설정과 그 registry, CORS 설정, `RequestMethod`)에만 의존하는 중첩 클래스는 설정의 일부로 본다. inbound channel의 thread 수만 정하는 설정도 설정용이다. ④ 그 밖의 클래스 가운데 사용자 전송 타입에 의존하는 것. 사용자 전송 패키지 밖에 둔 channel interceptor가 여기에 든다. 그래서 handler를 bean으로 등록하는 설정은 같은 클래스에서 `WebMvcConfigurer`(설정 필드를 읽는 익명 클래스여도)·CORS 설정·controller bean을 함께 만들어도 걸리지 않는다. 같은 클래스에 "지금 실행" route·data fetcher·interceptor를 쓰거나, route를 등록하거나, 안에 중첩한 endpoint가 작업을 부르면(설정의 메서드를 거쳐 불러도) 걸린다. route·data fetcher·interceptor 등록은 handler bean을 만드는 설정과 다른 설정에 둔다. 설정이 만드는 controller는 controller 자신이 검사받는다 | `USER_TRANSPORTS_DO_NOT_REACH_SYSTEM_CALLERS`(같은 파일) | | 프로젝트 밖 상위 타입 금지 | `@SystemCaller` 클래스와 그 안에 중첩된 클래스(익명·지역 클래스와 예외 제외)는 프로젝트(`dev.caskeleton..`) 밖의 클래스·인터페이스를 상속·구현하지 않는다. `Runnable`은 누구나 의존하는 타입이라, endpoint가 작업을 `Runnable`로 주입받아도 위 규칙이 다른 사용과 구별하지 못하기 때문이다. 메시지 handler의 `MessageHandler`는 프로젝트 타입이라 된다. record·enum은 언어가 붙이는 상위 타입(`Record`, `Enum`과 `Enum`이 구현하는 `Comparable`·`Serializable`·`Constable`)만은 가져도 된다. 그래서 handler 안의 파싱 결과 record, 결과 enum, 독(poison) 메시지 예외, record로 쓴 handler는 통과하고, `Runnable`을 구현한 record는 걸린다 | `SYSTEM_CALLERS_HAVE_ONLY_PROJECT_SUPERTYPES`(같은 파일) | 규칙은 "누가 닿으면 안 되나"가 아니라 "누가 닿아도 되나"를 적는다. 이 성질은 **패키지** 쪽에서만 온다. 패키지는 허용 목록이라, 나중에 새 전송 패키지가 생겨도 따로 고치지 않아도 막힌다. 사용자 전송 **타입** 쪽은 나열 목록이다(`ARE_USER_TRANSPORT_TYPES`). 시스템 패키지 안에 놓인 endpoint를 알아보는 데 쓰는 목록이라, 목록에 없는 전송 라이브러리로 만든 endpoint는 전송으로 보이지 않는다. 새 전송 라이브러리를 -들이면 그 패키지를 이 목록에 더한다. 설정 클래스 자신을 판정하는 요청 처리기 타입 -(`ARE_REQUEST_HANDLER_TYPES`)도 나열 목록이라, 새 전송 라이브러리의 handler 타입을 함께 더한다. 요청 처리기 +들이면 그 패키지를 이 목록에 더한다. 들인 라이브러리에서 사용자 요청이 지나는 타입을 새로 쓸 때도 같다. +STOMP는 `org.springframework.messaging` 가운데 `simp` 패키지, `@MessageMapping`, inbound channel +interceptor 두 타입(`ChannelInterceptor`·`ExecutorChannelInterceptor`)만 목록에 있다. 같은 라이브러리의 +broker listener용 `@Payload`·`@Header`는 시스템 쪽이라 넣지 않는다. 설정 클래스 자신을 판정하는 요청 처리기 +타입(`ARE_REQUEST_HANDLER_TYPES`)도 나열 목록이라, 새 전송 라이브러리의 handler 타입을 함께 더한다. 요청 처리기 타입은 모두 사용자 전송 타입이어야 하고, 설정용 타입(`ARE_TRANSPORT_SETUP_TYPES`)은 요청 처리기 타입을 덮지 않아야 한다. `UserTransportTypeListsTest`가 둘을 검사한다. 설정용 타입 목록에 없는 configurer 타입을 쓰는 중첩 클래스는 사용자 전송으로 읽혀, 설정 필드를 읽으면 빌드가 실패한다. 그 타입이 요청마다 도는 코드가 아니라 기동 때 @@ -132,7 +136,9 @@ client가 같은 이름의 역할을 정의해도 이 서비스 권한이 되지 아니다. - 설정 클래스 자신에 쓴 요청 처리 코드가 요청 처리기 타입 목록(`ARE_REQUEST_HANDLER_TYPES`)에 없는 타입으로 쓰인 경우. 목록 방식이라, 목록에 없는 endpoint 타입으로 설정 클래스에 직접 쓴 endpoint는 사용자 전송으로 - 보이지 않는다. 설정 안에 중첩한 클래스는 더 넓은 사용자 전송 타입 목록으로 보므로 여기에 들지 않는다. + 보이지 않는다. 설정 안에 중첩한 클래스는 더 넓은 사용자 전송 타입 목록으로 보므로 여기에 들지 않는다. 다만 + 그 목록도 나열 목록이라, 그 목록에 없는 타입으로 만든 endpoint는 어디에 두든 보이지 않는다. 그런 타입을 + 쓰게 되면 앞 절의 사용자 전송 타입 목록 문단대로 목록에 더한다. 이 길을 막는 것은 ArchUnit 규칙이 아니라 다음 셋이다. diff --git a/docs/upgrade/2026-11-maturity-review.md b/docs/upgrade/2026-11-maturity-review.md index fc94b1ef..1ee3922c 100644 --- a/docs/upgrade/2026-11-maturity-review.md +++ b/docs/upgrade/2026-11-maturity-review.md @@ -4,7 +4,7 @@ - 커밋: `34565130` High·P1 19건 · `1400dc15` 남은 발견·매뉴얼·생성 명령 · `5786126c` 남은 항목과 합친 뒤 결함 · `7ef8d0b4` 재리뷰 기록 · `bbe944bd` 재리뷰 결함 · `ecc74b7d` 2차 재리뷰 기록·이 안내 · `1885bf8d` 2차 재리뷰 결함 · `339cf8fd` 3차 확인 리뷰 기록 · `f40c03c6` 3차 확인 리뷰 Minor · `c2e55510` 마지막 확인 리뷰 기록 · - `2678955c` 테스트 코드 정적 분석(B-40) · `70fb80bf` 소유자가 다시 정한 기본값 3가지(늦은 멱등 완료 기록, `failure-retention` 기동 검사, workflow `cd`) · B4 성능 lane 단언 상시화(2026-11-06, B-43) · `paths` 필터 trigger를 단계 실행으로 세지 않음(2026-11-06 소유자 결정, B-36) · r8-f1 전송 오류 처리(2026-11-07, B-45~B-48) · r9-g1 GraphQL 판정 순서와 인자 변환 단계(2026-11-07 소유자 결정, B-45·B-46) · 태그 push·`release` workflow는 `releaseCheck`에만 셈(2026-11-07 소유자 결정, B-36) · 실패한 동시 인덱스 drop의 복구 절차(2026-11-07, 재리뷰 RR8-03-01, 5절) — `docs(...)` 커밋은 문서만 바꾼다 + `2678955c` 테스트 코드 정적 분석(B-40) · `70fb80bf` 소유자가 다시 정한 기본값 3가지(늦은 멱등 완료 기록, `failure-retention` 기동 검사, workflow `cd`) · B4 성능 lane 단언 상시화(2026-11-06, B-43) · `paths` 필터 trigger를 단계 실행으로 세지 않음(2026-11-06 소유자 결정, B-36) · r8-f1 전송 오류 처리(2026-11-07, B-45~B-48) · r9-g1 GraphQL 판정 순서와 인자 변환 단계(2026-11-07 소유자 결정, B-45·B-46) · 태그 push·`release` workflow는 `releaseCheck`에만 셈(2026-11-07 소유자 결정, B-36) · 실패한 동시 인덱스 drop의 복구 절차(2026-11-07, 재리뷰 RR8-03-01, 5절) · STOMP channel interceptor를 사용자 전송으로 셈(2026-11-07, B-16) — `docs(...)` 커밋은 문서만 바꾼다 - 근거 문서: `docs/reviews/2026-11-01-maturity-review/README.md` 13~16절, `docs/reviews/2026-11-03-rereview/README.md` 4·6·8~13절, 각 커밋의 `BREAKING CHANGE:` 꼬리말 - 아래 표의 각 줄은 위 범위의 diff와 코드로 확인했다. 확인하지 못한 것은 그 자리에 "확인 못 함"으로 적었고 9절에 @@ -75,7 +75,7 @@ | B-13 | `app.security.*` strict 바인딩: 접두어 아래 오타 키, 또는 설정·placeholder 어디에도 쓰이지 않는 `APP_SECURITY_*` 환경 변수가 기동을 막는다 | 기동 실패(메시지는 `StrictSettingsBinder`가 키 이름을 담아 냄, 정확한 문구 확인 못 함) | 쓰지 않는 `APP_SECURITY_*` 변수를 지운다 | `5786126c` · `SecuritySettings.bind`, `src/adapter/outbound/support/.../StrictSettingsBinder.java` | | B-14 | prod 프로필에서 `fixture-`로 시작하는 비밀값을 거부(레지스트리 `secret` 행, 모듈이 기여한 비밀, `secret://…/` 참조 대상. `HOSTNAME`·앱 이름 같은 비밀 아닌 값은 보지 않는다 — RR2-04-01). Redis ACL fixture 파일 이름 변경: `infra/redis-sdk/acl/all-accounts.acl` → `lane-fixture-accounts.acl` | prod 기동 실패, 요약 `prod secret/config-source contract is invalid`(exit 78). 옛 ACL 경로를 mount하던 compose는 파일 없음 | prod 값을 진짜 비밀로 바꾼다. compose의 ACL 경로를 새 이름으로. Redis SDK admin 계정(`RedisAccountContribution`)을 조립했다면 그 변수를 `static` `RequiredProductionSecrets` bean으로도 낸다(코드에 든 참조는 검사가 보지 않는다, RR3-04-03, `src/adapter/outbound/redis-sdk/README.md`) | `bbe944bd` · `src/app-bootstrap/.../runtime/SecretSourceValidator.java`, `docs/registries/secrets-classification.yaml` | | B-15 | 기동 rule이 모든 singleton보다 먼저 돈다(`StartupRuleRunner`가 `BeanFactoryPostProcessor`). `StartupRule`과 `RequiredProductionSecrets` bean은 `static @Bean`이고 `Environment`, bean factory, static 무인자 `RequiredProductionSecrets`의 `ObjectProvider`만 받아야 한다. 두 타입의 클래스는 `@Value`·`@Autowired`·`@Inject`·`@Resource` 멤버, `@PostConstruct`·`@PreDestroy`, `@ConfigurationProperties`를 가질 수 없다(post-processor보다 먼저 만들어져 비어 있게 된다, RR2-04-03) | non-static `@Bean`이거나 다른 bean을 받으면 기동 실패 `startup rule or secret list '<이름>' created [] while creating it ... Declare the rule with a static @Bean method ...`, 위 멤버가 있으면 `'<이름>' (...) is a StartupRule or RequiredProductionSecrets ... but it needs one: [...]`(둘 다 exit 78, 둘 다 모든 프로필. runner가 rule과 비밀 목록을 프로필과 무관하게 먼저 만들어, 인터페이스 타입 `@Bean`이 돌려준 실제 클래스까지 본다, RR3-04-01) | rule 선언을 `static`으로, 인자를 위 셋으로 줄인다. 값은 `violations(Environment)`가 받는 `Environment`에서 읽는다. 다른 bean이 필요한 검사는 rule이 아니라 일반 bean으로 둔다 | `34565130`, `bbe944bd` · `src/adapter/outbound/support/.../startup/StartupRule.java`, `StartupRuleRunner.java` | -| B-16 | 권한 가드(새 `PermissionEnforcementGuard`): `@SystemInvoked` 유스케이스가 bean이면 기동 실패. `@RequiresPermission`을 단 bean에 적용되는 advisor가 없어도 기동 실패. ArchUnit `SYSTEM_INVOKED_USE_CASES_DECLARE_NO_PERMISSION`, `ONLY_SYSTEM_CALLERS_REACH_SYSTEM_INVOKED_USE_CASES`, `SYSTEM_CALLERS_ARE_SYSTEM_DRIVEN_INBOUND_ADAPTERS`, `USER_TRANSPORTS_DO_NOT_REACH_SYSTEM_CALLERS`, `SYSTEM_CALLERS_HAVE_ONLY_PROJECT_SUPERTYPES` 추가, 새 표시 `@SystemCaller` | 기동 실패 `@SystemInvoked use cases are registered as beans ...` 또는 `beans declare @RequiresPermission but no advisor enforces it ...`(exit 72). `@SystemCaller`가 아닌 inbound adapter가 그 유스케이스를 부르거나, 사용자 전송(controller 등)이 `@SystemCaller` bean을 직접·중간 클래스를 거쳐·그 작업이 구현하는 프로젝트 인터페이스로 부르면 architectureTest 실패. `@SystemCaller` 클래스가 `Runnable`·`ApplicationRunner` 같은 프로젝트 밖 타입을 구현·상속해도 실패. 설정(`@Configuration`)은 웹 bean(`WebMvcConfigurer`·CORS 설정·controller bean)과 handler bean을 함께 등록해도 사용자 전송으로 세지 않지만, 요청 처리기 타입(함수형 route·data fetcher·interceptor)에 의존하면 사용자 전송으로 센다. 처리 코드를 설정에 직접 쓰든, 다른 클래스의 메서드를 참조해 등록만 하든 같다. 설정 안에 중첩된 클래스는 설정용 타입(configurer·registry·CORS 설정·`RequestMethod`)에만 의존할 때를 빼고 다른 클래스처럼 사용자 전송 타입으로 판정한다(중첩된 JAX-RS 자원·`@ServerEndpoint`도 잡힌다). record·enum이 언어로 받는 상위 타입(`Record`·`Enum` 등)과 예외 클래스는 프로젝트 밖 상위 타입으로 세지 않는다 | 시스템만 부르는 쓰기 유스케이스는 composition에서 `new`로 만들어 스케줄러에 넘기거나, 메시지 handler·예약 작업이면 그 클래스에 `@SystemCaller`를 달고 생성자에서 `new`로 만든다. 예약 작업은 서비스 leaf의 `..adapter.inbound.scheduler..` 패키지에 둔다. 세 경로와 두는 곳은 매뉴얼 07장 「시스템이 부르는 쓰기」(handler 작업 순서는 09장 「소비」 4단계). "지금 실행" endpoint가 필요하면 `@RequiresPermission` 유스케이스를 따로 만든다. 작업을 task scheduler에 직접 등록하던 코드는 작업이 `Runnable`을 구현하는 대신 등록하는 곳에서 `job::run`을 넘긴다. route·data fetcher·interceptor 등록은 handler bean을 만드는 설정과 다른 설정에 둔다. `@RequiresPermission`을 쓰면 web adapter(`MethodSecurityConfig`)가 조립돼 있어야 한다 | `1400dc15`, `bbe944bd`, r9 · `src/composition/service-runtime/.../authorization/PermissionEnforcementGuard.java`, `src/application-core/.../security/SystemInvoked.java`, `SystemCaller.java` | +| B-16 | 권한 가드(새 `PermissionEnforcementGuard`): `@SystemInvoked` 유스케이스가 bean이면 기동 실패. `@RequiresPermission`을 단 bean에 적용되는 advisor가 없어도 기동 실패. ArchUnit `SYSTEM_INVOKED_USE_CASES_DECLARE_NO_PERMISSION`, `ONLY_SYSTEM_CALLERS_REACH_SYSTEM_INVOKED_USE_CASES`, `SYSTEM_CALLERS_ARE_SYSTEM_DRIVEN_INBOUND_ADAPTERS`, `USER_TRANSPORTS_DO_NOT_REACH_SYSTEM_CALLERS`, `SYSTEM_CALLERS_HAVE_ONLY_PROJECT_SUPERTYPES` 추가, 새 표시 `@SystemCaller` | 기동 실패 `@SystemInvoked use cases are registered as beans ...` 또는 `beans declare @RequiresPermission but no advisor enforces it ...`(exit 72). `@SystemCaller`가 아닌 inbound adapter가 그 유스케이스를 부르거나, 사용자 전송(controller 등)이 `@SystemCaller` bean을 직접·중간 클래스를 거쳐·그 작업이 구현하는 프로젝트 인터페이스로 부르면 architectureTest 실패. `@SystemCaller` 클래스가 `Runnable`·`ApplicationRunner` 같은 프로젝트 밖 타입을 구현·상속해도 실패. 설정(`@Configuration`)은 웹 bean(`WebMvcConfigurer`·CORS 설정·controller bean)과 handler bean을 함께 등록해도 사용자 전송으로 세지 않지만, 요청 처리기 타입(함수형 route·data fetcher·interceptor)에 의존하면 사용자 전송으로 센다. 처리 코드를 설정에 직접 쓰든, 다른 클래스의 메서드를 참조해 등록만 하든 같다. 설정 안에 중첩된 클래스는 설정용 타입(configurer·registry·CORS 설정·`RequestMethod`)에만 의존할 때를 빼고 다른 클래스처럼 사용자 전송 타입으로 판정한다(중첩된 JAX-RS 자원·`@ServerEndpoint`도 잡힌다). STOMP inbound channel interceptor(`ChannelInterceptor`·`ExecutorChannelInterceptor`)도 사용자 전송 타입이자 요청 처리기 타입이다. 사용자 전송 패키지 밖에 둔 interceptor, 설정에 중첩한 interceptor(익명 클래스 포함), interceptor를 구현한 설정이 `@SystemCaller`에 닿거나, interceptor를 `@Bean`으로 내놓는 설정이 `@SystemCaller` bean도 만들면 실패한다(2026-11-07 전에는 STOMP 헤더 타입을 읽는 interceptor만 잡혔다). record·enum이 언어로 받는 상위 타입(`Record`·`Enum` 등)과 예외 클래스는 프로젝트 밖 상위 타입으로 세지 않는다 | 시스템만 부르는 쓰기 유스케이스는 composition에서 `new`로 만들어 스케줄러에 넘기거나, 메시지 handler·예약 작업이면 그 클래스에 `@SystemCaller`를 달고 생성자에서 `new`로 만든다. 예약 작업은 서비스 leaf의 `..adapter.inbound.scheduler..` 패키지에 둔다. 세 경로와 두는 곳은 매뉴얼 07장 「시스템이 부르는 쓰기」(handler 작업 순서는 09장 「소비」 4단계). "지금 실행" endpoint가 필요하면 `@RequiresPermission` 유스케이스를 따로 만든다. 작업을 task scheduler에 직접 등록하던 코드는 작업이 `Runnable`을 구현하는 대신 등록하는 곳에서 `job::run`을 넘긴다. route·data fetcher·interceptor 등록은 handler bean을 만드는 설정과 다른 설정에 둔다. STOMP channel interceptor 등록도 같다. `@RequiresPermission`을 쓰면 web adapter(`MethodSecurityConfig`)가 조립돼 있어야 한다 | `1400dc15`, `bbe944bd`, r9 · `src/composition/service-runtime/.../authorization/PermissionEnforcementGuard.java`, `src/application-core/.../security/SystemInvoked.java`, `SystemCaller.java` | | B-17 | `IntegrationEventDraft`: `eventId`·`causationId`는 소문자 UUIDv7만. ArchUnit `INTEGRATION_EVENT_DRAFTS_ARE_BUILT_BY_THE_SHARED_HELPER`: `new IntegrationEventDraft<>(...)` 금지, `IntegrationEventDrafts.draft(...)`만 | 이벤트를 만드는 쓰기 요청이 `IllegalArgumentException: eventId must be a canonical lower-case UUIDv7...`로 실패. architectureTest 실패 | event id를 UUIDv7로 만든다(예: sample `UuidOutboxEventIdFactory`가 `UuidCreator.getTimeOrderedEpochPlus1()`). draft는 헬퍼로 만든다. tenant가 없는 이벤트는 `IntegrationEventDrafts.SINGLE_TENANT_SCOPE`(`global`) | `1400dc15`, `bbe944bd` · `src/application-core/.../messaging/event/IntegrationEventDraft.java`, `IntegrationEventDrafts.java` | | B-18 | `MessageHandler.schemaVersions()`(vendored `messaging-core-api`, default `{v1}`): 소비자 decode 목록을 handler 선언으로 만든다. 같은 (메시지 타입, 버전)에 다른 payload class를 선언하면 실패 | 컴파일은 된다. v1이 아닌 메시지는 `SCHEMA_VERSION_NOT_REGISTERED`로 거부. 발행 등록(`MessageContracts`)과 class가 다르면 기동 실패 `MESSAGING_CONTRACT_CONFLICT` | v2 이상을 읽는 handler는 `schemaVersions()`를 override한다. 소비 타입을 `MessageContracts`에 따로 등록하던 코드는 지운다 | `5786126c` · `src/messaging/messaging-core-api/.../delivery/MessageHandler.java`, `messaging-spring-boot-starter/.../MessageContracts.java` | | B-19 | `APP_FLYWAY_ENABLED`가 모든 프로필에서 읽힌다. dev·prod 프로필 파일의 `spring.flyway.enabled: true`·`app.persistence.vendor` 고정값을 지우고 persistence-jpa `config/module-defaults`가 `${APP_FLYWAY_ENABLED:true}`를 싣는다 | dev·prod 환경에 `APP_FLYWAY_ENABLED=false`가 있으면 전에는 무시됐지만 이제 기동 때 마이그레이션이 안 돈다 | dev·prod 환경 값을 확인한다. 자기 `application-dev.yml`·`application-prod.yml`에 같은 고정값을 다시 넣지 않는다 | `5786126c` · `src/app-bootstrap/src/main/resources/application-{dev,prod}.yml`, `src/adapter/outbound/persistence-jpa/.../module-defaults/persistence-jpa.yml` | diff --git a/src/app-bootstrap/README.md b/src/app-bootstrap/README.md index 82a299da..91b2b7ee 100644 --- a/src/app-bootstrap/README.md +++ b/src/app-bootstrap/README.md @@ -501,6 +501,11 @@ ArchUnit 규칙이 **금지**하는 타입을 fixture 가 일부러 import 해 - `graphql-java` (`architectureTestCompileOnly`) — `SYSTEM_CALLERS_ARE_SYSTEM_DRIVEN_INBOUND_ADAPTERS`의 사용자 전송 타입 목록 중 `graphql..` 항목을 증명하는 fixture(`GraphQlJavaSystemCallerFixture`)가 graphql-java 타입 하나만 쓴다. runtime 은 GraphQL adapter 가 이미 같은 버전을 싣는다(lock 동일). +- `spring-messaging` (`architectureTestCompileOnly`) — 사용자 전송 타입 목록의 STOMP channel interceptor + 항목(`ChannelInterceptor`·`ExecutorChannelInterceptor`)을 증명하는 위반 fixture + (`violations/configuration/stomp/`)와 허용 fixture(inbound channel 설정만 하는 + `SystemCallerBesideStompBrokerSetupFixture`, 따로 둔 interceptor 설정 `FrameInterceptorConfigurationFixture`)가 쓴다. runtime 은 WebSocket adapter 가 이미 같은 버전을 + 싣는다(lock 동일). - `spring-cloud-context` — `@RefreshScope` 금지(no-refresh-scope) fixture 용. Spring Cloud 는 production 에 없고 규칙은 애너테이션을 FQN 문자열로 참조한다. BOM 이 spring-cloud 좌표를 관리하지 않아 버전을 명시 고정한다. diff --git a/src/app-bootstrap/build.gradle b/src/app-bootstrap/build.gradle index 3568cbf1..6aea0486 100644 --- a/src/app-bootstrap/build.gradle +++ b/src/app-bootstrap/build.gradle @@ -282,6 +282,11 @@ dependencies { // type list is a raw graphql-java data fetcher. The adapter brings graphql-java onto this source // set's runtime already (capabilityProjects); compile-only here so no shipped graph changes. architectureTestCompileOnly 'com.graphql-java:graphql-java' + // architecture-only: the STOMP fixtures for the channel-interceptor entries of the user-transport + // type list implement spring-messaging's ChannelInterceptor. The websocket adapter brings it onto + // this source set's runtime already (capabilityProjects); compile-only here so no shipped graph + // changes. + architectureTestCompileOnly 'org.springframework:spring-messaging' // Kafka producer ownership lives in adapter:outbound:messaging. The composition root sees only // the adapter module; it no longer implements the broker seam itself. testCompileOnly 'jakarta.ws.rs:jakarta.ws.rs-api' // jakarta.ws.rs.. diff --git a/src/app-bootstrap/gradle.lockfile b/src/app-bootstrap/gradle.lockfile index 5f322c6e..be76571d 100644 --- a/src/app-bootstrap/gradle.lockfile +++ b/src/app-bootstrap/gradle.lockfile @@ -361,7 +361,7 @@ org.springframework:spring-context:7.0.9=architectureTestCompileClasspath,archit org.springframework:spring-core:7.0.9=architectureTestCompileClasspath,architectureTestRuntimeClasspath,bootRunH2Classpath,compileClasspath,conditionalTransportBuildContractTestRuntimeClasspath,integrationTestCompileClasspath,integrationTestRuntimeClasspath,productionRuntimeClasspath,qualificationRuntimeClasspath,runtimeClasspath,systemTestCompileClasspath,systemTestRuntimeClasspath,testCompileClasspath,testRuntimeClasspath org.springframework:spring-expression:7.0.9=architectureTestCompileClasspath,architectureTestRuntimeClasspath,bootRunH2Classpath,compileClasspath,conditionalTransportBuildContractTestRuntimeClasspath,integrationTestCompileClasspath,integrationTestRuntimeClasspath,productionRuntimeClasspath,qualificationRuntimeClasspath,runtimeClasspath,systemTestCompileClasspath,systemTestRuntimeClasspath,testCompileClasspath,testRuntimeClasspath org.springframework:spring-jdbc:7.0.9=architectureTestCompileClasspath,architectureTestRuntimeClasspath,bootRunH2Classpath,integrationTestCompileClasspath,integrationTestRuntimeClasspath,qualificationRuntimeClasspath,systemTestCompileClasspath,testCompileClasspath,testRuntimeClasspath -org.springframework:spring-messaging:7.0.9=architectureTestRuntimeClasspath,bootRunH2Classpath,conditionalTransportBuildContractTestRuntimeClasspath,integrationTestRuntimeClasspath,qualificationRuntimeClasspath,testRuntimeClasspath +org.springframework:spring-messaging:7.0.9=architectureTestCompileClasspath,architectureTestRuntimeClasspath,bootRunH2Classpath,conditionalTransportBuildContractTestRuntimeClasspath,integrationTestRuntimeClasspath,qualificationRuntimeClasspath,testRuntimeClasspath org.springframework:spring-orm:7.0.9=architectureTestCompileClasspath,architectureTestRuntimeClasspath,bootRunH2Classpath,integrationTestCompileClasspath,integrationTestRuntimeClasspath,qualificationRuntimeClasspath,systemTestCompileClasspath,testCompileClasspath,testRuntimeClasspath org.springframework:spring-test:7.0.9=architectureTestCompileClasspath,architectureTestRuntimeClasspath,integrationTestCompileClasspath,integrationTestRuntimeClasspath,systemTestCompileClasspath,systemTestRuntimeClasspath,testCompileClasspath,testRuntimeClasspath org.springframework:spring-tx:7.0.9=architectureTestCompileClasspath,architectureTestRuntimeClasspath,bootRunH2Classpath,integrationTestCompileClasspath,integrationTestRuntimeClasspath,qualificationRuntimeClasspath,systemTestCompileClasspath,testCompileClasspath,testRuntimeClasspath diff --git a/src/app-bootstrap/src/architectureTest/java/dev/caskeleton/bootstrap/architecture/ApplicationBoundaryArchitectureTest.java b/src/app-bootstrap/src/architectureTest/java/dev/caskeleton/bootstrap/architecture/ApplicationBoundaryArchitectureTest.java index 2e51e6e1..41c77504 100644 --- a/src/app-bootstrap/src/architectureTest/java/dev/caskeleton/bootstrap/architecture/ApplicationBoundaryArchitectureTest.java +++ b/src/app-bootstrap/src/architectureTest/java/dev/caskeleton/bootstrap/architecture/ApplicationBoundaryArchitectureTest.java @@ -460,9 +460,10 @@ class ApplicationBoundaryArchitectureTest { /** * The framework packages user-transport endpoints are built from, each with its subpackages. - * {@code org.springframework.messaging} is named only for STOMP ({@code simp}, {@code - * MessageMapping} in {@link #USER_TRANSPORT_TYPE_NAMES}): a broker listener's {@code @Payload} - * and {@code @Header} live beside them and are a system consumer's, not a user's. + * {@code org.springframework.messaging} is named only for STOMP ({@code simp} here; {@code + * MessageMapping} and the channel interceptors in {@link #USER_TRANSPORT_TYPE_NAMES}): a broker + * listener's {@code @Payload} and {@code @Header} live beside them and are a system consumer's, + * not a user's. * *

This is a list, unlike the package allowlist above: a transport library missing from it is * not recognised as one. A service that brings in a new transport library adds its packages here @@ -479,11 +480,18 @@ class ApplicationBoundaryArchitectureTest { "jakarta.ws.rs", "graphql"); - /** The single user-transport types named beside the framework packages. */ + /** + * The single user-transport types named beside the framework packages. A STOMP client-inbound + * channel interceptor sees every frame a client sends and needs no {@code simp} type to act on + * one, so the two interceptor types are named here (review 2026-11-07 RR8-02-01); the rest of + * their package is a broker's plumbing, not an endpoint. + */ static final Set USER_TRANSPORT_TYPE_NAMES = Set.of( "org.springframework.stereotype.Controller", - "org.springframework.messaging.handler.annotation.MessageMapping"); + "org.springframework.messaging.handler.annotation.MessageMapping", + "org.springframework.messaging.support.ChannelInterceptor", + "org.springframework.messaging.support.ExecutorChannelInterceptor"); /** * What makes a class a way in for a user request: a user-transport adapter package, or the @@ -500,7 +508,9 @@ class ApplicationBoundaryArchitectureTest { JavaClass.Predicates.resideInAnyPackage( withSubpackages(USER_TRANSPORT_FRAMEWORK_PACKAGES))) .or(namedAnyOf("user-transport annotations", USER_TRANSPORT_TYPE_NAMES)) - .as("user-transport types (web, JAX-RS, GraphQL, gRPC, WebSocket/STOMP endpoints)"); + .as( + "user-transport types (web, JAX-RS, GraphQL, gRPC, WebSocket/STOMP endpoints and" + + " STOMP channel interceptors)"); /** Spring's configuration stereotype, which {@code @AutoConfiguration} carries as well. */ private static final String CONFIGURATION = @@ -543,21 +553,27 @@ class ApplicationBoundaryArchitectureTest { "io.grpc.ServerCallHandler", "io.grpc.ServerInterceptor", "io.grpc.ServerCall", - "io.grpc.stub.StreamObserver"); + "io.grpc.stub.StreamObserver", + "org.springframework.messaging.support.ChannelInterceptor", + "org.springframework.messaging.support.ExecutorChannelInterceptor"); /** * The framework types request-handling code is written against or registered with: an annotated * controller, a functional route or handler function, a servlet, filter or handler interceptor, a * WebSocket handler, a GraphQL data fetcher, runtime wiring or request interceptor, a gRPC - * service, call handler or server interceptor. A configuration that names one holds or registers - * request-handling code, and then the configuration is an endpoint: a route or data fetcher - * written as a lambda compiles into a method of the configuration itself (review 2026-11-05 - * RR6-01-01), and a route registered by method reference names the same route builder although - * its handling code is in another class (review 2026-11-06 RR7-01-02). Class dependencies cannot - * tell that registration from handling code, so routes are registered in a configuration apart - * from the one that builds a system caller. The types a configuration names to set a transport up - * — {@link #ARE_TRANSPORT_SETUP_TYPES}, the controller beans it builds — do not count - * (RR4-01-02). + * service, call handler or server interceptor, a STOMP channel interceptor. A configuration that + * names one holds or registers request-handling code, and then the configuration is an endpoint: + * a route or data fetcher written as a lambda compiles into a method of the configuration itself + * (review 2026-11-05 RR6-01-01), a route registered by method reference names the same route + * builder although its handling code is in another class (review 2026-11-06 RR7-01-02). A + * configuration that is the channel interceptor it registers runs its own method on every client + * frame, and one that hands an interceptor out as a bean names the interceptor type as route + * registration names the builder (review 2026-11-07 RR8-02-01). Setting the inbound channel up + * names only {@code ChannelRegistration}, a setup type. Class dependencies cannot tell that + * registration from handling code, so routes and interceptors are registered in a configuration + * apart from the one that builds a system caller. The types a configuration names to set a + * transport up — {@link #ARE_TRANSPORT_SETUP_TYPES}, the controller beans it builds — do not + * count (RR4-01-02). * *

Only a configuration itself is read with this list; a class nested in one is read with the * wider user-transport list (RR7-01-01). Like that list, this one is a list: a request-handler @@ -802,13 +818,14 @@ class ApplicationBoundaryArchitectureTest { + "through (a user-transport package; a configuration that holds or registers " + "request-handling code such as a functional route, a data fetcher or an " + "interceptor; a class nested in a configuration built from a web, JAX-RS, " - + "GraphQL, gRPC or WebSocket type other than a setup type such as " - + "WebMvcConfigurer; any other class built from one of those types) does not " + + "GraphQL, gRPC, WebSocket or STOMP type — a channel interceptor among them — " + + "other than a setup type such as WebMvcConfigurer; any other class built from " + + "one of those types) does not " + "reach a @SystemCaller or a " + "project type one extends or implements, directly or through other classes — " + "the system caller runs a @SystemInvoked write with no permission check. " - + "Register routes in a configuration apart from the one that builds the system " - + "caller. A user-triggered run of the same work is its own use case with " + + "Register routes, data fetchers and interceptors in a configuration apart from " + + "the one that builds the system caller. A user-triggered run of the same work is its own use case with " + "@RequiresPermission (manual 07 「시스템이 부르는 쓰기」)") .allowEmptyShould(true); diff --git a/src/app-bootstrap/src/architectureTest/java/dev/caskeleton/bootstrap/architecture/ArchitectureViolationFixtureTest.java b/src/app-bootstrap/src/architectureTest/java/dev/caskeleton/bootstrap/architecture/ArchitectureViolationFixtureTest.java index 7c6f3ae5..c6e997b5 100644 --- a/src/app-bootstrap/src/architectureTest/java/dev/caskeleton/bootstrap/architecture/ArchitectureViolationFixtureTest.java +++ b/src/app-bootstrap/src/architectureTest/java/dev/caskeleton/bootstrap/architecture/ArchitectureViolationFixtureTest.java @@ -13,12 +13,15 @@ import dev.caskeleton.bootstrap.architecture.allowed.adapter.inbound.messaging.S import dev.caskeleton.bootstrap.architecture.allowed.adapter.inbound.messaging.SystemCallerWithNestedValueTypesFixture; import dev.caskeleton.bootstrap.architecture.allowed.adapter.inbound.web.PingControllerFixture; import dev.caskeleton.bootstrap.architecture.allowed.application.CleanProjectionQueryPort; +import dev.caskeleton.bootstrap.architecture.allowed.configuration.FrameCountingInterceptorFixture; +import dev.caskeleton.bootstrap.architecture.allowed.configuration.FrameInterceptorConfigurationFixture; import dev.caskeleton.bootstrap.architecture.allowed.configuration.OrderHandlerFixture; import dev.caskeleton.bootstrap.architecture.allowed.configuration.OrderRoutesConfigurationFixture; import dev.caskeleton.bootstrap.architecture.allowed.configuration.SystemCallerBesideControllerRegistrationFixture; import dev.caskeleton.bootstrap.architecture.allowed.configuration.SystemCallerBesideCorsMappingFixture; import dev.caskeleton.bootstrap.architecture.allowed.configuration.SystemCallerBesideCorsSourceFixture; import dev.caskeleton.bootstrap.architecture.allowed.configuration.SystemCallerBesideFieldReadingWebMvcConfigurerFixture; +import dev.caskeleton.bootstrap.architecture.allowed.configuration.SystemCallerBesideStompBrokerSetupFixture; import dev.caskeleton.bootstrap.architecture.allowed.configuration.SystemCallerBesideWebMvcRegistrationFixture; import dev.caskeleton.bootstrap.architecture.allowed.persistence.flyway.SchemaPolicyFlywayFixture; import dev.caskeleton.bootstrap.architecture.fixtures.application.RootWriteTransactionBoundaryUseCase; @@ -376,6 +379,37 @@ class ArchitectureViolationFixtureTest { "dev.caskeleton.bootstrap.architecture.violations.configuration.jsr356", "dev.caskeleton.bootstrap.architecture.allowed.adapter.inbound.messaging"); + // RR8-02-01: a STOMP client-inbound channel interceptor runs on every frame a client sends, so it + // is a way in wherever it is kept — nested in a configuration, on its own, or the configuration + // itself — whether or not it reads a STOMP header, and a configuration handing one out as a bean + // is read as one registering routes is. Setting the inbound channel's threads up beside a system + // caller registers no interceptor and is setup; the interceptor bean in a configuration of its + // own passes. + private static final String STOMP_INTERCEPTOR_FIXTURES = + "dev.caskeleton.bootstrap.architecture.violations.configuration.stomp"; + + private static final JavaClasses STOMP_INTERCEPTORS_CALLING_A_SYSTEM_CALLER_FIXTURE_ONLY = + new ClassFileImporter() + .importPackages( + STOMP_INTERCEPTOR_FIXTURES, + "dev.caskeleton.bootstrap.architecture.allowed.adapter.inbound.messaging"); + + private static final JavaClasses SYSTEM_CALLER_BESIDE_STOMP_BROKER_SETUP_FIXTURE_ONLY = + new ClassFileImporter() + .importClasses( + SystemCallerBesideStompBrokerSetupFixture.class, + SystemCallerHandlerFixture.class, + SystemInvokedFixtureUseCase.class); + + private static final JavaClasses INTERCEPTOR_APART_FROM_A_SYSTEM_CALLER_FIXTURE_ONLY = + new ClassFileImporter() + .importClasses( + FrameInterceptorConfigurationFixture.class, + FrameCountingInterceptorFixture.class, + SystemCallerHandlerRegistrationFixture.class, + SystemCallerHandlerFixture.class, + SystemInvokedFixtureUseCase.class); + // RR7-01-02: routes registered by method reference make their configuration an endpoint, so the // configuration that also builds a system caller is caught and the same routes in a configuration // of their own pass. A CORS setup naming RequestMethod is setup, in the configuration and in its @@ -751,6 +785,52 @@ class ArchitectureViolationFixtureTest { .contains(SystemCallerHandlerFixture.class.getName())); } + @ParameterizedTest + @ValueSource( + strings = { + "RunNowOnFrameConfigurationFixture$1", + "RunNowOnFrameConfigurationFixture$RunNowAfterHandling", + "RunNowOnFrameInterceptorFixture", + "RunNowInterceptingConfigurationFixture", + "InterceptorBesideASystemCallerConfigurationFixture" + }) + void aStompChannelInterceptorThatCallsASystemCallerIsCaughtWhereverItIsKept(String interceptor) { + // when + EvaluationResult result = + ApplicationBoundaryArchitectureTest.USER_TRANSPORTS_DO_NOT_REACH_SYSTEM_CALLERS.evaluate( + STOMP_INTERCEPTORS_CALLING_A_SYSTEM_CALLER_FIXTURE_ONLY); + + // then + assertThat(result.getFailureReport().getDetails()) + .anySatisfy( + detail -> + assertThat(detail) + .contains("<" + STOMP_INTERCEPTOR_FIXTURES + "." + interceptor + ">") + .contains(SystemCallerHandlerFixture.class.getName())); + } + + @Test + void aStompBrokerSetUpBesideASystemCallerPasses() { + // when + EvaluationResult result = + ApplicationBoundaryArchitectureTest.USER_TRANSPORTS_DO_NOT_REACH_SYSTEM_CALLERS.evaluate( + SYSTEM_CALLER_BESIDE_STOMP_BROKER_SETUP_FIXTURE_ONLY); + + // then + assertThat(result.getFailureReport().getDetails()).isEmpty(); + } + + @Test + void aChannelInterceptorHandedOutApartFromTheSystemCallersConfigurationPasses() { + // when + EvaluationResult result = + ApplicationBoundaryArchitectureTest.USER_TRANSPORTS_DO_NOT_REACH_SYSTEM_CALLERS.evaluate( + INTERCEPTOR_APART_FROM_A_SYSTEM_CALLER_FIXTURE_ONLY); + + // then + assertThat(result.getFailureReport().getDetails()).isEmpty(); + } + @Test void aConfigurationThatRegistersMethodReferenceRoutesBesideASystemCallerIsCaught() { // when diff --git a/src/app-bootstrap/src/architectureTest/java/dev/caskeleton/bootstrap/architecture/allowed/configuration/FrameCountingInterceptorFixture.java b/src/app-bootstrap/src/architectureTest/java/dev/caskeleton/bootstrap/architecture/allowed/configuration/FrameCountingInterceptorFixture.java new file mode 100644 index 00000000..126786a0 --- /dev/null +++ b/src/app-bootstrap/src/architectureTest/java/dev/caskeleton/bootstrap/architecture/allowed/configuration/FrameCountingInterceptorFixture.java @@ -0,0 +1,18 @@ +package dev.caskeleton.bootstrap.architecture.allowed.configuration; + +import java.util.concurrent.atomic.AtomicLong; +import org.springframework.messaging.Message; +import org.springframework.messaging.MessageChannel; +import org.springframework.messaging.support.ChannelInterceptor; + +/** A STOMP client-inbound channel interceptor that only counts the frames it sees. */ +public final class FrameCountingInterceptorFixture implements ChannelInterceptor { + + private final AtomicLong frames = new AtomicLong(); + + @Override + public Message preSend(Message message, MessageChannel channel) { + frames.incrementAndGet(); + return message; + } +} diff --git a/src/app-bootstrap/src/architectureTest/java/dev/caskeleton/bootstrap/architecture/allowed/configuration/FrameInterceptorConfigurationFixture.java b/src/app-bootstrap/src/architectureTest/java/dev/caskeleton/bootstrap/architecture/allowed/configuration/FrameInterceptorConfigurationFixture.java new file mode 100644 index 00000000..bad9fc1b --- /dev/null +++ b/src/app-bootstrap/src/architectureTest/java/dev/caskeleton/bootstrap/architecture/allowed/configuration/FrameInterceptorConfigurationFixture.java @@ -0,0 +1,20 @@ +package dev.caskeleton.bootstrap.architecture.allowed.configuration; + +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; +import org.springframework.messaging.support.ChannelInterceptor; + +/** + * A feature's channel interceptor bean in a configuration of its own, apart from the one that + * builds the message handler. Handing an interceptor out names a request-handler type, as + * registering a route does, so it does not sit beside a system caller (review 2026-11-07 + * RR8-02-01). + */ +@Configuration(proxyBeanMethods = false) +public class FrameInterceptorConfigurationFixture { + + @Bean + ChannelInterceptor frameCountingInterceptor() { + return new FrameCountingInterceptorFixture(); + } +} diff --git a/src/app-bootstrap/src/architectureTest/java/dev/caskeleton/bootstrap/architecture/allowed/configuration/SystemCallerBesideStompBrokerSetupFixture.java b/src/app-bootstrap/src/architectureTest/java/dev/caskeleton/bootstrap/architecture/allowed/configuration/SystemCallerBesideStompBrokerSetupFixture.java new file mode 100644 index 00000000..3c127238 --- /dev/null +++ b/src/app-bootstrap/src/architectureTest/java/dev/caskeleton/bootstrap/architecture/allowed/configuration/SystemCallerBesideStompBrokerSetupFixture.java @@ -0,0 +1,32 @@ +package dev.caskeleton.bootstrap.architecture.allowed.configuration; + +import dev.caskeleton.bootstrap.architecture.allowed.adapter.inbound.messaging.SystemCallerHandlerFixture; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; +import org.springframework.messaging.simp.config.ChannelRegistration; +import org.springframework.messaging.simp.config.MessageBrokerRegistry; +import org.springframework.web.socket.config.annotation.WebSocketMessageBrokerConfigurer; + +/** + * One feature configuration: its STOMP broker and the client-inbound channel's threads, set up + * beside the feature's message handler. Setting the channel up registers no interceptor, so no + * client frame runs code of this configuration (review 2026-11-07 RR8-02-01). + */ +@Configuration(proxyBeanMethods = false) +public class SystemCallerBesideStompBrokerSetupFixture implements WebSocketMessageBrokerConfigurer { + + @Override + public void configureMessageBroker(MessageBrokerRegistry registry) { + registry.enableSimpleBroker("/topic"); + } + + @Override + public void configureClientInboundChannel(ChannelRegistration registration) { + registration.taskExecutor().corePoolSize(2); + } + + @Bean + SystemCallerHandlerFixture systemCallerHandler() { + return new SystemCallerHandlerFixture(); + } +} diff --git a/src/app-bootstrap/src/architectureTest/java/dev/caskeleton/bootstrap/architecture/allowed/configuration/package-info.java b/src/app-bootstrap/src/architectureTest/java/dev/caskeleton/bootstrap/architecture/allowed/configuration/package-info.java index 1e1a0f07..f73016cf 100644 --- a/src/app-bootstrap/src/architectureTest/java/dev/caskeleton/bootstrap/architecture/allowed/configuration/package-info.java +++ b/src/app-bootstrap/src/architectureTest/java/dev/caskeleton/bootstrap/architecture/allowed/configuration/package-info.java @@ -1,10 +1,11 @@ /** * "Allowed-as-data" composition for {@code USER_TRANSPORTS_DO_NOT_REACH_SYSTEM_CALLERS}: a * feature's configuration that registers its message handler beside its web beans — a {@code - * WebMvcConfigurer}, a CORS setup, or the feature's controller. A configuration is the composition - * root, not a way a user request comes in, so naming a web type does not make it a user transport - * (review 2026-11-04 RR4-01-02); registering routes does, so the feature's routes sit in a - * configuration of their own (review 2026-11-06 RR7-01-02). Manual 09 「소비」 step 4 registers the - * handler in "this leaf's configuration class", which is where both kinds of bean meet. + * WebMvcConfigurer}, a CORS setup, a STOMP broker setup, or the feature's controller. A + * configuration is the composition root, not a way a user request comes in, so naming a web type + * does not make it a user transport (review 2026-11-04 RR4-01-02); registering routes does, so the + * feature's routes sit in a configuration of their own (review 2026-11-06 RR7-01-02), and so does + * its STOMP channel interceptor bean (review 2026-11-07 RR8-02-01). Manual 09 「소비」 step 4 registers + * the handler in "this leaf's configuration class", which is where both kinds of bean meet. */ package dev.caskeleton.bootstrap.architecture.allowed.configuration; diff --git a/src/app-bootstrap/src/architectureTest/java/dev/caskeleton/bootstrap/architecture/violations/configuration/stomp/InterceptorBesideASystemCallerConfigurationFixture.java b/src/app-bootstrap/src/architectureTest/java/dev/caskeleton/bootstrap/architecture/violations/configuration/stomp/InterceptorBesideASystemCallerConfigurationFixture.java new file mode 100644 index 00000000..9af97864 --- /dev/null +++ b/src/app-bootstrap/src/architectureTest/java/dev/caskeleton/bootstrap/architecture/violations/configuration/stomp/InterceptorBesideASystemCallerConfigurationFixture.java @@ -0,0 +1,29 @@ +package dev.caskeleton.bootstrap.architecture.violations.configuration.stomp; + +import dev.caskeleton.bootstrap.architecture.allowed.adapter.inbound.messaging.SystemCallerHandlerFixture; +import dev.caskeleton.bootstrap.architecture.allowed.configuration.FrameCountingInterceptorFixture; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; +import org.springframework.messaging.support.ChannelInterceptor; + +/** + * Negative fixture for {@code USER_TRANSPORTS_DO_NOT_REACH_SYSTEM_CALLERS}: one feature + * configuration hands a channel interceptor out as a bean, the usual way to register one, and + * builds its message handler. The interceptor itself runs no job. Handing it out still names the + * interceptor type, a request-handler type, so the configuration is read as an endpoint that + * reaches the handler, as one registering routes is. The interceptor bean goes in a configuration + * of its own ({@code FrameInterceptorConfigurationFixture}) (review 2026-11-07 RR8-02-01). + */ +@Configuration(proxyBeanMethods = false) +public class InterceptorBesideASystemCallerConfigurationFixture { + + @Bean + ChannelInterceptor frameCountingInterceptor() { + return new FrameCountingInterceptorFixture(); + } + + @Bean + SystemCallerHandlerFixture systemCallerHandler() { + return new SystemCallerHandlerFixture(); + } +} diff --git a/src/app-bootstrap/src/architectureTest/java/dev/caskeleton/bootstrap/architecture/violations/configuration/stomp/RunNowInterceptingConfigurationFixture.java b/src/app-bootstrap/src/architectureTest/java/dev/caskeleton/bootstrap/architecture/violations/configuration/stomp/RunNowInterceptingConfigurationFixture.java new file mode 100644 index 00000000..f43d3ff0 --- /dev/null +++ b/src/app-bootstrap/src/architectureTest/java/dev/caskeleton/bootstrap/architecture/violations/configuration/stomp/RunNowInterceptingConfigurationFixture.java @@ -0,0 +1,33 @@ +package dev.caskeleton.bootstrap.architecture.violations.configuration.stomp; + +import dev.caskeleton.bootstrap.architecture.allowed.adapter.inbound.messaging.SystemCallerHandlerFixture; +import org.springframework.context.annotation.Configuration; +import org.springframework.messaging.Message; +import org.springframework.messaging.MessageChannel; +import org.springframework.messaging.simp.config.ChannelRegistration; +import org.springframework.messaging.support.ChannelInterceptor; +import org.springframework.web.socket.config.annotation.WebSocketMessageBrokerConfigurer; + +/** + * Negative fixture for {@code USER_TRANSPORTS_DO_NOT_REACH_SYSTEM_CALLERS}: a feature configuration + * that is itself the channel interceptor it registers. Its own method runs on each client frame, so + * the configuration is the endpoint, as one holding a route written as a lambda is (review + * 2026-11-07 RR8-02-01). + */ +@Configuration(proxyBeanMethods = false) +public class RunNowInterceptingConfigurationFixture + implements WebSocketMessageBrokerConfigurer, ChannelInterceptor { + + private final SystemCallerHandlerFixture handler = new SystemCallerHandlerFixture(); + + @Override + public void configureClientInboundChannel(ChannelRegistration registration) { + registration.interceptors(this); + } + + @Override + public Message preSend(Message message, MessageChannel channel) { + handler.handle(); + return message; + } +} diff --git a/src/app-bootstrap/src/architectureTest/java/dev/caskeleton/bootstrap/architecture/violations/configuration/stomp/RunNowOnFrameConfigurationFixture.java b/src/app-bootstrap/src/architectureTest/java/dev/caskeleton/bootstrap/architecture/violations/configuration/stomp/RunNowOnFrameConfigurationFixture.java new file mode 100644 index 00000000..e074609f --- /dev/null +++ b/src/app-bootstrap/src/architectureTest/java/dev/caskeleton/bootstrap/architecture/violations/configuration/stomp/RunNowOnFrameConfigurationFixture.java @@ -0,0 +1,51 @@ +package dev.caskeleton.bootstrap.architecture.violations.configuration.stomp; + +import dev.caskeleton.bootstrap.architecture.allowed.adapter.inbound.messaging.SystemCallerHandlerFixture; +import org.springframework.context.annotation.Configuration; +import org.springframework.messaging.Message; +import org.springframework.messaging.MessageChannel; +import org.springframework.messaging.MessageHandler; +import org.springframework.messaging.simp.config.ChannelRegistration; +import org.springframework.messaging.support.ChannelInterceptor; +import org.springframework.messaging.support.ExecutorChannelInterceptor; +import org.springframework.web.socket.config.annotation.WebSocketMessageBrokerConfigurer; + +/** + * Negative fixture for {@code USER_TRANSPORTS_DO_NOT_REACH_SYSTEM_CALLERS}: STOMP client-inbound + * channel interceptors a feature configuration registers beside the system caller it holds. Every + * frame a client sends passes through them, so each is a way a user request comes in, although the + * configuration names only setup types and neither interceptor reads a STOMP header (review + * 2026-11-07 RR8-02-01). The anonymous one runs the job before the frame is sent on, the nested one + * after the frame is handled on the channel's executor. Loaded with {@code importPackages}: + * spring-messaging is compile-only here. + */ +@Configuration(proxyBeanMethods = false) +public class RunNowOnFrameConfigurationFixture implements WebSocketMessageBrokerConfigurer { + + private final SystemCallerHandlerFixture handler = new SystemCallerHandlerFixture(); + + @Override + public void configureClientInboundChannel(ChannelRegistration registration) { + registration.interceptors( + new ChannelInterceptor() { + @Override + public Message preSend(Message message, MessageChannel channel) { + handler.handle(); + return message; + } + }, + new RunNowAfterHandling()); + } + + /** Runs the job after each client frame is handled on the inbound channel's executor. */ + public static final class RunNowAfterHandling implements ExecutorChannelInterceptor { + + private final SystemCallerHandlerFixture job = new SystemCallerHandlerFixture(); + + @Override + public void afterMessageHandled( + Message message, MessageChannel channel, MessageHandler handler, Exception failure) { + job.handle(); + } + } +} diff --git a/src/app-bootstrap/src/architectureTest/java/dev/caskeleton/bootstrap/architecture/violations/configuration/stomp/RunNowOnFrameInterceptorFixture.java b/src/app-bootstrap/src/architectureTest/java/dev/caskeleton/bootstrap/architecture/violations/configuration/stomp/RunNowOnFrameInterceptorFixture.java new file mode 100644 index 00000000..53a02e4e --- /dev/null +++ b/src/app-bootstrap/src/architectureTest/java/dev/caskeleton/bootstrap/architecture/violations/configuration/stomp/RunNowOnFrameInterceptorFixture.java @@ -0,0 +1,23 @@ +package dev.caskeleton.bootstrap.architecture.violations.configuration.stomp; + +import dev.caskeleton.bootstrap.architecture.allowed.adapter.inbound.messaging.SystemCallerHandlerFixture; +import org.springframework.messaging.Message; +import org.springframework.messaging.MessageChannel; +import org.springframework.messaging.support.ChannelInterceptor; + +/** + * Negative fixture for {@code USER_TRANSPORTS_DO_NOT_REACH_SYSTEM_CALLERS}: a STOMP client-inbound + * channel interceptor of its own, outside every user-transport package, that runs the job on each + * frame a client sends. It reads no STOMP header, so it names no {@code simp} type (review + * 2026-11-07 RR8-02-01). + */ +public final class RunNowOnFrameInterceptorFixture implements ChannelInterceptor { + + private final SystemCallerHandlerFixture handler = new SystemCallerHandlerFixture(); + + @Override + public Message preSend(Message message, MessageChannel channel) { + handler.handle(); + return message; + } +}