# 주제: gRPC 경계 규칙 두 개가 완성되어 있고 테스트되며, 실제 저장소 소스를 한 번도 보지 않는다
# revision: 21234e38cdb9a926cbc92bb97a2aee2e4a7d2916
# severity: P2

# ---- 선언 ----
# grpc-server/build.gradle:2-3
#   "Server boundary: the ArchUnit-shaped application boundary rules, the typed service adapter SPI,
#    the interceptor order contract, and the Netty server/executor/admission profiles."
# src/grpc/CLAUDE.md:93
#   "…이고 GrpcApplicationBoundaryRules·GrpcRawApiImportRule·GrpcServiceAdapter가 그 경계를…"

# ---- 두 규칙의 실체 ----
# GrpcApplicationBoundaryRules (92줄)
#   violations(String adapterName, Set<String> referencedTypes) -> List<String>
#   forbiddenTypes() -> Set<String>   (java.sql.Connection, javax.sql.DataSource, ...)
#   금지 대상: 퍼시스턴스·메시징·HTTP 직접 참조, 인바운드→아웃바운드 어댑터 참조
#
# GrpcRawApiImportRule (108줄)
#   RAW_API_TYPES 14종: io.grpc.ManagedChannelBuilder, ManagedChannel, ServerBuilder, Server,
#     ClientCall, ClientCalls, MethodDescriptor, CallCredentials,
#     io.grpc.netty[.shaded].NettyChannelBuilder/NettyServerBuilder,
#     io.grpc.inprocess.InProcessChannelBuilder/InProcessServerBuilder
#   Pattern IMPORT = "^\s*import\s+(?:static\s+)?([\w.]+)\s*;"   <- **소스 파일을 스캔하도록 만들어졌다**
#   Pattern PACKAGE = ...
#   패키지 허용목록을 받아 플랫폼·생성코드는 통과시킨다
#   javadoc:9-16 "Every one of them bypasses a Stable guarantee: a hand-built ManagedChannel has no
#                 named profile, no deadline policy and no credential rotation; a hand-built
#                 ClientCall skips the interceptor chain entirely."

# ---- 측정: 실제 소스를 넘기는 호출부가 없다 ----
# command: git grep -n "GrpcRawApiImportRule|GrpcApplicationBoundaryRules|GrpcServiceAdapterMarker" -- src
#          (자기 패키지 파일 제외)
#   src/grpc/CLAUDE.md:93     <- 문서 언급 1건. 그게 전부다.
# => 프로덕션 호출부 0, 테스트 호출부도 자기 테스트뿐.
#
# GrpcApplicationBoundaryRulesTest (142줄)가 넘기는 것:
#   violations("DocumentServiceAdapter",
#              Set.of("dev.caskeleton.application.document.CreateDocumentUseCase",
#                     "jakarta.persistence.EntityManager",
#                     "org.springframework.data.jpa.repository.JpaRepository",
#                     "org.apache.kafka.clients.producer.KafkaProducer",
#                     "java.net.http.HttpClient"))
# => "DocumentServiceAdapter" 는 저장소에 존재하지 않는 이름이고,
#    참조 집합은 손으로 쓴 문자열이다. 실제 파일을 읽지 않는다.
#
# GrpcRawApiImportRule 은 IMPORT/PACKAGE 정규식을 갖는 **소스 스캐너**인데,
# 어떤 파일 경로도 이 클래스에 전달되지 않는다.

# ---- 대조: 이 저장소에는 실제로 소스를 보는 경계 테스트가 있다 ----
#   src/adapter/outbound/persistence-jpa/src/test/.../JpaModuleBoundaryTest.java
#     javadoc:26 "verifyCleanArchitectureDependencies does not cover this. It governs edges *between*…"
#   src/app-bootstrap/src/test/.../MongoRegistryPermissionParityTest.java
#     javadoc:22 "verifyCleanArchitectureDependencies checks that the edges Gradle resolved are a subset…"
# => 같은 저장소가 "Gradle 게이트가 못 보는 것을 테스트가 본다" 는 패턴을 이미 갖고 있다.
#    gRPC 쪽 두 규칙은 그 패턴의 재료만 있고 적용이 없다.

# ---- 판정 ----
# 규칙 엔진이 완성되어 있고(200줄), 테스트되며(142줄), **입력이 없다.**
# 저장소의 어떤 소스 파일도 이 규칙을 통과한 적이 없다.
# grpc 블록 전체가 배포되지 않으므로(EVD-325) 현재 실제 피해는 없다.
# 그러나 이 규칙들의 목적은 "애플리케이션 코드가 raw API 를 쓰지 못하게" 인데,
# 그 애플리케이션 코드가 생기는 시점에 규칙이 자동으로 적용되지는 않는다.

# ---- 부수: server/client 주요 타입 도달성 ----
  GrpcAdmissionController          다른리프=3 src/main생성=1
  GrpcServiceAdapter               다른리프=1 src/main생성=0
  GrpcServerProfile                다른리프=1 src/main생성=1
  GrpcServerInterceptorChain       다른리프=0 src/main생성=1
  GrpcTypedStubFactory             다른리프=0 src/main생성=1
  GrpcNettyVariantSelector         다른리프=0 src/main생성=0
  GrpcChannelRuntimeRegistry       다른리프=0 src/main생성=0
  GrpcClientMetadataPolicy         다른리프=0 src/main생성=0
  GrpcStubPolicyApplier            다른리프=0 src/main생성=0
# => grpc-policy 와 같은 패턴: 경계/프로필 타입은 다른 리프가 참조하고,
#    런타임 조정자(채널 레지스트리, 메타데이터 정책, 스텁 정책 적용기)는 자기 테스트에서만 산다.
