diff --git a/.github/workflows/ci-quality-gates.yml b/.github/workflows/ci-quality-gates.yml index 26e71224..3fd2196e 100644 --- a/.github/workflows/ci-quality-gates.yml +++ b/.github/workflows/ci-quality-gates.yml @@ -71,6 +71,40 @@ jobs: working-directory: src run: ./gradlew -p optional-platforms ci --stacktrace + # gRPC schema policy (owner decision 18). protoc compiles src/grpc/grpc-contract inside the + # optional-platforms build above; lint and breaking-change policy belong to Buf, configured by + # buf.yaml next to the schema. Buf is a native binary rather than a Maven artifact, so it runs here + # and not inside Gradle — and nothing in the repository re-implements its rules. + grpc-proto-buf: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # actions/checkout@v4.2.2 + with: + # buf breaking reads the baseline schema from Git history. + fetch-depth: 0 + - uses: bufbuild/buf-action@85aebf73123b5c15fd5528aaecbf9129cddf7fa7 # bufbuild/buf-action@v1.6.0 + with: + version: 1.73.0 + setup_only: true + - name: Lint the gRPC schema + working-directory: src/grpc/grpc-contract + run: buf lint + - name: Refuse a breaking change to the gRPC schema + working-directory: src/grpc/grpc-contract + env: + # Pull request: the target branch. Push: the commit this push replaced. + BASELINE: ${{ github.event_name == 'pull_request' && format('origin/{0}', github.base_ref) || github.event.before }} + run: | + set -euo pipefail + baseline_commit="$(git rev-parse --verify --quiet "${BASELINE}^{commit}" || true)" + if [[ -z "${baseline_commit}" ]] \ + || ! git cat-file -e "${baseline_commit}:src/grpc/grpc-contract/buf.yaml" 2>/dev/null; then + # The first change that introduces the module has nothing to be compatible with. + echo "::notice::grpc-proto-buf: baseline ${BASELINE} has no src/grpc/grpc-contract/buf.yaml; breaking check skipped." + exit 0 + fi + buf breaking --against "../../../.git#ref=${baseline_commit},subdir=src/grpc/grpc-contract" + release-gate: needs: - quality-gates diff --git a/AGENTS.md b/AGENTS.md index d42f2b5a..1f2b630a 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -252,6 +252,8 @@ Docker/runtime 규칙: 1. `src/settings.gradle`의 `rootProject.name`을 새 프로젝트명으로 바꾼다. 2. Java package `dev.caskeleton`을 새 organization/project package로 바꾼다. + gRPC 플랫폼을 쓰면 proto 조직 이름 `caskeleton`(`src/grpc/grpc-contract/src/main/proto/caskeleton/`의 + 디렉터리, 각 `.proto`의 `package`·`java_package`)도 함께 바꾸고 `buf lint`로 확인한다. 3. `CaSkeletonApplication` 이름을 새 애플리케이션 이름으로 바꾼다. 4. production 모듈에는 목표 도메인의 entity, repository port, use case, adapter만 추가하고, 예시 코드는 `sample-portfolio`에 격리한다. 5. 모듈 이름과 경계는 유지한다. diff --git a/docs/adr/ADR-GRPC-002-schema-governance-without-protoc.md b/docs/adr/ADR-GRPC-002-schema-governance-without-protoc.md index 560d4948..5e3b523e 100644 --- a/docs/adr/ADR-GRPC-002-schema-governance-without-protoc.md +++ b/docs/adr/ADR-GRPC-002-schema-governance-without-protoc.md @@ -1,8 +1,17 @@ # ADR-GRPC-002: Schema governance runs without protoc and without the Buf CLI -- Status: accepted +- Status: **superseded (2026-09-28)** by owner decision 18 of the 2026-09-25 review follow-up - Date: 2026-08-30 -- Scope: `:grpc:grpc-proto-contract`, `:grpc:grpc-codegen` +- Scope: `:grpc:grpc-proto-contract`, `:grpc:grpc-codegen` (both removed) + +> **Superseded.** The regex `.proto` validator and the Java re-implementation of Buf's rules were +> deleted. The schema now lives in `:grpc:grpc-contract` (`src/grpc/grpc-contract/src/main/proto`), +> compiled by the Gradle protobuf plugin (`com.google.protobuf`, version pinned in +> `src/gradle/libs.versions.toml`; protoc and the protobuf-java runtime are both `protobufGrpc`). +> Generated sources are excluded from Spotless, Checkstyle and Error Prone in that leaf only. +> `buf lint` and `buf breaking` (`src/grpc/grpc-contract/buf.yaml`, STANDARD lint, FILE breaking) +> run in CI, job `grpc-proto-buf` in `.github/workflows/ci-quality-gates.yml`. The proto organization +> is `caskeleton` (was `hyeonworks`). The text below is kept as the record of the original decision. ## Context diff --git a/docs/adr/ADR-GRPC-003-three-axis-execution-evidence.md b/docs/adr/ADR-GRPC-003-three-axis-execution-evidence.md index aff2a68d..e4f6d50d 100644 --- a/docs/adr/ADR-GRPC-003-three-axis-execution-evidence.md +++ b/docs/adr/ADR-GRPC-003-three-axis-execution-evidence.md @@ -2,7 +2,7 @@ - Status: accepted - Date: 2026-08-30 -- Scope: `:grpc:grpc-core-api`, `:grpc:grpc-policy`, `:grpc:grpc-testkit` +- Scope: `:grpc:grpc-core-api`, `:grpc:grpc-runtime` (was `grpc-policy`), `:grpc:grpc-testkit` ## Context diff --git a/docs/adr/ADR-GRPC-004-retry-ownership-and-durable-idempotency.md b/docs/adr/ADR-GRPC-004-retry-ownership-and-durable-idempotency.md index dafadad7..a7e2ebfd 100644 --- a/docs/adr/ADR-GRPC-004-retry-ownership-and-durable-idempotency.md +++ b/docs/adr/ADR-GRPC-004-retry-ownership-and-durable-idempotency.md @@ -2,7 +2,7 @@ - Status: accepted - Date: 2026-08-30 -- Scope: `:grpc:grpc-policy`, `:grpc:grpc-operation-ledger-jpa`, `:grpc:grpc-core-api` +- Scope: `:grpc:grpc-runtime` (was `grpc-policy`), `:grpc:grpc-operation-ledger-jpa`, `:grpc:grpc-core-api` ## Context diff --git a/docs/adr/ADR-GRPC-005-server-streaming-single-writer-and-resume.md b/docs/adr/ADR-GRPC-005-server-streaming-single-writer-and-resume.md index e6d885de..b648be9e 100644 --- a/docs/adr/ADR-GRPC-005-server-streaming-single-writer-and-resume.md +++ b/docs/adr/ADR-GRPC-005-server-streaming-single-writer-and-resume.md @@ -2,7 +2,7 @@ - Status: accepted - Date: 2026-08-30 -- Scope: `:grpc:grpc-policy` +- Scope: `:grpc:grpc-runtime` (was `grpc-policy`) ## Context diff --git a/docs/adr/ADR-GRPC-006-stable-discovery-and-kubernetes-routing.md b/docs/adr/ADR-GRPC-006-stable-discovery-and-kubernetes-routing.md index 135abd97..3be4e14a 100644 --- a/docs/adr/ADR-GRPC-006-stable-discovery-and-kubernetes-routing.md +++ b/docs/adr/ADR-GRPC-006-stable-discovery-and-kubernetes-routing.md @@ -2,7 +2,7 @@ - Status: accepted - Date: 2026-08-31 -- Scope: `:grpc:grpc-discovery`, `:grpc:grpc-client` +- Scope: `:grpc:grpc-runtime` (was `grpc-discovery`, `grpc-client`) ## Context @@ -63,6 +63,6 @@ declaration is a wrong statement somebody wrote down, and a missing one is a que `GrpcChannelProfileValidator` takes resolved counts where they are known at startup and skips the check where they are not, rather than guessing and failing on a name that cannot be resolved yet. -**xDS is reachable, and not by this route.** It lives in `grpc-advanced-resilience` behind its +**xDS is reachable, and not by this route.** It lives in `grpc-advanced` (package `resilience`/`xds`) behind its capability flag and its production approval, and `GrpcXdsStartupGuard.advertisableAsStableSupport()` returns false so the Stable support statement cannot widen quietly. See ADR-GRPC-ADV-001. diff --git a/docs/capability-status.md b/docs/capability-status.md index 7c6c3fb5..84f85a7d 100644 --- a/docs/capability-status.md +++ b/docs/capability-status.md @@ -341,3 +341,20 @@ web 경로의 `W/`는 `src/adapter/inbound/web/src/main/java/dev/caskeleton/adap | `GitCommandResult` record | `src/build-logic/src/main/java/dev/caskeleton/buildlogic/architecture/GitCommandResult.java` | `6d27356e` | O-3b에서 git 호출이 exit code를 직접 판정하는 `checkIgnore` 하나로 줄어 쓰는 곳이 없음 | | `git rev-parse --show-toplevel` 호출(checkout 판정) | `VerifyNoIgnoredSourcePackagesTask.java` | `6d27356e` | 실패하면 "checkout 아님"으로 읽혀 게이트가 통과하던 원인. `.git` 존재 판정으로 대체 | | compose 계약 필드 `expectedSwitchesOn` | `src/config/runtime/compose-profile-contracts.json` | `6d27356e` | 읽는 코드가 없던 필드. `expectedCapabilitiesOn`(info 이름)으로 재정의 | +| `grpc-policy` leaf | `src/grpc/grpc-policy` | `6d27356e` | 병합: → `grpc-runtime`(S7-#3) | +| `grpc-server` leaf | `src/grpc/grpc-server` | `6d27356e` | 병합: → `grpc-runtime`(S7-#3) | +| `grpc-client` leaf | `src/grpc/grpc-client` | `6d27356e` | 병합: → `grpc-runtime`(S7-#3) | +| `grpc-discovery` leaf | `src/grpc/grpc-discovery` | `6d27356e` | 병합: → `grpc-runtime`(S7-#3) | +| `grpc-admin` leaf | `src/grpc/grpc-admin` | `6d27356e` | 병합: → `grpc-runtime`(S7-#3) | +| `grpc-proto-contract` leaf (`.proto`는 이동) | `src/grpc/grpc-proto-contract` | `6d27356e` | 병합: → `grpc-contract`. `.proto` 두 파일은 `grpc-contract/src/main/proto/caskeleton/…`로 이동, 나머지는 삭제(S7-#13) | +| `GrpcProtoContractValidator`, `GrpcProtoStyleManifest`, `GrpcProtoRuleViolation` + 테스트 | `src/grpc/grpc-proto-contract/src/main/java/dev/caskeleton/grpc/contract/` | `6d27356e` | regex `.proto` 파서·style 규칙 재구현 — protoc + Buf lint로 대체(결정 18) | +| `buf.gen.yaml`, `buf.lock`, 구 `buf.yaml` | `src/grpc/grpc-proto-contract/src/main/resources/proto/` | `6d27356e` | 명세용 파일. 생성은 Gradle protobuf 플러그인, 설정은 `src/grpc/grpc-contract/buf.yaml` | +| `grpc-codegen` leaf 전체(`GrpcBufPolicy`, `GrpcBreakingCategory`, `GrpcCodegenManifest`, `GrpcCodegenOutput`, `GrpcGeneratedPackagePolicy`, `GrpcDescriptorArtifact`, `GrpcConsumerFixture`, `GrpcSchemaArtifactPublisher`, `GrpcSchemaBaseline` + 테스트·consumer fixture) | `src/grpc/grpc-codegen` | `6d27356e` | Buf lint/breaking·codegen 소유 규칙의 Java 재구현 — Buf(CI)·protobuf 플러그인으로 대체(결정 18) | +| `grpc-advanced-bootstrap` leaf | `src/grpc-advanced/grpc-advanced-bootstrap` | `6d27356e` | 병합: → `grpc-advanced`(S7-#3) | +| `grpc-advanced-edition` leaf | `src/grpc-advanced/grpc-advanced-edition` | `6d27356e` | 병합: → `grpc-advanced`(S7-#3); `compatibility.proto`는 test resources로 | +| `grpc-advanced-streaming` leaf | `src/grpc-advanced/grpc-advanced-streaming` | `6d27356e` | 병합: → `grpc-advanced`(S7-#3) | +| `grpc-advanced-resilience` leaf | `src/grpc-advanced/grpc-advanced-resilience` | `6d27356e` | 병합: → `grpc-advanced`(S7-#3) | +| `grpc-advanced-diagnostics` leaf | `src/grpc-advanced/grpc-advanced-diagnostics` | `6d27356e` | 병합: → `grpc-advanced`(S7-#3) | +| `GrpcStreamProfile` | `src/grpc/grpc-policy/src/main/java/dev/caskeleton/grpc/streaming/GrpcStreamProfile.java` | `6d27356e` | 테스트에서만 쓰였고 `GrpcFlowControlPolicy`의 256/8 MiB를 복제(N-10b) | +| `GrpcAuthenticationPolicy.isAuthenticated(Metadata)` | `src/adapter/inbound/grpc/src/main/java/dev/caskeleton/adapter/inbound/grpc/GrpcAuthenticationPolicy.java` | `6d27356e` | `authenticate(Metadata): Optional`로 교체(K-10a) | +| `GrpcCredentialRotationManager.completeDrain()`(무인자) | `src/grpc/grpc-policy/src/main/java/dev/caskeleton/grpc/security/GrpcCredentialRotationManager.java` | `6d27356e` | `completeDrain(GrpcCredentialGeneration)`로 교체(P5-new-3) | diff --git a/docs/compatibility/grpc-support-matrix.md b/docs/compatibility/grpc-support-matrix.md index ab646de0..0300565b 100644 --- a/docs/compatibility/grpc-support-matrix.md +++ b/docs/compatibility/grpc-support-matrix.md @@ -53,13 +53,13 @@ tested the adapter and not the transport. | | Where it lives | | --- | --- | -| Client streaming, bidirectional streaming | `grpc-advanced-streaming` | -| Manual flow control | `grpc-advanced-streaming` | -| Hedging | `grpc-advanced-resilience` | -| Custom name resolver, custom load balancer | `grpc-advanced-resilience` | -| xDS | `grpc-advanced-resilience` | +| Client streaming, bidirectional streaming | `grpc-advanced` (`streaming`) | +| Manual flow control | `grpc-advanced` (`streaming`) | +| Hedging | `grpc-advanced` (`resilience`) | +| Custom name resolver, custom load balancer | `grpc-advanced` (`resilience`) | +| xDS | `grpc-advanced` (`resilience`) | | gRPC-Web, Servlet HTTP/2, Spring Integration, Reactor, Kotlin | `grpc-advanced-compat` | -| Channelz / CSDS diagnostics | `grpc-advanced-diagnostics` | +| Channelz / CSDS diagnostics | `grpc-advanced` (`diagnostics`) | ## Current release status diff --git a/docs/reviews/2026-09-25-review-followup-results/W2-P14.md b/docs/reviews/2026-09-25-review-followup-results/W2-P14.md new file mode 100644 index 00000000..303101a8 --- /dev/null +++ b/docs/reviews/2026-09-25-review-followup-results/W2-P14.md @@ -0,0 +1,44 @@ +# W2-P14 — Wave 2.5 정합성 잔여 + +worktree `.claude/worktrees/agent-a49c7a7a5ac7707e8`, 브랜치 `worktree-agent-a49c7a7a5ac7707e8`. +커밋(모두 W2): `5928fb06`(P9-new-1·P8-new-2), `1fa968df`(P4-new-2·3·4), `c90bb445`(P3-new-3·5·6), +`7540c638`(P12-new-1), `50823043`(P11-new-4), `450c55e4`(P2-new-3), `facf0a80`(P2-new-2). +새 migration 없음. + +## 행 결과 +| ID | 결과 | 근거 | +|---|---|---| +| P2-new-2 | 완료 | 결정 22. `PosterImageAbortReconcileRaceTest`(sample test) — `aPublicationThatFinishesAfterTheAbortWasAuthorizedIsAttached` FAIL(`IllegalStateException: publication intent handoff changed before TX3`)→PASS, `anAbortAuthorizedIntentWhoseObjectWasPublishedIsAttachedByTheNextReconcile` FAIL(`Poster image publication is not ready to reconcile`)→PASS, `anAbortThatArrivesAfterThePublicationIsAConflict` FAIL(예외 없음, 저장소 abort 진행)→PASS, `anAbortOfAnUploadAlreadyAttachedIsAConflict` 신규 PASS. `DomainExceptionHandlerTest.anAbortThatLostToThePublicationIsA409Conflict` PASS. 수정: 저장소 `kernel/ObjectPublicationHandoffService.java:117-125` `authorizeAbort`가 게시된 operation에 예외 대신 `REJECTED`/`CONFLICT` receipt(수정 전에는 `IllegalStateException`이라 sample이 "이미 게시됨"을 다른 장애와 구분할 수 없었음; D-1b 테스트 `StagedObjectPublicationLifecycleTest$AuthorizeAbort.authorizeAbortIsRejectedOnceTheReferenceIsPublished`를 receipt 단언으로 갱신). `AbortPosterImageUploadUseCase.java:83-87,99-105` READY/SUPERSEDED intent나 REJECTED receipt면 `PosterImageAlreadyPublishedException`(409 `POSTER_IMAGE_ALREADY_PUBLISHED`, `DomainExceptionHandler`), 아무것도 지우지 않고 intent는 ABORT_AUTHORIZED로 둠. `ReconcilePosterImageUploadUseCase.java:103,145,166`와 `PosterImageUploadIntent.requirePublishable`(ready/superseded)가 ABORT_AUTHORIZED도 받아 게시된 객체를 붙임(저장소가 abort를 먼저 받았으면 finalize가 거부돼 abort가 이김). 실제 PG `:sample-portfolio:integrationTest` 49/49 | +| P2-new-3 | 완료 | 두 번째 선택지(주장 금지). `S3ProviderBindingTest.aProfileCannotClaimRetirementTheManagedS3ProviderDoesNotImplement` FAIL(`Expecting actual not to be null`)→PASS. `s3/S3ProviderBinding.java:199-206` profile이 `CONDITIONAL_RETIREMENT`를 주장하면 바인딩 거부. retire 구현은 S3 readiness 근거가 없어 하지 않음. 결과: 기본 요구 집합(CONDITIONAL_RETIREMENT 포함)의 S3 destination은 시작 시 거부된다 — `S3ProviderCompositionTest` destination은 명시 요구 집합으로 바꿈 | +| P3-new-3 | 완료 | `JdkNotificationHttpGatewaySecurityTest.aResponseBodyThatStallsBelowTheCapEndsAtTheRequestTimeout` FAIL(`TimeoutException: ... timed out after 15 seconds`)→PASS. `provider/http/JdkNotificationHttpGateway.java:81,88,167` 요청 timeout의 남은 시간을 body 읽기 deadline으로 걸고, 넘기면 daemon 타이머가 stream을 닫아 `RESPONSE_TIMEOUT`(body committed=true). SNS 인증서 fetch도 같은 gateway를 씀 | +| P3-new-5 | 완료 | 결정 21. `RegistryProviderDispatchGatewayTest.aProfileNoRuntimeServesIsAProviderUnavailableFailure` FAIL(`IllegalStateException: no provider runtime registered for the profile`)→PASS; `NotificationDispatchServiceTest.aRouteWhoseProviderProfileIsGoneWaitsForTheRetryBackoff` FAIL(`[FAILED, Optional.empty, 0, ...]`)→PASS, `...FailsOnceTheRetryBudgetIsSpent` PASS. `ntf-adapter/dispatch/RegistryProviderDispatchGateway.java:35` 없는 profile → `ProviderUnavailableException(PROVIDER_UNAVAILABLE, TRANSIENT_PROVIDER)`(port javadoc에 명시). `ntf-app/dispatch/NotificationDispatchService.java:159,236` 일반 `NotificationRetryPolicy`(backoff·`RetryBudget(maxAdditionalAttempts, attemptCount)`·만료)로 RETRY_WAITING+nextDispatchAt, 한도면 FAILED, 어느 쪽이든 fenced `saveHeldBy` 후 lease 해제. attempt row가 없으므로 횟수는 수신자 `attemptCount`로 셈. 사유: 수신자 행에는 실패 코드 열이 없어 `lastFailureCategory=TRANSIENT_PROVIDER`로 남김(코드 `PROVIDER_UNAVAILABLE`은 예외 descriptor에만 있음) | +| P3-new-6 | 완료 | `NotificationDispatchServiceTest.aGuardBlockWrittenAfterTheLeaseWasLostChangesNothing`·`aRoutingStopWrittenAfterTheLeaseWasLostChangesNothing` FAIL(수신자 행이 바뀜)→PASS. `NotificationDispatchService.java:146`(guard Blocked), `:564`(`applyRoutingStop`)를 `transitionHeldBy(..., lease)`로. 실제 PG `jpaPlatformContractTest` 217/217 | +| P4-new-2 | 완료 | `FileReconciliationServiceTest.restoringReadyCommitsThePublishedBytesToQuota` FAIL(`expected: 10L but was: 0L`, 동작 비활성화로 재현)→PASS, `aPublishWithoutItsUploadSessionIsUnresolvedRatherThanReadyWithoutQuota` PASS. `recovery/DefaultFileReconciliationService.java:160,175` READY 복원과 같은 경계에서 `QuotaCommitGateway.commit`; upload 세션을 못 찾으면 READY를 복원하지 않고 UNRESOLVED(`PUBLISH_UPLOAD_SESSION_ABSENT`). 생성자에 `UploadSessionStore`·`StagingUploadLocator`·`QuotaCommitGateway` 추가, 조립 `FileserverMaintenanceServiceConfiguration`. 실제 PG `postgresqlFileserverReclamationIntegrationTest` 15/15 | +| P4-new-3 | 완료 | `FinalizeUploadServiceTest.aRecordStillCreatedIsWalkedThroughUploadingToReady` FAIL(`IllegalStateException: illegal file transition: CREATED -> UPLOADED`)→PASS. `upload/DefaultFinalizeUploadService.java:196-214` CREATED→UPLOADING→UPLOADED | +| P4-new-4 | 완료 | `FileLifecycleServiceTest.deletingAnInProgressUploadEndsItsSessionAndSchedulesItsStagingForCleanup` FAIL(`[false, []]`, 동작 비활성화로 재현)→PASS. `lifecycle/DefaultFileLifecycleService.java:94,109` UPLOADING/UPLOADED/FAILED 레코드 삭제 시 `StagingUploadLocator`로 upload를 찾아 세션 terminate + `CANCELLED_STAGING` 예약(cancel과 같은 규칙). `FileRetirement`은 건드리지 않음(admin 경로는 새로 발견한 결함 참고). fake: `InMemoryUploadSessionStore`가 `StagingUploadLocator`도 구현 | +| P8-new-2 | 완료 | `GraphQlPlatformInstrumentationTest.aRequestWithoutPlatformContextIsLoggedAsAWiringFaultAtWarn` FAIL(`Expected size: 1 but was: 0`)→PASS. `runtime/GraphQlPlatformInstrumentation.java:72` executionId와 함께 WARN. 에러 매퍼는 건드리지 않음 | +| P9-new-1 | 완료 | `InboxItemEntityTest.archiveLeavesAnExpiredOrDeletedItemInItsTerminalState[EXPIRED,DELETED]` FAIL(`[true, "ARCHIVED", ...]`)→PASS. `.../platform/inbox/InboxItemEntity.java:145-146` EXPIRED·DELETED면 no-op(false) | +| P11-new-4 | 완료 | 결정 23. `DefaultDynamicTargetGatewayTest.crossOriginHopKeepsOnlySafeCallerHeaders` FAIL(`[(true, true), (true, true)]`)→PASS. `HC/dynamic/DefaultDynamicTargetGateway.java:164,172-185` cross-origin hop에서 호출자 헤더를 allowlist(`Accept`·`Accept-Language`·`Content-Type`·`Content-Language`)로만 남김. 자격증명 binding 헤더는 hop마다 새 target 기준으로 다시 붙음(기존) | +| P12-new-1 | 완료 | 실제 replica set lane `MongoBulkMappingLaneTest.aBulkWriteCarriesTheProfileWriteConcern` FAIL(update 명령 writeConcern `["null"]`)→PASS(`{"w": "majority"}`, CommandListener로 관찰). `imperative/MongoPlatformCollectionAccess.writeConcern()`, `MongoConsistencyBinder.java:93` `writeConcernFor`, `bulk/MongoBulkExecutor.java:94` `withWriteConcern`. `mongoReplicaSetTest` 7/7 | + +## 제거된 코드 +| 대상 | 경로 | 마지막으로 존재한 커밋 | 이유 | +|---|---|---|---| +| (없음) | | | | + +## 새로 발견한 결함 +- `P14-new-1` (미수정): operator force-delete(`application-fileserver/.../admin/DefaultFileserverAdminService.java:167` `retirement.retire(record, Optional.empty())`)도 P4-new-4와 같은 결함 — 진행 중 upload를 지우면 세션이 ACTIVE로 남고 staging 정리가 예약되지 않는다. 같은 `unfinishedUpload` 처리를 admin에도 넣으면 되지만(생성자에 `StagingUploadLocator` 추가) 행 범위 밖이라 두었다. +- `P14-new-2` (미수정, 불안정 테스트): `adapter:outbound:objectstorage`의 `S3AsyncResponseBodyBridgeTest.deliversAnExactBoundedBodyOnTheWorkerAndInvalidatesTheSource`가 전체 `check` 한 번에서 실패(`Expecting code to raise a throwable`), 단독 실행과 재실행에서는 통과. 이 묶음 변경과 무관한 타이밍 의존으로 보인다. +- `P14-new-3` (관찰): main 코드에 `ReconcilePosterImageUploadUseCase`를 부르는 worker가 없다(`claimPending` 호출자도 없음). P2-new-2 수정 후 게시가 이긴 ABORT_AUTHORIZED intent는 reconcile 명령이 와야 붙는다 — worker가 생기면 PENDING뿐 아니라 ABORT_AUTHORIZED도 집어야 한다. +- 테스트 규칙 잔여: `PosterImagePublicationWorkflowTest`는 이번에 testFixtures에 추가한 `InMemoryPosterImageUploadIntentStore` 대신 자기 `FakeIntents`를 계속 쓴다(중복 fake). `application-objectstorage`에 testFixtures가 없어 `ObjectPublicationHandoffPort`·`StagedObjectPublicationPort` 대역은 `PosterImageAbortReconcileRaceTest` 안의 스크립트 스텁으로 두었다. + +## 검증 +- leaf check 통과: `:adapter:outbound:persistence-jpa` 494, `:adapter:inbound:graphql` 373, `:application-fileserver` 244, `:adapter:outbound:fileserver` 222(skip 3, 기존), `:application-notification` 215, `:adapter:outbound:notification` 333(skip 1, 기존), `:adapter:outbound:persistence-mongo`(test 80 + mongoStableContractTest 464), `:adapter:outbound:httpclient` 304, `:adapter:outbound:objectstorage` 147, `:sample-portfolio` 296, `:app-bootstrap` 642(skip 5, 기존) — 실패 0. +- 실제 벤더 lane: `mongoReplicaSetTest` 7/7, `jpaPlatformContractTest` 217/217, `postgresqlFileserverReclamationIntegrationTest` 15/15, `:sample-portfolio:integrationTest` 49/49. +- `architectureCheck` 통과. 설정 키·의존성 변경 없음(`verifyEnvKeys`·`verifyDependencyLocks` 불필요). + +## 기타 +- 규칙 이탈: 소스 두 곳을 셸(python heredoc)로 편집했다 — `GraphQlPlatformInstrumentation.java`(import·LOG·warn 추가)와 `DefaultFileLifecycleService.java`(생성자 인자·필드 추가). 결과는 Read와 leaf check로 확인했고 이후 편집은 전부 Edit/Write로 했다. +- P4-new-2·P4-new-4의 FAIL은 생성자 변경 후 새 동작을 잠시 끈 상태로 재현했다(Error Prone이 읽지 않는 필드를 컴파일 오류로 막아, 동작 없는 생성자 변경만으로는 컴파일되지 않음). +- `ObjectPublicationHandoffPort.authorizeAbort`의 "이미 게시됨" 신호가 예외에서 `REJECTED`/`CONFLICT` receipt로 바뀌었다. 호출자는 sample 하나뿐이다. +- 결과 파일 위치: worktree 격리 때문에 원본 작업 트리 경로(`docs/reviews/2026-09-25-review-followup-results/W2-P14.md`)에 쓰기가 거부되어 이 scratchpad 파일로 남겼다. 오케스트레이터가 원본 경로로 옮겨야 한다. diff --git a/docs/reviews/2026-09-25-review-followup-results/W3-P17.md b/docs/reviews/2026-09-25-review-followup-results/W3-P17.md new file mode 100644 index 00000000..bd4a01b7 --- /dev/null +++ b/docs/reviews/2026-09-25-review-followup-results/W3-P17.md @@ -0,0 +1,55 @@ +# W3-P17 — gRPC 플랫폼 (Wave 3) + +worktree `.claude/worktrees/agent-aee5125c9de434b73`, 브랜치 `worktree-agent-aee5125c9de434b73`. +커밋: `6df06c6f`(W2 결함 2건), `119b25b7`(W3 K-10a), `e2397d2f`(W3 구조·protobuf/Buf·이름). + +## 행 결과 +| ID | 결과 | 근거 | +|---|---|---| +| K-10a | 완료 | `119b25b7`. `GrpcAuthenticationPolicy`가 `Optional authenticate(Metadata)`(`src/adapter/inbound/grpc/src/main/java/dev/caskeleton/adapter/inbound/grpc/GrpcAuthenticationPolicy.java:20`), 인터셉터가 `Context.Key`에 담아 `Contexts.interceptCall`(`GrpcAuthenticationInterceptor.java:40`), handler는 새 `GrpcAuthenticatedCaller.current()`로 읽는다. `null` 반환은 fail-closed. status/trailer 매핑(`call.close(...)`·`GrpcStatusMapper`)은 바꾸지 않았다(P15 영역). 테스트: `GrpcP1BoundaryWireTest.theAuthenticatedCallerReachesTheFeatureHandlerThroughTheGrpcContext`(실제 loopback Netty로 handler가 principal 이름을 응답), `GrpcAuthenticationInterceptorTest.aPolicyReturningNullIsRejectedAsUnauthenticated`. API 변경이라 FAIL 단계는 컴파일 실패(구 `isAuthenticated` 계약에 식별자 경로 없음). `:adapter:inbound:grpc:check`·`grpcTransportQualificationTest` 통과. CLAUDE.md·README 문구 갱신 | +| N-8d | 완료 | `e2397d2f`. `envoy.yaml`을 `src/grpc-advanced/grpc-advanced-compat/src/test/resources/envoy/envoy.yaml`로(jar에서 빠짐). 같은 이유로 테스트만 읽던 `compatibility.proto`(Edition 2024 fixture)도 `src/grpc-advanced/grpc-advanced/src/test/resources/proto/edition2024/`로. `GrpcWebCompatibilityTest`·`GrpcEdition2024PolicyTest` 통과. P5-new-1(envoy CORS deprecated, W5)은 손대지 않음 | +| N-9a | 완료 | `e2397d2f`. `src/grpc/grpc-spring-boot-starter/build.gradle`의 proto-contract·codegen 두 줄과 registry edge 삭제(두 leaf 자체도 S7-#13으로 삭제) | +| N-10a | 완료 | `e2397d2f`. 기본 한도 상수를 `src/grpc/grpc-core-api/src/main/java/dev/caskeleton/grpc/api/policy/GrpcTransportLimits.java` 한 곳으로(메시지 1 MiB, metadata 8 KiB); `GrpcServerProfile`·`GrpcNamedChannelProfile`·`GrpcMessageSizeProfile`·`GrpcMetadataBudget`·`GrpcMethodPolicy` 기본값이 이 상수를 쓴다. `GrpcServerProfile.stable(transport, executor)` 팩토리 추가(`src/grpc/grpc-runtime/src/main/java/dev/caskeleton/grpc/server/GrpcServerProfile.java:76`), starter bean이 재사용(`GrpcPlatformAutoConfiguration.java:56`). validator가 "method inbound 한도 ≤ server 한도" 검사(`GrpcPlatformStartupValidator.java:125`, 입력에 `GrpcServerProfile` 추가). `GrpcPlatformStartupValidatorTest.aMethodBoundAboveTheServerBoundIsRefused` 추가. 이 규칙을 넣자 기존 `aCoherentConfigurationStarts`가 FAIL(`Expecting empty but was: ["method '…/GetDocument' accepts 4194304-byte messages but the server rejects anything over 1048576; …"]`) → `GrpcMethodPolicy` 기본값 4 MiB를 1 MiB로 맞춰 PASS(아래 P17-new-1) | +| N-10b | 완료 | `e2397d2f`. `GrpcStreamProfile`과 `GrpcStreamEnvelopeTest.theDefaultProfileBuffersLiveEventsUntilTheSnapshotCompletes` 삭제. 256/8 MiB는 `GrpcFlowControlPolicy`만 소유 | +| S7-#3 | 완료 | `e2397d2f`. registry의 `optional-grpc` leaf 18 → 9: `grpc-core-api`, `grpc-runtime`(policy+server+client+discovery+admin), `grpc-contract`(proto-contract+codegen 자리), `grpc-observability`, `grpc-operation-ledger-jpa`, `grpc-spring-boot-starter`, `grpc-testkit`, `grpc-advanced`(bootstrap+edition+streaming+resilience+diagnostics), `grpc-advanced-compat`. 패키지 이름은 그대로(import 변경 없음). settings는 registry 구동(`OptionalArchitectureRegistrySettingsPlugin`)이라 `src/optional-platforms/settings.gradle` 변경 불필요, build-logic 무변경. 새 edge 없음, 미사용 edge 삭제: grpc-client의 io.grpc(leaf 합병으로 소멸), codegen→proto-contract, edition→core-api/proto-contract/bootstrap, testkit→proto-contract/codegen. starter·grpc-advanced·compat는 grpc-runtime의 versionless io.grpc api를 받으므로 `ca.grpc-platform-module`(gRPC BOM)로 전환 — 새 leaf로 lockfile을 재생성할 때 BOM 없이 `Could not find io.grpc:grpc-api:.`로 실패해서다(기존 lockfile 값과 동일하게 해석됨). `GrpcPackageOwnershipTest` leaf 목록 갱신. lockfile은 `-p optional-platforms resolveAndLockAll --write-locks`로 재생성 | +| S7-#13 | 완료 | `e2397d2f`. 소유자 결정 18대로 `GrpcProtoContractValidator`(regex 파서)·`GrpcProtoStyleManifest`·`GrpcProtoRuleViolation`·`grpc-codegen` 전체(Buf 규칙 재구현, codegen manifest, descriptor/consumer fixture) 삭제. `src/grpc/grpc-contract/build.gradle`: `com.google.protobuf` 플러그인(카탈로그 `protobufPlugin = "0.10.0"`, `libs.plugins.protobuf`), protoc·runtime은 `protobufGrpc`(3.25.5, gRPC BOM 1.68.1과 같은 줄) — `libs.protoc`, `libs.protobuf.java.grpc` 추가. 생성 코드는 Spotless target·Checkstyle·Error Prone에서 이 leaf만 제외, SpotBugs(qualityCheck)는 통과. protoc tool locator 설정은 locking 해제(정확 버전 좌표라 lock이 같은 값을 반복). `src/grpc/grpc-contract/buf.yaml`(STANDARD lint, FILE breaking). CI: `.github/workflows/ci-quality-gates.yml` job `grpc-proto-buf`(`bufbuild/buf-action` SHA 고정, `buf lint` + baseline에 모듈이 있으면 `buf breaking`, 없으면 notice 후 skip). 로컬 검증: buf 1.73.0 바이너리를 scratchpad에 받아 `buf lint`·`buf build`·`buf breaking --against '../../../.git#ref=e2397d2f,subdir=src/grpc/grpc-contract'` 모두 exit 0. 테스트 `GrpcContractGeneratedCodeTest`(생성 message wire 왕복·explicit presence, 패키지 disjoint). testkit `GrpcStableReleaseGate.evaluate`의 schema 입력은 `PublishDecision` 대신 `List schemaBreakages`(buf breaking 결과). ADR-GRPC-002를 superseded로 표시, 설계서에 변경 주석. **통합 시 확인 필요:** 새 job은 추가만 했고 `release-gate`의 `needs`에는 넣지 않았다(기존 job 수정 금지 지시) — required로 만들려면 오케스트레이터가 `release-gate.needs`에 `grpc-proto-buf`를 추가해야 한다 | +| P5-new-2 | 완료 | `6df06c6f`. `GrpcMethodName` 생성자가 `parse`와 같은 전체 256자 한도 적용(`src/grpc/grpc-core-api/src/main/java/dev/caskeleton/grpc/core/GrpcMethodName.java:31`). `GrpcCoreIdentifiersTest.constructedMethodNameLongerThanTheParseLimitIsRefused` FAIL(`Expecting actual not to be null` — 308자 이름이 생성됨) → PASS | +| P5-new-3 | 완료 | `6df06c6f`. `completeDrain(GrpcCredentialGeneration drained)`가 대상 세대가 지금 draining인 경우에만 CAS로 지우고 boolean 반환(`src/grpc/grpc-runtime/src/main/java/dev/caskeleton/grpc/security/GrpcCredentialRotationManager.java:134`, W2 커밋 시점 경로는 `grpc-policy`). `GrpcCredentialRotationManagerTest.completingAnOlderDrainLeavesTheNewerDrainInPlace` FAIL(`Expecting Optional to contain: GrpcCredentialGeneration[generation=2, …] but was empty.`) → PASS. 경합 테스트·`GrpcTlsProfileTest` 호출부 갱신 | +| P5-new-4 | 완료 | `e2397d2f`. bootstrap이 `grpc-advanced`로 합쳐져 resilience/edition/streaming/diagnostics의 `api project(':grpc-advanced:grpc-advanced-bootstrap')`가 사라졌고, compat의 bootstrap 의존(main 사용 0)과 registry edge 삭제 | +| NEW-15 | 완료 | `e2397d2f`. `hyeonworks` → `caskeleton`: proto 디렉터리 `src/grpc/grpc-contract/src/main/proto/caskeleton/grpc/common/v1/`, `package caskeleton.grpc.common.v1`, `java_package caskeleton.grpc.common.v1.generated`, Edition fixture, 테스트 문자열 전부(기계적 치환). `GrpcProtoStyleManifest`·`GrpcCodegenManifest`는 S7-#13으로 삭제돼 organization 필드 자체가 없다. `AGENTS.md` 「템플릿 재사용 체크리스트」 2번에 proto 조직 이름 한 줄. `src/grpc/**`·`src/grpc-advanced/**`에 `hyeonworks` 0건. 과거 리뷰·계획 문서(`docs/reviews/**`, `docs/*-superpowers-package/**`, 7월 계획)의 언급은 이력이라 두었다 | + +## 제거된 코드 +| 대상 | 경로 | 마지막으로 존재한 커밋 | 이유 | +|---|---|---|---| +| `grpc-policy` leaf | `src/grpc/grpc-policy` | `6d27356e` | 병합: → `grpc-runtime`(S7-#3) | +| `grpc-server` leaf | `src/grpc/grpc-server` | `6d27356e` | 병합: → `grpc-runtime`(S7-#3) | +| `grpc-client` leaf | `src/grpc/grpc-client` | `6d27356e` | 병합: → `grpc-runtime`(S7-#3) | +| `grpc-discovery` leaf | `src/grpc/grpc-discovery` | `6d27356e` | 병합: → `grpc-runtime`(S7-#3) | +| `grpc-admin` leaf | `src/grpc/grpc-admin` | `6d27356e` | 병합: → `grpc-runtime`(S7-#3) | +| `grpc-proto-contract` leaf (`.proto`는 이동) | `src/grpc/grpc-proto-contract` | `6d27356e` | 병합: → `grpc-contract`. `.proto` 두 파일은 `grpc-contract/src/main/proto/caskeleton/…`로 이동, 나머지는 삭제(S7-#13) | +| `GrpcProtoContractValidator`, `GrpcProtoStyleManifest`, `GrpcProtoRuleViolation` + 테스트 | `src/grpc/grpc-proto-contract/src/main/java/dev/caskeleton/grpc/contract/` | `6d27356e` | regex `.proto` 파서·style 규칙 재구현 — protoc + Buf lint로 대체(결정 18) | +| `buf.gen.yaml`, `buf.lock`, 구 `buf.yaml` | `src/grpc/grpc-proto-contract/src/main/resources/proto/` | `6d27356e` | 명세용 파일. 생성은 Gradle protobuf 플러그인, 설정은 `src/grpc/grpc-contract/buf.yaml` | +| `grpc-codegen` leaf 전체(`GrpcBufPolicy`, `GrpcBreakingCategory`, `GrpcCodegenManifest`, `GrpcCodegenOutput`, `GrpcGeneratedPackagePolicy`, `GrpcDescriptorArtifact`, `GrpcConsumerFixture`, `GrpcSchemaArtifactPublisher`, `GrpcSchemaBaseline` + 테스트·consumer fixture) | `src/grpc/grpc-codegen` | `6d27356e` | Buf lint/breaking·codegen 소유 규칙의 Java 재구현 — Buf(CI)·protobuf 플러그인으로 대체(결정 18) | +| `grpc-advanced-bootstrap` leaf | `src/grpc-advanced/grpc-advanced-bootstrap` | `6d27356e` | 병합: → `grpc-advanced`(S7-#3) | +| `grpc-advanced-edition` leaf | `src/grpc-advanced/grpc-advanced-edition` | `6d27356e` | 병합: → `grpc-advanced`(S7-#3); `compatibility.proto`는 test resources로 | +| `grpc-advanced-streaming` leaf | `src/grpc-advanced/grpc-advanced-streaming` | `6d27356e` | 병합: → `grpc-advanced`(S7-#3) | +| `grpc-advanced-resilience` leaf | `src/grpc-advanced/grpc-advanced-resilience` | `6d27356e` | 병합: → `grpc-advanced`(S7-#3) | +| `grpc-advanced-diagnostics` leaf | `src/grpc-advanced/grpc-advanced-diagnostics` | `6d27356e` | 병합: → `grpc-advanced`(S7-#3) | +| `GrpcStreamProfile` | `src/grpc/grpc-policy/src/main/java/dev/caskeleton/grpc/streaming/GrpcStreamProfile.java` | `6d27356e` | 테스트에서만 쓰였고 `GrpcFlowControlPolicy`의 256/8 MiB를 복제(N-10b) | +| `GrpcAuthenticationPolicy.isAuthenticated(Metadata)` | `src/adapter/inbound/grpc/src/main/java/dev/caskeleton/adapter/inbound/grpc/GrpcAuthenticationPolicy.java` | `6d27356e` | `authenticate(Metadata): Optional`로 교체(K-10a) | +| `GrpcCredentialRotationManager.completeDrain()`(무인자) | `src/grpc/grpc-policy/src/main/java/dev/caskeleton/grpc/security/GrpcCredentialRotationManager.java` | `6d27356e` | `completeDrain(GrpcCredentialGeneration)`로 교체(P5-new-3) | + +`docs/capability-status.md`(고치지 말 파일)에 옛 leaf 이름 6곳(`grpc-policy` 등)이 남아 있다 — 오케스트레이터가 「제거된 코드」 표를 옮길 때 함께 갱신 필요. + +## 새로 발견한 결함 +- `P17-new-1` — `src/grpc/grpc-core-api/src/main/java/dev/caskeleton/grpc/api/policy/GrpcMethodPolicy.java`(`readOnlyUnary`·`nonIdempotentUnary`): 기본 method 한도가 4 MiB인데 기본 server profile(`GrpcServerProfile.stableNetty`, starter bean)은 1 MiB 초과를 거부해, 기본값만으로 만든 method가 전송이 깨는 크기를 약속했다. N-10a의 validator 규칙이 드러냈고(`aCoherentConfigurationStarts` FAIL), 기본값을 `GrpcTransportLimits.DEFAULT_MAX_MESSAGE_BYTES`(1 MiB)로 맞춰 **고침**. +- `P17-new-2` — `src/grpc/grpc-spring-boot-starter/build.gradle`(및 이전 advanced leaf들): `ca.platform-module`이라 gRPC BOM이 없는데 versionless `io.grpc:grpc-api`를 전이로 받아, lockfile을 새로 쓰면 `Could not find io.grpc:grpc-api:.`로 해석이 실패한다(기존 lockfile이 있을 때만 통과). `ca.grpc-platform-module`로 바꿔 **고침**. + +## 실행한 검증 +- `./gradlew -p optional-platforms clean ci --max-workers=2` — BUILD SUCCESSFUL, 단위 테스트 564건 통과(실패 0). 포함: 전 leaf `check`, `qualityCheck`(SpotBugs), `architectureCheck`(registry direction·ignored sources). +- `./gradlew -p optional-platforms integrationCheck` — gRPC ledger PG lane(`grpc-operation-ledger-jpa:integrationTest`, Testcontainers PostgreSQL) 18건 통과. +- `./gradlew -p optional-platforms verifyDependencyLocks` — 9 leaf 통과. +- `./gradlew -p optional-platforms :grpc:grpc-contract:check --warning-mode=fail --rerun-tasks` — protobuf 플러그인 0.10.0 deprecation 경고 없음. +- `./gradlew architectureCheck :adapter:inbound:grpc:check :adapter:inbound:grpc:grpcTransportQualificationTest :adapter:inbound:grpc:verifyDependencyLocks --max-workers=2` — 통과. +- buf 1.73.0(scratchpad): `buf lint`, `buf build`, `buf breaking`(자기 커밋 대비) exit 0; CI step의 "baseline에 모듈 없음 → skip" 분기를 `git cat-file`로 확인. +- 실행하지 않음: env 키·공개 HTTP 경로·API surface는 바뀌지 않아 `verifyEnvKeys`/`verifyPublicPathSnapshot` 생략. 루트 build-logic은 건드리지 않음(P16). diff --git a/docs/reviews/2026-09-25-review-followup-status.md b/docs/reviews/2026-09-25-review-followup-status.md index 25192ae9..9648d485 100644 --- a/docs/reviews/2026-09-25-review-followup-status.md +++ b/docs/reviews/2026-09-25-review-followup-status.md @@ -469,7 +469,7 @@ Wave 1–2 구현 중 나온 질문에 대해 받은 7건(2026-09-28): | K-7 | Required | `WebSocketSessionRegistry` register/deregister 경쟁으로 actor당 상한 초과 | 해당 없음(코드 삭제) | 제거 표 「platform catalog·정책 패키지 … `session` …」(K#7 명시) | - | - | | K-8 | Consider | conflation 교체가 연결당 상한을 건너뛰고 손실을 `CONFLATED`로 보고 | 완료 | `src/adapter/inbound/websocket/src/main/java/dev/caskeleton/adapter/inbound/websocket/outbound/OutboundQueue.java:192-210`(로컬·전역 둘 다 검사, 실패 시 `DROPPED`), 테스트 `OutboundQueueTest.conflationThatDoesNotFitTheConnectionBoundIsReportedAsDropped`. 커밋 `6d27356e` | - | - | | K-9 | Consider | `WebSocketCorrelationRegistry.countFor`가 노드 전체 in-flight를 요청마다 순회 | 해당 없음(코드 삭제) | 제거 표 「platform catalog·정책 패키지 … `handler` …」, 현재 websocket main에 `handler/` 없음 | - | - | -| K-10a | Consider | gRPC 인증 정책이 yes/no만 반환해 식별자를 `Context`로 넘기지 못함 | 남음 | `src/adapter/inbound/grpc/src/main/java/dev/caskeleton/adapter/inbound/grpc/GrpcAuthenticationPolicy.java:16`(`boolean isAuthenticated(Metadata)`) | W3 | `Optional authenticate(Metadata)`로 바꾸고 인터셉터가 `Context.Key`에 담아 `Contexts.interceptCall` | +| K-10a | Consider | gRPC 인증 정책이 yes/no만 반환해 식별자를 `Context`로 넘기지 못함 | 완료 | Wave 3 W3-P17 (Wave 3 라운드 1 커밋): `119b25b7`. `GrpcAuthenticationPolicy`가 `Optional authenticate(Metadata)`(`src/adapter/inbound/grpc/src/main/java/dev/caskeleton/adapter/inbound/grpc/GrpcAuthenticationPolicy.java:20`), 인터셉터가 `Context.Key`에 담아 `Contexts.interceptCall`(`GrpcAuthenticationInterceptor.java:40`), handler는 새 `GrpcAuthenticatedCaller.current()`로 읽는다. `null` 반환은 fail-closed. status/trailer 매핑(`call.close(...)`·`GrpcStatusMapper`)은 바꾸지 않았다(P15 영역). 테스트: `GrpcP1BoundaryWireTest.theAuthenticatedCallerReachesTheFeatureHandlerThroughTheGrpcContext`(실제 loopback Netty로 handler가 principal 이름을 응답), `GrpcAuthenticationInterceptorTest.aPolicyReturningNullIsRejectedAsUnauthenticated`. API 변경이라 FAIL 단계는 컴파일 실패(구 `isAuthenticated` 계약에 식별자 경로 없음). `:adapter:inbound:grpc:check`·`grpcTransportQualificationTest` 통과. CLAUDE.md·README 문구 갱신 | - | `Optional authenticate(Metadata)`로 바꾸고 인터셉터가 `Context.Key`에 담아 `Contexts.interceptCall` | | K-10b | Consider | gRPC 인증 정책 예외를 로그 없이 삼킴 | 완료 | Wave 1–2 P5 (fcddab7e·Wave 2 커밋): `GrpcAuthenticationInterceptorTest.aThrowingPolicyIsLoggedWithItsTypeAndMethodButNotItsMessage` FAIL(출력 `""`)→PASS. 예외 타입·메서드만 WARN, 메시지(자격 증명 가능)는 남기지 않음 `src/adapter/inbound/grpc/src/main/java/dev/caskeleton/adapter/inbound/grpc/GrpcAuthenticationInterceptor.java:44`. 커밋 `a498ad84` | - | 예외 타입·메서드명만 WARN 로그(자격 증명 제외) 후 UNAUTHENTICATED | | K-11a | Consider | live STOMP inbound/outbound 채널 executor queue가 무제한(`Integer.MAX_VALUE`) | 완료 | Wave 1–2 P5 (fcddab7e·Wave 2 커밋): `WebSocketAutoConfigurationTest.clientChannelExecutorsAreBoundedByTheConfiguredQueueCapacity` FAIL(`[(2147483647, false), (2147483647, false)]` ≠ `[(64, true), (64, true)]`)→PASS. inbound·outbound 둘 다 스레드 CPU×2 고정(core=max), 큐 `app.websocket.channel-queue-capacity`(기본 10000, `@Positive`) `src/adapter/inbound/websocket/src/main/java/dev/caskeleton/adapter/inbound/websocket/stomp/WebSocketConfig.java:74,83`, `.../stomp/WebSocketSettings.java:32`. 새 env 키 `APP_WEBSOCKET_CHANNEL_QUEUE_CAPACITY`(`docs/registries/env-keys.yaml`, `src/.env.example`), `verifyEnvKeys` 통과. 커밋 `b39d3de0` | - | `registration.taskExecutor().corePoolSize/maxPoolSize/queueCapacity(n)`을 inbound·outbound 둘 다 설정(`WebSocketSettings`에서 값) | | K-11b | Consider | 동기 `@EventListener` 브로드캐스트가 구독자 수만큼 발행 스레드에서 fan-out | 남음 | `src/adapter/inbound/websocket/src/main/java/dev/caskeleton/adapter/inbound/websocket/stomp/LiveEventStompBroadcaster.java:57-87` | W3 | best-effort(R1) 문서 기준이면 브로커 채널에 executor를 두거나(`configureMessageBroker`의 `brokerChannel` taskExecutor) 리스너를 비동기로 | @@ -522,12 +522,12 @@ Wave 1–2 구현 중 나온 질문에 대해 받은 7건(2026-09-28): | N-8a | Consider | envoy 참조 설정의 `DownstreamTlsContext`에 인증서가 없음 | 완료 | Wave 1–2 P5 (fcddab7e·Wave 2 커밋): 실제 Envoy v1.31 `--mode validate`: 수정 전 `No TLS certificates found for server context`, 수정 후 `configuration ... OK`(임시 자체서명 인증서를 placeholder 경로에 마운트). `GrpcWebCompatibilityTest.theReferenceProxyTerminatesTlsWithACertificate` FAIL→PASS. `src/grpc-advanced/grpc-advanced-compat/src/main/resources/envoy/envoy.yaml:62`. 커밋 `a498ad84` | - | 인증서 경로 placeholder를 넣고 `envoy --mode validate` 통과 확인 | | N-8b | Consider | CORS header 목록이 실제 gRPC trailer와 다름(`expose_headers`에 `error-code,error-category`, 실제는 `error-reason`·`error-execution-id`·`completion-outcome`, `grpc-status-details-bin` 없음. `allow_headers`에 `x-user-agent`·`grpc-timeout` 없음) | 완료 | Wave 1–2 P5 (fcddab7e·Wave 2 커밋): `GrpcWebCompatibilityTest.theReferenceProxyExposesEveryTrailerThePlatformSends`(`GrpcErrorMapper`·`GrpcValidationInterceptor` 상수와 대조) FAIL(`error-code,error-category`만 있음)→PASS, `theReferenceProxyLetsTheBrowserSendItsDeadlineAndClientHeaders` FAIL→PASS. `envoy.yaml:41,43` | - | header 목록을 정정하고 `GrpcErrorMapper` 상수와 envoy.yaml을 대조하는 테스트 추가 | | N-8c | Consider | route `timeout: 30s`가 server stream을 30초에 끊음 | 완료 | Wave 1–2 P5 (fcddab7e·Wave 2 커밋): `GrpcWebCompatibilityTest.theReferenceRouteLeavesStreamLengthToTheCallersDeadline` FAIL→PASS. route `timeout: 0s` + `max_stream_duration.grpc_timeout_header_max: 0s` `envoy.yaml:34,36`(Envoy validate 통과) | - | stream route는 `timeout: 0s` + `grpc_timeout_header_max: 0s` | -| N-8d | Consider | 참조 설정이 main resources라 jar에 포함, 테스트는 부분 문자열만 확인 | 남음 | `src/grpc-advanced/grpc-advanced-compat/src/main/resources/envoy/envoy.yaml` | W3 | test resources 또는 docs로 이동 | -| N-9a | Consider | starter의 `grpc-proto-contract`·`grpc-codegen` 의존이 main에서 안 쓰임 | 남음 | `src/grpc/grpc-spring-boot-starter/build.gradle:21-22` (starter main의 `grpc.contract`·`grpc.codegen` import 0) | W3 | 두 줄과 registry edge 삭제 | +| N-8d | Consider | 참조 설정이 main resources라 jar에 포함, 테스트는 부분 문자열만 확인 | 완료 | Wave 3 W3-P17 (Wave 3 라운드 1 커밋): `e2397d2f`. `envoy.yaml`을 `src/grpc-advanced/grpc-advanced-compat/src/test/resources/envoy/envoy.yaml`로(jar에서 빠짐). 같은 이유로 테스트만 읽던 `compatibility.proto`(Edition 2024 fixture)도 `src/grpc-advanced/grpc-advanced/src/test/resources/proto/edition2024/`로. `GrpcWebCompatibilityTest`·`GrpcEdition2024PolicyTest` 통과. P5-new-1(envoy CORS deprecated, W5)은 손대지 않음 | - | test resources 또는 docs로 이동 | +| N-9a | Consider | starter의 `grpc-proto-contract`·`grpc-codegen` 의존이 main에서 안 쓰임 | 완료 | Wave 3 W3-P17 (Wave 3 라운드 1 커밋): `e2397d2f`. `src/grpc/grpc-spring-boot-starter/build.gradle`의 proto-contract·codegen 두 줄과 registry edge 삭제(두 leaf 자체도 S7-#13으로 삭제) | - | 두 줄과 registry edge 삭제 | | N-9b | Consider | `requireValid(..., Set.of())`로 advanced 격리 검사가 항상 통과 | 해당 없음(코드 삭제) | Wave 1–2 P5 (fcddab7e·Wave 2 커밋): P5 목록 밖이지만 D 삭제로 함께 닫힘: `validateAdvancedIsolation`과 `stableModuleDependencies` 파라미터 삭제(`GrpcStableBuildInvariant` 삭제에 따른 것). 커밋 `9b296c7c` | - | 파라미터와 `validateAdvancedIsolation` 삭제(격리는 Gradle 방향 게이트가 담당) | | N-9c | Consider | 문서가 `GrpcStableBuildInvariant`가 runtime에 강제한다고 적지만 호출하는 `requireStableStarterIsClean`의 main 호출자 0 | 완료 | Wave 1–2 P5 (fcddab7e·Wave 2 커밋): P5 목록 밖이지만 D에서 함께 닫힘: runtime 강제를 적던 문장을 build-time만으로 정정 `src/grpc/CLAUDE.md`(Stable 범위 절), `src/grpc-advanced/CLAUDE.md:18-19`. 커밋 `9b296c7c` | - | 두 CLAUDE.md에서 "runtime에 강제" 문구 삭제(또는 guard와 함께 삭제) | -| N-10a | Consider | 같은 한계값(1 MiB/8192)이 여러 곳에 따로 정의되고 정합 검사 없음(server profile bean의 리터럴 복사 포함) | 남음 | `src/grpc/grpc-server/src/main/java/dev/caskeleton/grpc/server/GrpcServerProfile.java:70-71`, `src/grpc/grpc-spring-boot-starter/src/main/java/dev/caskeleton/grpc/boot/GrpcPlatformAutoConfiguration.java:59-60`, `src/grpc/grpc-policy/src/main/java/dev/caskeleton/grpc/policy/GrpcMessageSizeProfile.java:43`, `src/grpc/grpc-client/src/main/java/dev/caskeleton/grpc/client/GrpcNamedChannelProfile.java:80-81,95-96`, `src/grpc/grpc-core-api/src/main/java/dev/caskeleton/grpc/api/context/GrpcMetadataBudget.java:33` | W3 | 상수를 `GrpcTransportLimits` 한 곳으로, starter bean은 `GrpcServerProfile` 팩토리 재사용, validator에 "method profile ≤ server profile" | -| N-10b | Consider | `GrpcStreamProfile`은 테스트에서만 쓰이고 `GrpcFlowControlPolicy`의 256/8MiB를 복제 | 남음 | `src/grpc/grpc-policy/src/main/java/dev/caskeleton/grpc/streaming/GrpcStreamProfile.java:40,45` (참조는 `GrpcStreamEnvelopeTest`뿐), `src/grpc/grpc-policy/src/main/java/dev/caskeleton/grpc/streaming/GrpcFlowControlPolicy.java:43` | W3 | `GrpcStreamProfile`과 그 테스트 참조 삭제 | +| N-10a | Consider | 같은 한계값(1 MiB/8192)이 여러 곳에 따로 정의되고 정합 검사 없음(server profile bean의 리터럴 복사 포함) | 완료 | Wave 3 W3-P17 (Wave 3 라운드 1 커밋): `e2397d2f`. 기본 한도 상수를 `src/grpc/grpc-core-api/src/main/java/dev/caskeleton/grpc/api/policy/GrpcTransportLimits.java` 한 곳으로(메시지 1 MiB, metadata 8 KiB); `GrpcServerProfile`·`GrpcNamedChannelProfile`·`GrpcMessageSizeProfile`·`GrpcMetadataBudget`·`GrpcMethodPolicy` 기본값이 이 상수를 쓴다. `GrpcServerProfile.stable(transport, executor)` 팩토리 추가(`src/grpc/grpc-runtime/src/main/java/dev/caskeleton/grpc/server/GrpcServerProfile.java:76`), starter bean이 재사용(`GrpcPlatformAutoConfiguration.java:56`). validator가 "method inbound 한도 ≤ server 한도" 검사(`GrpcPlatformStartupValidator.java:125`, 입력에 `GrpcServerProfile` 추가). `GrpcPlatformStartupValidatorTest.aMethodBoundAboveTheServerBoundIsRefused` 추가. 이 규칙을 넣자 기존 `aCoherentConfigurationStarts`가 FAIL(`Expecting empty but was: ["method '…/GetDocument' accepts 4194304-byte messages but the server rejects anything over 1048576; …"]`) → `GrpcMethodPolicy` 기본값 4 MiB를 1 MiB로 맞춰 PASS(아래 P17-new-1) | - | 상수를 `GrpcTransportLimits` 한 곳으로, starter bean은 `GrpcServerProfile` 팩토리 재사용, validator에 "method profile ≤ server profile" | +| N-10b | Consider | `GrpcStreamProfile`은 테스트에서만 쓰이고 `GrpcFlowControlPolicy`의 256/8MiB를 복제 | 완료 | Wave 3 W3-P17 (Wave 3 라운드 1 커밋): `e2397d2f`. `GrpcStreamProfile`과 `GrpcStreamEnvelopeTest.theDefaultProfileBuffersLiveEventsUntilTheSnapshotCompletes` 삭제. 256/8 MiB는 `GrpcFlowControlPolicy`만 소유 | - | `GrpcStreamProfile`과 그 테스트 참조 삭제 | | N-11a | Consider | ledger claim에서 insert 0행 + 조회 실패를 소유 획득으로 처리 | 완료 | Wave 1–2 P5 (fcddab7e·Wave 2 커밋): `GrpcOperationLedgerRepositoryTest.aConflictWhoseRowVanishedBeforeTheReadIsNotTakenAsOwnership` FAIL(`Expecting actual not to be null`)→PASS. 0행 + 조회 실패면 `IllegalStateException` `src/grpc/grpc-operation-ledger-jpa/src/main/java/dev/caskeleton/grpc/ledger/JpaGrpcOperationLedger.java:58`. PG lane(`integrationCheck`) 18건 통과. 커밋 `a498ad84` | - | 0행인데 조회도 비면 `IllegalStateException` | | N-11b | Consider | `callerFingerprint` 길이 제한이 없어 storageKey가 `VARCHAR(512)`를 넘을 수 있음 | 완료 | Wave 1–2 P5 (fcddab7e·Wave 2 커밋): 리뷰의 "`sha256:` 형식 검증 안 거침"은 틀림(`GrpcOperationIdentity.java:29`가 검사) — 길이만 고침. `GrpcOperationIdentityTest.aCallerFingerprintWiderThanItsLedgerColumnIsRefused`·`anIdentityWhoseStorageKeyWouldNotFitTheLedgerIsRefused` FAIL(`Expecting actual not to be null`)→PASS. V001 컬럼 폭(caller 256, method 256, hash 80, storage key 512)으로 compact constructor에서 거부 `src/grpc/grpc-core-api/src/main/java/dev/caskeleton/grpc/api/ledger/GrpcOperationIdentity.java:24,40`. migration 변경 없음. 커밋 `a498ad84` | - | fingerprint ≤256자 검증 또는 storage key를 해시로 고정 길이화 | | N-12a | Nit | `GrpcClientMessageDeduplicator`가 "constant space"라지만 outcome이 세션 내내 누적, `endSession`이 O(N) `removeIf` | 남음 | `src/grpc-advanced/grpc-advanced-streaming/src/main/java/dev/caskeleton/grpc/advanced/streaming/GrpcClientMessageDeduplicator.java:13,110-112` | W5 | outcome을 세션별 map으로 나눠 `endSession`은 한 번에 제거, javadoc 정정 | @@ -999,7 +999,7 @@ Wave 1–2 구현 중 나온 질문에 대해 받은 7건(2026-09-28): | S7-#1b | Required | 쓰는 곳 없는 `schema-avro`·`schema-protobuf`·`cloudevents`·`claim-check`가 기본 build에 | 남음 | 4개 leaf 유지(`CS:133` "leaf는 유지"), main 345·199·228·418줄, main 참조 0, 각 leaf에 README 없음 | W5 | Wave 3 방침(이동 대신 라이브러리로 유지)대로 각 leaf README에 "라이브러리 API — 서비스 leaf가 `implementation`으로 받음"과 SDK 의존을 적음 | | S7-#1c | Required | starter가 쓰지 않는 cloudevents·claim-check edge, 바인딩만 되는 `Experimental`·`Bridge` 설정 | 완료 | `CS:131`, `CS:133`; `src/messaging/messaging-spring-boot-starter/build.gradle:20-37`에 두 leaf 없음, `6d27356e` | - | - | | S7-#2 | Required | consume 계약 3개, 조립 0 | 남음 | `MessageHandler.java:14`(main 참조 0), `DefaultDeliveryProcessor.java:40-47`(참조 0), `IdempotentMessageHandler.java:21`; `KafkaConsumerRegistrar`(645줄)·`KafkaBatchConsumerRegistrar`(146줄) main 참조 0, 자동 조립 transport는 발행 전용(`KafkaMessagingTransport.java:89` `KAFKA_CONSUMER_NOT_CONFIGURED`) | W3 | 결정(2026-09-25): Kafka 소비 지원 — `MessageHandler` 하나, starter-kafka가 handler bean이 있으면 consumer 조립, 실제 Kafka lane 테스트 | -| S7-#3 | Required | grpc 18 leaf를 9 leaf로 | 남음 | `MJ`에 grpc leaf 18개 그대로. io.grpc import main 파일은 `grpc-policy` 4 + `grpc-server` 1(+testkit 6); `src/grpc/grpc-client/build.gradle:12-13` io.grpc api인데 import 0; 미사용 edge `src/grpc/grpc-codegen/build.gradle:13`, `src/grpc-advanced/grpc-advanced-edition/build.gradle:9-11` | W3 | policy+server+client+discovery+admin → `grpc-runtime`, proto-contract+codegen → `grpc-contract`, advanced 5개 → `grpc-advanced`, 미사용 edge 삭제 | +| S7-#3 | Required | grpc 18 leaf를 9 leaf로 | 완료 | Wave 3 W3-P17 (Wave 3 라운드 1 커밋): `e2397d2f`. registry의 `optional-grpc` leaf 18 → 9: `grpc-core-api`, `grpc-runtime`(policy+server+client+discovery+admin), `grpc-contract`(proto-contract+codegen 자리), `grpc-observability`, `grpc-operation-ledger-jpa`, `grpc-spring-boot-starter`, `grpc-testkit`, `grpc-advanced`(bootstrap+edition+streaming+resilience+diagnostics), `grpc-advanced-compat`. 패키지 이름은 그대로(import 변경 없음). settings는 registry 구동(`OptionalArchitectureRegistrySettingsPlugin`)이라 `src/optional-platforms/settings.gradle` 변경 불필요, build-logic 무변경. 새 edge 없음, 미사용 edge 삭제: grpc-client의 io.grpc(leaf 합병으로 소멸), codegen→proto-contract, edition→core-api/proto-contract/bootstrap, testkit→proto-contract/codegen. starter·grpc-advanced·compat는 grpc-runtime의 versionless io.grpc api를 받으므로 `ca.grpc-platform-module`(gRPC BOM)로 전환 — 새 leaf로 lockfile을 재생성할 때 BOM 없이 `Could not find io.grpc:grpc-api:.`로 실패해서다(기존 lockfile 값과 동일하게 해석됨). `GrpcPackageOwnershipTest` leaf 목록 갱신. lockfile은 `-p optional-platforms resolveAndLockAll --write-locks`로 재생성 | - | policy+server+client+discovery+admin → `grpc-runtime`, proto-contract+codegen → `grpc-contract`, advanced 5개 → `grpc-advanced`, 미사용 edge 삭제 | | S7-#4 | Required | gate·guard·catalog 같은 governance를 운영 코드로 (≈ N-9) | 완료 | Wave 1–2 P5 (fcddab7e·Wave 2 커밋): 삭제 커밋 `9b296c7c`(P5 D). 상수 gate·guard·catalog·invariant·testkit·문자열 ArchUnit 흉내 삭제(아래 「제거된 코드」). 전부 main 호출자 0이었다. `GrpcRawApiImportRule`·`GrpcApplicationBoundaryRules`는 자기 테스트의 합성 입력만 검사하고 저장소 코드를 검사하지 않아서 테스트로 옮기지 않고 삭제했다(inbound→outbound 규칙은 app-bootstrap ArchUnit `INBOUND_ADAPTERS_DO_NOT_DEPEND_ON_OUTBOUND_ADAPTERS`가 이미 검사). `GrpcResolverSafetyPolicy`는 상수 메서드 2개만 삭제. starter의 항상 통과하던 advanced 격리 검사도 함께 제거 `src/grpc/grpc-spring-boot-starter/src/main/java/dev/caskeleton/grpc/boot/GrpcPlatformStartupValidator.java:41`. 문서 갱신: `src/grpc/CLAUDE.md`, `src/grpc-advanced/CLAUDE.md`, `docs/runbooks/grpc-advanced-capabilities.md`, `docs/compatibility/grpc-advanced-support-matrix.md` | - | 상수 gate·catalog·invariant·testkit 삭제, import 규칙은 ArchUnit 테스트로 | | S7-#5a | Required | `messaging-outbox-jdbc-postgresql`의 Debezium 4개 | 해당 없음(코드 삭제) | `CS:130` | - | - | | S7-#5b | Required | 한 leaf가 relay 로직·PG repository·admin journal을 함께 가짐 | 남음 | `src/messaging/messaging-outbox-jdbc-postgresql/src/main/java/dev/caskeleton/messaging/outbox/`: relay 7클래스 877줄, `JdbcOutboxRepository` 721줄, `JdbcAdminOperationJournal` 326줄; Spring JDBC import 파일 2개. inbox는 6개 중 5개가 stdlib | W3 | `messaging-reliability`(stdlib relay·inbox 로직) + `messaging-reliability-jdbc-postgresql`(Jdbc 3종)으로 재분할 | @@ -1014,7 +1014,7 @@ Wave 1–2 구현 중 나온 질문에 대해 받은 7건(2026-09-28): | S7-#10 | Consider | 미사용 API 타입 (1차 M-9 목록 외) | 남음 | `MessagingException` 서브클래스 24개 중 13개 main 참조 0(Authentication, BrokerUnavailable, Consumer, DeadLetter, HandlerTimeout, HeaderRejected, PublishAmbiguous, PublishRejected, Redrive, RetryExhausted, Routing, Settlement, SettlementUnknown); `MessageHandler`·`KafkaTopologyInspector`·`ReliableMessagePublisher`·`InboxRecord` 참조 0. `RabbitRequestReply`만 삭제로 소멸 | W3 | 삭제(consumer 쪽 타입은 S7-#2 결정에 따름) | | S7-#11 | Consider | `MessagingCapabilities` 위치 boolean 12개 | 남음 | record boolean 12개, `KafkaMessagingTransport.java:62-64` `new MessagingCapabilities(true, …, true)`; 생성 11곳 → 4곳 | W3 | `EnumSet`로, 읽지 않는 flag 삭제 | | S7-#12 | Consider | messaging API leaf 병합(core-api+schema-api, admin-api+admin-runtime) | 남음 | 두 쌍 모두 별도 leaf(`MJ`). 기본 build messaging leaf 27 → 21(삭제분만) | W3 | 두 쌍 병합 | -| S7-#13 | Consider | `.proto` regex 파서·Buf 규칙 재구현 | 남음 | `GrpcProtoContractValidator.java` 447줄, `grpc-codegen` main 692줄, 근거 주석 `src/grpc/grpc-codegen/build.gradle:8-10`(설계 D5: CLI 없음) | W3 | 결정(2026-09-25): protobuf Gradle 플러그인(protoc) + Buf(CI)로 전환, 자체 `.proto` 파서·Buf 규칙 재구현 삭제 | +| S7-#13 | Consider | `.proto` regex 파서·Buf 규칙 재구현 | 완료 | Wave 3 W3-P17 (Wave 3 라운드 1 커밋): `e2397d2f`. 소유자 결정 18대로 `GrpcProtoContractValidator`(regex 파서)·`GrpcProtoStyleManifest`·`GrpcProtoRuleViolation`·`grpc-codegen` 전체(Buf 규칙 재구현, codegen manifest, descriptor/consumer fixture) 삭제. `src/grpc/grpc-contract/build.gradle`: `com.google.protobuf` 플러그인(카탈로그 `protobufPlugin = "0.10.0"`, `libs.plugins.protobuf`), protoc·runtime은 `protobufGrpc`(3.25.5, gRPC BOM 1.68.1과 같은 줄) — `libs.protoc`, `libs.protobuf.java.grpc` 추가. 생성 코드는 Spotless target·Checkstyle·Error Prone에서 이 leaf만 제외, SpotBugs(qualityCheck)는 통과. protoc tool locator 설정은 locking 해제(정확 버전 좌표라 lock이 같은 값을 반복). `src/grpc/grpc-contract/buf.yaml`(STANDARD lint, FILE breaking). CI: `.github/workflows/ci-quality-gates.yml` job `grpc-proto-buf`(`bufbuild/buf-action` SHA 고정, `buf lint` + baseline에 모듈이 있으면 `buf breaking`, 없으면 notice 후 skip). 로컬 검증: buf 1.73.0 바이너리를 scratchpad에 받아 `buf lint`·`buf build`·`buf breaking --against '../../../.git#ref=e2397d2f,subdir=src/grpc/grpc-contract'` 모두 exit 0. 테스트 `GrpcContractGeneratedCodeTest`(생성 message wire 왕복·explicit presence, 패키지 disjoint). testkit `GrpcStableReleaseGate.evaluate`의 schema 입력은 `PublishDecision` 대신 `List schemaBreakages`(buf breaking 결과). ADR-GRPC-002를 superseded로 표시, 설계서에 변경 주석. **통합 시 확인 필요:** 새 job은 추가만 했고 `release-gate`의 `needs`에는 넣지 않았다(기존 job 수정 금지 지시) — required로 만들려면 오케스트레이터가 `release-gate.needs`에 `grpc-proto-buf`를 추가해야 한다 | - | 결정(2026-09-25): protobuf Gradle 플러그인(protoc) + Buf(CI)로 전환, 자체 `.proto` 파서·Buf 규칙 재구현 삭제 | | S7-#14 | Consider | 패키지·leaf 이름 불일치, 등급 용어 4개 | 남음 | `src/grpc/grpc-policy/src/main/java/dev/caskeleton/grpc/{resilience,streaming}`(leaf `grpc-advanced-resilience`/`-streaming`과 이름 겹침); `CapabilityTier`(messaging-policy), `CompatibilityMatrix`(messaging-testkit), `GrpcCapabilityGrade`(grpc-advanced-bootstrap), `GrpcEvidenceGrade`(grpc-testkit) | W3 | S7-#3 병합 때 패키지 = leaf 이름으로 맞추고 등급 용어 하나로 | | S7-#15a | Consider | 리뷰 ID 주석 | 남음 | `MSG-INT-003` 9곳 그대로(예: `MS/MessagingCoreAutoConfiguration.java:370,442,480`, `DeclaredDestinationAccess.java:11`, `RegisteredMessageCodecs.java:12`) | W5 | ID 삭제, 이유만 남김 | | S7-#15b | Consider | 이력 주석·inline FQN | 남음 | "used to/no longer" 58 → 52줄; inline FQN 약 218줄(`KafkaConsumerRegistrar` 34) | W5 | 이력 문장 삭제, OpenRewrite `ShortenFullyQualifiedTypeReferences` | @@ -1119,22 +1119,22 @@ Wave 1–2 구현 묶음(`P1`–`P13`)이 작업 중 찾은 결함과 통합 검 | P1-new-2 | 발견 | `src/messaging/messaging-kafka/src/main/java/dev/caskeleton/messaging/kafka/KafkaConsumerRegistrar.java` — in-flight 천장·drain·pool 거부로 pause한 partition을 다시 resume하는 코드가 없음. ordered partition은 한 poll에 두 record를 받으면 첫 record 뒤 영구 정지… | 완료 | Wave 1–2 P1 (fcddab7e·Wave 2 커밋): 결과 파일 `docs/reviews/2026-09-25-review-followup-results/P1.md` | - | - | | P1-new-3 | 발견 | 같은 파일 — requeue 재개 시각을 `Instant.now()`로, poll은 호출자가 준 `now`로 비교해 두 시계가 섞임(테스트에서 재시도가 영원히 안 풀리거나 즉시 풀림). `InstantSource` 하나로 통일(M-7 수정에 포함) | 완료 | Wave 1–2 P1 (fcddab7e·Wave 2 커밋): 결과 파일 `docs/reviews/2026-09-25-review-followup-results/P1.md` | - | - | | P2-new-1 | 발견 | managed `publish`가 SCAN_CLEAN destination에서 scan 없이 게시한다 — `RoutingObjectMutationAdapter.publish`가 INTEGRITY_VERIFIED에서 곧바로 REFERENCE_PUBLISH_IN_PROGRESS로 가고 `requirePolicy`는 요구 수준이 같은지만 봤다. 이제 scan-gated destination이면 거부한다(`confi… | 완료 | Wave 1–2 P2 (fcddab7e·Wave 2 커밋): 결과 파일 `docs/reviews/2026-09-25-review-followup-results/P2.md` | - | - | -| P2-new-2 | 발견 | sample abort와 reconcile의 경합에서 intent가 멈춘다 — `AbortPosterImageUploadUseCase`(`sample-portfolio/.../poster/AbortPosterImageUploadUseCase.java:63-81,91`)는 DB에 ABORT_AUTHORIZED를 먼저 커밋한 뒤 저장소에 `authorizeAbort`를 부른다. 그 사이 reconcile이 fin… | 남음 | 결과 파일 `docs/reviews/2026-09-25-review-followup-results/P2.md` | W2 | 결정 22: 먼저 끝난 쪽이 이긴다 — 이미 게시됐으면 abort는 409, 게시된 객체를 붙인다 | -| P2-new-3 | 발견 | S3 managed provider `retire`가 항상 UNSUPPORTED를 던진다(`s3/S3ManagedObjectProvider.java:121-125`). S3 profile은 `CONDITIONAL_RETIREMENT`를 주장할 수 있어 destination 컴파일은 통과한다. D-1a 순서에서 S3 abort는 ABORTED를 기록한 뒤 retire에서 실패한다(바이트 잔존, 재시도도 같은 실… | 남음 | 결과 파일 `docs/reviews/2026-09-25-review-followup-results/P2.md` | W2 | S3 `retire` 구현 또는 S3 profile이 `CONDITIONAL_RETIREMENT`를 주장하지 못하게 | +| P2-new-2 | 발견 | sample abort와 reconcile의 경합에서 intent가 멈춘다 — `AbortPosterImageUploadUseCase`(`sample-portfolio/.../poster/AbortPosterImageUploadUseCase.java:63-81,91`)는 DB에 ABORT_AUTHORIZED를 먼저 커밋한 뒤 저장소에 `authorizeAbort`를 부른다. 그 사이 reconcile이 fin… | 완료 | Wave 2.5 W2-P14 (Wave 3 라운드 1 커밋): 결정 22. `PosterImageAbortReconcileRaceTest`(sample test) — `aPublicationThatFinishesAfterTheAbortWasAuthorizedIsAttached` FAIL(`IllegalStateException: publication intent handoff changed before TX3`)→PASS, `anAbortAuthorizedIntentWhoseObjectWasPublishedIsAttachedByTheNextReconcile` FAIL(`Poster image publication is not ready to reconcile`)→PASS, `anAbortThatArrivesAfterThePublicationIsAConflict` FAIL(예외 없음, 저장소 abort 진행)→PASS, `anAbortOfAnUploadAlreadyAttachedIsAConflict` 신규 PASS. `DomainExceptionHandlerTest.anAbortThatLostToThePublicationIsA409Conflict` PASS. 수정: 저장소 `kernel/ObjectPublicationHandoffService.java:117-125` `authorizeAbort`가 게시된 operation에 예외 대신 `REJECTED`/`CONFLICT` receipt(수정 전에는 `IllegalStateException`이라 sample이 "이미 게시됨"을 다른 장애와 구분할 수 없었음; D-1b 테스트 `StagedObjectPublicationLifecycleTest$AuthorizeAbort.authorizeAbortIsRejectedOnceTheReferenceIsPublished`를 receipt 단언으로 갱신). `AbortPosterImageUploadUseCase.java:83-87,99-105` READY/SUPERSEDED intent나 REJECTED receipt면 `PosterImageAlreadyPublishedException`(409 `POSTER_IMAGE_ALREADY_PUBLISHED`, `DomainExceptionHandler`), 아무것도 지우지 않고 intent는 ABORT_AUTHORIZED로 둠. `ReconcilePosterImageUploadUseCase.java:103,145,166`와 `PosterImageUploadIntent.requirePublishable`(ready/superseded)가 ABORT_AUTHORIZED도 받아 게시된 객체를 붙임(저장소가 abort를 먼저 받았으면 finalize가 거부돼 abort가 이김). 실제 PG `:sample-portfolio:integrationTest` 49/49 | - | 결정 22: 먼저 끝난 쪽이 이긴다 — 이미 게시됐으면 abort는 409, 게시된 객체를 붙인다 | +| P2-new-3 | 발견 | S3 managed provider `retire`가 항상 UNSUPPORTED를 던진다(`s3/S3ManagedObjectProvider.java:121-125`). S3 profile은 `CONDITIONAL_RETIREMENT`를 주장할 수 있어 destination 컴파일은 통과한다. D-1a 순서에서 S3 abort는 ABORTED를 기록한 뒤 retire에서 실패한다(바이트 잔존, 재시도도 같은 실… | 완료 | Wave 2.5 W2-P14 (Wave 3 라운드 1 커밋): 두 번째 선택지(주장 금지). `S3ProviderBindingTest.aProfileCannotClaimRetirementTheManagedS3ProviderDoesNotImplement` FAIL(`Expecting actual not to be null`)→PASS. `s3/S3ProviderBinding.java:199-206` profile이 `CONDITIONAL_RETIREMENT`를 주장하면 바인딩 거부. retire 구현은 S3 readiness 근거가 없어 하지 않음. 결과: 기본 요구 집합(CONDITIONAL_RETIREMENT 포함)의 S3 destination은 시작 시 거부된다 — `S3ProviderCompositionTest` destination은 명시 요구 집합으로 바꿈 | - | S3 `retire` 구현 또는 S3 profile이 `CONDITIONAL_RETIREMENT`를 주장하지 못하게 | | P3-new-1 | 발견 | `ntf-app/admin/AdminAuthorizationGuard.java` `requireTenant`가 어떤 작업이든 거부 시 `AdminAccessDeniedException(SUPPRESS)`를 던졌다 — redrive·reconcile 거부가 SUPPRESS 권한 부족으로 보고됨. 실제 권한을 인자로 받게 고침(`:41`). | 완료 | Wave 1–2 P3 (fcddab7e·Wave 2 커밋): 결과 파일 `docs/reviews/2026-09-25-review-followup-results/P3.md` | - | - | | P3-new-2 | 발견 | SNS 서명 인증서의 유효기간을 확인하지 않았다(`NotificationCallbackProviderConfig.java:80` `checkValidity()` 추가, B-2e와 함께). | 완료 | Wave 1–2 P3 (fcddab7e·Wave 2 커밋): 결과 파일 `docs/reviews/2026-09-25-review-followup-results/P3.md` | - | - | -| P3-new-3 | 발견 | JDK HttpClient의 요청 timeout은 응답 body 읽기를 덮지 않는다. B-6 재현 테스트의 FAIL이 증거다(요청 timeout 10초가 지나도 body 대기가 끝나지 않아 JUnit 20초 timeout). 상한 전까지 body를 조금씩 흘리는 provider(또는 SNS 인증서 host)는 dispatch 스레드를 무기한 잡을 수 있다. 위치 `ntf-adapter/provider/http… | 남음 | 결과 파일 `docs/reviews/2026-09-25-review-followup-results/P3.md` | W2 | 응답 body 읽기에 별도 deadline | +| P3-new-3 | 발견 | JDK HttpClient의 요청 timeout은 응답 body 읽기를 덮지 않는다. B-6 재현 테스트의 FAIL이 증거다(요청 timeout 10초가 지나도 body 대기가 끝나지 않아 JUnit 20초 timeout). 상한 전까지 body를 조금씩 흘리는 provider(또는 SNS 인증서 host)는 dispatch 스레드를 무기한 잡을 수 있다. 위치 `ntf-adapter/provider/http… | 완료 | Wave 2.5 W2-P14 (Wave 3 라운드 1 커밋): `JdkNotificationHttpGatewaySecurityTest.aResponseBodyThatStallsBelowTheCapEndsAtTheRequestTimeout` FAIL(`TimeoutException: ... timed out after 15 seconds`)→PASS. `provider/http/JdkNotificationHttpGateway.java:81,88,167` 요청 timeout의 남은 시간을 body 읽기 deadline으로 걸고, 넘기면 daemon 타이머가 stream을 닫아 `RESPONSE_TIMEOUT`(body committed=true). SNS 인증서 fetch도 같은 gateway를 씀 | - | 응답 body 읽기에 별도 deadline | | P3-new-4 | 발견 | SES adapter도 B-9a와 같은 결함(비 email 연락처·reveal 실패가 ambiguous로 기록). 공용 `EmailRecipients`로 SMTP와 함께 고침. | 완료 | Wave 1–2 P3 (fcddab7e·Wave 2 커밋): 결과 파일 `docs/reviews/2026-09-25-review-followup-results/P3.md` | - | - | -| P3-new-5 | 발견 | 라우트의 profile runtime이 사라진 경우 `gateway.profile()`이 `IllegalStateException`(`ntf-adapter/dispatch/ProviderRuntimeRegistry.java:50`)을 던져 B-3과 같은 경로(attempt row 전, lease 미해제 → requeue 반복)를 탄다. 설정 drift라 "고쳐질 때까지 재시도"로 볼 수도 있어 FAILED로 … | 남음 | 결과 파일 `docs/reviews/2026-09-25-review-followup-results/P3.md` | W2 | 결정 21: 일반 재시도 정책(backoff·최대 횟수) 적용 후 FAILED + 사유 코드 | -| P3-new-6 | 발견 | dispatch의 guard `Blocked` 전이와 routing stop 전이(`ntf-app/dispatch/NotificationDispatchService.java:138-142`, `applyRoutingStop`)는 lease fencing 없는 `transition`을 쓴다(B-5b와 같은 계열). provider 호출 전 짧은 구간이라 위험은 낮다. | 남음 | 결과 파일 `docs/reviews/2026-09-25-review-followup-results/P3.md` | W2 | guard `Blocked`·routing stop 전이를 lease fencing 있는 전이로 | +| P3-new-5 | 발견 | 라우트의 profile runtime이 사라진 경우 `gateway.profile()`이 `IllegalStateException`(`ntf-adapter/dispatch/ProviderRuntimeRegistry.java:50`)을 던져 B-3과 같은 경로(attempt row 전, lease 미해제 → requeue 반복)를 탄다. 설정 drift라 "고쳐질 때까지 재시도"로 볼 수도 있어 FAILED로 … | 완료 | Wave 2.5 W2-P14 (Wave 3 라운드 1 커밋): 결정 21. `RegistryProviderDispatchGatewayTest.aProfileNoRuntimeServesIsAProviderUnavailableFailure` FAIL(`IllegalStateException: no provider runtime registered for the profile`)→PASS; `NotificationDispatchServiceTest.aRouteWhoseProviderProfileIsGoneWaitsForTheRetryBackoff` FAIL(`[FAILED, Optional.empty, 0, ...]`)→PASS, `...FailsOnceTheRetryBudgetIsSpent` PASS. `ntf-adapter/dispatch/RegistryProviderDispatchGateway.java:35` 없는 profile → `ProviderUnavailableException(PROVIDER_UNAVAILABLE, TRANSIENT_PROVIDER)`(port javadoc에 명시). `ntf-app/dispatch/NotificationDispatchService.java:159,236` 일반 `NotificationRetryPolicy`(backoff·`RetryBudget(maxAdditionalAttempts, attemptCount)`·만료)로 RETRY_WAITING+nextDispatchAt, 한도면 FAILED, 어느 쪽이든 fenced `saveHeldBy` 후 lease 해제. attempt row가 없으므로 횟수는 수신자 `attemptCount`로 셈. 사유: 수신자 행에는 실패 코드 열이 없어 `lastFailureCategory=TRANSIENT_PROVIDER`로 남김(코드 `PROVIDER_UNAVAILABLE`은 예외 descriptor에만 있음) | - | 결정 21: 일반 재시도 정책(backoff·최대 횟수) 적용 후 FAILED + 사유 코드 | +| P3-new-6 | 발견 | dispatch의 guard `Blocked` 전이와 routing stop 전이(`ntf-app/dispatch/NotificationDispatchService.java:138-142`, `applyRoutingStop`)는 lease fencing 없는 `transition`을 쓴다(B-5b와 같은 계열). provider 호출 전 짧은 구간이라 위험은 낮다. | 완료 | Wave 2.5 W2-P14 (Wave 3 라운드 1 커밋): `NotificationDispatchServiceTest.aGuardBlockWrittenAfterTheLeaseWasLostChangesNothing`·`aRoutingStopWrittenAfterTheLeaseWasLostChangesNothing` FAIL(수신자 행이 바뀜)→PASS. `NotificationDispatchService.java:146`(guard Blocked), `:564`(`applyRoutingStop`)를 `transitionHeldBy(..., lease)`로. 실제 PG `jpaPlatformContractTest` 217/217 | - | guard `Blocked`·routing stop 전이를 lease fencing 있는 전이로 | | P4-new-1 | 발견 | fileserver migration(`src/adapter/outbound/persistence-fileserver/src/main/resources/db/migration/jpa/fileserver/V1..V5`)은 불변성 테스트가 없다. `AppliedMigrationImmutabilityTest`는 persistence-jpa의 `src/main/resources/db/migration`만 읽는다(`s… | 남음 | 결과 파일 `docs/reviews/2026-09-25-review-followup-results/P4.md` | W4 | fileserver migration에도 적용 파일 해시 고정 테스트 | -| P4-new-2 | 발견 | 재조정이 READY를 복원할 때 quota를 commit하지 않는다. `src/application-fileserver/.../recovery/DefaultFileReconciliationService.java` `reconcilePrePublishWithKey`는 VERIFYING→READY 전이만 하고 `QuotaCommitGateway.commit`이 없다. C-3a·C-3b로 이 경로가 실제로 실행되므… | 남음 | 결과 파일 `docs/reviews/2026-09-25-review-followup-results/P4.md` | W2 | 재조정 READY 복원 때 quota commit | -| P4-new-3 | 발견 | `DefaultFinalizeUploadService.advanceToVerifying`의 CREATED 분기가 CREATED→UPLOADED를 시도하지만 전이표에는 CREATED→UPLOADING뿐이라 `IllegalStateException`이 난다(`.../upload/DefaultFinalizeUploadService.java` `advanceToVerifying` 첫 if). | 남음 | 결과 파일 `docs/reviews/2026-09-25-review-followup-results/P4.md` | W2 | CREATED 분기 전이를 전이표에 맞게 | -| P4-new-4 | 발견 | lifecycle delete(`DefaultFileLifecycleService.delete`)로 진행 중 upload(UPLOADING)를 지우면 레코드는 DELETED가 되지만 세션은 ACTIVE로 남고 staging 정리가 예약되지 않는다. 이후 만료 sweep도 레코드가 DELETED라 staging을 예약하지 않아 staged bytes가 남는다. `FileRetirement`에 upload를 찾는… | 남음 | 결과 파일 `docs/reviews/2026-09-25-review-followup-results/P4.md` | W2 | 진행 중 upload 삭제 시 세션 종료·staging 정리 예약 | +| P4-new-2 | 발견 | 재조정이 READY를 복원할 때 quota를 commit하지 않는다. `src/application-fileserver/.../recovery/DefaultFileReconciliationService.java` `reconcilePrePublishWithKey`는 VERIFYING→READY 전이만 하고 `QuotaCommitGateway.commit`이 없다. C-3a·C-3b로 이 경로가 실제로 실행되므… | 완료 | Wave 2.5 W2-P14 (Wave 3 라운드 1 커밋): `FileReconciliationServiceTest.restoringReadyCommitsThePublishedBytesToQuota` FAIL(`expected: 10L but was: 0L`, 동작 비활성화로 재현)→PASS, `aPublishWithoutItsUploadSessionIsUnresolvedRatherThanReadyWithoutQuota` PASS. `recovery/DefaultFileReconciliationService.java:160,175` READY 복원과 같은 경계에서 `QuotaCommitGateway.commit`; upload 세션을 못 찾으면 READY를 복원하지 않고 UNRESOLVED(`PUBLISH_UPLOAD_SESSION_ABSENT`). 생성자에 `UploadSessionStore`·`StagingUploadLocator`·`QuotaCommitGateway` 추가, 조립 `FileserverMaintenanceServiceConfiguration`. 실제 PG `postgresqlFileserverReclamationIntegrationTest` 15/15 | - | 재조정 READY 복원 때 quota commit | +| P4-new-3 | 발견 | `DefaultFinalizeUploadService.advanceToVerifying`의 CREATED 분기가 CREATED→UPLOADED를 시도하지만 전이표에는 CREATED→UPLOADING뿐이라 `IllegalStateException`이 난다(`.../upload/DefaultFinalizeUploadService.java` `advanceToVerifying` 첫 if). | 완료 | Wave 2.5 W2-P14 (Wave 3 라운드 1 커밋): `FinalizeUploadServiceTest.aRecordStillCreatedIsWalkedThroughUploadingToReady` FAIL(`IllegalStateException: illegal file transition: CREATED -> UPLOADED`)→PASS. `upload/DefaultFinalizeUploadService.java:196-214` CREATED→UPLOADING→UPLOADED | - | CREATED 분기 전이를 전이표에 맞게 | +| P4-new-4 | 발견 | lifecycle delete(`DefaultFileLifecycleService.delete`)로 진행 중 upload(UPLOADING)를 지우면 레코드는 DELETED가 되지만 세션은 ACTIVE로 남고 staging 정리가 예약되지 않는다. 이후 만료 sweep도 레코드가 DELETED라 staging을 예약하지 않아 staged bytes가 남는다. `FileRetirement`에 upload를 찾는… | 완료 | Wave 2.5 W2-P14 (Wave 3 라운드 1 커밋): `FileLifecycleServiceTest.deletingAnInProgressUploadEndsItsSessionAndSchedulesItsStagingForCleanup` FAIL(`[false, []]`, 동작 비활성화로 재현)→PASS. `lifecycle/DefaultFileLifecycleService.java:94,109` UPLOADING/UPLOADED/FAILED 레코드 삭제 시 `StagingUploadLocator`로 upload를 찾아 세션 terminate + `CANCELLED_STAGING` 예약(cancel과 같은 규칙). `FileRetirement`은 건드리지 않음(admin 경로는 새로 발견한 결함 참고). fake: `InMemoryUploadSessionStore`가 `StagingUploadLocator`도 구현 | - | 진행 중 upload 삭제 시 세션 종료·staging 정리 예약 | | P5-new-1 | 발견 | `src/grpc-advanced/grpc-advanced-compat/src/main/resources/envoy/envoy.yaml:37`(virtual host `cors`): Envoy v1.31 validate가 `VirtualHost.cors`를 deprecated("will be removed soon")로 경고한다. per-filter `typed_per_filter_config`의 `CorsP… | 남음 | 결과 파일 `docs/reviews/2026-09-25-review-followup-results/P5.md` | W5 | envoy CORS를 per-filter 설정으로 | -| P5-new-2 | 발견 | `src/grpc/grpc-core-api/src/main/java/dev/caskeleton/grpc/core/GrpcMethodName.java`: `parse`는 전체 이름을 256자로 제한하지만 생성자는 service·method를 각각 256자로만 제한해 canonical이 최대 513자가 된다. ledger 쪽은 N-11b에서 막았지만 타입 자체의 두 경로가 다르다. 안 고침. | 남음 | 결과 파일 `docs/reviews/2026-09-25-review-followup-results/P5.md` | W2 | `GrpcMethodName` 두 생성 경로의 길이 제한 통일 | -| P5-new-3 | 발견 | `src/grpc/grpc-policy/src/main/java/dev/caskeleton/grpc/security/GrpcCredentialRotationManager.java:125` `completeDrain()`이 인자 없이 "지금 draining인 것"을 지워서, 그 사이 새 rotation이 시작한 drain(방금 교체된 세대)을 일찍 끝낼 수 있다. 경합 자체(현재 세대 되돌림)는 N-5b로 고쳤… | 남음 | 결과 파일 `docs/reviews/2026-09-25-review-followup-results/P5.md` | W2 | `completeDrain`이 대상 rotation을 인자로 받게 | -| P5-new-4 | 발견 | `src/grpc-advanced/grpc-advanced-{resilience,compat,edition,streaming}/build.gradle`: `api project(':grpc-advanced:grpc-advanced-bootstrap')`를 main이 쓰지 않는다(resilience는 `GrpcXdsStartupGuard` 삭제로 새로 0, 나머지 셋은 원래 0). build 줄과 registr… | 남음 | 결과 파일 `docs/reviews/2026-09-25-review-followup-results/P5.md` | W3 | 쓰지 않는 bootstrap 의존 제거 | +| P5-new-2 | 발견 | `src/grpc/grpc-core-api/src/main/java/dev/caskeleton/grpc/core/GrpcMethodName.java`: `parse`는 전체 이름을 256자로 제한하지만 생성자는 service·method를 각각 256자로만 제한해 canonical이 최대 513자가 된다. ledger 쪽은 N-11b에서 막았지만 타입 자체의 두 경로가 다르다. 안 고침. | 완료 | Wave 3 W3-P17 (Wave 3 라운드 1 커밋): `6df06c6f`. `GrpcMethodName` 생성자가 `parse`와 같은 전체 256자 한도 적용(`src/grpc/grpc-core-api/src/main/java/dev/caskeleton/grpc/core/GrpcMethodName.java:31`). `GrpcCoreIdentifiersTest.constructedMethodNameLongerThanTheParseLimitIsRefused` FAIL(`Expecting actual not to be null` — 308자 이름이 생성됨) → PASS | - | `GrpcMethodName` 두 생성 경로의 길이 제한 통일 | +| P5-new-3 | 발견 | `src/grpc/grpc-policy/src/main/java/dev/caskeleton/grpc/security/GrpcCredentialRotationManager.java:125` `completeDrain()`이 인자 없이 "지금 draining인 것"을 지워서, 그 사이 새 rotation이 시작한 drain(방금 교체된 세대)을 일찍 끝낼 수 있다. 경합 자체(현재 세대 되돌림)는 N-5b로 고쳤… | 완료 | Wave 3 W3-P17 (Wave 3 라운드 1 커밋): `6df06c6f`. `completeDrain(GrpcCredentialGeneration drained)`가 대상 세대가 지금 draining인 경우에만 CAS로 지우고 boolean 반환(`src/grpc/grpc-runtime/src/main/java/dev/caskeleton/grpc/security/GrpcCredentialRotationManager.java:134`, W2 커밋 시점 경로는 `grpc-policy`). `GrpcCredentialRotationManagerTest.completingAnOlderDrainLeavesTheNewerDrainInPlace` FAIL(`Expecting Optional to contain: GrpcCredentialGeneration[generation=2, …] but was empty.`) → PASS. 경합 테스트·`GrpcTlsProfileTest` 호출부 갱신 | - | `completeDrain`이 대상 rotation을 인자로 받게 | +| P5-new-4 | 발견 | `src/grpc-advanced/grpc-advanced-{resilience,compat,edition,streaming}/build.gradle`: `api project(':grpc-advanced:grpc-advanced-bootstrap')`를 main이 쓰지 않는다(resilience는 `GrpcXdsStartupGuard` 삭제로 새로 0, 나머지 셋은 원래 0). build 줄과 registr… | 완료 | Wave 3 W3-P17 (Wave 3 라운드 1 커밋): `e2397d2f`. bootstrap이 `grpc-advanced`로 합쳐져 resilience/edition/streaming/diagnostics의 `api project(':grpc-advanced:grpc-advanced-bootstrap')`가 사라졌고, compat의 bootstrap 의존(main 사용 0)과 registry edge 삭제 | - | 쓰지 않는 bootstrap 의존 제거 | | P6-new-1 | 발견 | `src/adapter/outbound/cache-redis/README.md` 「Useful focused checks」가 `./gradlew :app-bootstrap:test --tests '*RedisSemanticScriptAclProbeTest'`를 안내했지만 그 테스트는 cache-redis leaf에 있다. `:adapter:outbound:cache-redis:test`로 수정. 같은 READ… | 완료 | Wave 1–2 P6 (fcddab7e·Wave 2 커밋): 결과 파일 `docs/reviews/2026-09-25-review-followup-results/P6.md` | - | - | | P6-new-2 | 발견 | `IdempotencyExecutor`(application-core)는 `complete`가 `UNAVAILABLE`이면 곧바로 `IdempotencyUnavailableException`을 던진다(`IdempotencyExecutor.java:228`). 이번 수정으로 SCRIPT lane 포화 시 complete가 `INDETERMINATE`(재조정 경로) 대신 `UNAVAILABLE`을 받으므로, 효과… | 남음 | 결과 파일 `docs/reviews/2026-09-25-review-followup-results/P6.md` | W5 | 결정 24: 현재 동작 유지, README·Javadoc에 복구 경로 명시 | | P7-new-1 | 발견 | `src/adapter/outbound/notification/src/test/java/dev/caskeleton/adapter/outbound/notification/core/NotificationAdapterTest.java:65-82`: `RoutingNotifierTest`와 같은, 절대 실패하지 않는 PII 단언이 있었다(`"provider-failure"`). 고쳤다(W1 `9a05d686`). | 완료 | Wave 1–2 P7 (fcddab7e·Wave 2 커밋): 결과 파일 `docs/reviews/2026-09-25-review-followup-results/P7.md` | - | - | @@ -1142,10 +1142,10 @@ Wave 1–2 구현 묶음(`P1`–`P13`)이 작업 중 찾은 결함과 통합 검 | P7-new-3 | 발견 | `src/sample-portfolio/src/main/resources/db/sample-migration/V2__work_log.sql:26-27`의 주석은 "local dev relies on ddl-auto=update"라고 적혀 있다. 실제로는 `SamplePostgreSqlPersistenceConfig.sampleMigrationStrategy`가 sample schema를 migrate한다. 이… | 남음 | 결과 파일 `docs/reviews/2026-09-25-review-followup-results/P7.md` | W5 | 적용된 migration은 못 바꾸므로 sample README에 실제 경로 명시 | | P7-new-4 | 발견 | L-7a로 `show-details: never`가 되면 `show-components`도 따라서 never가 된다. 그러면 `/actuator/health` 응답에 component가 나오지 않는다. P13 `NEW-1a`(compose smoke가 켜진 capability를 확인)는 health component 대신 `info` 경로를 써야 한다. | 완료 | Wave 1–2 P7 (fcddab7e·Wave 2 커밋): 결과 파일 `docs/reviews/2026-09-25-review-followup-results/P7.md` | - | - | | P8-new-1 | 발견 | `GraphQlBatchLoadException`(per-key 실패, adopter가 준 `errorCode`)을 mapper가 모른다 → `INTERNAL_ERROR`로 가려지고 adopter code가 사라짐. `src/adapter/inbound/graphql/src/main/java/dev/caskeleton/adapter/inbound/graphql/dataloader/GraphQlBatchResu… | 남음 | 결과 파일 `docs/reviews/2026-09-25-review-followup-results/P8.md` | W3 | 결정 25: 등록된 `ApiErrorCode`만 노출(3-A와 함께) | -| P8-new-2 | 발견 | instrumentation 이 platform context 없이 온 요청(= interceptor 미배선 설정 오류)을 `INTERNAL_ERROR`+`PLATFORM_CONTEXT`로 거부하지만 로그를 남기지 않아, 잘못 조립된 배포가 모든 요청을 조용히 실패시킨다. `.../runtime/GraphQlPlatformInstrumentation.java:65-70`. | 남음 | 결과 파일 `docs/reviews/2026-09-25-review-followup-results/P8.md` | W2 | platform context 없는 요청 거부 시 WARN 로그 | +| P8-new-2 | 발견 | instrumentation 이 platform context 없이 온 요청(= interceptor 미배선 설정 오류)을 `INTERNAL_ERROR`+`PLATFORM_CONTEXT`로 거부하지만 로그를 남기지 않아, 잘못 조립된 배포가 모든 요청을 조용히 실패시킨다. `.../runtime/GraphQlPlatformInstrumentation.java:65-70`. | 완료 | Wave 2.5 W2-P14 (Wave 3 라운드 1 커밋): `GraphQlPlatformInstrumentationTest.aRequestWithoutPlatformContextIsLoggedAsAWiringFaultAtWarn` FAIL(`Expected size: 1 but was: 0`)→PASS. `runtime/GraphQlPlatformInstrumentation.java:72` executionId와 함께 WARN. 에러 매퍼는 건드리지 않음 | - | platform context 없는 요청 거부 시 WARN 로그 | | P8-new-3 | 발견 | graphql `CLAUDE.md` 「Error mapping」 절이 없는 클래스 `GraphqlExceptionResolver`와 "비-carrier 예외는 null 반환"을 설명하고 있었음. 현재 경로(한 mapper, 마스킹+로그)로 고침. 커밋 `aa5f4d90`. | 완료 | Wave 1–2 P8 (fcddab7e·Wave 2 커밋): 결과 파일 `docs/reviews/2026-09-25-review-followup-results/P8.md` | - | - | | P8-new-4 | 발견 | 이번 D 삭제 대상(`GraphQlRuntimeTransport`, `GraphQlExecutionProfile`, `GraphQlBlockingBridge`)을 설명하는 학습 문서가 남아 있음 — `docs/study/graphql-walkthrough.ko.md:157,461,871,1078`(결정 6 대상), `docs/graphql-superpowers-package/`. | 남음 | 결과 파일 `docs/reviews/2026-09-25-review-followup-results/P8.md` | W5 | 학습 문서 갱신(결정 6) | -| P9-new-1 | 발견 | `InboxItemEntity.archive()`가 EXPIRED·DELETED 항목도 ARCHIVED로 바꾼다(`src/adapter/outbound/persistence-jpa/src/main/java/dev/caskeleton/adapter/outbound/persistence/notification/platform/inbox/InboxItemEntity.java` `archive`). terminal … | 남음 | 결과 파일 `docs/reviews/2026-09-25-review-followup-results/P9.md` | W2 | `archive()`가 EXPIRED·DELETED를 거부 | +| P9-new-1 | 발견 | `InboxItemEntity.archive()`가 EXPIRED·DELETED 항목도 ARCHIVED로 바꾼다(`src/adapter/outbound/persistence-jpa/src/main/java/dev/caskeleton/adapter/outbound/persistence/notification/platform/inbox/InboxItemEntity.java` `archive`). terminal … | 완료 | Wave 2.5 W2-P14 (Wave 3 라운드 1 커밋): `InboxItemEntityTest.archiveLeavesAnExpiredOrDeletedItemInItsTerminalState[EXPIRED,DELETED]` FAIL(`[true, "ARCHIVED", ...]`)→PASS. `.../platform/inbox/InboxItemEntity.java:145-146` EXPIRED·DELETED면 no-op(false) | - | `archive()`가 EXPIRED·DELETED를 거부 | | P9-new-2 | 발견 | `PostgreSqlInboxCutoffIntegrationTest`가 repository의 SQL이 아니라 테스트 안의 사본을 실행하고 있어 E-4a가 PG lane에서 보이지 않았다. 고침(repository `@Query`를 읽어 실행). | 완료 | Wave 1–2 P9 (fcddab7e·Wave 2 커밋): 결과 파일 `docs/reviews/2026-09-25-review-followup-results/P9.md` | - | - | | P9-new-3 | 발견 | 같은 operationId를 다른 요청(다른 scope)으로 재사용하면 fake(`InMemoryDurableOperationStore`)는 조용히 덮어쓰고 PG adapter는 PK 위반으로 실패한다 — fake/adapter 불일치. HTTP 경로는 id를 서버가 발급해 영향 없음. 고치지 않음. | 남음 | 결과 파일 `docs/reviews/2026-09-25-review-followup-results/P9.md` | W4 | durable operation store 계약 테스트에 id 재사용 경우 추가, fake를 adapter와 맞춤 | | P9-new-4 | 발견 | `WebMvcRequestContextHolder.store(...)`를 부르는 운영 코드가 없어 `WebRequestContext`를 파라미터로 받는 컨트롤러는 항상 `IllegalStateException`으로 실패한다(`src/adapter/inbound/web/src/main/java/dev/caskeleton/adapter/inbound/web/mvc/context/WebMvcRequestContex… | 남음 | 결과 파일 `docs/reviews/2026-09-25-review-followup-results/P9.md` | W2 | 운영 경로에서 `WebRequestContext`를 채우거나 파라미터 사용처 제거 | @@ -1156,9 +1156,18 @@ Wave 1–2 구현 묶음(`P1`–`P13`)이 작업 중 찾은 결함과 통합 검 | P11-new-1 | 발견 | `app.httpclient.clients[N].timeout.streaming-idle`(`APP_HTTPCLIENT_CLIENTS_N_TIMEOUT_STREAMING_IDLE`)은 바인딩만 되고 main 코드 어디서도 읽지 않음(reactive 삭제 전에도 그랬음). `HC/profile/TimeoutSettings.java:25`, `docs/httpclient/configuration-reference… | 남음 | 결과 파일 `docs/reviews/2026-09-25-review-followup-results/P11.md` | W3 | 읽지 않는 `timeout.streaming-idle` 키·env 키 삭제 | | P11-new-2 | 발견 | `scripts/verify-httpclient-docs.py:22`가 없는 경로 `src/app-bootstrap/.../autoconfigure/httpclient/HttpClientStartupValidator.java`를 읽어 `FileNotFoundError`로 실패함. 경로를 `.../httpclient/autoconfigure`로 바꿔 돌리면 `rotation-drain-timeout`이 `doc… | 남음 | 결과 파일 `docs/reviews/2026-09-25-review-followup-results/P11.md` | W5 | `scripts/verify-httpclient-docs.py` 경로 수정, `rotation-drain-timeout` 문서 추가 | | P11-new-3 | 발견 | `httpClientFailureInjectionTest`의 `FailureInjectionContractTest.disabledProxyFailsBeforeARequestCanBeSent`가 이 머신에서 실패(`expected: NOT_SENT but was: SENT_NO_RESPONSE`). Docker userland proxy(`docker-proxy` 동작 중)가 꺼진 Toxiproxy 리스너의 p… | 남음 | 결과 파일 `docs/reviews/2026-09-25-review-followup-results/P11.md` | W4 | Docker userland proxy에 의존하지 않는 방식으로 lane 수정(기준 커밋에서도 실패 — 기존 결함) | -| P11-new-4 | 발견 | Dynamic Target cross-origin hop은 `SensitiveHeaderStripper` 표준 이름(`authorization`·`cookie`·`x-api-key`·`api-key` 등)만 제거하므로, 호출자가 `HeaderPolicy`로 넘긴 관례 밖 이름의 자격증명 헤더(예: `X-Client-Key`)는 다음 origin으로 따라감 `HC/dynamic/DefaultDynamicTarg… | 남음 | 결과 파일 `docs/reviews/2026-09-25-review-followup-results/P11.md` | W1 | 결정 23: cross-origin hop에서 호출자 헤더 전부 제거, 안전한 헤더만 유지 | -| P12-new-1 | 발견 | bulk 경로가 `access.rawOperations().getCollection(...)`의 raw collection에 `bulkWrite`를 해서, `MongoConsistencyBinder`가 profile별 template에 `setWriteConcern`으로 건 write concern이 적용되지 않는다(Spring `MongoTemplate.getCollection`은 template write… | 남음 | 결과 파일 `docs/reviews/2026-09-25-review-followup-results/P12.md` | W2 | bulk 경로에 profile write concern 적용 | +| P11-new-4 | 발견 | Dynamic Target cross-origin hop은 `SensitiveHeaderStripper` 표준 이름(`authorization`·`cookie`·`x-api-key`·`api-key` 등)만 제거하므로, 호출자가 `HeaderPolicy`로 넘긴 관례 밖 이름의 자격증명 헤더(예: `X-Client-Key`)는 다음 origin으로 따라감 `HC/dynamic/DefaultDynamicTarg… | 완료 | Wave 2.5 W2-P14 (Wave 3 라운드 1 커밋): 결정 23. `DefaultDynamicTargetGatewayTest.crossOriginHopKeepsOnlySafeCallerHeaders` FAIL(`[(true, true), (true, true)]`)→PASS. `HC/dynamic/DefaultDynamicTargetGateway.java:164,172-185` cross-origin hop에서 호출자 헤더를 allowlist(`Accept`·`Accept-Language`·`Content-Type`·`Content-Language`)로만 남김. 자격증명 binding 헤더는 hop마다 새 target 기준으로 다시 붙음(기존) | - | 결정 23: cross-origin hop에서 호출자 헤더 전부 제거, 안전한 헤더만 유지 | +| P12-new-1 | 발견 | bulk 경로가 `access.rawOperations().getCollection(...)`의 raw collection에 `bulkWrite`를 해서, `MongoConsistencyBinder`가 profile별 template에 `setWriteConcern`으로 건 write concern이 적용되지 않는다(Spring `MongoTemplate.getCollection`은 template write… | 완료 | Wave 2.5 W2-P14 (Wave 3 라운드 1 커밋): 실제 replica set lane `MongoBulkMappingLaneTest.aBulkWriteCarriesTheProfileWriteConcern` FAIL(update 명령 writeConcern `["null"]`)→PASS(`{"w": "majority"}`, CommandListener로 관찰). `imperative/MongoPlatformCollectionAccess.writeConcern()`, `MongoConsistencyBinder.java:93` `writeConcernFor`, `bulk/MongoBulkExecutor.java:94` `withWriteConcern`. `mongoReplicaSetTest` 7/7 | - | bulk 경로에 profile write concern 적용 | | P13-new-1 | 발견 | included build lock은 build-logic·build-tools 자신의 configuration(compile/test)만 잠근다. main build가 plugin을 쓸 때의 settings·root buildscript classpath는 main build에서 따로 해석되고 잠기지 않는다. 증거: `./gradlew buildEnvironment`에서 `project :build-tool… | 보류 | 사유: 잠그면 Spring Boot plugin을 올릴 때마다 lock 갱신 필요, included build 자체는 잠갔다. 승인자: 저장소 소유자(2026-09-28, 결정 27) | - | - | | P13-new-2 | 발견 | `local-redis` lane은 기동 로그 무음 검사(스크립트 3c)를 통과할 수 없다. lane 자신이 주는 `APP_REDIS_AUTHENTICATION_ANONYMOUS_ACCESS_ACCEPTED=true`와 advanced credential 미설정 때문에 `RedisSdkAutoConfiguration`이 기동 중 WARN 2줄(`Redis is running without credentials… | 남음 | 결과 파일 `docs/reviews/2026-09-25-review-followup-results/P13.md` | W4 | `local-redis` lane 설정 또는 smoke 무음 검사 기준 정리(NEW-1b와 함께) | -| NEW-15 | 발견 | gRPC proto 조직 이름이 템플릿 이름이 아니라 `hyeonworks`로 고정 — `GrpcProtoStyleManifest.caSkeleton()` `organization`, 기본 proto 패키지 `hyeonworks.grpc.common.v1`, `GrpcCodegenManifest`, 테스트 38개 파일. 재사용 체크리스트에도 없음 | 남음 | `src/grpc/grpc-proto-contract/src/main/java/dev/caskeleton/grpc/contract/GrpcProtoStyleManifest.java:62`, `src/grpc/grpc-proto-contract/src/main/resources/proto/hyeonworks/`, `src/grpc/grpc-codegen/.../GrpcCodegenManifest.java:63` | W3 | 결정 18(protobuf 플러그인 전환)과 함께 `caskeleton`으로 바꾸고 `AGENTS.md` 재사용 체크리스트에 한 줄 | +| NEW-15 | 발견 | gRPC proto 조직 이름이 템플릿 이름이 아니라 `hyeonworks`로 고정 — `GrpcProtoStyleManifest.caSkeleton()` `organization`, 기본 proto 패키지 `hyeonworks.grpc.common.v1`, `GrpcCodegenManifest`, 테스트 38개 파일. 재사용 체크리스트에도 없음 | 완료 | Wave 3 W3-P17 (Wave 3 라운드 1 커밋): `e2397d2f`. `hyeonworks` → `caskeleton`: proto 디렉터리 `src/grpc/grpc-contract/src/main/proto/caskeleton/grpc/common/v1/`, `package caskeleton.grpc.common.v1`, `java_package caskeleton.grpc.common.v1.generated`, Edition fixture, 테스트 문자열 전부(기계적 치환). `GrpcProtoStyleManifest`·`GrpcCodegenManifest`는 S7-#13으로 삭제돼 organization 필드 자체가 없다. `AGENTS.md` 「템플릿 재사용 체크리스트」 2번에 proto 조직 이름 한 줄. `src/grpc/**`·`src/grpc-advanced/**`에 `hyeonworks` 0건. 과거 리뷰·계획 문서(`docs/reviews/**`, `docs/*-superpowers-package/**`, 7월 계획)의 언급은 이력이라 두었다 | - | 결정 18(protobuf 플러그인 전환)과 함께 `caskeleton`으로 바꾸고 `AGENTS.md` 재사용 체크리스트에 한 줄 | | NEW-16 | 발견 | `integrationCheck`가 로컬에서 통과할 수 없는 lane을 묶음 — Redis topology 3개는 `-Predis.topology.mode` 없이 fail-closed, AWS 보호 lane은 보호 자격 증명 env가 없으면 실패. 그래서 집계 태스크가 항상 실패 | 남음 | Wave 1·2 검증 로그: `redisTopologyTest was selected with redis.topology.mode='unset'`, `AwsS3QualificationPreconditionsTest` | W3 | 매개변수·자격 증명이 필요한 lane은 `integrationCheck`에서 빼고 전용 워크플로에서만(또는 입력이 있을 때만 포함) | +| P14-new-1 | 발견 | operator force-delete(`application-fileserver/.../admin/DefaultFileserverAdminService.java:167`)가 P4-new-4와 같은 결함 — 진행 중 upload를 지우면 세션이 ACTIVE로 남고 staging 정리가 예약되지 않는다. | 남음 | Wave 2.5 P14 결과 파일 | W2 | lifecycle delete와 같은 `unfinishedUpload` 처리를 admin 경로에도(생성자에 `StagingUploadLocator`). 라운드 2 P24 | +| P14-new-2 | 발견 | `S3AsyncResponseBodyBridgeTest.deliversAnExactBoundedBodyOnTheWorkerAndInvalidatesTheSource`가 전체 `check` 부하에서 간헐 실패(`Expecting code to raise a throwable`), 단독 통과. | 남음 | Wave 2.5 P14 결과 파일 | W4 | 타이밍 의존 제거(결정적 executor/latch) | +| P14-new-3 | 발견 | main에 `ReconcilePosterImageUploadUseCase`를 부르는 worker가 없다(`claimPending` 호출자 0). 게시가 이긴 ABORT_AUTHORIZED intent는 reconcile 명령이 와야 붙는다. | 남음 | Wave 2.5 P14 결과 파일 | W3 | sample에 reconcile worker(PENDING·ABORT_AUTHORIZED 모두)를 두거나 수동 명령임을 문서화. 라운드 2 P25 | +| P14-new-4 | 발견 | P2-new-3 수정 뒤 기본 요구 집합(`CONDITIONAL_RETIREMENT` 포함, `ObjectStorageDestinationSettings.java:40`)을 쓰는 S3 destination은 기동 시 거부된다 — 운영 provider인 S3로 sample 포스터 게시(`PublishPosterImageUseCase.java:197`)를 쓸 수 없다. | 남음 | `S3ProviderBinding.java:202` | W3 | S3 조건부 retire 구현(버전·ETag 조건 삭제, MinIO lane으로 검증) 또는 기본 요구 집합 재검토. 라운드 2 P24 | +| P14-new-5 | 발견 | 테스트 규칙 잔여: `PosterImagePublicationWorkflowTest`가 testFixtures `InMemoryPosterImageUploadIntentStore` 대신 자기 `FakeIntents` 사용, `application-objectstorage`에 testFixtures가 없어 포트 대역이 테스트 안 스텁. | 남음 | Wave 2.5 P14 결과 파일 | W4 | 공용 fake로 교체, application-objectstorage testFixtures 신설 | +| P17-new-1 | 발견 | `GrpcMethodPolicy` 기본 method 한도 4 MiB가 기본 server profile 1 MiB와 어긋남. | 완료 | Wave 3 P17: N-10a validator가 드러냄(`aCoherentConfigurationStarts` FAIL), 기본값을 `GrpcTransportLimits.DEFAULT_MAX_MESSAGE_BYTES`로 | - | - | +| P17-new-2 | 발견 | gRPC starter·advanced leaf가 BOM 없이 versionless `io.grpc:grpc-api`를 받아 lockfile 재생성 시 해석 실패. | 완료 | Wave 3 P17: `ca.grpc-platform-module`로 교체 | - | - | +| P17-new-3 | 발견 | 새 CI job `grpc-proto-buf`(buf lint·breaking)가 `ci-quality-gates.yml` `release-gate.needs`에 없어 병합을 막지 않는다. | 남음 | Wave 3 P17 결과 | W3 | 오케스트레이터가 P16 통합 때 `release-gate.needs`에 추가 | +| ORCH-new-1 | 발견 | `messaging-policy` `MessagingAdmissionControllerTest.aWaitingCallerIsAdmittedOnceAPermitIsReturned`가 에이전트 4개 부하 중 실패, 단독 재실행 통과(타이밍 의존). | 남음 | desktop 기준선 `check`(2026-09-28, `016597ac`) | W4 | 대기 확인을 sleep/시간이 아닌 결정적 신호로 | diff --git a/docs/superpowers/plans/2026-09-25-review-followup-tools/by_area.py b/docs/superpowers/plans/2026-09-25-review-followup-tools/by_area.py index a24998b5..8f577035 100644 --- a/docs/superpowers/plans/2026-09-25-review-followup-tools/by_area.py +++ b/docs/superpowers/plans/2026-09-25-review-followup-tools/by_area.py @@ -42,7 +42,7 @@ def area(rid, text): if group: return GROUP_AREA[group.group(1)] new = re.match(r"NEW-(\d+)", head) - if new: + if new and int(new.group(1)) in NEW_AREA: return NEW_AREA[int(new.group(1))] if head.startswith("S3-"): return "httpclient" if re.search(r"httpclient|HttpClient|WebClient|OAuth2|reactive|redirect|Dynamic", text) else "redis" diff --git a/docs/superpowers/plans/2026-09-25-review-followup.md b/docs/superpowers/plans/2026-09-25-review-followup.md index cf3105e2..6f194df0 100644 --- a/docs/superpowers/plans/2026-09-25-review-followup.md +++ b/docs/superpowers/plans/2026-09-25-review-followup.md @@ -194,7 +194,7 @@ Wave마다 Slack `#clean-architecture-전체`에 템플릿 1로 브리핑한다. --- -## Wave 3 — 구조 (시작할 때 상세 Task 추가) +## Wave 3 — 구조 (상세 Task: 2026-09-28 desktop 재개 때 추가) 공통 작업(여러 leaf를 한 번에 바꿔서 순차로 한다): @@ -205,6 +205,35 @@ Wave마다 Slack `#clean-architecture-전체`에 템플릿 1로 브리핑한다. 그다음 영역별: Kafka 소비(결정 10), SES → AWS SDK(결정 17), gRPC protobuf 플러그인 + Buf(결정 18), `persistence-notification` leaf 추출, SRP 분해, 구현 1개 인터페이스 정리, 이름 규칙, 빌드 게이트 이동(결정 4, API surface → `check` 결정 20). +### 실행 환경 (desktop) + +12코어·메모리 31GB(여유 약 24GB). 동시 묶음은 **최대 4개**, 각 Gradle은 `--max-workers=2`. 결과 파일은 `docs/reviews/2026-09-25-review-followup-results/-P<번호>.md`. 공통 작업 4개는 서로 순차(3-A → 3-C → 3-D → 3-B)로 두고, 같은 라운드의 나머지 자리는 그 공통 작업과 겹침이 적은 영역 묶음으로 채운다. 3-B(prefix)는 모든 설정이 자리 잡은 뒤 한 번에 이름을 바꾸도록 마지막에 혼자 돈다. 라운드마다 통합 → `check`·`architectureCheck`·`ci` → 커밋, Wave 끝에 Wave 종료 검증 전체. + +W1·W2 잔여 21행(Wave 2.5)은 P14로 1라운드에서 함께 처리한다. W1 3행(legacy Kafka seam)과 W2 messaging 3행은 3-C(P18), W2 `P9-new-4`는 3-D(P19), gRPC 플랫폼 `P5-new-2`·`P5-new-3`은 P17이 맡는다. + +### 묶음 (행 ID는 현황표 첫 열) + +| 묶음 | 라운드 | 내용 | 행 | +|---|---|---|---| +| P14 | 1 | Wave 2.5 정합성 잔여(결정 21·22·23) | `P2-new-2` `P2-new-3` `P3-new-3` `P3-new-5` `P3-new-6` `P4-new-2` `P4-new-3` `P4-new-4` `P8-new-2` `P9-new-1` `P11-new-4` `P12-new-1` | +| P15 | 1 | 3-A 에러 어휘(결정 2·11·12·25, IAE 400) | `I-3a` `J-10e` `X2-P1-6` `X2-P2-1d` `X2-P2-1e` `X2-P2-1f` `X2-P2-2a` `X2-P2-2b` `X2-P2-3a` `X2-P2-3b` `X2-P2-9a` `X2-P2-9b` `S1-#7` `S2-lead-4` `S5-#1c` `S5-#1d` `S5-#6c` `S5-#6d` `S5-lead-1` `P8-new-1` | +| P16 | 1 | 빌드 게이트(결정 4·20, NEW-16) | `O-4c` `O-8` `BUILD-결론-1` `-2` `-4` `BUILD-중복-3` `-6` `-7` `-8` `BUILD-계획-B2` `-B3` `-B4-17` `-B4-27` `-B4-28` `-B4-30` `-C` `BUILD-O3-2` `-5` `-6` `BUILD-바로할것-7` `-12d` `X1-지도-readiness…` `X1-#7a` `S1-#16` `S5-lead-4` `NEW-13a` `-13b` `-13d` `-13e` `NEW-16` | +| P17 | 1 | gRPC 플랫폼(결정 18, 18→9 leaf, `hyeonworks`→`caskeleton`) | `K-10a` `N-8d` `N-9a` `N-10a` `N-10b` `S7-#3` `S7-#13` `P5-new-2` `P5-new-3` `P5-new-4` `NEW-15` | +| P18 | 2 | 3-C outbox canonical + `composition:*` + legacy Kafka seam 삭제(결정 3·7) | `X1-지도-Kafka producer` `X1-#1f` `NEW-4a` `S6-lead-3` `S7-lead-3` `X1-지도-Outbox` `X1-#1b` `X1-#1i` `S1-#2b` `S2-lead-1` `S7-#8` `S4-lead-4b` `NEW-2a` `NEW-2b` `G-11b` `X1-#2b` `S1-lead-3` `X1-지도-요청 멱등성` `S6-#7` `S7-#5b` `S2-#9b` | +| P24 | 2 | fileserver·object storage 구조 | `D-7d` `D-7e` `D-8a` `D-8b` `D-8c` `S1-#6a` `S1-#6b` `S1-#12` `S1-#13` `S1-#17a` `S1-#17b` `S1-#18b` `S1-lead-4` `S4-#11a` `S4-#11b` `S4-#12` `S4-lead-2` `S5-#10` `S6-lead-5` | +| P25 | 2 | core 죽은 표면 · web · GraphQL · sample 구조(NEW-10d) | `A-2c` `A-4b` `A-5b` `A-5c` `A-10c` `I-5b` `I-6b` `I-8d` `J-7` `J-10d` `K-11b` `X1-#6f` `S1-#15b` `S5-#7a` `S6-#8` `S6-#10a` `S6-#10b` `S6-#10c` `S6-#10d` `S6-#11a` `S6-#13` `NEW-9b` `NEW-10d` `NEW-12` | +| P26 | 2 | HTTP client · JPA 구조 | `E-6b` `H-4b` `H-7a` `S2-#3b` `S3-#2b` `S3-#6` `S3-#7` `S3-#8b` `S3-#10` `S3-lead-5` `S6-#3c` `S6-#3d` | +| P19 | 3 | 3-D 공통 유틸·tenant·context·caller 트랜잭션 guard | `D-8d` `E-3b` `I-1c` `J-12` `X1-지도-caller 트랜잭션 guard` `X1-지도-Backoff 계산식` `X1-#1c` `X1-#4` `X1-#9` `X1-#10b` `X2-P1-4b` `X2-P1-5` `X2-P1-7` `X2-P2-4` `X2-P2-5` `X2-P2-6a` `S1-#11` `S1-lead-2` `S2-lead-3` `S5-lead-3` `P9-new-4` `P9-new-5` | +| P21 | 3 | messaging 플랫폼: Kafka 소비(결정 10)·API 정리 | `M-9` `S7-#2` `S7-#6a` `S7-#6b` `S7-#9a` `S7-#9b` `S7-#9c` `S7-#10` `S7-#11` `S7-#12` `S7-#14` | +| P22 | 3 | Redis 구조 · startup rule | `G-4i` `G-6b` `G-7a` `G-7c` `G-7d` `G-7e` `G-8` `X1-지도-lock / lease / fencing` `S1-#15c` `S3-#3a` `S3-#3b` `S3-#4b` `S3-#5` `S3-#9` `S6-#2c` `S6-#3a` | +| P23 | 3 | notification: SES → sesv2(결정 17), `persistence-notification` 추출, SRP | `S1-#4` `S1-#9` `S1-#10b` `S2-#1b` `S2-#6c` `S2-#8a` `S2-#13b` `S4-#3c` `S4-#4b` `S4-#9` `S4-#14b` `S4-#15` `S4-lead-3` `S4-lead-5` | +| P20 | 4 | 3-B 설정 prefix `app.*`(결정 16), strict 바인딩 | `X2-P1-3c` `S3-lead-2` `S3-lead-4` `S6-#14` `P11-new-1` | + +- [ ] 라운드 1: P14 · P15 · P16 · P17 → 통합·검증·커밋 +- [ ] 라운드 2: P18 · P24 · P25 · P26 → 통합·검증·커밋 +- [ ] 라운드 3: P19 · P21 · P22 · P23 → 통합·검증·커밋 +- [ ] 라운드 4: P20 → 통합 → Wave 종료 검증 → 현황표·「제거된 코드」 갱신 → 커밋 `review-followup Wave 3` + ## Wave 4 — 테스트 규칙 (시작할 때 상세 Task 추가) `AGENTS.md` 규칙 2를 한국어로 수정, 포트별 추상 계약 테스트(lock·lease 포함, 결정 8), 약한 단언 정리, 계층별 모범 모듈. diff --git a/docs/superpowers/specs/2026-08-30-grpc-platform-adaptation-design.md b/docs/superpowers/specs/2026-08-30-grpc-platform-adaptation-design.md index 5ff42ccf..c7f2c244 100644 --- a/docs/superpowers/specs/2026-08-30-grpc-platform-adaptation-design.md +++ b/docs/superpowers/specs/2026-08-30-grpc-platform-adaptation-design.md @@ -39,6 +39,13 @@ src/adapter/inbound/grpc 기존 인바운드 전송 어댑터 ( 원본 모듈 경계 중 **이 저장소가 이미 다른 메커니즘으로 표현하는 것**만 합친다. 능력(capability)은 하나도 버리지 않는다. +> **2026-09-28 변경(리뷰 후속 S7-#3·S7-#13, 소유자 결정 18).** 아래 두 표는 채택 당시의 leaf 구성이다. +> 현재는 `grpc-policy`·`grpc-server`·`grpc-client`·`grpc-discovery`·`grpc-admin` → `grpc-runtime`, +> `grpc-proto-contract`·`grpc-codegen` → `grpc-contract`(protobuf Gradle 플러그인 + CI의 Buf, D5/D6 폐기 — +> ADR-GRPC-002 superseded), `grpc-advanced-bootstrap`·`-edition`·`-streaming`·`-resilience`·`-diagnostics` +> → `grpc-advanced`로 합쳐졌다. `grpc-advanced-compat`은 그대로다. 패키지 이름은 바뀌지 않았다. 현재 +> leaf 목록은 registry(`src/config/architecture/modules.json`)가 SSOT다. + ### Stable — `src/grpc/` | leaf | 원본 모듈 | 담는 Task | 의존 | diff --git a/src/adapter/inbound/graphql/src/main/java/dev/caskeleton/adapter/inbound/graphql/runtime/GraphQlPlatformInstrumentation.java b/src/adapter/inbound/graphql/src/main/java/dev/caskeleton/adapter/inbound/graphql/runtime/GraphQlPlatformInstrumentation.java index f7b28340..97c943d4 100644 --- a/src/adapter/inbound/graphql/src/main/java/dev/caskeleton/adapter/inbound/graphql/runtime/GraphQlPlatformInstrumentation.java +++ b/src/adapter/inbound/graphql/src/main/java/dev/caskeleton/adapter/inbound/graphql/runtime/GraphQlPlatformInstrumentation.java @@ -13,6 +13,8 @@ import graphql.execution.instrumentation.SimplePerformantInstrumentation; import graphql.execution.instrumentation.parameters.InstrumentationExecuteOperationParameters; import java.util.List; import java.util.Objects; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; /** * The seam where the platform's policies meet a real GraphQL request. @@ -29,6 +31,8 @@ import java.util.Objects; */ public final class GraphQlPlatformInstrumentation extends SimplePerformantInstrumentation { + private static final Logger LOG = LoggerFactory.getLogger(GraphQlPlatformInstrumentation.class); + /** Constraint reported when the request arrived without a platform context. */ public static final String MISSING_CONTEXT_CONSTRAINT = "PLATFORM_CONTEXT"; @@ -63,6 +67,12 @@ public final class GraphQlPlatformInstrumentation extends SimplePerformantInstru GraphQlRequestContext requestContext = execution.getGraphQLContext().get(GraphQlRequestContext.CONTEXT_KEY); if (requestContext == null) { + // The client only sees INTERNAL_ERROR; without this line a mis-assembled deployment fails + // every request and nothing on the operator side says why. + LOG.warn( + "graphql request rejected: no platform context (executionId={});" + + " the platform transport interceptor is not wired", + executionId); throw new AbortExecutionException( List.of( GraphQlWireErrors.toGraphQlError( diff --git a/src/adapter/inbound/graphql/src/test/java/dev/caskeleton/adapter/inbound/graphql/runtime/GraphQlPlatformInstrumentationTest.java b/src/adapter/inbound/graphql/src/test/java/dev/caskeleton/adapter/inbound/graphql/runtime/GraphQlPlatformInstrumentationTest.java new file mode 100644 index 00000000..c581f541 --- /dev/null +++ b/src/adapter/inbound/graphql/src/test/java/dev/caskeleton/adapter/inbound/graphql/runtime/GraphQlPlatformInstrumentationTest.java @@ -0,0 +1,69 @@ +package dev.caskeleton.adapter.inbound.graphql.runtime; + +import static org.assertj.core.api.Assertions.assertThat; + +import ch.qos.logback.classic.Level; +import ch.qos.logback.classic.Logger; +import ch.qos.logback.classic.spi.ILoggingEvent; +import ch.qos.logback.core.read.ListAppender; +import dev.caskeleton.adapter.inbound.graphql.execution.GraphQlExecutionStage; +import graphql.ExecutionInput; +import graphql.GraphQL; +import graphql.schema.idl.SchemaParser; +import graphql.schema.idl.UnExecutableSchemaGenerator; +import java.util.List; +import org.junit.jupiter.api.Test; +import org.slf4j.LoggerFactory; + +class GraphQlPlatformInstrumentationTest { + + @Test + void aRequestWithoutPlatformContextIsLoggedAsAWiringFaultAtWarn() { + // given + GraphQL graphQl = + GraphQL.newGraphQL( + UnExecutableSchemaGenerator.makeUnExecutableSchema( + new SchemaParser().parse("type Query { _health: String }"))) + .instrumentation( + new GraphQlPlatformInstrumentation( + new GraphQlExecutionChain( + List.of( + new PassThrough(GraphQlExecutionStage.PARSE_VALIDATE), + new PassThrough(GraphQlExecutionStage.AUTHORIZATION), + new PassThrough(GraphQlExecutionStage.COST))), + GraphQlWireErrorMapper.masking())) + .build(); + Logger logger = (Logger) LoggerFactory.getLogger(GraphQlPlatformInstrumentation.class); + ListAppender appender = new ListAppender<>(); + appender.start(); + logger.addAppender(appender); + + // when + try { + graphQl.execute( + ExecutionInput.newExecutionInput("{ _health }") + .executionId(graphql.execution.ExecutionId.from("exec-7"))); + } finally { + logger.detachAppender(appender); + appender.stop(); + } + + // then + assertThat(appender.list) + .singleElement() + .extracting(ILoggingEvent::getLevel, ILoggingEvent::getFormattedMessage) + .containsExactly( + Level.WARN, + "graphql request rejected: no platform context (executionId=exec-7);" + + " the platform transport interceptor is not wired"); + } + + /** A pipeline stage that passes the state through. */ + private record PassThrough(GraphQlExecutionStage stage) implements GraphQlExecutionHandler { + + @Override + public GraphQlExecutionContext handle(GraphQlExecutionContext context) { + return context; + } + } +} diff --git a/src/adapter/inbound/grpc/CLAUDE.md b/src/adapter/inbound/grpc/CLAUDE.md index a563b9c0..aed959c9 100644 --- a/src/adapter/inbound/grpc/CLAUDE.md +++ b/src/adapter/inbound/grpc/CLAUDE.md @@ -82,7 +82,9 @@ credential path and a separately qualified non-loopback bind. 현재 저장소에는 production feature RPC나 sample gRPC service가 없다. 향후 feature를 도입할 때는 `.proto`/generated stub/`BindableService`를 해당 feature가 소유하고, 서비스 빈과 정확히 한 개의 caller-supplied `GrpcAuthenticationPolicy` 빈을 함께 제공한다. 정책이 없거나 여러 개면 -listener 시작이 실패한다. 정책이 `false`를 반환하거나 예외를 던진 요청은 feature handler에 닿지 +listener 시작이 실패한다. 정책은 `Optional authenticate(Metadata)`이고, 돌려준 +호출자는 gRPC `Context`에 담겨 handler가 `GrpcAuthenticatedCaller.current()`로 읽는다. 정책이 +빈 값·`null`을 반환하거나 예외를 던진 요청은 feature handler에 닿지 않고 안정적인 `UNAUTHENTICATED` status/code/category로 종료된다. 정책 예외는 예외 타입과 메서드 이름만 WARN으로 남긴다(메시지는 자격 증명을 담을 수 있어 남기지 않는다). diff --git a/src/adapter/inbound/grpc/README.md b/src/adapter/inbound/grpc/README.md index 5671af83..96959f91 100644 --- a/src/adapter/inbound/grpc/README.md +++ b/src/adapter/inbound/grpc/README.md @@ -63,7 +63,9 @@ 개의 `GrpcAuthenticationPolicy`를 함께 기여한다. runner는 qualifier로 선택된 서비스만 등록하며, 같은 context의 unqualified `BindableService`는 gRPC 포트에 노출하지 않는다. 노출 서비스가 하나라도 있는데 인증 정책이 없거나 단일하지 않으면 listener 시작을 거부한다. 정책은 gRPC `Metadata`만 받아 -Spring Security에 결합되지 않으며, `false` 반환과 policy 예외는 동일한 안정적 +Spring Security에 결합되지 않는다. 인증된 호출자(`Optional`)는 인터셉터가 gRPC +`Context`에 담아(`Contexts.interceptCall`) handler가 `GrpcAuthenticatedCaller.current()`로 읽으므로, +handler가 metadata를 다시 해석하지 않는다. 빈 값·`null` 반환과 policy 예외는 동일한 안정적 `UNAUTHENTICATED` 계약으로 끝난다. ## 에러 매핑 — web `GlobalExceptionHandler` 의 gRPC 형제 diff --git a/src/adapter/inbound/grpc/src/main/java/dev/caskeleton/adapter/inbound/grpc/GrpcAuthenticatedCaller.java b/src/adapter/inbound/grpc/src/main/java/dev/caskeleton/adapter/inbound/grpc/GrpcAuthenticatedCaller.java new file mode 100644 index 00000000..2db694d3 --- /dev/null +++ b/src/adapter/inbound/grpc/src/main/java/dev/caskeleton/adapter/inbound/grpc/GrpcAuthenticatedCaller.java @@ -0,0 +1,23 @@ +package dev.caskeleton.adapter.inbound.grpc; + +import io.grpc.Context; +import java.security.Principal; +import java.util.Optional; + +/** + * The caller {@link GrpcAuthenticationPolicy} authenticated for the current feature RPC. + * + *

{@link GrpcAuthenticationInterceptor} binds it to the gRPC {@link Context} of the call, so a + * handler reads it on the thread that runs the call's callbacks without re-parsing metadata. + */ +public final class GrpcAuthenticatedCaller { + + static final Context.Key KEY = Context.key("ca-skeleton.grpc.authenticated-caller"); + + private GrpcAuthenticatedCaller() {} + + /** The authenticated caller of the current call, or empty outside an authenticated call. */ + public static Optional current() { + return Optional.ofNullable(KEY.get()); + } +} diff --git a/src/adapter/inbound/grpc/src/main/java/dev/caskeleton/adapter/inbound/grpc/GrpcAuthenticationInterceptor.java b/src/adapter/inbound/grpc/src/main/java/dev/caskeleton/adapter/inbound/grpc/GrpcAuthenticationInterceptor.java index 25552ec9..bf262f40 100644 --- a/src/adapter/inbound/grpc/src/main/java/dev/caskeleton/adapter/inbound/grpc/GrpcAuthenticationInterceptor.java +++ b/src/adapter/inbound/grpc/src/main/java/dev/caskeleton/adapter/inbound/grpc/GrpcAuthenticationInterceptor.java @@ -1,15 +1,22 @@ package dev.caskeleton.adapter.inbound.grpc; import dev.caskeleton.shared.error.OperationalError; +import io.grpc.Context; +import io.grpc.Contexts; import io.grpc.Metadata; import io.grpc.ServerCall; import io.grpc.ServerCallHandler; import io.grpc.ServerInterceptor; import io.grpc.Status; +import java.security.Principal; +import java.util.Optional; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -/** Applies the caller-supplied authentication policy before a feature RPC can reach its handler. */ +/** + * Applies the caller-supplied authentication policy before a feature RPC can reach its handler, and + * hands the authenticated caller to the handler through the gRPC {@link Context}. + */ final class GrpcAuthenticationInterceptor implements ServerInterceptor { private static final Logger log = LoggerFactory.getLogger(GrpcAuthenticationInterceptor.class); @@ -26,8 +33,11 @@ final class GrpcAuthenticationInterceptor implements ServerInterceptor { @Override public ServerCall.Listener interceptCall( ServerCall call, Metadata headers, ServerCallHandler next) { - if (isAuthenticated(headers, call.getMethodDescriptor().getFullMethodName())) { - return next.startCall(call, headers); + Optional caller = + authenticate(headers, call.getMethodDescriptor().getFullMethodName()); + if (caller.isPresent()) { + Context context = Context.current().withValue(GrpcAuthenticatedCaller.KEY, caller.get()); + return Contexts.interceptCall(context, call, headers, next); } call.close( @@ -36,16 +46,18 @@ final class GrpcAuthenticationInterceptor implements ServerInterceptor { return new ServerCall.Listener<>() {}; } - private boolean isAuthenticated(Metadata headers, String method) { + private Optional authenticate(Metadata headers, String method) { try { - return authenticationPolicy.isAuthenticated(headers); + Optional caller = authenticationPolicy.authenticate(headers); + // A policy that returns null has not authenticated anybody; fail closed. + return caller == null ? Optional.empty() : caller; } catch (RuntimeException failure) { // Type and method only: the message of a failing credential check may echo the credential. log.warn( "gRPC authentication policy threw {} for {}; the call is rejected as UNAUTHENTICATED", failure.getClass().getName(), method); - return false; + return Optional.empty(); } } } diff --git a/src/adapter/inbound/grpc/src/main/java/dev/caskeleton/adapter/inbound/grpc/GrpcAuthenticationPolicy.java b/src/adapter/inbound/grpc/src/main/java/dev/caskeleton/adapter/inbound/grpc/GrpcAuthenticationPolicy.java index b6d4b8bc..a129a6b4 100644 --- a/src/adapter/inbound/grpc/src/main/java/dev/caskeleton/adapter/inbound/grpc/GrpcAuthenticationPolicy.java +++ b/src/adapter/inbound/grpc/src/main/java/dev/caskeleton/adapter/inbound/grpc/GrpcAuthenticationPolicy.java @@ -1,6 +1,8 @@ package dev.caskeleton.adapter.inbound.grpc; import io.grpc.Metadata; +import java.security.Principal; +import java.util.Optional; /** * Caller-supplied policy that authenticates feature RPC metadata without Spring Security coupling. @@ -9,9 +11,11 @@ import io.grpc.Metadata; public interface GrpcAuthenticationPolicy { /** - * Returns {@code true} only when the request metadata represents an authenticated caller. A - * {@code false} result or policy exception becomes the same stable {@code UNAUTHENTICATED} wire + * Returns the authenticated caller, or empty when the request metadata does not authenticate one. + * The returned principal is placed in the gRPC {@code Context} for the rest of the call and read + * by the handler through {@link GrpcAuthenticatedCaller#current()}. An empty result, a {@code + * null} result or a policy exception all become the same stable {@code UNAUTHENTICATED} wire * contract; policy diagnostics never reach the client. */ - boolean isAuthenticated(Metadata metadata); + Optional authenticate(Metadata metadata); } diff --git a/src/adapter/inbound/grpc/src/test/java/dev/caskeleton/adapter/inbound/grpc/GrpcAuthenticationInterceptorTest.java b/src/adapter/inbound/grpc/src/test/java/dev/caskeleton/adapter/inbound/grpc/GrpcAuthenticationInterceptorTest.java index 971f9a9a..265348e9 100644 --- a/src/adapter/inbound/grpc/src/test/java/dev/caskeleton/adapter/inbound/grpc/GrpcAuthenticationInterceptorTest.java +++ b/src/adapter/inbound/grpc/src/test/java/dev/caskeleton/adapter/inbound/grpc/GrpcAuthenticationInterceptorTest.java @@ -7,6 +7,8 @@ import io.grpc.MethodDescriptor; import io.grpc.ServerCall; import io.grpc.Status; import java.io.InputStream; +import java.util.concurrent.atomic.AtomicBoolean; +import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.ExtendWith; import org.springframework.boot.test.system.CapturedOutput; @@ -37,6 +39,29 @@ class GrpcAuthenticationInterceptorTest { .doesNotContain(CREDENTIAL_SENTINEL); } + @Test + @DisplayName("인증 정책이 null을 돌려주면 handler에 닿지 않고 UNAUTHENTICATED로 닫힌다") + void aPolicyReturningNullIsRejectedAsUnauthenticated() { + // given + GrpcAuthenticationInterceptor interceptor = + new GrpcAuthenticationInterceptor(metadata -> null, new GrpcStatusMapper()); + MethodCall call = new MethodCall(); + AtomicBoolean handlerReached = new AtomicBoolean(); + + // when + interceptor.interceptCall( + call, + new Metadata(), + (ignoredCall, headers) -> { + handlerReached.set(true); + return new ServerCall.Listener<>() {}; + }); + + // then + assertThat(handlerReached).isFalse(); + assertThat(call.closedWith).isEqualTo(Status.Code.UNAUTHENTICATED); + } + /** A server call that only knows its method; the interceptor closes it as unauthenticated. */ private static final class MethodCall extends ServerCall { @@ -62,8 +87,12 @@ class GrpcAuthenticationInterceptorTest { @Override public void sendMessage(String message) {} + private Status.Code closedWith; + @Override - public void close(Status status, Metadata trailers) {} + public void close(Status status, Metadata trailers) { + closedWith = status.getCode(); + } @Override public boolean isCancelled() { diff --git a/src/adapter/inbound/grpc/src/test/java/dev/caskeleton/adapter/inbound/grpc/GrpcP1BoundaryWireTest.java b/src/adapter/inbound/grpc/src/test/java/dev/caskeleton/adapter/inbound/grpc/GrpcP1BoundaryWireTest.java index 100311e5..d2625bfa 100644 --- a/src/adapter/inbound/grpc/src/test/java/dev/caskeleton/adapter/inbound/grpc/GrpcP1BoundaryWireTest.java +++ b/src/adapter/inbound/grpc/src/test/java/dev/caskeleton/adapter/inbound/grpc/GrpcP1BoundaryWireTest.java @@ -29,10 +29,13 @@ import java.io.ByteArrayInputStream; import java.io.IOException; import java.io.InputStream; import java.nio.charset.StandardCharsets; +import java.security.Principal; +import java.util.Optional; import java.util.concurrent.CountDownLatch; import java.util.concurrent.TimeUnit; import java.util.concurrent.atomic.AtomicReference; import java.util.function.Consumer; +import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.Test; import org.springframework.boot.test.context.runner.ApplicationContextRunner; import org.springframework.context.annotation.Bean; @@ -42,6 +45,7 @@ class GrpcP1BoundaryWireTest { private static final String SERVICE_NAME = "test.p1.Feature"; private static final String AUTH_TOKEN = "Bearer p1-test-token"; + private static final String CALLER_NAME = "p1-test-caller"; private static final String INVALID_TOKEN_SENTINEL = "invalid-token-secret-sentinel"; private static final String HANDLER_SENTINEL = "handler-secret-sentinel"; private static final String LISTENER_SENTINEL = "listener-secret-sentinel"; @@ -110,6 +114,15 @@ class GrpcP1BoundaryWireTest { .isEqualTo("authorized-ok")); } + @Test + @DisplayName("인증 정책이 돌려준 호출자 식별자가 feature handler의 gRPC Context로 전달된다") + void theAuthenticatedCallerReachesTheFeatureHandlerThroughTheGrpcContext() { + withChannel( + channel -> + assertThat(unary(authenticated(channel), UNARY_METHOD, "whoami")) + .isEqualTo(CALLER_NAME)); + } + @Test void reflectionRemainsUnavailableWhenItsIndependentFlagIsFalse() { withChannel( @@ -309,7 +322,10 @@ class GrpcP1BoundaryWireTest { @Bean GrpcAuthenticationPolicy grpcAuthenticationPolicy() { - return metadata -> AUTH_TOKEN.equals(metadata.get(AUTHORIZATION)); + return metadata -> + AUTH_TOKEN.equals(metadata.get(AUTHORIZATION)) + ? Optional.of(() -> CALLER_NAME) + : Optional.empty(); } @Bean @@ -334,6 +350,14 @@ class GrpcP1BoundaryWireTest { .asRuntimeException()); return; } + if ("whoami".equals(request)) { + observer.onNext( + GrpcAuthenticatedCaller.current() + .map(Principal::getName) + .orElse("no-caller")); + observer.onCompleted(); + return; + } observer.onNext("authorized-" + request); observer.onCompleted(); })) diff --git a/src/adapter/outbound/fileserver/src/main/java/dev/caskeleton/adapter/outbound/fileserver/platform/autoconfigure/FileserverDownloadLifecycleConfiguration.java b/src/adapter/outbound/fileserver/src/main/java/dev/caskeleton/adapter/outbound/fileserver/platform/autoconfigure/FileserverDownloadLifecycleConfiguration.java index 378b5a74..ce902c65 100644 --- a/src/adapter/outbound/fileserver/src/main/java/dev/caskeleton/adapter/outbound/fileserver/platform/autoconfigure/FileserverDownloadLifecycleConfiguration.java +++ b/src/adapter/outbound/fileserver/src/main/java/dev/caskeleton/adapter/outbound/fileserver/platform/autoconfigure/FileserverDownloadLifecycleConfiguration.java @@ -1,6 +1,7 @@ package dev.caskeleton.adapter.outbound.fileserver.platform.autoconfigure; import dev.caskeleton.application.fileserver.api.metadata.FileMetadataStore; +import dev.caskeleton.application.fileserver.api.metadata.UploadSessionStore; import dev.caskeleton.application.fileserver.api.security.FileAccessPolicy; import dev.caskeleton.application.fileserver.api.security.OriginalFilenamePolicy; import dev.caskeleton.application.fileserver.cleanup.CleanupQueue; @@ -12,6 +13,7 @@ import dev.caskeleton.application.fileserver.lifecycle.CopyContentGateway; import dev.caskeleton.application.fileserver.lifecycle.DefaultFileLifecycleService; import dev.caskeleton.application.fileserver.lifecycle.FileLifecycleService; import dev.caskeleton.application.fileserver.observability.FileserverMetricsPort; +import dev.caskeleton.application.fileserver.recovery.StagingUploadLocator; import dev.caskeleton.application.fileserver.upload.UploadIdentifierFactory; import dev.caskeleton.application.transaction.TransactionPort; import java.time.Clock; @@ -48,6 +50,8 @@ class FileserverDownloadLifecycleConfiguration { FileAccessPolicy accessPolicy, OriginalFilenamePolicy filenamePolicy, CleanupQueue cleanupQueue, + UploadSessionStore sessionStore, + StagingUploadLocator stagingLocator, UploadIdentifierFactory identifierFactory, TransactionPort transactions, Clock clock) { @@ -57,6 +61,8 @@ class FileserverDownloadLifecycleConfiguration { accessPolicy, filenamePolicy, cleanupQueue, + sessionStore, + stagingLocator, identifierFactory, transactions, clock); diff --git a/src/adapter/outbound/fileserver/src/main/java/dev/caskeleton/adapter/outbound/fileserver/platform/autoconfigure/FileserverMaintenanceServiceConfiguration.java b/src/adapter/outbound/fileserver/src/main/java/dev/caskeleton/adapter/outbound/fileserver/platform/autoconfigure/FileserverMaintenanceServiceConfiguration.java index d9b7790f..2fa95b91 100644 --- a/src/adapter/outbound/fileserver/src/main/java/dev/caskeleton/adapter/outbound/fileserver/platform/autoconfigure/FileserverMaintenanceServiceConfiguration.java +++ b/src/adapter/outbound/fileserver/src/main/java/dev/caskeleton/adapter/outbound/fileserver/platform/autoconfigure/FileserverMaintenanceServiceConfiguration.java @@ -19,6 +19,8 @@ import dev.caskeleton.application.fileserver.recovery.DefaultFileReconciliationS import dev.caskeleton.application.fileserver.recovery.FileReconciliationService; import dev.caskeleton.application.fileserver.recovery.ReconciliationContentProbe; import dev.caskeleton.application.fileserver.recovery.RecoveryQueue; +import dev.caskeleton.application.fileserver.recovery.StagingUploadLocator; +import dev.caskeleton.application.fileserver.upload.QuotaCommitGateway; import dev.caskeleton.application.transaction.TransactionPort; import java.time.Clock; import org.springframework.beans.factory.ObjectProvider; @@ -58,12 +60,22 @@ class FileserverMaintenanceServiceConfiguration { @ConditionalOnMissingBean FileReconciliationService fileserverReconciliationService( FileMetadataStore metadataStore, + UploadSessionStore sessionStore, + StagingUploadLocator stagingLocator, ReconciliationContentProbe contentProbe, + QuotaCommitGateway quotaGateway, RecoveryQueue recoveryQueue, TransactionPort transactions, Clock clock) { return new DefaultFileReconciliationService( - metadataStore, contentProbe, recoveryQueue, transactions, clock); + metadataStore, + sessionStore, + stagingLocator, + contentProbe, + quotaGateway, + recoveryQueue, + transactions, + clock); } /** diff --git a/src/adapter/outbound/httpclient/src/main/java/dev/caskeleton/adapter/outbound/httpclient/dynamic/DefaultDynamicTargetGateway.java b/src/adapter/outbound/httpclient/src/main/java/dev/caskeleton/adapter/outbound/httpclient/dynamic/DefaultDynamicTargetGateway.java index 27c207bd..497e6d7d 100644 --- a/src/adapter/outbound/httpclient/src/main/java/dev/caskeleton/adapter/outbound/httpclient/dynamic/DefaultDynamicTargetGateway.java +++ b/src/adapter/outbound/httpclient/src/main/java/dev/caskeleton/adapter/outbound/httpclient/dynamic/DefaultDynamicTargetGateway.java @@ -29,10 +29,12 @@ import io.micrometer.core.instrument.Tag; import java.net.URI; import java.util.LinkedHashMap; import java.util.List; +import java.util.Locale; import java.util.Map; import java.util.NoSuchElementException; import java.util.Objects; import java.util.Optional; +import java.util.Set; import java.util.function.Function; /** @@ -155,17 +157,32 @@ public final class DefaultDynamicTargetGateway implements DynamicTargetGateway { hopOperation = hopOperation.withMethod(HttpMethod.GET).withBody(EmptyBody.instance()); } // Headers the caller chose for the first origin do not travel to an origin the upstream - // chose. The next loop iteration revalidates the new target from scratch. + // chose. Not a list of names known to carry credentials — a caller's X-Client-Key is one + // under any name — but an allowlist: only content-negotiation headers survive the hop. + // The next loop iteration revalidates the new target from scratch. if (follow.crossOrigin()) { - hopOperation = - hopOperation.withHeaders( - runtime.support().headerStripper().stripForCrossOrigin(hopOperation.headers())); + hopOperation = hopOperation.withHeaders(safeForCrossOrigin(hopOperation.headers())); } current = follow.target(); } } } + /** The caller headers that describe the content, not the caller; nothing else crosses origins. */ + private static final Set CROSS_ORIGIN_SAFE_HEADERS = + Set.of("accept", "accept-language", "content-type", "content-language"); + + private static Map> safeForCrossOrigin(Map> headers) { + Map> retained = new LinkedHashMap<>(); + headers.forEach( + (name, values) -> { + if (CROSS_ORIGIN_SAFE_HEADERS.contains(name.toLowerCase(Locale.ROOT))) { + retained.put(name, List.copyOf(values)); + } + }); + return Map.copyOf(retained); + } + private PinnedTarget validate( DynamicTargetPolicy policy, ValidatedDnsResolver resolver, URI target) { CanonicalTarget canonical = canonicalizer.canonicalize(policy, target); diff --git a/src/adapter/outbound/httpclient/src/test/java/dev/caskeleton/adapter/outbound/httpclient/dynamic/DefaultDynamicTargetGatewayTest.java b/src/adapter/outbound/httpclient/src/test/java/dev/caskeleton/adapter/outbound/httpclient/dynamic/DefaultDynamicTargetGatewayTest.java index 56740921..bacc92de 100644 --- a/src/adapter/outbound/httpclient/src/test/java/dev/caskeleton/adapter/outbound/httpclient/dynamic/DefaultDynamicTargetGatewayTest.java +++ b/src/adapter/outbound/httpclient/src/test/java/dev/caskeleton/adapter/outbound/httpclient/dynamic/DefaultDynamicTargetGatewayTest.java @@ -2,6 +2,7 @@ package dev.caskeleton.adapter.outbound.httpclient.dynamic; import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.catchThrowable; +import static org.assertj.core.api.Assertions.tuple; import dev.caskeleton.adapter.outbound.httpclient.api.HttpMethod; import dev.caskeleton.adapter.outbound.httpclient.api.OperationName; @@ -127,6 +128,33 @@ class DefaultDynamicTargetGatewayTest { .containsExactly(true, false); } + @Test + void crossOriginHopKeepsOnlySafeCallerHeaders() { + // given + transport.redirect(302, "https://b.example/next").json(200, USER); + HttpOperation get = + HttpOperation.get(new OperationName("fetch"), "/start", Map.of()) + .withHeaders( + Map.of( + "X-Client-Key", List.of("caller-secret"), + "Accept-Language", List.of("ko"))); + + // when + gateway(false) + .exchange( + POLICY, + URI.create("https://a.example/start"), + get, + ResponseType.of(UserResponse.class)); + + // then + assertThat(transport.sent()) + .extracting( + request -> request.hasHeader("X-Client-Key"), + request -> request.hasHeader("Accept-Language")) + .containsExactly(tuple(true, true), tuple(false, true)); + } + @Test void traceHeadersStayOffTheWireWhenThePolicyDisablesPropagation() { // given diff --git a/src/adapter/outbound/notification/src/main/java/dev/caskeleton/adapter/outbound/notification/platform/dispatch/RegistryProviderDispatchGateway.java b/src/adapter/outbound/notification/src/main/java/dev/caskeleton/adapter/outbound/notification/platform/dispatch/RegistryProviderDispatchGateway.java index 9249058d..532fca6a 100644 --- a/src/adapter/outbound/notification/src/main/java/dev/caskeleton/adapter/outbound/notification/platform/dispatch/RegistryProviderDispatchGateway.java +++ b/src/adapter/outbound/notification/src/main/java/dev/caskeleton/adapter/outbound/notification/platform/dispatch/RegistryProviderDispatchGateway.java @@ -1,6 +1,10 @@ package dev.caskeleton.adapter.outbound.notification.platform.dispatch; import dev.caskeleton.application.notification.platform.api.ProviderProfileId; +import dev.caskeleton.application.notification.platform.api.error.FailureCategory; +import dev.caskeleton.application.notification.platform.api.error.NotificationFailureCode; +import dev.caskeleton.application.notification.platform.api.error.NotificationFailureDescriptor; +import dev.caskeleton.application.notification.platform.api.error.ProviderUnavailableException; import dev.caskeleton.application.notification.platform.dispatch.ProviderDispatchGatewayPort; import dev.caskeleton.application.notification.platform.provider.ProviderProfileSnapshot; import dev.caskeleton.application.notification.platform.provider.ProviderRuntimeState; @@ -29,7 +33,17 @@ public final class RegistryProviderDispatchGateway implements ProviderDispatchGa @Override public ProviderProfileSnapshot profile(ProviderProfileId profileId) { - return runtimes.current(profileId).profile(); + // A route naming a profile no runtime serves is configuration drift, not a programming error: + // typed, so the dispatcher can put it on the retry policy instead of escaping with the lease. + return runtimes + .find(profileId) + .orElseThrow( + () -> + new ProviderUnavailableException( + NotificationFailureDescriptor.preDispatch( + NotificationFailureCode.PROVIDER_UNAVAILABLE, + FailureCategory.TRANSIENT_PROVIDER))) + .profile(); } @Override diff --git a/src/adapter/outbound/notification/src/main/java/dev/caskeleton/adapter/outbound/notification/platform/provider/http/JdkNotificationHttpGateway.java b/src/adapter/outbound/notification/src/main/java/dev/caskeleton/adapter/outbound/notification/platform/provider/http/JdkNotificationHttpGateway.java index 2cbe77ba..e6ee65fd 100644 --- a/src/adapter/outbound/notification/src/main/java/dev/caskeleton/adapter/outbound/notification/platform/provider/http/JdkNotificationHttpGateway.java +++ b/src/adapter/outbound/notification/src/main/java/dev/caskeleton/adapter/outbound/notification/platform/provider/http/JdkNotificationHttpGateway.java @@ -12,7 +12,11 @@ import java.util.List; import java.util.Map; import java.util.Objects; import java.util.Set; -import java.util.function.Supplier; +import java.util.concurrent.Executors; +import java.util.concurrent.ScheduledExecutorService; +import java.util.concurrent.ScheduledFuture; +import java.util.concurrent.TimeUnit; +import java.util.concurrent.atomic.AtomicBoolean; /** * Default gateway on the JDK HTTP client. @@ -72,14 +76,18 @@ public final class JdkNotificationHttpGateway implements NotificationHttpGateway } }); + // The request timeout covers the exchange up to the response headers and nothing after them, + // so the body read gets its own deadline: whatever is left of the same budget. + long deadlineNanos = System.nanoTime() + request.timeout().toNanos(); try { // Bounded, not ofByteArray(). A provider response is diagnostic — a status, some headers, an // error document — and reading it without a cap makes the sender's heap a function of what // the far end chooses to send. A chunked response with no end is a single-request outage. - HttpResponse> response = - client.send(builder.build(), boundedBody(MAX_RESPONSE_BYTES)); + HttpResponse response = + client.send(builder.build(), HttpResponse.BodyHandlers.ofInputStream()); + byte[] body = readBounded(response.body(), MAX_RESPONSE_BYTES, deadlineNanos); return new NotificationHttpResponse( - response.statusCode(), Map.copyOf(response.headers().map()), response.body().get()); + response.statusCode(), Map.copyOf(response.headers().map()), body); } catch (UncheckedIOException bodyFailure) { throw new NotificationHttpTransportException( "TRANSPORT_FAILURE", bodyWasLikelyCommitted(bodyFailure.getCause()), bodyFailure); @@ -133,31 +141,69 @@ public final class JdkNotificationHttpGateway implements NotificationHttpGateway */ public static final int MAX_RESPONSE_BYTES = 65_536; + /** Closes body streams whose deadline passed; a daemon, so it never holds the JVM open. */ + private static final ScheduledExecutorService BODY_DEADLINES = + Executors.newSingleThreadScheduledExecutor( + task -> { + Thread thread = new Thread(task, "notification-http-body-deadline"); + thread.setDaemon(true); + return thread; + }); + /** - * A body handler that stops reading at the cap. + * Reads the body up to the cap and no later than the deadline, on the caller's thread. * - *

Truncating rather than failing: the status code is the part that decides the outcome, and a - * provider that accepted the message and then wrote a large body should not turn into an - * ambiguous submission. - * - *

It reads from a stream and closes it at the cap, which cancels the subscription. Mapping + *

Truncating at the cap rather than failing: the status code is the part that decides the + * outcome, and a provider that accepted the message and then wrote a large body should not turn + * into an ambiguous submission. Closing the stream at the cap cancels the subscription. Mapping * {@code ofByteArray()} looked bounded but buffered the whole body before cutting it, so an * endless chunked response still held the thread and grew the heap until the far end stopped. + * + *

The deadline is the other half. A provider that trickles bytes and never reaches the cap + * held the dispatch thread for as long as it cared to — the request timeout had already been + * satisfied by the headers. At the deadline the stream is closed from outside, and the exchange + * is a response timeout: the body was sent, so the provider may well have the message. */ - private static HttpResponse.BodyHandler> boundedBody(int maxBytes) { - // A Supplier, so the blocking read runs on the caller's thread rather than the client's - // executor, as the JDK documents for mapping over an InputStream. - return responseInfo -> - HttpResponse.BodySubscribers.mapping( - HttpResponse.BodySubscribers.ofInputStream(), - stream -> - () -> { - try (InputStream body = stream) { - return body.readNBytes(maxBytes); - } catch (IOException failure) { - throw new UncheckedIOException(failure); - } - }); + private static byte[] readBounded(InputStream stream, int maxBytes, long deadlineNanos) + throws HttpTimeoutException { + AtomicBoolean expired = new AtomicBoolean(); + long remaining = Math.max(0L, deadlineNanos - System.nanoTime()); + ScheduledFuture watchdog = + BODY_DEADLINES.schedule( + () -> { + expired.set(true); + closeQuietly(stream); + }, + remaining, + TimeUnit.NANOSECONDS); + byte[] body; + try (InputStream closing = stream) { + body = closing.readNBytes(maxBytes); + } catch (IOException failure) { + if (expired.get()) { + throw bodyDeadlineExceeded(); + } + throw new UncheckedIOException(failure); + } finally { + watchdog.cancel(false); + } + // A stream closed from outside may end as a short read rather than an exception. + if (expired.get()) { + throw bodyDeadlineExceeded(); + } + return body; + } + + private static HttpTimeoutException bodyDeadlineExceeded() { + return new HttpTimeoutException("response body was not received before the request timeout"); + } + + private static void closeQuietly(InputStream stream) { + try { + stream.close(); + } catch (IOException ignored) { + // The reader sees the closed stream; there is nothing more to do here. + } } /** Header map helper for adapters. */ diff --git a/src/adapter/outbound/notification/src/test/java/dev/caskeleton/adapter/outbound/notification/platform/dispatch/RegistryProviderDispatchGatewayTest.java b/src/adapter/outbound/notification/src/test/java/dev/caskeleton/adapter/outbound/notification/platform/dispatch/RegistryProviderDispatchGatewayTest.java new file mode 100644 index 00000000..4eb95e11 --- /dev/null +++ b/src/adapter/outbound/notification/src/test/java/dev/caskeleton/adapter/outbound/notification/platform/dispatch/RegistryProviderDispatchGatewayTest.java @@ -0,0 +1,32 @@ +package dev.caskeleton.adapter.outbound.notification.platform.dispatch; + +import static org.assertj.core.api.Assertions.assertThat; +import static org.assertj.core.api.Assertions.catchThrowable; + +import dev.caskeleton.application.notification.platform.api.ProviderProfileId; +import dev.caskeleton.application.notification.platform.api.error.FailureCategory; +import dev.caskeleton.application.notification.platform.api.error.NotificationFailureCode; +import dev.caskeleton.application.notification.platform.api.error.ProviderUnavailableException; +import org.junit.jupiter.api.Test; + +class RegistryProviderDispatchGatewayTest { + + @Test + void aProfileNoRuntimeServesIsAProviderUnavailableFailure() { + // given + RegistryProviderDispatchGateway gateway = + new RegistryProviderDispatchGateway(new ProviderRuntimeRegistry()); + + // when + Throwable thrown = catchThrowable(() -> gateway.profile(new ProviderProfileId("gone"))); + + // then + assertThat(thrown) + .isInstanceOf(ProviderUnavailableException.class) + .extracting( + failure -> ((ProviderUnavailableException) failure).descriptor().code(), + failure -> ((ProviderUnavailableException) failure).descriptor().category()) + .containsExactly( + NotificationFailureCode.PROVIDER_UNAVAILABLE, FailureCategory.TRANSIENT_PROVIDER); + } +} diff --git a/src/adapter/outbound/notification/src/test/java/dev/caskeleton/adapter/outbound/notification/platform/provider/http/JdkNotificationHttpGatewaySecurityTest.java b/src/adapter/outbound/notification/src/test/java/dev/caskeleton/adapter/outbound/notification/platform/provider/http/JdkNotificationHttpGatewaySecurityTest.java index 4310e34b..69757081 100644 --- a/src/adapter/outbound/notification/src/test/java/dev/caskeleton/adapter/outbound/notification/platform/provider/http/JdkNotificationHttpGatewaySecurityTest.java +++ b/src/adapter/outbound/notification/src/test/java/dev/caskeleton/adapter/outbound/notification/platform/provider/http/JdkNotificationHttpGatewaySecurityTest.java @@ -2,6 +2,7 @@ package dev.caskeleton.adapter.outbound.notification.platform.provider.http; import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThatThrownBy; +import static org.assertj.core.api.Assertions.catchThrowable; import com.sun.net.httpserver.HttpServer; import java.io.IOException; @@ -80,4 +81,55 @@ class JdkNotificationHttpGatewaySecurityTest { server.stop(0); } } + + @Test + @Timeout(value = 15, threadMode = Timeout.ThreadMode.SEPARATE_THREAD) + @DisplayName("상한 아래에서 멈춘 응답 body는 요청 timeout에 끊겨 RESPONSE_TIMEOUT으로 끝난다") + void aResponseBodyThatStallsBelowTheCapEndsAtTheRequestTimeout() throws IOException { + // given + CountDownLatch release = new CountDownLatch(1); + HttpServer server = + HttpServer.create(new InetSocketAddress(InetAddress.getLoopbackAddress(), 0), 0); + server.createContext( + "/provider", + exchange -> { + exchange.sendResponseHeaders(200, 0); + OutputStream body = exchange.getResponseBody(); + body.write(new byte[16]); + body.flush(); + try { + // A trickle that never reaches the cap and never ends. + release.await(30, TimeUnit.SECONDS); + } catch (InterruptedException interrupted) { + Thread.currentThread().interrupt(); + } + exchange.close(); + }); + server.start(); + JdkNotificationHttpGateway gateway = + new JdkNotificationHttpGateway(Duration.ofSeconds(1), true); + NotificationHttpRequest request = + new NotificationHttpRequest( + "POST", + URI.create("http://127.0.0.1:" + server.getAddress().getPort() + "/provider"), + Map.of(), + new byte[] {1}, + Duration.ofSeconds(2)); + + try { + // when + Throwable thrown = catchThrowable(() -> gateway.exchange(request)); + + // then + assertThat(thrown) + .isInstanceOf(NotificationHttpTransportException.class) + .extracting( + failure -> ((NotificationHttpTransportException) failure).reasonCode(), + failure -> ((NotificationHttpTransportException) failure).requestBodyCommitted()) + .containsExactly("RESPONSE_TIMEOUT", true); + } finally { + release.countDown(); + server.stop(0); + } + } } diff --git a/src/adapter/outbound/objectstorage/src/main/java/dev/caskeleton/adapter/outbound/objectstorage/kernel/ObjectPublicationHandoffService.java b/src/adapter/outbound/objectstorage/src/main/java/dev/caskeleton/adapter/outbound/objectstorage/kernel/ObjectPublicationHandoffService.java index 925b2c7a..5dd840ae 100644 --- a/src/adapter/outbound/objectstorage/src/main/java/dev/caskeleton/adapter/outbound/objectstorage/kernel/ObjectPublicationHandoffService.java +++ b/src/adapter/outbound/objectstorage/src/main/java/dev/caskeleton/adapter/outbound/objectstorage/kernel/ObjectPublicationHandoffService.java @@ -114,7 +114,13 @@ public final class ObjectPublicationHandoffService implements ObjectPublicationH .stablePhase(); if (phase == PublicationOperationState.REFERENCE_PUBLISH_IN_PROGRESS || phase == PublicationOperationState.PUBLISHED) { - throw new IllegalStateException("published operation cannot authorize abort"); + // The publication finished first and wins. A typed refusal rather than an exception, so the + // caller can tell "already published" — an expected race outcome — from a broken store. + return new ObjectMutationReceipt( + authorization.operationKey(), + ObjectMutationOutcome.REJECTED, + ObjectOperationError.CONFLICT, + clock.instant()); } ObjectControlStore.StoredControlRecord stored = loadHandoff(state); ObjectPublicationHandoffRecord authorized = diff --git a/src/adapter/outbound/objectstorage/src/main/java/dev/caskeleton/adapter/outbound/objectstorage/s3/S3ProviderBinding.java b/src/adapter/outbound/objectstorage/src/main/java/dev/caskeleton/adapter/outbound/objectstorage/s3/S3ProviderBinding.java index 4ddcf5a4..54180830 100644 --- a/src/adapter/outbound/objectstorage/src/main/java/dev/caskeleton/adapter/outbound/objectstorage/s3/S3ProviderBinding.java +++ b/src/adapter/outbound/objectstorage/src/main/java/dev/caskeleton/adapter/outbound/objectstorage/s3/S3ProviderBinding.java @@ -196,6 +196,14 @@ public record S3ProviderBinding( throw invalid( "the exact MinIO release cannot claim native conditional managed mutation support"); } + // S3ManagedObjectProvider.retire is UNSUPPORTED. A profile that claimed the capability + // compiled a destination whose abort recorded ABORTED and then failed on every retire, + // leaving the bytes behind — refused here, before a destination can depend on it. + if (config.capabilities().contains(ObjectStorageProvider.Capability.CONDITIONAL_RETIREMENT)) { + throw invalid( + "the managed-single S3 provider does not implement retirement and cannot claim" + + " CONDITIONAL_RETIREMENT"); + } profiles.put(name, new ObjectStorageOperationProfile(name, config.capabilities(), evidence)); } return Map.copyOf(profiles); diff --git a/src/adapter/outbound/objectstorage/src/test/java/dev/caskeleton/adapter/outbound/objectstorage/kernel/StagedObjectPublicationLifecycleTest.java b/src/adapter/outbound/objectstorage/src/test/java/dev/caskeleton/adapter/outbound/objectstorage/kernel/StagedObjectPublicationLifecycleTest.java index 9b5a277a..d4405a9d 100644 --- a/src/adapter/outbound/objectstorage/src/test/java/dev/caskeleton/adapter/outbound/objectstorage/kernel/StagedObjectPublicationLifecycleTest.java +++ b/src/adapter/outbound/objectstorage/src/test/java/dev/caskeleton/adapter/outbound/objectstorage/kernel/StagedObjectPublicationLifecycleTest.java @@ -39,6 +39,7 @@ import dev.caskeleton.application.objectstorage.model.ObjectHandoffReceipt; import dev.caskeleton.application.objectstorage.model.ObjectMediaType; import dev.caskeleton.application.objectstorage.model.ObjectMutationOutcome; import dev.caskeleton.application.objectstorage.model.ObjectMutationReceipt; +import dev.caskeleton.application.objectstorage.model.ObjectOperationError; import dev.caskeleton.application.objectstorage.model.ObjectPublicationRequirement; import dev.caskeleton.application.objectstorage.model.ObjectPublishReceipt; import dev.caskeleton.application.objectstorage.model.ObjectReadRange; @@ -240,13 +241,13 @@ class StagedObjectPublicationLifecycleTest { handoffsAt(START).releaseClaim(release(POSTER, stage, claim)); // when - Throwable thrown = - catchThrowable(() -> handoffsAt(START).authorizeAbort(abortAuth(POSTER, stage, claim))); + ObjectMutationReceipt refused = + handoffsAt(START).authorizeAbort(abortAuth(POSTER, stage, claim)); // then - assertThat(thrown) - .isInstanceOf(IllegalStateException.class) - .hasMessage("published operation cannot authorize abort"); + assertThat(refused) + .extracting(ObjectMutationReceipt::outcome, ObjectMutationReceipt::error) + .containsExactly(ObjectMutationOutcome.REJECTED, ObjectOperationError.CONFLICT); } @Test diff --git a/src/adapter/outbound/objectstorage/src/test/java/dev/caskeleton/adapter/outbound/objectstorage/s3/S3ProviderBindingTest.java b/src/adapter/outbound/objectstorage/src/test/java/dev/caskeleton/adapter/outbound/objectstorage/s3/S3ProviderBindingTest.java index e26a6e06..40ef018d 100644 --- a/src/adapter/outbound/objectstorage/src/test/java/dev/caskeleton/adapter/outbound/objectstorage/s3/S3ProviderBindingTest.java +++ b/src/adapter/outbound/objectstorage/src/test/java/dev/caskeleton/adapter/outbound/objectstorage/s3/S3ProviderBindingTest.java @@ -2,6 +2,7 @@ package dev.caskeleton.adapter.outbound.objectstorage.s3; import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException; +import static org.assertj.core.api.Assertions.catchThrowable; import dev.caskeleton.adapter.outbound.objectstorage.config.ObjectStorageProviderSettings; import dev.caskeleton.adapter.outbound.objectstorage.provider.ObjectStorageProvider; @@ -231,6 +232,46 @@ class S3ProviderBindingTest { .requireSupportedProfile("managed-common")); } + @Test + void aProfileCannotClaimRetirementTheManagedS3ProviderDoesNotImplement() { + // given + S3ProviderCapabilityConfig existing = awsSettings().capabilityProfiles().get("managed-common"); + S3ProviderCapabilityConfig retirementClaim = + new S3ProviderCapabilityConfig( + existing.status(), + existing.source(), + existing.evidenceDigest(), + existing.observedAt(), + existing.validUntil(), + existing.providerAndDeploymentIdentity(), + Set.of( + ObjectStorageProvider.Capability.IMMUTABLE_CREATE, + ObjectStorageProvider.Capability.CONDITIONAL_RETIREMENT), + List.of("retirement claim")); + ObjectStorageProviderSettings claiming = + provider( + "aws-s3-general-purpose", + mutate( + awsSettings(), + null, + null, + null, + null, + null, + null, + null, + null, + Map.of("managed-common", retirementClaim))); + + // when + Throwable thrown = catchThrowable(() -> S3ProviderBinding.compile("aws", claiming, CLOCK)); + + // then + assertThat(thrown) + .isInstanceOf(IllegalArgumentException.class) + .hasMessageContaining("CONDITIONAL_RETIREMENT"); + } + static ObjectStorageProviderSettings provider(String type, S3ProviderSettings settings) { return new ObjectStorageProviderSettings( type, @@ -351,7 +392,6 @@ class S3ProviderBindingTest { ObjectStorageProvider.Capability.EXACT_INSPECT, ObjectStorageProvider.Capability.FULL_READ, ObjectStorageProvider.Capability.RANGE_READ, - ObjectStorageProvider.Capability.CONDITIONAL_RETIREMENT, ObjectStorageProvider.Capability.RESPONSE_LOSS_RESOLUTION), List.of("managed common subset only")); } diff --git a/src/adapter/outbound/objectstorage/src/test/java/dev/caskeleton/adapter/outbound/objectstorage/s3/S3ProviderCompositionTest.java b/src/adapter/outbound/objectstorage/src/test/java/dev/caskeleton/adapter/outbound/objectstorage/s3/S3ProviderCompositionTest.java index bf17b0ee..21e912cd 100644 --- a/src/adapter/outbound/objectstorage/src/test/java/dev/caskeleton/adapter/outbound/objectstorage/s3/S3ProviderCompositionTest.java +++ b/src/adapter/outbound/objectstorage/src/test/java/dev/caskeleton/adapter/outbound/objectstorage/s3/S3ProviderCompositionTest.java @@ -15,6 +15,7 @@ import dev.caskeleton.adapter.outbound.objectstorage.config.ObjectStorageDestina import dev.caskeleton.adapter.outbound.objectstorage.config.ObjectStorageProviderContribution; import dev.caskeleton.adapter.outbound.objectstorage.config.ObjectStorageProviderSettings; import dev.caskeleton.adapter.outbound.objectstorage.config.SelectedObjectStorageProviderFactory; +import dev.caskeleton.application.objectstorage.model.ObjectCapabilityRequirement; import dev.caskeleton.application.outbound.SecretSourcePort; import java.nio.file.Path; import java.time.Clock; @@ -208,7 +209,13 @@ class S3ProviderCompositionTest { null, null, null, - null, + // Everything the default asks for except retirement, which this provider does not + // implement and so cannot be asked of it. + Set.of( + ObjectCapabilityRequirement.IMMUTABLE_CREATE, + ObjectCapabilityRequirement.EXACT_VERSION_READ, + ObjectCapabilityRequirement.SHA_256_VERIFICATION, + ObjectCapabilityRequirement.RESPONSE_LOSS_RECONCILIATION), null, "managed-common")), null); diff --git a/src/adapter/outbound/persistence-jpa/src/main/java/dev/caskeleton/adapter/outbound/persistence/notification/platform/inbox/InboxItemEntity.java b/src/adapter/outbound/persistence-jpa/src/main/java/dev/caskeleton/adapter/outbound/persistence/notification/platform/inbox/InboxItemEntity.java index 07cab073..f437aaa2 100644 --- a/src/adapter/outbound/persistence-jpa/src/main/java/dev/caskeleton/adapter/outbound/persistence/notification/platform/inbox/InboxItemEntity.java +++ b/src/adapter/outbound/persistence-jpa/src/main/java/dev/caskeleton/adapter/outbound/persistence/notification/platform/inbox/InboxItemEntity.java @@ -138,9 +138,12 @@ public class InboxItemEntity { || "DELETED".equals(state); } - /** Archive; idempotent. */ + /** + * Archive; idempotent. Expired and deleted are terminal: archiving them would move the item back + * to a state the owner can still list, so both are left alone. + */ boolean archive(Instant at) { - if (archivedAt != null) { + if (archivedAt != null || "EXPIRED".equals(state) || "DELETED".equals(state)) { return false; } archivedAt = at; diff --git a/src/adapter/outbound/persistence-jpa/src/test/java/dev/caskeleton/adapter/outbound/persistence/notification/platform/inbox/InboxItemEntityTest.java b/src/adapter/outbound/persistence-jpa/src/test/java/dev/caskeleton/adapter/outbound/persistence/notification/platform/inbox/InboxItemEntityTest.java index 6f7dbe38..4a51b0a8 100644 --- a/src/adapter/outbound/persistence-jpa/src/test/java/dev/caskeleton/adapter/outbound/persistence/notification/platform/inbox/InboxItemEntityTest.java +++ b/src/adapter/outbound/persistence-jpa/src/test/java/dev/caskeleton/adapter/outbound/persistence/notification/platform/inbox/InboxItemEntityTest.java @@ -39,6 +39,20 @@ class InboxItemEntityTest { assertThat(List.of(changed, item.state())).containsExactly(false, state); } + @ParameterizedTest + @ValueSource(strings = {"EXPIRED", "DELETED"}) + void archiveLeavesAnExpiredOrDeletedItemInItsTerminalState(String state) { + // given + InboxItemEntity item = item(state); + + // when + boolean changed = item.archive(LATER); + + // then + assertThat(List.of(changed, item.state(), String.valueOf(item.archivedAt()))) + .containsExactly(false, state, "null"); + } + private static InboxItemEntity item(String state) { return new InboxItemEntity( UUID.randomUUID(), "tenant-a", "user-1", null, "transactional", "{}", state, CREATED, null); diff --git a/src/adapter/outbound/persistence-mongo/src/main/java/dev/caskeleton/adapter/outbound/mongo/imperative/DefaultMongoImperativeExecutor.java b/src/adapter/outbound/persistence-mongo/src/main/java/dev/caskeleton/adapter/outbound/mongo/imperative/DefaultMongoImperativeExecutor.java index c8f6f91f..9f667c05 100644 --- a/src/adapter/outbound/persistence-mongo/src/main/java/dev/caskeleton/adapter/outbound/mongo/imperative/DefaultMongoImperativeExecutor.java +++ b/src/adapter/outbound/persistence-mongo/src/main/java/dev/caskeleton/adapter/outbound/mongo/imperative/DefaultMongoImperativeExecutor.java @@ -82,7 +82,12 @@ public final class DefaultMongoImperativeExecutor implements MongoImperativeExec String physicalCollection = collections.require(context.collectionProfile()); MongoOperations operations = consistency.templateFor(context.consistency()); - ScopedAccess access = new ScopedAccess(physicalCollection, operations, context.timeout()); + ScopedAccess access = + new ScopedAccess( + physicalCollection, + operations, + context.timeout(), + consistency.writeConcernFor(context.consistency())); long startedAt = System.nanoTime(); try (MongoOperationObservation observation = observer.start(context, operationType)) { @@ -151,11 +156,22 @@ public final class DefaultMongoImperativeExecutor implements MongoImperativeExec private final java.time.Duration timeout; + private final com.mongodb.WriteConcern writeConcern; + private ScopedAccess( - String physicalCollection, MongoOperations operations, java.time.Duration timeout) { + String physicalCollection, + MongoOperations operations, + java.time.Duration timeout, + com.mongodb.WriteConcern writeConcern) { this.physicalCollection = physicalCollection; this.operations = operations; this.timeout = timeout; + this.writeConcern = writeConcern; + } + + @Override + public com.mongodb.WriteConcern writeConcern() { + return writeConcern; } @Override diff --git a/src/adapter/outbound/persistence-mongo/src/main/java/dev/caskeleton/adapter/outbound/mongo/imperative/MongoConsistencyBinder.java b/src/adapter/outbound/persistence-mongo/src/main/java/dev/caskeleton/adapter/outbound/mongo/imperative/MongoConsistencyBinder.java index a64d0ded..21005470 100644 --- a/src/adapter/outbound/persistence-mongo/src/main/java/dev/caskeleton/adapter/outbound/mongo/imperative/MongoConsistencyBinder.java +++ b/src/adapter/outbound/persistence-mongo/src/main/java/dev/caskeleton/adapter/outbound/mongo/imperative/MongoConsistencyBinder.java @@ -89,6 +89,11 @@ public final class MongoConsistencyBinder { return bound; } + /** The write concern a profile's template was bound to, for driver-level writes. */ + public WriteConcern writeConcernFor(MongoConsistencyProfile profile) { + return writeConcernOf(registry.require(profile)); + } + /** * Applies a profile's read settings to one query. * diff --git a/src/adapter/outbound/persistence-mongo/src/main/java/dev/caskeleton/adapter/outbound/mongo/imperative/MongoPlatformCollectionAccess.java b/src/adapter/outbound/persistence-mongo/src/main/java/dev/caskeleton/adapter/outbound/mongo/imperative/MongoPlatformCollectionAccess.java index be99d0e5..6691d4be 100644 --- a/src/adapter/outbound/persistence-mongo/src/main/java/dev/caskeleton/adapter/outbound/mongo/imperative/MongoPlatformCollectionAccess.java +++ b/src/adapter/outbound/persistence-mongo/src/main/java/dev/caskeleton/adapter/outbound/mongo/imperative/MongoPlatformCollectionAccess.java @@ -1,5 +1,6 @@ package dev.caskeleton.adapter.outbound.mongo.imperative; +import com.mongodb.WriteConcern; import java.time.Duration; import org.springframework.data.mongodb.core.MongoOperations; @@ -21,4 +22,13 @@ public interface MongoPlatformCollectionAccess extends MongoCollectionAccess { /** The same finite operation deadline platform executors must attach to raw driver work. */ Duration operationTimeout(); + + /** + * The operation's consistency-profile write concern, for raw driver work. + * + *

A collection taken from {@code rawOperations().getCollection(...)} carries the client's + * default write concern, not the one the profile's template was bound to: the template applies + * its own only to the writes it issues itself. Driver-level writes attach this one explicitly. + */ + WriteConcern writeConcern(); } diff --git a/src/adapter/outbound/persistence-mongo/src/main/java/dev/caskeleton/adapter/outbound/mongo/imperative/bulk/MongoBulkExecutor.java b/src/adapter/outbound/persistence-mongo/src/main/java/dev/caskeleton/adapter/outbound/mongo/imperative/bulk/MongoBulkExecutor.java index 098c64f6..19011dd8 100644 --- a/src/adapter/outbound/persistence-mongo/src/main/java/dev/caskeleton/adapter/outbound/mongo/imperative/bulk/MongoBulkExecutor.java +++ b/src/adapter/outbound/persistence-mongo/src/main/java/dev/caskeleton/adapter/outbound/mongo/imperative/bulk/MongoBulkExecutor.java @@ -89,7 +89,9 @@ public final class MongoBulkExecutor { access .rawOperations() .getCollection(access.collection()) - .withTimeout(access.operationTimeout().toMillis(), TimeUnit.MILLISECONDS); + .withTimeout(access.operationTimeout().toMillis(), TimeUnit.MILLISECONDS) + // The raw collection has the client's write concern, not the profile's. + .withWriteConcern(access.writeConcern()); List> writes = mappedWrites( plan, diff --git a/src/adapter/outbound/persistence-mongo/src/mongoIntegrationTest/java/dev/caskeleton/adapter/outbound/mongo/rs/MongoBulkMappingLaneTest.java b/src/adapter/outbound/persistence-mongo/src/mongoIntegrationTest/java/dev/caskeleton/adapter/outbound/mongo/rs/MongoBulkMappingLaneTest.java index a21306c9..42e3cbb0 100644 --- a/src/adapter/outbound/persistence-mongo/src/mongoIntegrationTest/java/dev/caskeleton/adapter/outbound/mongo/rs/MongoBulkMappingLaneTest.java +++ b/src/adapter/outbound/persistence-mongo/src/mongoIntegrationTest/java/dev/caskeleton/adapter/outbound/mongo/rs/MongoBulkMappingLaneTest.java @@ -2,8 +2,12 @@ package dev.caskeleton.adapter.outbound.mongo.rs; import static org.assertj.core.api.Assertions.assertThat; +import com.mongodb.ConnectionString; +import com.mongodb.MongoClientSettings; import com.mongodb.client.MongoClient; import com.mongodb.client.MongoClients; +import com.mongodb.event.CommandListener; +import com.mongodb.event.CommandStartedEvent; import dev.caskeleton.adapter.outbound.mongo.api.CollectionProfileName; import dev.caskeleton.adapter.outbound.mongo.api.MongoOperationContext; import dev.caskeleton.adapter.outbound.mongo.api.consistency.MongoConsistencyProfile; @@ -28,6 +32,10 @@ import dev.caskeleton.adapter.outbound.mongo.mapping.MongoCustomConversionsFacto import dev.caskeleton.adapter.outbound.mongo.testkit.rs.MongoSingleReplicaSetContainer; import java.math.BigInteger; import java.time.Duration; +import java.util.List; +import java.util.concurrent.CopyOnWriteArrayList; +import org.bson.BsonDocument; +import org.bson.BsonString; import org.bson.Document; import org.junit.jupiter.api.AfterAll; import org.junit.jupiter.api.BeforeAll; @@ -59,6 +67,9 @@ class MongoBulkMappingLaneTest { MongoConsistencyProfile.PRIMARY_MAJORITY, Duration.ofSeconds(10)); + /** Every command the client started, as the server received it. */ + private static final List SENT = new CopyOnWriteArrayList<>(); + private static MongoSingleReplicaSetContainer mongo; private static MongoClient client; @@ -74,7 +85,18 @@ class MongoBulkMappingLaneTest { static void start() { mongo = MongoSingleReplicaSetContainer.mongoEight(); mongo.start(); - client = MongoClients.create(mongo.connectionString()); + client = + MongoClients.create( + MongoClientSettings.builder() + .applyConnectionString(new ConnectionString(mongo.connectionString())) + .addCommandListener( + new CommandListener() { + @Override + public void commandStarted(CommandStartedEvent event) { + SENT.add(event.getCommand().clone()); + } + }) + .build()); template = templateWithTheManifestConversions(client); bulk = new MongoBulkExecutor( @@ -140,6 +162,28 @@ class MongoBulkMappingLaneTest { .isEqualTo(new Order(new DomainDocumentId("o-2"), "NEW", amount)); } + @Test + void aBulkWriteCarriesTheProfileWriteConcern() { + // given + template.getCollection("orders").insertOne(new Document("_id", "o-3").append("st", "NEW")); + MongoBulkWritePlan plan = + MongoBulkWritePlan.builder(MongoBulkMode.ORDERED) + .update(AtomicFilter.id("o-3"), AtomicUpdate.set("status", "PAID")) + .build(); + SENT.clear(); + + // when + bulk.execute(CONTEXT, Order.class, plan); + + // then + assertThat( + SENT.stream() + .filter(command -> command.containsKey("update")) + .map(command -> String.valueOf(command.get("writeConcern"))) + .toList()) + .containsExactly(new BsonDocument("w", new BsonString("majority")).toString()); + } + private static MongoTemplate templateWithTheManifestConversions(MongoClient client) { SimpleMongoClientDatabaseFactory factory = new SimpleMongoClientDatabaseFactory(client, "bulkmapping"); diff --git a/src/application-fileserver/src/main/java/dev/caskeleton/application/fileserver/lifecycle/DefaultFileLifecycleService.java b/src/application-fileserver/src/main/java/dev/caskeleton/application/fileserver/lifecycle/DefaultFileLifecycleService.java index 89b5c481..e0e9514c 100644 --- a/src/application-fileserver/src/main/java/dev/caskeleton/application/fileserver/lifecycle/DefaultFileLifecycleService.java +++ b/src/application-fileserver/src/main/java/dev/caskeleton/application/fileserver/lifecycle/DefaultFileLifecycleService.java @@ -3,6 +3,7 @@ package dev.caskeleton.application.fileserver.lifecycle; import dev.caskeleton.application.fileserver.api.FileId; import dev.caskeleton.application.fileserver.api.FileState; import dev.caskeleton.application.fileserver.api.StorageNamespace; +import dev.caskeleton.application.fileserver.api.UploadId; import dev.caskeleton.application.fileserver.api.content.StoredContent; import dev.caskeleton.application.fileserver.api.error.ConcurrentFileModificationException; import dev.caskeleton.application.fileserver.api.error.FileNotFoundException; @@ -13,6 +14,7 @@ import dev.caskeleton.application.fileserver.api.metadata.FileMetadataStore; import dev.caskeleton.application.fileserver.api.metadata.FileRecord; import dev.caskeleton.application.fileserver.api.metadata.FileRecordDraft; import dev.caskeleton.application.fileserver.api.metadata.FileRecordMutation; +import dev.caskeleton.application.fileserver.api.metadata.UploadSessionStore; import dev.caskeleton.application.fileserver.api.security.FileAccessPolicy; import dev.caskeleton.application.fileserver.api.security.FileOperation; import dev.caskeleton.application.fileserver.api.security.OriginalFilenamePolicy; @@ -20,6 +22,7 @@ import dev.caskeleton.application.fileserver.api.security.RequestContext; import dev.caskeleton.application.fileserver.api.security.SanitizedFilename; import dev.caskeleton.application.fileserver.cleanup.CleanupQueue; import dev.caskeleton.application.fileserver.cleanup.FileRetirement; +import dev.caskeleton.application.fileserver.recovery.StagingUploadLocator; import dev.caskeleton.application.fileserver.upload.FileView; import dev.caskeleton.application.fileserver.upload.UploadIdentifierFactory; import dev.caskeleton.application.transaction.TransactionPort; @@ -45,6 +48,8 @@ public final class DefaultFileLifecycleService implements FileLifecycleService { private final TransactionPort transactions; private final Clock clock; private final FileRetirement retirement; + private final UploadSessionStore sessionStore; + private final StagingUploadLocator stagingLocator; public DefaultFileLifecycleService( FileMetadataStore metadataStore, @@ -52,6 +57,8 @@ public final class DefaultFileLifecycleService implements FileLifecycleService { FileAccessPolicy accessPolicy, OriginalFilenamePolicy filenamePolicy, CleanupQueue cleanupQueue, + UploadSessionStore sessionStore, + StagingUploadLocator stagingLocator, UploadIdentifierFactory identifierFactory, TransactionPort transactions, Clock clock) { @@ -63,6 +70,8 @@ public final class DefaultFileLifecycleService implements FileLifecycleService { this.transactions = transactions; this.clock = clock; this.retirement = new FileRetirement(metadataStore, cleanupQueue); + this.sessionStore = sessionStore; + this.stagingLocator = stagingLocator; } @Override @@ -81,7 +90,28 @@ public final class DefaultFileLifecycleService implements FileLifecycleService { // One boundary for the whole decision: a record that reached DELETING without either its // terminal transition or a queued reclamation would be unreachable and never collected. return transactions.inWrite( - () -> new DeleteOutcome(fileId, retirement.retire(record, Optional.empty()))); + () -> { + Optional upload = unfinishedUpload(record); + // Same rule as cancel: the session ends in the commit that queues its staging bytes, so + // no writer can take a lease on bytes the cleanup is about to delete, and the expiry + // sweep — which skips a DELETED record — is not left as the only way to reclaim them. + upload.ifPresent(sessionStore::terminate); + return new DeleteOutcome(fileId, retirement.retire(record, upload)); + }); + } + + /** + * The upload whose staging bytes an unfinished record still owns. + * + *

Only a record the upload has not finished with — UPLOADING, UPLOADED or FAILED — can have + * staged bytes; a published record's bytes are its content key, which retirement already queues. + */ + private Optional unfinishedUpload(FileRecord record) { + FileState state = record.state(); + if (state != FileState.UPLOADING && state != FileState.UPLOADED && state != FileState.FAILED) { + return Optional.empty(); + } + return stagingLocator.locate(record.fileId()); } @Override diff --git a/src/application-fileserver/src/main/java/dev/caskeleton/application/fileserver/recovery/DefaultFileReconciliationService.java b/src/application-fileserver/src/main/java/dev/caskeleton/application/fileserver/recovery/DefaultFileReconciliationService.java index 5581897d..acacd7e9 100644 --- a/src/application-fileserver/src/main/java/dev/caskeleton/application/fileserver/recovery/DefaultFileReconciliationService.java +++ b/src/application-fileserver/src/main/java/dev/caskeleton/application/fileserver/recovery/DefaultFileReconciliationService.java @@ -8,6 +8,9 @@ import dev.caskeleton.application.fileserver.api.metadata.FileMetadataStore; import dev.caskeleton.application.fileserver.api.metadata.FileRecord; import dev.caskeleton.application.fileserver.api.metadata.FileRecordMutation; import dev.caskeleton.application.fileserver.api.metadata.FileRecoveryQuery; +import dev.caskeleton.application.fileserver.api.metadata.UploadSession; +import dev.caskeleton.application.fileserver.api.metadata.UploadSessionStore; +import dev.caskeleton.application.fileserver.upload.QuotaCommitGateway; import dev.caskeleton.application.transaction.TransactionPort; import java.time.Clock; import java.time.Duration; @@ -27,19 +30,28 @@ public final class DefaultFileReconciliationService implements FileReconciliatio private static final Duration STALE_AFTER = Duration.ofMinutes(5); private final FileMetadataStore metadataStore; + private final UploadSessionStore sessionStore; + private final StagingUploadLocator stagingLocator; private final ReconciliationContentProbe contentProbe; + private final QuotaCommitGateway quotaGateway; private final RecoveryQueue recoveryQueue; private final TransactionPort transactions; private final Clock clock; public DefaultFileReconciliationService( FileMetadataStore metadataStore, + UploadSessionStore sessionStore, + StagingUploadLocator stagingLocator, ReconciliationContentProbe contentProbe, + QuotaCommitGateway quotaGateway, RecoveryQueue recoveryQueue, TransactionPort transactions, Clock clock) { this.metadataStore = metadataStore; + this.sessionStore = sessionStore; + this.stagingLocator = stagingLocator; this.contentProbe = contentProbe; + this.quotaGateway = quotaGateway; this.recoveryQueue = recoveryQueue; this.transactions = transactions; this.clock = clock; @@ -139,19 +151,30 @@ public final class DefaultFileReconciliationService implements FileReconciliatio if (record.state() != FileState.VERIFYING) { return unresolved(record, "PUBLISH_STATE_UNEXPECTED"); } + // READY is where the finalize path converts the upload's reservation into durable usage. A + // restored READY that skipped it would hold bytes no quota counts, so without the upload whose + // reservation this is, the case is reported rather than restored half-way. + Optional session = + stagingLocator.locate(record.fileId()).flatMap(sessionStore::find); + if (session.isEmpty()) { + return unresolved(record, "PUBLISH_UPLOAD_SESSION_ABSENT"); + } + long size = record.actualSize().getAsLong(); FileRecord restored = transactions.inWrite( - () -> - metadataStore.transition( - record.fileId(), - record.version(), - FileState.VERIFYING, - FileState.READY, - FileRecordMutation.publishAt( - key, - record.actualSize().getAsLong(), - record.sha256().get(), - clock.instant()))); + () -> { + FileRecord ready = + metadataStore.transition( + record.fileId(), + record.version(), + FileState.VERIFYING, + FileState.READY, + FileRecordMutation.publishAt( + key, size, record.sha256().get(), clock.instant())); + // Same boundary as the READY transition, as on the finalize path. + quotaGateway.commit(session.get(), size); + return ready; + }); return ReconciliationResult.resolved( record.fileId(), ReconciliationStatus.CONFIRMED_SUCCESS, diff --git a/src/application-fileserver/src/main/java/dev/caskeleton/application/fileserver/upload/DefaultFinalizeUploadService.java b/src/application-fileserver/src/main/java/dev/caskeleton/application/fileserver/upload/DefaultFinalizeUploadService.java index 1d866bd1..8e4279fd 100644 --- a/src/application-fileserver/src/main/java/dev/caskeleton/application/fileserver/upload/DefaultFinalizeUploadService.java +++ b/src/application-fileserver/src/main/java/dev/caskeleton/application/fileserver/upload/DefaultFinalizeUploadService.java @@ -193,12 +193,23 @@ public final class DefaultFinalizeUploadService implements FinalizeUploadService return transactions.inWrite( () -> { FileRecord current = record; - if (current.state() == FileState.UPLOADING || current.state() == FileState.CREATED) { + if (current.state() == FileState.CREATED) { + // CREATED has one edge, to UPLOADING; the record takes it rather than a shortcut the + // transition table refuses. current = metadataStore.transition( current.fileId(), current.version(), - current.state(), + FileState.CREATED, + FileState.UPLOADING, + FileRecordMutation.none()); + } + if (current.state() == FileState.UPLOADING) { + current = + metadataStore.transition( + current.fileId(), + current.version(), + FileState.UPLOADING, FileState.UPLOADED, FileRecordMutation.uploaded(committedOffset, serverDigest)); } diff --git a/src/application-fileserver/src/test/java/dev/caskeleton/application/fileserver/lifecycle/FileLifecycleServiceTest.java b/src/application-fileserver/src/test/java/dev/caskeleton/application/fileserver/lifecycle/FileLifecycleServiceTest.java index 2e5238ac..58ea6e20 100644 --- a/src/application-fileserver/src/test/java/dev/caskeleton/application/fileserver/lifecycle/FileLifecycleServiceTest.java +++ b/src/application-fileserver/src/test/java/dev/caskeleton/application/fileserver/lifecycle/FileLifecycleServiceTest.java @@ -5,13 +5,17 @@ import static org.assertj.core.api.Assertions.assertThatThrownBy; import dev.caskeleton.application.fileserver.api.FileState; import dev.caskeleton.application.fileserver.api.StorageNamespace; +import dev.caskeleton.application.fileserver.api.UploadId; import dev.caskeleton.application.fileserver.api.error.ConcurrentFileModificationException; import dev.caskeleton.application.fileserver.api.error.FileAccessDeniedException; import dev.caskeleton.application.fileserver.api.error.FileNotReadyException; import dev.caskeleton.application.fileserver.api.error.StorageUnavailableException; import dev.caskeleton.application.fileserver.api.metadata.FileRecord; +import dev.caskeleton.application.fileserver.api.metadata.UploadSessionDraft; import dev.caskeleton.application.fileserver.api.security.FileOperation; import dev.caskeleton.application.fileserver.api.security.OriginalFilenamePolicy; +import dev.caskeleton.application.fileserver.api.transfer.UploadMode; +import dev.caskeleton.application.fileserver.cleanup.CleanupRequest; import dev.caskeleton.application.fileserver.cleanup.CleanupType; import dev.caskeleton.application.fileserver.testkit.DirectTransactions; import dev.caskeleton.application.fileserver.testkit.FakeCopyContentGateway; @@ -19,12 +23,16 @@ import dev.caskeleton.application.fileserver.testkit.FakeFileAccessPolicy; import dev.caskeleton.application.fileserver.testkit.FileserverFixtures; import dev.caskeleton.application.fileserver.testkit.InMemoryCleanupQueue; import dev.caskeleton.application.fileserver.testkit.InMemoryFileMetadataStore; +import dev.caskeleton.application.fileserver.testkit.InMemoryUploadSessionStore; import dev.caskeleton.application.fileserver.testkit.ReadyFileFixture; import dev.caskeleton.application.fileserver.testkit.SequentialUploadIdentifierFactory; import dev.caskeleton.application.fileserver.upload.FileView; import java.time.Clock; import java.time.ZoneOffset; +import java.util.List; import java.util.Optional; +import java.util.OptionalLong; +import java.util.UUID; import org.junit.jupiter.api.Test; class FileLifecycleServiceTest { @@ -36,6 +44,7 @@ class FileLifecycleServiceTest { private final FakeCopyContentGateway copyGateway = new FakeCopyContentGateway(); private final FakeFileAccessPolicy accessPolicy = new FakeFileAccessPolicy(); private final InMemoryCleanupQueue cleanup = new InMemoryCleanupQueue(); + private final InMemoryUploadSessionStore sessions = new InMemoryUploadSessionStore(); private final FileLifecycleService service = new DefaultFileLifecycleService( @@ -44,6 +53,8 @@ class FileLifecycleServiceTest { accessPolicy, OriginalFilenamePolicy.standard(), cleanup, + sessions, + sessions, new SequentialUploadIdentifierFactory(), new DirectTransactions(), Clock.fixed(FileserverFixtures.NOW, ZoneOffset.UTC)); @@ -77,6 +88,34 @@ class FileLifecycleServiceTest { assertThat(cleanup.queued()).isEmpty(); } + @Test + void deletingAnInProgressUploadEndsItsSessionAndSchedulesItsStagingForCleanup() { + // given + FileRecord uploading = ReadyFileFixture.uploading(metadata, SIZE, DIGEST); + UploadId uploadId = UploadId.of(UUID.randomUUID()); + sessions.create( + new UploadSessionDraft( + uploadId, + uploading.fileId(), + UploadMode.SINGLE_SHOT, + OptionalLong.of(SIZE), + FileserverFixtures.NOW.plusSeconds(3600))); + + // when + service.delete(uploading.fileId(), Optional.empty(), FileserverFixtures.context()); + + // then + assertThat( + List.of( + sessions.find(uploadId).orElseThrow().terminal(), + cleanup.queued().stream().map(item -> item.request()).toList())) + .containsExactly( + true, + List.of( + CleanupRequest.forStaging( + CleanupType.CANCELLED_STAGING, uploading.fileId(), uploadId))); + } + @Test void deletingAVerifyingFileIsAConflictRatherThanAnInventedTransition() { FileRecord verifying = ReadyFileFixture.verifying(metadata, SIZE, DIGEST); diff --git a/src/application-fileserver/src/test/java/dev/caskeleton/application/fileserver/recovery/FileReconciliationServiceTest.java b/src/application-fileserver/src/test/java/dev/caskeleton/application/fileserver/recovery/FileReconciliationServiceTest.java index 7fbb409c..b352eb9e 100644 --- a/src/application-fileserver/src/test/java/dev/caskeleton/application/fileserver/recovery/FileReconciliationServiceTest.java +++ b/src/application-fileserver/src/test/java/dev/caskeleton/application/fileserver/recovery/FileReconciliationServiceTest.java @@ -5,15 +5,23 @@ import static org.assertj.core.api.Assertions.assertThat; import dev.caskeleton.application.fileserver.api.ContentKey; import dev.caskeleton.application.fileserver.api.FileId; import dev.caskeleton.application.fileserver.api.FileState; +import dev.caskeleton.application.fileserver.api.UploadId; import dev.caskeleton.application.fileserver.api.metadata.FileRecord; import dev.caskeleton.application.fileserver.api.metadata.FileRecordMutation; +import dev.caskeleton.application.fileserver.api.metadata.UploadSessionDraft; +import dev.caskeleton.application.fileserver.api.transfer.UploadMode; import dev.caskeleton.application.fileserver.testkit.DirectTransactions; +import dev.caskeleton.application.fileserver.testkit.FakeQuotaCommitGateway; import dev.caskeleton.application.fileserver.testkit.FakeReconciliationContentProbe; import dev.caskeleton.application.fileserver.testkit.FileserverFixtures; import dev.caskeleton.application.fileserver.testkit.InMemoryFileMetadataStore; import dev.caskeleton.application.fileserver.testkit.InMemoryRecoveryQueue; +import dev.caskeleton.application.fileserver.testkit.InMemoryUploadSessionStore; import java.time.Clock; import java.time.ZoneOffset; +import java.util.List; +import java.util.Optional; +import java.util.OptionalLong; import java.util.UUID; import org.junit.jupiter.api.Test; @@ -24,11 +32,16 @@ class FileReconciliationServiceTest { private final InMemoryFileMetadataStore metadata = new InMemoryFileMetadataStore(); private final FakeReconciliationContentProbe probe = new FakeReconciliationContentProbe(); private final InMemoryRecoveryQueue recovery = new InMemoryRecoveryQueue(); + private final InMemoryUploadSessionStore sessions = new InMemoryUploadSessionStore(); + private final FakeQuotaCommitGateway quota = new FakeQuotaCommitGateway(); private final FileReconciliationService service = new DefaultFileReconciliationService( metadata, + sessions, + sessions, probe, + quota, recovery, new DirectTransactions(), Clock.fixed(FileserverFixtures.NOW, ZoneOffset.UTC)); @@ -43,6 +56,42 @@ class FileReconciliationServiceTest { assertThat(metadata.find(fileId).orElseThrow().state()).isEqualTo(FileState.READY); } + @Test + void restoringReadyCommitsThePublishedBytesToQuota() { + // given + FileId fileId = preparePhysicalObjectAndVerifyingMetadata(); + + // when + service.reconcile(fileId); + + // then + assertThat(quota.committedBytes()).isEqualTo(10); + } + + @Test + void aPublishWithoutItsUploadSessionIsUnresolvedRatherThanReadyWithoutQuota() { + // given + FileId fileId = preparePhysicalObjectAndVerifyingMetadata(); + FileReconciliationService withoutSessions = + new DefaultFileReconciliationService( + metadata, + sessions, + ignored -> Optional.empty(), + probe, + quota, + recovery, + new DirectTransactions(), + Clock.fixed(FileserverFixtures.NOW, ZoneOffset.UTC)); + + // when + ReconciliationResult result = withoutSessions.reconcile(fileId); + + // then + assertThat(List.of(result.status(), result.reasonCode(), metadata.find(fileId).get().state())) + .containsExactly( + ReconciliationStatus.UNRESOLVED, "PUBLISH_UPLOAD_SESSION_ABSENT", FileState.VERIFYING); + } + @Test void neverGuessesReadyWhenDigestCannotBeVerified() { FileId fileId = prepareUnknownPhysicalObject(); @@ -90,7 +139,10 @@ class FileReconciliationServiceTest { FileReconciliationService withoutObject = new DefaultFileReconciliationService( metadata, + sessions, + sessions, emptyProbe, + quota, recovery, new DirectTransactions(), Clock.fixed(FileserverFixtures.NOW, ZoneOffset.UTC)); @@ -219,6 +271,13 @@ class FileReconciliationServiceTest { private FileId verifyingWithContentKeyButNoObject() { FileId fileId = FileId.of(UUID.randomUUID()); FileRecord created = metadata.insert(FileserverFixtures.draft(fileId, 10)); + sessions.create( + new UploadSessionDraft( + UploadId.of(UUID.randomUUID()), + fileId, + UploadMode.SINGLE_SHOT, + OptionalLong.of(10), + FileserverFixtures.NOW.plusSeconds(3600))); FileRecord uploading = metadata.transition( created.fileId(), diff --git a/src/application-fileserver/src/test/java/dev/caskeleton/application/fileserver/testkit/InMemoryUploadSessionStore.java b/src/application-fileserver/src/test/java/dev/caskeleton/application/fileserver/testkit/InMemoryUploadSessionStore.java index 8258c706..a99fae38 100644 --- a/src/application-fileserver/src/test/java/dev/caskeleton/application/fileserver/testkit/InMemoryUploadSessionStore.java +++ b/src/application-fileserver/src/test/java/dev/caskeleton/application/fileserver/testkit/InMemoryUploadSessionStore.java @@ -1,5 +1,6 @@ package dev.caskeleton.application.fileserver.testkit; +import dev.caskeleton.application.fileserver.api.FileId; import dev.caskeleton.application.fileserver.api.UploadId; import dev.caskeleton.application.fileserver.api.error.ConcurrentFileModificationException; import dev.caskeleton.application.fileserver.api.error.FileserverErrorCode; @@ -8,6 +9,7 @@ import dev.caskeleton.application.fileserver.api.metadata.UploadSession; import dev.caskeleton.application.fileserver.api.metadata.UploadSessionDraft; import dev.caskeleton.application.fileserver.api.metadata.UploadSessionStore; import dev.caskeleton.application.fileserver.api.metadata.WriterLease; +import dev.caskeleton.application.fileserver.recovery.StagingUploadLocator; import java.time.Duration; import java.time.Instant; import java.util.ArrayList; @@ -23,8 +25,11 @@ import java.util.UUID; *

A lease is granted only when none is held or the held one expired, and an offset commit * requires the exact token plus the expected offset. A terminal session refuses all three, which is * what the {@code lifecycle_state = 'ACTIVE'} clause on the JPA statements does. + * + *

Also answers {@link StagingUploadLocator} from the same sessions, as the JPA locator reads the + * session table: the newest session recorded for a file. */ -public final class InMemoryUploadSessionStore implements UploadSessionStore { +public final class InMemoryUploadSessionStore implements UploadSessionStore, StagingUploadLocator { private final Map sessions = new LinkedHashMap<>(); private Instant now = FileserverFixtures.NOW; @@ -59,6 +64,17 @@ public final class InMemoryUploadSessionStore implements UploadSessionStore { return Optional.ofNullable(sessions.get(uploadId)); } + @Override + public Optional locate(FileId fileId) { + UploadId newest = null; + for (UploadSession session : sessions.values()) { + if (session.fileId().equals(fileId)) { + newest = session.uploadId(); + } + } + return Optional.ofNullable(newest); + } + @Override public WriterLease acquireLease( UploadId uploadId, diff --git a/src/application-fileserver/src/test/java/dev/caskeleton/application/fileserver/upload/FinalizeUploadServiceTest.java b/src/application-fileserver/src/test/java/dev/caskeleton/application/fileserver/upload/FinalizeUploadServiceTest.java index 63e83b48..56294cc9 100644 --- a/src/application-fileserver/src/test/java/dev/caskeleton/application/fileserver/upload/FinalizeUploadServiceTest.java +++ b/src/application-fileserver/src/test/java/dev/caskeleton/application/fileserver/upload/FinalizeUploadServiceTest.java @@ -307,6 +307,24 @@ class FinalizeUploadServiceTest { assertThat(quota.anyCommitted()).isFalse(); } + @Test + void aRecordStillCreatedIsWalkedThroughUploadingToReady() { + // given + FileId fileId = FileId.of(UUID.randomUUID()); + metadata.insert(FileserverFixtures.draft(fileId, 10)); + UploadSession session = FileserverFixtures.session(fileId, 10, 10); + + // when + FileView result = + service.finalizeUpload( + session, + FinalizeUploadRequest.synchronousWithoutDigest(), + FileserverFixtures.context()); + + // then + assertThat(result.state()).isEqualTo(FileState.READY); + } + private UploadSession uploadedSession(long length) { return uploadedSession(length, length); } diff --git a/src/application-notification/src/main/java/dev/caskeleton/application/notification/platform/dispatch/NotificationDispatchService.java b/src/application-notification/src/main/java/dev/caskeleton/application/notification/platform/dispatch/NotificationDispatchService.java index 6b66c818..b19651f0 100644 --- a/src/application-notification/src/main/java/dev/caskeleton/application/notification/platform/dispatch/NotificationDispatchService.java +++ b/src/application-notification/src/main/java/dev/caskeleton/application/notification/platform/dispatch/NotificationDispatchService.java @@ -1,11 +1,13 @@ package dev.caskeleton.application.notification.platform.dispatch; import dev.caskeleton.application.notification.platform.api.NotificationVariable; +import dev.caskeleton.application.notification.platform.api.delivery.AttemptConfirmation; import dev.caskeleton.application.notification.platform.api.delivery.RecipientDeliveryState; import dev.caskeleton.application.notification.platform.api.delivery.SubmissionOutcome; import dev.caskeleton.application.notification.platform.api.error.FailureCategory; import dev.caskeleton.application.notification.platform.api.error.NotificationException; import dev.caskeleton.application.notification.platform.api.error.NotificationFailureCode; +import dev.caskeleton.application.notification.platform.api.error.ProviderUnavailableException; import dev.caskeleton.application.notification.platform.policy.NotificationRetryPolicy; import dev.caskeleton.application.notification.platform.policy.RetryBudget; import dev.caskeleton.application.notification.platform.policy.RetryContext; @@ -17,6 +19,7 @@ import dev.caskeleton.application.notification.platform.policy.RoutingDecisionEn import dev.caskeleton.application.notification.platform.provider.ProviderExecutionEvidence; import dev.caskeleton.application.notification.platform.provider.ProviderFailure; import dev.caskeleton.application.notification.platform.provider.ProviderProfileSnapshot; +import dev.caskeleton.application.notification.platform.provider.ProviderRuntimeState; import dev.caskeleton.application.notification.platform.provider.ProviderSubmission; import dev.caskeleton.application.notification.platform.provider.ProviderSubmissionResult; import dev.caskeleton.application.notification.platform.provider.TraceContext; @@ -121,7 +124,7 @@ public final class NotificationDispatchService { RoutingDecision decision = routing.next(routingContext(work, now)); if (decision.selected().isEmpty()) { - applyRoutingStop(work, decision); + applyRoutingStop(work, decision, lease); releaseLease(lease); return; } @@ -136,10 +139,12 @@ public final class NotificationDispatchService { route, now); if (guard instanceof DispatchGuardOutcome.Blocked blocked) { + // Fenced like every other write this worker makes: a lease that expired while the guard ran + // belongs to another worker now, and an unfenced write would overwrite its state. transactions.inWrite( () -> - recipients.transition( - work.recipient().id(), blocked.state(), blocked.nextDispatchAt())); + recipients.transitionHeldBy( + work.recipient().id(), blocked.state(), blocked.nextDispatchAt(), lease)); refreshStatus(work); releaseLease(lease); return; @@ -151,6 +156,13 @@ public final class NotificationDispatchService { try { content = render(work, route); profile = gateway.profile(route.providerProfileId()); + } catch (ProviderUnavailableException profileUnavailable) { + // The route names a profile no runtime serves — configuration drift that a deploy may well + // correct. It gets the ordinary retry policy rather than an immediate FAILED, and rather + // than the old escape that left the lease held and requeued the job with no bound at all. + retryBeforeAttempt(work, lease, now); + releaseLease(lease); + return; } catch (NotificationException preDispatch) { if (preDispatch.descriptor().retryable()) { throw preDispatch; @@ -201,37 +213,107 @@ public final class NotificationDispatchService { private void failBeforeAttempt( Work work, RecipientLease lease, FailureCategory category, Instant now) { RecipientDeliveryRecord recipient = work.recipient(); - RecipientDeliveryRecord failed = - new RecipientDeliveryRecord( - recipient.id(), - recipient.notificationId(), - recipient.tenantId(), - recipient.recipientRef(), - recipient.locale(), - recipient.timeZone(), - recipient.routingPlan(), - recipient.routeCursor(), + saveBeforeAttempt( + work, + lease, + beforeAttempt( + recipient, RecipientDeliveryState.FAILED, - recipient.submissionOutcome(), - recipient.deliveryOutcome(), - recipient.evidenceLevel(), - recipient.ambiguousAttemptExists(), - recipient.duplicateRisk(), Optional.empty(), - recipient.expiresAt(), - recipient.leaseOwner(), - recipient.leaseUntil(), recipient.attemptCount(), - Optional.of(category.name()), - recipient.createdAt(), - now); + category, + now)); + } + + /** + * Schedules another pass for a delivery that failed before any attempt row, or closes it. + * + *

No attempt was made, so the attempt table cannot count these passes; the recipient's attempt + * count does, and the budget is read from it the same way the post-attempt path reads it from the + * attempt number. The provider state is taken as degraded — a runtime that is not there now but + * may be registered again — so the decision rests on the backoff, the budget and the expiry. + */ + private void retryBeforeAttempt(Work work, RecipientLease lease, Instant now) { + RecipientDeliveryRecord recipient = work.recipient(); + int attemptNumber = recipient.attemptCount() + 1; + RetryDecision decision = + retryPolicy.decide( + new RetryContext( + FailureCategory.TRANSIENT_PROVIDER, + AttemptConfirmation.REJECTED, + SubmissionOutcome.NOT_SUBMITTED, + ProviderExecutionEvidence.notStarted(), + false, + false, + true, + false, + recipient.ambiguousAttemptExists(), + work.request().expiresAt(), + Optional.empty(), + attemptNumber, + new RetryBudget(maxAdditionalAttempts, recipient.attemptCount()), + ProviderRuntimeState.DEGRADED, + estimatedDispatchDuration, + now)); + RecipientDeliveryRecord next = + decision instanceof RetryDecision.RetryAfter retry + ? beforeAttempt( + recipient, + RecipientDeliveryState.RETRY_WAITING, + Optional.of(now.plus(retry.delay())), + attemptNumber, + FailureCategory.TRANSIENT_PROVIDER, + now) + : beforeAttempt( + recipient, + RecipientDeliveryState.FAILED, + Optional.empty(), + attemptNumber, + FailureCategory.TRANSIENT_PROVIDER, + now); + saveBeforeAttempt(work, lease, next); + } + + private void saveBeforeAttempt(Work work, RecipientLease lease, RecipientDeliveryRecord updated) { transactions.inWrite( () -> { - recipients.saveHeldBy(failed, lease); + recipients.saveHeldBy(updated, lease); refreshStatus(work); }); } + private static RecipientDeliveryRecord beforeAttempt( + RecipientDeliveryRecord recipient, + RecipientDeliveryState state, + Optional nextDispatchAt, + int attemptCount, + FailureCategory category, + Instant now) { + return new RecipientDeliveryRecord( + recipient.id(), + recipient.notificationId(), + recipient.tenantId(), + recipient.recipientRef(), + recipient.locale(), + recipient.timeZone(), + recipient.routingPlan(), + recipient.routeCursor(), + state, + recipient.submissionOutcome(), + recipient.deliveryOutcome(), + recipient.evidenceLevel(), + recipient.ambiguousAttemptExists(), + recipient.duplicateRisk(), + nextDispatchAt, + recipient.expiresAt(), + recipient.leaseOwner(), + recipient.leaseUntil(), + attemptCount, + Optional.of(category.name()), + recipient.createdAt(), + now); + } + /** * Recomputes and stores the request status. * @@ -472,14 +554,14 @@ public final class NotificationDispatchService { clock.instant()); } - private void applyRoutingStop(Work work, RoutingDecision decision) { + private void applyRoutingStop(Work work, RoutingDecision decision, RecipientLease lease) { RecipientDeliveryState state = decision.reconciliationRequired() ? RecipientDeliveryState.RECONCILIATION_REQUIRED : terminalStateFor(work); transactions.inWrite( () -> { - recipients.transition(work.recipient().id(), state, Optional.empty()); + recipients.transitionHeldBy(work.recipient().id(), state, Optional.empty(), lease); refreshStatus(work); }); } diff --git a/src/application-notification/src/main/java/dev/caskeleton/application/notification/platform/dispatch/ProviderDispatchGatewayPort.java b/src/application-notification/src/main/java/dev/caskeleton/application/notification/platform/dispatch/ProviderDispatchGatewayPort.java index 0ee57f45..4d91ebdc 100644 --- a/src/application-notification/src/main/java/dev/caskeleton/application/notification/platform/dispatch/ProviderDispatchGatewayPort.java +++ b/src/application-notification/src/main/java/dev/caskeleton/application/notification/platform/dispatch/ProviderDispatchGatewayPort.java @@ -15,7 +15,12 @@ import dev.caskeleton.application.notification.platform.provider.ProviderSubmiss */ public interface ProviderDispatchGatewayPort { - /** Current profile snapshot including credential generation. */ + /** + * Current profile snapshot including credential generation. + * + * @throws dev.caskeleton.application.notification.platform.api.error.ProviderUnavailableException + * when no runtime serves the profile, so the dispatcher can retry it on the ordinary policy + */ ProviderProfileSnapshot profile(ProviderProfileId profileId); /** Current health of a provider runtime. */ diff --git a/src/application-notification/src/test/java/dev/caskeleton/application/notification/platform/dispatch/NotificationDispatchServiceTest.java b/src/application-notification/src/test/java/dev/caskeleton/application/notification/platform/dispatch/NotificationDispatchServiceTest.java index e8b47370..c2f5e739 100644 --- a/src/application-notification/src/test/java/dev/caskeleton/application/notification/platform/dispatch/NotificationDispatchServiceTest.java +++ b/src/application-notification/src/test/java/dev/caskeleton/application/notification/platform/dispatch/NotificationDispatchServiceTest.java @@ -17,11 +17,15 @@ import dev.caskeleton.application.notification.platform.api.delivery.SubmissionO import dev.caskeleton.application.notification.platform.api.error.FailureCategory; import dev.caskeleton.application.notification.platform.api.error.NotificationFailureCode; import dev.caskeleton.application.notification.platform.api.error.NotificationFailureDescriptor; +import dev.caskeleton.application.notification.platform.api.error.ProviderUnavailableException; import dev.caskeleton.application.notification.platform.api.error.TemplateVariableValidationException; import dev.caskeleton.application.notification.platform.api.routing.Channel; import dev.caskeleton.application.notification.platform.contact.ContactPointStatus; import dev.caskeleton.application.notification.platform.contact.ContactPointType; +import dev.caskeleton.application.notification.platform.policy.DefaultNotificationRetryPolicy; +import dev.caskeleton.application.notification.platform.policy.JitterSource; import dev.caskeleton.application.notification.platform.policy.NotificationEligibilityPolicy; +import dev.caskeleton.application.notification.platform.policy.RetryBackoff; import dev.caskeleton.application.notification.platform.policy.RetryDecision; import dev.caskeleton.application.notification.platform.policy.RoutingDecisionEngine; import dev.caskeleton.application.notification.platform.provider.ProviderCapabilities; @@ -226,6 +230,125 @@ class NotificationDispatchServiceTest { assertThat(scenario.stored().nextDispatchAt()).contains(notBefore); } + @Test + @DisplayName("provider profile 이 사라진 route 는 일반 재시도 backoff 뒤에 다시 꺼낸다") + void aRouteWhoseProviderProfileIsGoneWaitsForTheRetryBackoff() { + // given + Scenario scenario = new Scenario(PlatformFakes.plan("profile-gone", Map.of())); + RecordingLeases leases = new RecordingLeases(); + NotificationDispatchService service = + scenario.service(leases, channel -> renderer(), new ProfileGoneGateway(), 3); + + // when + service.dispatch(scenario.lease()); + + // then + assertThat(scenario.stored()) + .extracting( + RecipientDeliveryRecord::state, + RecipientDeliveryRecord::nextDispatchAt, + RecipientDeliveryRecord::attemptCount, + RecipientDeliveryRecord::lastFailureCategory) + .containsExactly( + RecipientDeliveryState.RETRY_WAITING, + Optional.of(NOW.plusSeconds(1)), + 1, + Optional.of("TRANSIENT_PROVIDER")); + } + + @Test + @DisplayName("provider profile 이 사라진 route 는 재시도 한도를 다 쓰면 FAILED 로 닫힌다") + void aRouteWhoseProviderProfileIsGoneFailsOnceTheRetryBudgetIsSpent() { + // given + Scenario scenario = new Scenario(PlatformFakes.plan("profile-gone-budget", Map.of())); + RecordingLeases leases = new RecordingLeases(); + NotificationDispatchService service = + scenario.service(leases, channel -> renderer(), new ProfileGoneGateway(), 0); + + // when + service.dispatch(scenario.lease()); + + // then + assertThat(List.of(scenario.stored().state(), leases.released)) + .containsExactly(RecipientDeliveryState.FAILED, List.of(scenario.lease())); + } + + @Test + void aGuardBlockWrittenAfterTheLeaseWasLostChangesNothing() { + // given + NotificationPlan base = PlatformFakes.plan("blocked-lease-lost", Map.of()); + Scenario scenario = + new Scenario( + new NotificationPlan( + base.tenantId(), + base.idempotencyKey(), + base.category(), + base.template(), + base.variables(), + base.recipients(), + base.deliveryStrategy(), + Optional.of(NOW.plusSeconds(3600)), + base.expiresAt(), + base.deduplication(), + base.collapse(), + base.correlationId(), + base.boundedMetadata())); + scenario.recipients.transition( + scenario.recipient.id(), RecipientDeliveryState.READY_TO_DISPATCH, Optional.of(NOW)); + RecipientDeliveryRecord beforeDispatch = scenario.stored(); + scenario.recipients.supersededLeases.add(scenario.lease()); + NotificationDispatchService service = + scenario.service(new RecordingLeases(), channel -> renderer()); + + // when + service.dispatch(scenario.lease()); + + // then + assertThat(scenario.stored()).isEqualTo(beforeDispatch); + } + + @Test + void aRoutingStopWrittenAfterTheLeaseWasLostChangesNothing() { + // given + Scenario scenario = new Scenario(PlatformFakes.plan("stop-lease-lost", Map.of())); + RecipientDeliveryRecord r = scenario.stored(); + // A non-retryable last failure makes the routing engine stop without selecting a route. + RecipientDeliveryRecord beforeDispatch = + scenario.recipients.save( + new RecipientDeliveryRecord( + r.id(), + r.notificationId(), + r.tenantId(), + r.recipientRef(), + r.locale(), + r.timeZone(), + r.routingPlan(), + r.routeCursor(), + RecipientDeliveryState.READY_TO_DISPATCH, + r.submissionOutcome(), + r.deliveryOutcome(), + r.evidenceLevel(), + r.ambiguousAttemptExists(), + r.duplicateRisk(), + Optional.of(NOW), + r.expiresAt(), + r.leaseOwner(), + r.leaseUntil(), + r.attemptCount(), + Optional.of("TEMPLATE_FAILURE"), + r.createdAt(), + r.updatedAt())); + scenario.recipients.supersededLeases.add(scenario.lease()); + NotificationDispatchService service = + scenario.service(new RecordingLeases(), channel -> renderer()); + + // when + service.dispatch(scenario.lease()); + + // then + assertThat(scenario.stored()).isEqualTo(beforeDispatch); + } + /** One accepted request and its recipient, dispatched against fakes. */ private static final class Scenario { private final PlatformFakes.RequestStore requests = new PlatformFakes.RequestStore(); @@ -262,6 +385,34 @@ class NotificationDispatchServiceTest { return new RecipientLease(recipient.id(), "worker-a", 1L, NOW.plusSeconds(30)); } + /** Dispatches through the real retry policy with no jitter, so the backoff is exact. */ + private NotificationDispatchService service( + RecipientLeaseStorePort leases, + TemplateRendererRegistry renderers, + ProviderDispatchGatewayPort gateway, + int maxAdditionalAttempts) { + return new NotificationDispatchService( + requests, + recipients, + attempts, + new DispatchPipeline( + new SingleContactStore(contactPoint()), + NotificationEligibilityPolicy.permitAll(), + new PlatformFakes.RecordingMetrics()), + new RoutingDecisionEngine(), + new DefaultNotificationRetryPolicy( + RetryBackoff.DEFAULT, JitterSource.none(), Duration.ofMinutes(1)), + new DeliveryAttemptFactory(new PlatformFakes.SequentialIds()), + NotificationPlatformNoops.outcomeRecorder(attempts, recipients), + gateway, + renderers, + leases, + new PlatformFakes.RecordingTransactions(), + Clock.fixed(NOW, ZoneOffset.UTC), + maxAdditionalAttempts, + Duration.ofSeconds(5)); + } + private NotificationDispatchService service( RecipientLeaseStorePort leases, TemplateRendererRegistry renderers) { return new NotificationDispatchService( @@ -388,6 +539,27 @@ class NotificationDispatchServiceTest { } } + /** A gateway whose route names a profile no runtime serves any more. */ + private static final class ProfileGoneGateway implements ProviderDispatchGatewayPort { + + @Override + public ProviderProfileSnapshot profile(ProviderProfileId profileId) { + throw new ProviderUnavailableException( + NotificationFailureDescriptor.preDispatch( + NotificationFailureCode.PROVIDER_UNAVAILABLE, FailureCategory.TRANSIENT_PROVIDER)); + } + + @Override + public ProviderRuntimeState state(ProviderProfileId profileId) { + throw new AssertionError("no runtime state exists for a profile that is gone"); + } + + @Override + public ProviderSubmissionResult submit(ProviderSubmission submission) { + throw new AssertionError("nothing may be submitted through a profile that is gone"); + } + } + private static final class EmptyContactStore implements ContactPointStorePort { @Override public Optional find(TenantId tenantId, ContactPointId id) { diff --git a/src/config/architecture/modules.json b/src/config/architecture/modules.json index 2d7929a8..ee3198e9 100644 --- a/src/config/architecture/modules.json +++ b/src/config/architecture/modules.json @@ -548,34 +548,10 @@ ] }, { - "id": "grpc-admin", - "gradle_path": ":grpc:grpc-admin", - "source_path": "src/grpc/grpc-admin", - "allowed_dependencies": [ - "grpc-core-api", - "grpc-server", - "grpc-policy" - ], - "build": "optional-grpc" - }, - { - "id": "grpc-client", - "gradle_path": ":grpc:grpc-client", - "source_path": "src/grpc/grpc-client", - "allowed_dependencies": [ - "grpc-core-api", - "grpc-policy" - ], - "build": "optional-grpc" - }, - { - "id": "grpc-codegen", - "gradle_path": ":grpc:grpc-codegen", - "source_path": "src/grpc/grpc-codegen", - "allowed_dependencies": [ - "grpc-core-api", - "grpc-proto-contract" - ], + "id": "grpc-contract", + "gradle_path": ":grpc:grpc-contract", + "source_path": "src/grpc/grpc-contract", + "allowed_dependencies": [], "build": "optional-grpc" }, { @@ -585,17 +561,6 @@ "allowed_dependencies": [], "build": "optional-grpc" }, - { - "id": "grpc-discovery", - "gradle_path": ":grpc:grpc-discovery", - "source_path": "src/grpc/grpc-discovery", - "allowed_dependencies": [ - "grpc-core-api", - "grpc-client", - "grpc-policy" - ], - "build": "optional-grpc" - }, { "id": "grpc-observability", "gradle_path": ":grpc:grpc-observability", @@ -615,47 +580,22 @@ "build": "optional-grpc" }, { - "id": "grpc-policy", - "gradle_path": ":grpc:grpc-policy", - "source_path": "src/grpc/grpc-policy", + "id": "grpc-runtime", + "gradle_path": ":grpc:grpc-runtime", + "source_path": "src/grpc/grpc-runtime", "allowed_dependencies": [ "grpc-core-api" ], "build": "optional-grpc" }, - { - "id": "grpc-proto-contract", - "gradle_path": ":grpc:grpc-proto-contract", - "source_path": "src/grpc/grpc-proto-contract", - "allowed_dependencies": [ - "grpc-core-api" - ], - "build": "optional-grpc" - }, - { - "id": "grpc-server", - "gradle_path": ":grpc:grpc-server", - "source_path": "src/grpc/grpc-server", - "allowed_dependencies": [ - "grpc-core-api", - "grpc-policy" - ], - "build": "optional-grpc" - }, { "id": "grpc-spring-boot-starter", "gradle_path": ":grpc:grpc-spring-boot-starter", "source_path": "src/grpc/grpc-spring-boot-starter", "allowed_dependencies": [ "grpc-core-api", - "grpc-policy", - "grpc-server", - "grpc-client", - "grpc-discovery", - "grpc-admin", - "grpc-observability", - "grpc-proto-contract", - "grpc-codegen" + "grpc-runtime", + "grpc-observability" ], "build": "optional-grpc" }, @@ -665,24 +605,19 @@ "source_path": "src/grpc/grpc-testkit", "allowed_dependencies": [ "grpc-core-api", - "grpc-policy", - "grpc-server", - "grpc-client", - "grpc-discovery", - "grpc-admin", + "grpc-runtime", "grpc-observability", - "grpc-proto-contract", - "grpc-codegen", "grpc-operation-ledger-jpa" ], "build": "optional-grpc" }, { - "id": "grpc-advanced-bootstrap", - "gradle_path": ":grpc-advanced:grpc-advanced-bootstrap", - "source_path": "src/grpc-advanced/grpc-advanced-bootstrap", + "id": "grpc-advanced", + "gradle_path": ":grpc-advanced:grpc-advanced", + "source_path": "src/grpc-advanced/grpc-advanced", "allowed_dependencies": [ - "grpc-core-api" + "grpc-core-api", + "grpc-runtime" ], "build": "optional-grpc" }, @@ -692,57 +627,7 @@ "source_path": "src/grpc-advanced/grpc-advanced-compat", "allowed_dependencies": [ "grpc-core-api", - "grpc-policy", - "grpc-server", - "grpc-client", - "grpc-advanced-bootstrap" - ], - "build": "optional-grpc" - }, - { - "id": "grpc-advanced-diagnostics", - "gradle_path": ":grpc-advanced:grpc-advanced-diagnostics", - "source_path": "src/grpc-advanced/grpc-advanced-diagnostics", - "allowed_dependencies": [ - "grpc-core-api", - "grpc-client", - "grpc-advanced-bootstrap", - "grpc-policy" - ], - "build": "optional-grpc" - }, - { - "id": "grpc-advanced-edition", - "gradle_path": ":grpc-advanced:grpc-advanced-edition", - "source_path": "src/grpc-advanced/grpc-advanced-edition", - "allowed_dependencies": [ - "grpc-core-api", - "grpc-proto-contract", - "grpc-advanced-bootstrap" - ], - "build": "optional-grpc" - }, - { - "id": "grpc-advanced-resilience", - "gradle_path": ":grpc-advanced:grpc-advanced-resilience", - "source_path": "src/grpc-advanced/grpc-advanced-resilience", - "allowed_dependencies": [ - "grpc-core-api", - "grpc-policy", - "grpc-client", - "grpc-discovery", - "grpc-advanced-bootstrap" - ], - "build": "optional-grpc" - }, - { - "id": "grpc-advanced-streaming", - "gradle_path": ":grpc-advanced:grpc-advanced-streaming", - "source_path": "src/grpc-advanced/grpc-advanced-streaming", - "allowed_dependencies": [ - "grpc-core-api", - "grpc-policy", - "grpc-advanced-bootstrap" + "grpc-runtime" ], "build": "optional-grpc" } diff --git a/src/gradle/libs.versions.toml b/src/gradle/libs.versions.toml index 447907b1..1ccf83b9 100644 --- a/src/gradle/libs.versions.toml +++ b/src/gradle/libs.versions.toml @@ -69,6 +69,10 @@ protobuf = "4.33.2" # imports protobuf-bom at this major to match the gRPC BOM above; it is read through # `ext.protobufVersion`. protobufGrpc = "3.25.5" +# The Gradle plugin that runs protoc for grpc:grpc-contract. protoc and the protobuf-java runtime +# the generated code links against are both `protobufGrpc` above, so generator and runtime move +# together with the gRPC BOM. +protobufPlugin = "0.10.0" # The websocket leaf's proto contract is generated against an older runtime and has not been # requalified; see the coordinate's own comment in that leaf. protobufLegacy = "4.29.3" @@ -116,6 +120,8 @@ mockwebserver = { module = "com.squareup.okhttp3:mockwebserver", version.ref = " okhttp-tls = { module = "com.squareup.okhttp3:okhttp-tls", version.ref = "okhttp" } protobuf-java = { module = "com.google.protobuf:protobuf-java", version.ref = "protobuf" } protobuf-java-legacy = { module = "com.google.protobuf:protobuf-java", version.ref = "protobufLegacy" } +protobuf-java-grpc = { module = "com.google.protobuf:protobuf-java", version.ref = "protobufGrpc" } +protoc = { module = "com.google.protobuf:protoc", version.ref = "protobufGrpc" } resilience4j-bulkhead = { module = "io.github.resilience4j:resilience4j-bulkhead", version.ref = "resilience4j" } resilience4j-circuitbreaker = { module = "io.github.resilience4j:resilience4j-circuitbreaker", version.ref = "resilience4j" } resilience4j-micrometer = { module = "io.github.resilience4j:resilience4j-micrometer", version.ref = "resilience4j" } @@ -143,3 +149,4 @@ spotless = { id = "com.diffplug.spotless", version.ref = "spotless" } spotbugs = { id = "com.github.spotbugs", version.ref = "spotbugsPlugin" } errorprone = { id = "net.ltgt.errorprone", version.ref = "errorpronePlugin" } jmh = { id = "me.champeau.jmh", version.ref = "jmhPlugin" } +protobuf = { id = "com.google.protobuf", version.ref = "protobufPlugin" } diff --git a/src/grpc-advanced/CLAUDE.md b/src/grpc-advanced/CLAUDE.md index aab663dc..c051e622 100644 --- a/src/grpc-advanced/CLAUDE.md +++ b/src/grpc-advanced/CLAUDE.md @@ -37,14 +37,19 @@ property key는 `ca-skeleton.grpc.advanced..enabled`이고 전부 ## Leaf별 담당 capability -| leaf | capability | -| --- | --- | -| `grpc-advanced-bootstrap` | capability grade, feature flag, module guard, capability별 promotion gate | -| `grpc-advanced-edition` | Protobuf Edition 2024 opt-in lane, Edition 2026 watch lane | -| `grpc-advanced-streaming` | client streaming(session/dedup/checkpoint), bidi(dual sequence), manual flow control | -| `grpc-advanced-resilience` | read-only hedging, custom name resolver SPI, custom load balancer SPI, proxyless xDS | -| `grpc-advanced-compat` | gRPC-Web, Spring Integration bridge, Reactor adapter, Kotlin coroutine 취소 bridge | -| `grpc-advanced-diagnostics` | Channelz/CSDS 진단 | +| leaf | 패키지(`dev.caskeleton.grpc.advanced.*`) | capability | +| --- | --- | --- | +| `grpc-advanced` | `bootstrap` | capability grade, feature flag, module guard, capability별 promotion gate | +| `grpc-advanced` | `edition` | Protobuf Edition 2024 opt-in lane, Edition 2026 watch lane | +| `grpc-advanced` | `streaming` | client streaming(session/dedup/checkpoint), bidi(dual sequence), manual flow control | +| `grpc-advanced` | `resilience`·`discovery`·`xds` | read-only hedging, custom name resolver SPI, custom load balancer SPI, proxyless xDS | +| `grpc-advanced` | `diagnostics` | Channelz/CSDS 진단 | +| `grpc-advanced-compat` | `web`·`integration`·`reactor`·`kotlin` | gRPC-Web, Spring Integration bridge, Reactor adapter, Kotlin coroutine 취소 bridge | + +`grpc-advanced-compat`만 따로 있는 이유는 Reactor·Spring Integration이라는 실제 의존성 경계다. 나머지 +다섯 capability는 framework 의존이 없어 한 leaf에 있다(2026-09-28까지는 leaf 다섯 개). capability별 +독립은 leaf 경계가 아니라 capability flag와 promotion 레코드가 보장한다. 참조 Envoy 설정은 jar에 싣지 +않는 테스트 fixture(`grpc-advanced-compat/src/test/resources/envoy/envoy.yaml`)다. ## Promotion은 capability별로 독립이다 diff --git a/src/grpc-advanced/grpc-advanced-bootstrap/build.gradle b/src/grpc-advanced/grpc-advanced-bootstrap/build.gradle deleted file mode 100644 index 347ed7df..00000000 --- a/src/grpc-advanced/grpc-advanced-bootstrap/build.gradle +++ /dev/null @@ -1,14 +0,0 @@ -plugins { - id 'ca.platform-module' -} - -// The Advanced boundary itself: capability grades, the `ca-skeleton.grpc.advanced.*` feature-flag -// contract, the module guard that refuses an unflagged capability, and the per-capability -// promotion gate. -// -// This leaf depends on Stable public types and never the other way round. The Stable starter's -// registry entry names no advanced id, so `verifyCleanArchitectureDependencies` is what makes -// "Advanced never leaks into Stable" a build failure rather than a review note. -dependencies { - api project(':grpc:grpc-core-api') -} diff --git a/src/grpc-advanced/grpc-advanced-bootstrap/gradle.lockfile b/src/grpc-advanced/grpc-advanced-bootstrap/gradle.lockfile deleted file mode 100644 index e2c95854..00000000 --- a/src/grpc-advanced/grpc-advanced-bootstrap/gradle.lockfile +++ /dev/null @@ -1,84 +0,0 @@ -# This is a Gradle generated file for dependency locking. -# Manual edits can break the build and are not advised. -# This file is expected to be part of source control. -com.github.ben-manes.caffeine:caffeine:3.2.4=annotationProcessor,testAnnotationProcessor -com.github.kevinstern:software-and-algorithms:1.0=annotationProcessor,testAnnotationProcessor -com.github.spotbugs:spotbugs-annotations:4.10.2=spotbugs -com.github.spotbugs:spotbugs:4.10.2=spotbugs -com.github.stephenc.jcip:jcip-annotations:1.0-1=spotbugs -com.google.auto.service:auto-service-annotations:1.0.1=annotationProcessor,testAnnotationProcessor -com.google.auto.value:auto-value-annotations:1.9=annotationProcessor,testAnnotationProcessor -com.google.auto:auto-common:1.2.2=annotationProcessor,testAnnotationProcessor -com.google.code.findbugs:jsr305:3.0.2=checkstyle,spotbugs -com.google.code.gson:gson:2.13.2=spotbugs -com.google.errorprone:error_prone_annotation:2.49.0=annotationProcessor,testAnnotationProcessor -com.google.errorprone:error_prone_annotations:2.41.0=spotbugs -com.google.errorprone:error_prone_annotations:2.47.0=checkstyle -com.google.errorprone:error_prone_annotations:2.49.0=annotationProcessor,testAnnotationProcessor -com.google.errorprone:error_prone_check_api:2.49.0=annotationProcessor,testAnnotationProcessor -com.google.errorprone:error_prone_core:2.49.0=annotationProcessor,testAnnotationProcessor -com.google.googlejavaformat:google-java-format:1.35.0=annotationProcessor,testAnnotationProcessor -com.google.guava:failureaccess:1.0.3=annotationProcessor,checkstyle,testAnnotationProcessor -com.google.guava:guava:33.5.0-jre=annotationProcessor,testAnnotationProcessor -com.google.guava:guava:33.6.0-jre=checkstyle -com.google.guava:listenablefuture:9999.0-empty-to-avoid-conflict-with-guava=annotationProcessor,checkstyle,testAnnotationProcessor -com.google.j2objc:j2objc-annotations:3.1=annotationProcessor,checkstyle,testAnnotationProcessor -com.google.protobuf:protobuf-java:4.33.2=annotationProcessor,testAnnotationProcessor -com.h3xstream.findsecbugs:findsecbugs-plugin:1.14.0=spotbugsPlugins -com.puppycrawl.tools:checkstyle:13.5.0=checkstyle -commons-beanutils:commons-beanutils:1.11.0=checkstyle -commons-collections:commons-collections:3.2.2=checkstyle -commons-io:commons-io:2.21.0=spotbugs -info.picocli:picocli:4.7.7=checkstyle -io.github.eisop:dataflow-errorprone:3.41.0-eisop1=annotationProcessor,testAnnotationProcessor -io.github.java-diff-utils:java-diff-utils:4.12=annotationProcessor,testAnnotationProcessor -javax.inject:javax.inject:1=annotationProcessor,testAnnotationProcessor -jaxen:jaxen:2.0.6=spotbugs -net.bytebuddy:byte-buddy:1.17.8=testCompileClasspath,testRuntimeClasspath -net.sf.saxon:Saxon-HE:12.9=checkstyle,spotbugs -org.antlr:antlr4-runtime:4.13.2=checkstyle -org.apache.bcel:bcel:6.12.0=spotbugs -org.apache.commons:commons-lang3:3.20.0=checkstyle,spotbugs -org.apache.commons:commons-text:1.15.0=spotbugs -org.apache.commons:commons-text:1.3=checkstyle -org.apache.httpcomponents:httpclient:4.5.13=checkstyle -org.apache.httpcomponents:httpcore:4.4.16=checkstyle -org.apache.logging.log4j:log4j-api:2.25.5=spotbugs -org.apache.logging.log4j:log4j-core:2.25.5=spotbugs -org.apache.maven.doxia:doxia-core:1.12.0=checkstyle -org.apache.maven.doxia:doxia-logging-api:1.12.0=checkstyle -org.apache.maven.doxia:doxia-module-xdoc:1.12.0=checkstyle -org.apache.maven.doxia:doxia-sink-api:1.12.0=checkstyle -org.apache.xbean:xbean-reflect:3.7=checkstyle -org.apiguardian:apiguardian-api:1.1.2=testCompileClasspath -org.assertj:assertj-core:3.27.7=testCompileClasspath,testRuntimeClasspath -org.codehaus.plexus:plexus-classworlds:2.6.0=checkstyle -org.codehaus.plexus:plexus-component-annotations:2.1.0=checkstyle -org.codehaus.plexus:plexus-container-default:2.1.0=checkstyle -org.codehaus.plexus:plexus-utils:3.3.0=checkstyle -org.dom4j:dom4j:2.2.0=spotbugs -org.javassist:javassist:3.28.0-GA=checkstyle -org.jspecify:jspecify:1.0.1=annotationProcessor,checkstyle,testAnnotationProcessor,testCompileClasspath -org.junit.jupiter:junit-jupiter-api:6.0.3=testCompileClasspath,testRuntimeClasspath -org.junit.jupiter:junit-jupiter-engine:6.0.3=testRuntimeClasspath -org.junit.jupiter:junit-jupiter-params:6.0.3=testCompileClasspath,testRuntimeClasspath -org.junit.jupiter:junit-jupiter:6.0.3=testCompileClasspath,testRuntimeClasspath -org.junit.platform:junit-platform-commons:6.0.3=testCompileClasspath,testRuntimeClasspath -org.junit.platform:junit-platform-engine:6.0.3=testRuntimeClasspath -org.junit.platform:junit-platform-launcher:6.0.3=testRuntimeClasspath -org.junit:junit-bom:6.0.3=testCompileClasspath,testRuntimeClasspath -org.junit:junit-bom:6.1.0=spotbugs -org.mockito:mockito-core:5.20.0=mockitoAgent -org.opentest4j:opentest4j:1.3.0=testCompileClasspath,testRuntimeClasspath -org.ow2.asm:asm-analysis:9.10.1=spotbugs -org.ow2.asm:asm-commons:9.10.1=spotbugs -org.ow2.asm:asm-tree:9.10.1=spotbugs -org.ow2.asm:asm-util:9.10.1=spotbugs -org.ow2.asm:asm:9.10.1=spotbugs -org.pcollections:pcollections:4.0.1=annotationProcessor,testAnnotationProcessor -org.reflections:reflections:0.10.2=checkstyle -org.slf4j:slf4j-api:2.0.18=spotbugs,spotbugsSlf4j -org.slf4j:slf4j-simple:2.0.17=spotbugsSlf4j -org.slf4j:slf4j-simple:2.0.18=checkstyle -org.xmlresolver:xmlresolver:5.3.3=checkstyle,spotbugs -empty=compileClasspath,runtimeClasspath diff --git a/src/grpc-advanced/grpc-advanced-compat/build.gradle b/src/grpc-advanced/grpc-advanced-compat/build.gradle index ec853573..bf0fccdb 100644 --- a/src/grpc-advanced/grpc-advanced-compat/build.gradle +++ b/src/grpc-advanced/grpc-advanced-compat/build.gradle @@ -1,5 +1,7 @@ plugins { - id 'ca.platform-module' + // grpc-platform, not platform: grpc-runtime's io.grpc api dependencies are versionless and + // need the gRPC BOM on every classpath they reach. + id 'ca.grpc-platform-module' } // Compatibility bridges: gRPC-Web, the Spring Integration bridge, the Reactor adapter, and the @@ -7,12 +9,12 @@ plugins { // // No Kotlin source set (adaptation D7): this repository has no Kotlin toolchain, so the Kotlin side // is only the Java-side cancellation bridge; nothing here claims Kotlin support. +// +// The reference Envoy configuration is a test fixture (src/test/resources/envoy), not something +// this jar ships: a proxy configuration belongs to the deployment that runs the proxy. dependencies { api project(':grpc:grpc-core-api') - api project(':grpc:grpc-policy') - api project(':grpc:grpc-server') - api project(':grpc:grpc-client') - api project(':grpc-advanced:grpc-advanced-bootstrap') + api project(':grpc:grpc-runtime') // api: the Reactor adapter's public signatures are Mono/Flux, and the Integration gateways name // Spring Integration's Message. Hiding either would only stop an adopter compiling against the diff --git a/src/grpc-advanced/grpc-advanced-compat/src/test/java/dev/caskeleton/grpc/advanced/compat/GrpcIntegrationBridgePolicyTest.java b/src/grpc-advanced/grpc-advanced-compat/src/test/java/dev/caskeleton/grpc/advanced/compat/GrpcIntegrationBridgePolicyTest.java index 5474b67f..b687080e 100644 --- a/src/grpc-advanced/grpc-advanced-compat/src/test/java/dev/caskeleton/grpc/advanced/compat/GrpcIntegrationBridgePolicyTest.java +++ b/src/grpc-advanced/grpc-advanced-compat/src/test/java/dev/caskeleton/grpc/advanced/compat/GrpcIntegrationBridgePolicyTest.java @@ -27,7 +27,7 @@ class GrpcIntegrationBridgePolicyTest { private static final GrpcMetadataKey CORRELATION = GrpcMetadataKey.ascii("x-correlation-id"); private static final GrpcMethodName GET = - GrpcMethodName.parse("hyeonworks.document.v1.DocumentService/GetDocument"); + GrpcMethodName.parse("caskeleton.document.v1.DocumentService/GetDocument"); private static GrpcRequestContext requestContext() { return GrpcRequestContext.create( diff --git a/src/grpc-advanced/grpc-advanced-compat/src/test/java/dev/caskeleton/grpc/advanced/compat/GrpcReactorContextBridgeTest.java b/src/grpc-advanced/grpc-advanced-compat/src/test/java/dev/caskeleton/grpc/advanced/compat/GrpcReactorContextBridgeTest.java index fcc3059d..ee4d99b6 100644 --- a/src/grpc-advanced/grpc-advanced-compat/src/test/java/dev/caskeleton/grpc/advanced/compat/GrpcReactorContextBridgeTest.java +++ b/src/grpc-advanced/grpc-advanced-compat/src/test/java/dev/caskeleton/grpc/advanced/compat/GrpcReactorContextBridgeTest.java @@ -28,7 +28,7 @@ import reactor.util.context.Context; class GrpcReactorContextBridgeTest { private static final GrpcMethodName GET = - GrpcMethodName.parse("hyeonworks.document.v1.DocumentService/GetDocument"); + GrpcMethodName.parse("caskeleton.document.v1.DocumentService/GetDocument"); private static final Instant NOW = Instant.parse("2026-08-30T10:00:00Z"); private static GrpcContextSnapshot snapshot() { diff --git a/src/grpc-advanced/grpc-advanced-compat/src/main/resources/envoy/envoy.yaml b/src/grpc-advanced/grpc-advanced-compat/src/test/resources/envoy/envoy.yaml similarity index 100% rename from src/grpc-advanced/grpc-advanced-compat/src/main/resources/envoy/envoy.yaml rename to src/grpc-advanced/grpc-advanced-compat/src/test/resources/envoy/envoy.yaml diff --git a/src/grpc-advanced/grpc-advanced-diagnostics/build.gradle b/src/grpc-advanced/grpc-advanced-diagnostics/build.gradle deleted file mode 100644 index be5a1d24..00000000 --- a/src/grpc-advanced/grpc-advanced-diagnostics/build.gradle +++ /dev/null @@ -1,11 +0,0 @@ -plugins { - id 'ca.platform-module' -} - -// Channelz/CSDS diagnostics for administrators, with the redactor that keeps socket authority, -// credentials, certificate material, metadata and payload out of a snapshot. -dependencies { - api project(':grpc:grpc-core-api') - api project(':grpc:grpc-client') - api project(':grpc-advanced:grpc-advanced-bootstrap') -} diff --git a/src/grpc-advanced/grpc-advanced-edition/build.gradle b/src/grpc-advanced/grpc-advanced-edition/build.gradle deleted file mode 100644 index f85d0e89..00000000 --- a/src/grpc-advanced/grpc-advanced-edition/build.gradle +++ /dev/null @@ -1,12 +0,0 @@ -plugins { - id 'ca.platform-module' -} - -// Protobuf Edition lanes. Edition 2024 is an opt-in Advanced lane that must produce cross-consumer -// compile evidence before anything public moves onto it; Edition 2026 is a watch lane that records -// release/toolchain status. -dependencies { - api project(':grpc:grpc-core-api') - api project(':grpc:grpc-proto-contract') - api project(':grpc-advanced:grpc-advanced-bootstrap') -} diff --git a/src/grpc-advanced/grpc-advanced-resilience/build.gradle b/src/grpc-advanced/grpc-advanced-resilience/build.gradle deleted file mode 100644 index 1e56b2dc..00000000 --- a/src/grpc-advanced/grpc-advanced-resilience/build.gradle +++ /dev/null @@ -1,13 +0,0 @@ -plugins { - id 'ca.platform-module' -} - -// Resilience and discovery capabilities that Stable refuses: read-only unary hedging, the custom -// name resolver SPI, the custom load balancer SPI, and the proxyless xDS experimental profile. -dependencies { - api project(':grpc:grpc-core-api') - api project(':grpc:grpc-policy') - api project(':grpc:grpc-client') - api project(':grpc:grpc-discovery') - api project(':grpc-advanced:grpc-advanced-bootstrap') -} diff --git a/src/grpc-advanced/grpc-advanced-streaming/build.gradle b/src/grpc-advanced/grpc-advanced-streaming/build.gradle deleted file mode 100644 index 2e5bbbdf..00000000 --- a/src/grpc-advanced/grpc-advanced-streaming/build.gradle +++ /dev/null @@ -1,12 +0,0 @@ -plugins { - id 'ca.platform-module' -} - -// The streaming shapes the Stable plan deliberately excludes: client streaming sessions with -// dedup/checkpoint/resume, bidirectional sessions with independent per-direction sequences, and the -// manual flow-control approval API. -dependencies { - api project(':grpc:grpc-core-api') - api project(':grpc:grpc-policy') - api project(':grpc-advanced:grpc-advanced-bootstrap') -} diff --git a/src/grpc-advanced/grpc-advanced-streaming/gradle.lockfile b/src/grpc-advanced/grpc-advanced-streaming/gradle.lockfile deleted file mode 100644 index 9369e831..00000000 --- a/src/grpc-advanced/grpc-advanced-streaming/gradle.lockfile +++ /dev/null @@ -1,91 +0,0 @@ -# This is a Gradle generated file for dependency locking. -# Manual edits can break the build and are not advised. -# This file is expected to be part of source control. -com.github.ben-manes.caffeine:caffeine:3.2.4=annotationProcessor,testAnnotationProcessor -com.github.kevinstern:software-and-algorithms:1.0=annotationProcessor,testAnnotationProcessor -com.github.spotbugs:spotbugs-annotations:4.10.2=spotbugs -com.github.spotbugs:spotbugs:4.10.2=spotbugs -com.github.stephenc.jcip:jcip-annotations:1.0-1=spotbugs -com.google.auto.service:auto-service-annotations:1.0.1=annotationProcessor,testAnnotationProcessor -com.google.auto.value:auto-value-annotations:1.9=annotationProcessor,testAnnotationProcessor -com.google.auto:auto-common:1.2.2=annotationProcessor,testAnnotationProcessor -com.google.code.findbugs:jsr305:3.0.2=checkstyle,compileClasspath,runtimeClasspath,spotbugs,testCompileClasspath,testRuntimeClasspath -com.google.code.gson:gson:2.13.2=spotbugs -com.google.errorprone:error_prone_annotation:2.49.0=annotationProcessor,testAnnotationProcessor -com.google.errorprone:error_prone_annotations:2.28.0=compileClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath -com.google.errorprone:error_prone_annotations:2.41.0=spotbugs -com.google.errorprone:error_prone_annotations:2.47.0=checkstyle -com.google.errorprone:error_prone_annotations:2.49.0=annotationProcessor,testAnnotationProcessor -com.google.errorprone:error_prone_check_api:2.49.0=annotationProcessor,testAnnotationProcessor -com.google.errorprone:error_prone_core:2.49.0=annotationProcessor,testAnnotationProcessor -com.google.googlejavaformat:google-java-format:1.35.0=annotationProcessor,testAnnotationProcessor -com.google.guava:failureaccess:1.0.2=compileClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath -com.google.guava:failureaccess:1.0.3=annotationProcessor,checkstyle,testAnnotationProcessor -com.google.guava:guava:33.2.1-android=compileClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath -com.google.guava:guava:33.5.0-jre=annotationProcessor,testAnnotationProcessor -com.google.guava:guava:33.6.0-jre=checkstyle -com.google.guava:listenablefuture:9999.0-empty-to-avoid-conflict-with-guava=annotationProcessor,checkstyle,compileClasspath,runtimeClasspath,testAnnotationProcessor,testCompileClasspath,testRuntimeClasspath -com.google.j2objc:j2objc-annotations:3.0.0=compileClasspath,testCompileClasspath -com.google.j2objc:j2objc-annotations:3.1=annotationProcessor,checkstyle,testAnnotationProcessor -com.google.protobuf:protobuf-java:4.33.2=annotationProcessor,testAnnotationProcessor -com.h3xstream.findsecbugs:findsecbugs-plugin:1.14.0=spotbugsPlugins -com.puppycrawl.tools:checkstyle:13.5.0=checkstyle -commons-beanutils:commons-beanutils:1.11.0=checkstyle -commons-collections:commons-collections:3.2.2=checkstyle -commons-io:commons-io:2.21.0=spotbugs -info.picocli:picocli:4.7.7=checkstyle -io.github.eisop:dataflow-errorprone:3.41.0-eisop1=annotationProcessor,testAnnotationProcessor -io.github.java-diff-utils:java-diff-utils:4.12=annotationProcessor,testAnnotationProcessor -io.grpc:grpc-api:1.68.1=compileClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath -io.grpc:grpc-stub:1.68.1=compileClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath -javax.inject:javax.inject:1=annotationProcessor,testAnnotationProcessor -jaxen:jaxen:2.0.6=spotbugs -net.bytebuddy:byte-buddy:1.17.8=testCompileClasspath,testRuntimeClasspath -net.sf.saxon:Saxon-HE:12.9=checkstyle,spotbugs -org.antlr:antlr4-runtime:4.13.2=checkstyle -org.apache.bcel:bcel:6.12.0=spotbugs -org.apache.commons:commons-lang3:3.20.0=checkstyle,spotbugs -org.apache.commons:commons-text:1.15.0=spotbugs -org.apache.commons:commons-text:1.3=checkstyle -org.apache.httpcomponents:httpclient:4.5.13=checkstyle -org.apache.httpcomponents:httpcore:4.4.16=checkstyle -org.apache.logging.log4j:log4j-api:2.25.5=spotbugs -org.apache.logging.log4j:log4j-core:2.25.5=spotbugs -org.apache.maven.doxia:doxia-core:1.12.0=checkstyle -org.apache.maven.doxia:doxia-logging-api:1.12.0=checkstyle -org.apache.maven.doxia:doxia-module-xdoc:1.12.0=checkstyle -org.apache.maven.doxia:doxia-sink-api:1.12.0=checkstyle -org.apache.xbean:xbean-reflect:3.7=checkstyle -org.apiguardian:apiguardian-api:1.1.2=testCompileClasspath -org.assertj:assertj-core:3.27.7=testCompileClasspath,testRuntimeClasspath -org.checkerframework:checker-qual:3.42.0=compileClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath -org.codehaus.plexus:plexus-classworlds:2.6.0=checkstyle -org.codehaus.plexus:plexus-component-annotations:2.1.0=checkstyle -org.codehaus.plexus:plexus-container-default:2.1.0=checkstyle -org.codehaus.plexus:plexus-utils:3.3.0=checkstyle -org.dom4j:dom4j:2.2.0=spotbugs -org.javassist:javassist:3.28.0-GA=checkstyle -org.jspecify:jspecify:1.0.1=annotationProcessor,checkstyle,testAnnotationProcessor,testCompileClasspath -org.junit.jupiter:junit-jupiter-api:6.0.3=testCompileClasspath,testRuntimeClasspath -org.junit.jupiter:junit-jupiter-engine:6.0.3=testRuntimeClasspath -org.junit.jupiter:junit-jupiter-params:6.0.3=testCompileClasspath,testRuntimeClasspath -org.junit.jupiter:junit-jupiter:6.0.3=testCompileClasspath,testRuntimeClasspath -org.junit.platform:junit-platform-commons:6.0.3=testCompileClasspath,testRuntimeClasspath -org.junit.platform:junit-platform-engine:6.0.3=testRuntimeClasspath -org.junit.platform:junit-platform-launcher:6.0.3=testRuntimeClasspath -org.junit:junit-bom:6.0.3=testCompileClasspath,testRuntimeClasspath -org.junit:junit-bom:6.1.0=spotbugs -org.mockito:mockito-core:5.20.0=mockitoAgent -org.opentest4j:opentest4j:1.3.0=testCompileClasspath,testRuntimeClasspath -org.ow2.asm:asm-analysis:9.10.1=spotbugs -org.ow2.asm:asm-commons:9.10.1=spotbugs -org.ow2.asm:asm-tree:9.10.1=spotbugs -org.ow2.asm:asm-util:9.10.1=spotbugs -org.ow2.asm:asm:9.10.1=spotbugs -org.pcollections:pcollections:4.0.1=annotationProcessor,testAnnotationProcessor -org.reflections:reflections:0.10.2=checkstyle -org.slf4j:slf4j-api:2.0.18=spotbugs,spotbugsSlf4j -org.slf4j:slf4j-simple:2.0.17=spotbugsSlf4j -org.slf4j:slf4j-simple:2.0.18=checkstyle -org.xmlresolver:xmlresolver:5.3.3=checkstyle,spotbugs -empty= diff --git a/src/grpc-advanced/grpc-advanced/build.gradle b/src/grpc-advanced/grpc-advanced/build.gradle new file mode 100644 index 00000000..eaf898d9 --- /dev/null +++ b/src/grpc-advanced/grpc-advanced/build.gradle @@ -0,0 +1,28 @@ +plugins { + // grpc-platform, not platform: grpc-runtime's io.grpc api dependencies are versionless and + // need the gRPC BOM on every classpath they reach. + id 'ca.grpc-platform-module' +} + +// The capabilities the Stable platform deliberately excludes, each behind its own capability flag: +// +// bootstrap capability grades, the `ca-skeleton.grpc.advanced.*` feature-flag contract, the +// module guard that refuses an unflagged capability, the per-capability promotion +// gate +// edition Protobuf Edition 2024 opt-in lane and Edition 2026 watch lane +// streaming client streaming sessions (dedup/checkpoint/resume), bidirectional sessions with +// independent per-direction sequences, the manual flow-control approval API +// resilience read-only unary hedging, custom name resolver / load balancer SPIs, proxyless xDS +// diagnostics Channelz/CSDS snapshots and the redactor that keeps secrets out of them +// +// These were five leaves until 2026-09-28. None of them carried a framework dependency of its own, +// and the only rule the split enforced — Stable never reaches Advanced — is expressed by the +// registry through the two prefixes (`grpc:*` may not depend on `grpc-advanced:*`), not by how many +// advanced leaves exist. `grpc-advanced-compat` stays separate because Reactor and Spring +// Integration are a real dependency boundary. +// +// This leaf depends on Stable public types and never the other way round. +dependencies { + api project(':grpc:grpc-core-api') + api project(':grpc:grpc-runtime') +} diff --git a/src/grpc-advanced/grpc-advanced-diagnostics/gradle.lockfile b/src/grpc-advanced/grpc-advanced/gradle.lockfile similarity index 100% rename from src/grpc-advanced/grpc-advanced-diagnostics/gradle.lockfile rename to src/grpc-advanced/grpc-advanced/gradle.lockfile diff --git a/src/grpc-advanced/grpc-advanced-bootstrap/src/main/java/dev/caskeleton/grpc/advanced/bootstrap/GrpcAdvancedCapability.java b/src/grpc-advanced/grpc-advanced/src/main/java/dev/caskeleton/grpc/advanced/bootstrap/GrpcAdvancedCapability.java similarity index 100% rename from src/grpc-advanced/grpc-advanced-bootstrap/src/main/java/dev/caskeleton/grpc/advanced/bootstrap/GrpcAdvancedCapability.java rename to src/grpc-advanced/grpc-advanced/src/main/java/dev/caskeleton/grpc/advanced/bootstrap/GrpcAdvancedCapability.java diff --git a/src/grpc-advanced/grpc-advanced-bootstrap/src/main/java/dev/caskeleton/grpc/advanced/bootstrap/GrpcAdvancedCapabilityDisabledException.java b/src/grpc-advanced/grpc-advanced/src/main/java/dev/caskeleton/grpc/advanced/bootstrap/GrpcAdvancedCapabilityDisabledException.java similarity index 100% rename from src/grpc-advanced/grpc-advanced-bootstrap/src/main/java/dev/caskeleton/grpc/advanced/bootstrap/GrpcAdvancedCapabilityDisabledException.java rename to src/grpc-advanced/grpc-advanced/src/main/java/dev/caskeleton/grpc/advanced/bootstrap/GrpcAdvancedCapabilityDisabledException.java diff --git a/src/grpc-advanced/grpc-advanced-bootstrap/src/main/java/dev/caskeleton/grpc/advanced/bootstrap/GrpcAdvancedFeatureFlags.java b/src/grpc-advanced/grpc-advanced/src/main/java/dev/caskeleton/grpc/advanced/bootstrap/GrpcAdvancedFeatureFlags.java similarity index 100% rename from src/grpc-advanced/grpc-advanced-bootstrap/src/main/java/dev/caskeleton/grpc/advanced/bootstrap/GrpcAdvancedFeatureFlags.java rename to src/grpc-advanced/grpc-advanced/src/main/java/dev/caskeleton/grpc/advanced/bootstrap/GrpcAdvancedFeatureFlags.java diff --git a/src/grpc-advanced/grpc-advanced-bootstrap/src/main/java/dev/caskeleton/grpc/advanced/bootstrap/GrpcAdvancedModuleGuard.java b/src/grpc-advanced/grpc-advanced/src/main/java/dev/caskeleton/grpc/advanced/bootstrap/GrpcAdvancedModuleGuard.java similarity index 100% rename from src/grpc-advanced/grpc-advanced-bootstrap/src/main/java/dev/caskeleton/grpc/advanced/bootstrap/GrpcAdvancedModuleGuard.java rename to src/grpc-advanced/grpc-advanced/src/main/java/dev/caskeleton/grpc/advanced/bootstrap/GrpcAdvancedModuleGuard.java diff --git a/src/grpc-advanced/grpc-advanced-bootstrap/src/main/java/dev/caskeleton/grpc/advanced/bootstrap/GrpcCapabilityGrade.java b/src/grpc-advanced/grpc-advanced/src/main/java/dev/caskeleton/grpc/advanced/bootstrap/GrpcCapabilityGrade.java similarity index 100% rename from src/grpc-advanced/grpc-advanced-bootstrap/src/main/java/dev/caskeleton/grpc/advanced/bootstrap/GrpcCapabilityGrade.java rename to src/grpc-advanced/grpc-advanced/src/main/java/dev/caskeleton/grpc/advanced/bootstrap/GrpcCapabilityGrade.java diff --git a/src/grpc-advanced/grpc-advanced-diagnostics/src/main/java/dev/caskeleton/grpc/advanced/diagnostics/GrpcChannelDiagnosticsPolicy.java b/src/grpc-advanced/grpc-advanced/src/main/java/dev/caskeleton/grpc/advanced/diagnostics/GrpcChannelDiagnosticsPolicy.java similarity index 100% rename from src/grpc-advanced/grpc-advanced-diagnostics/src/main/java/dev/caskeleton/grpc/advanced/diagnostics/GrpcChannelDiagnosticsPolicy.java rename to src/grpc-advanced/grpc-advanced/src/main/java/dev/caskeleton/grpc/advanced/diagnostics/GrpcChannelDiagnosticsPolicy.java diff --git a/src/grpc-advanced/grpc-advanced-diagnostics/src/main/java/dev/caskeleton/grpc/advanced/diagnostics/GrpcChannelDiagnosticsSnapshot.java b/src/grpc-advanced/grpc-advanced/src/main/java/dev/caskeleton/grpc/advanced/diagnostics/GrpcChannelDiagnosticsSnapshot.java similarity index 100% rename from src/grpc-advanced/grpc-advanced-diagnostics/src/main/java/dev/caskeleton/grpc/advanced/diagnostics/GrpcChannelDiagnosticsSnapshot.java rename to src/grpc-advanced/grpc-advanced/src/main/java/dev/caskeleton/grpc/advanced/diagnostics/GrpcChannelDiagnosticsSnapshot.java diff --git a/src/grpc-advanced/grpc-advanced-diagnostics/src/main/java/dev/caskeleton/grpc/advanced/diagnostics/GrpcDiagnosticsRedactor.java b/src/grpc-advanced/grpc-advanced/src/main/java/dev/caskeleton/grpc/advanced/diagnostics/GrpcDiagnosticsRedactor.java similarity index 100% rename from src/grpc-advanced/grpc-advanced-diagnostics/src/main/java/dev/caskeleton/grpc/advanced/diagnostics/GrpcDiagnosticsRedactor.java rename to src/grpc-advanced/grpc-advanced/src/main/java/dev/caskeleton/grpc/advanced/diagnostics/GrpcDiagnosticsRedactor.java diff --git a/src/grpc-advanced/grpc-advanced-resilience/src/main/java/dev/caskeleton/grpc/advanced/discovery/GrpcCustomResolver.java b/src/grpc-advanced/grpc-advanced/src/main/java/dev/caskeleton/grpc/advanced/discovery/GrpcCustomResolver.java similarity index 100% rename from src/grpc-advanced/grpc-advanced-resilience/src/main/java/dev/caskeleton/grpc/advanced/discovery/GrpcCustomResolver.java rename to src/grpc-advanced/grpc-advanced/src/main/java/dev/caskeleton/grpc/advanced/discovery/GrpcCustomResolver.java diff --git a/src/grpc-advanced/grpc-advanced-resilience/src/main/java/dev/caskeleton/grpc/advanced/discovery/GrpcEndpointCandidate.java b/src/grpc-advanced/grpc-advanced/src/main/java/dev/caskeleton/grpc/advanced/discovery/GrpcEndpointCandidate.java similarity index 100% rename from src/grpc-advanced/grpc-advanced-resilience/src/main/java/dev/caskeleton/grpc/advanced/discovery/GrpcEndpointCandidate.java rename to src/grpc-advanced/grpc-advanced/src/main/java/dev/caskeleton/grpc/advanced/discovery/GrpcEndpointCandidate.java diff --git a/src/grpc-advanced/grpc-advanced-resilience/src/main/java/dev/caskeleton/grpc/advanced/discovery/GrpcEndpointSnapshot.java b/src/grpc-advanced/grpc-advanced/src/main/java/dev/caskeleton/grpc/advanced/discovery/GrpcEndpointSnapshot.java similarity index 100% rename from src/grpc-advanced/grpc-advanced-resilience/src/main/java/dev/caskeleton/grpc/advanced/discovery/GrpcEndpointSnapshot.java rename to src/grpc-advanced/grpc-advanced/src/main/java/dev/caskeleton/grpc/advanced/discovery/GrpcEndpointSnapshot.java diff --git a/src/grpc-advanced/grpc-advanced-resilience/src/main/java/dev/caskeleton/grpc/advanced/discovery/GrpcLoadBalancerDecision.java b/src/grpc-advanced/grpc-advanced/src/main/java/dev/caskeleton/grpc/advanced/discovery/GrpcLoadBalancerDecision.java similarity index 100% rename from src/grpc-advanced/grpc-advanced-resilience/src/main/java/dev/caskeleton/grpc/advanced/discovery/GrpcLoadBalancerDecision.java rename to src/grpc-advanced/grpc-advanced/src/main/java/dev/caskeleton/grpc/advanced/discovery/GrpcLoadBalancerDecision.java diff --git a/src/grpc-advanced/grpc-advanced-resilience/src/main/java/dev/caskeleton/grpc/advanced/discovery/GrpcLoadBalancerPicker.java b/src/grpc-advanced/grpc-advanced/src/main/java/dev/caskeleton/grpc/advanced/discovery/GrpcLoadBalancerPicker.java similarity index 100% rename from src/grpc-advanced/grpc-advanced-resilience/src/main/java/dev/caskeleton/grpc/advanced/discovery/GrpcLoadBalancerPicker.java rename to src/grpc-advanced/grpc-advanced/src/main/java/dev/caskeleton/grpc/advanced/discovery/GrpcLoadBalancerPicker.java diff --git a/src/grpc-advanced/grpc-advanced-resilience/src/main/java/dev/caskeleton/grpc/advanced/discovery/GrpcLoadBalancerSafetyPolicy.java b/src/grpc-advanced/grpc-advanced/src/main/java/dev/caskeleton/grpc/advanced/discovery/GrpcLoadBalancerSafetyPolicy.java similarity index 100% rename from src/grpc-advanced/grpc-advanced-resilience/src/main/java/dev/caskeleton/grpc/advanced/discovery/GrpcLoadBalancerSafetyPolicy.java rename to src/grpc-advanced/grpc-advanced/src/main/java/dev/caskeleton/grpc/advanced/discovery/GrpcLoadBalancerSafetyPolicy.java diff --git a/src/grpc-advanced/grpc-advanced-resilience/src/main/java/dev/caskeleton/grpc/advanced/discovery/GrpcResolverSafetyPolicy.java b/src/grpc-advanced/grpc-advanced/src/main/java/dev/caskeleton/grpc/advanced/discovery/GrpcResolverSafetyPolicy.java similarity index 100% rename from src/grpc-advanced/grpc-advanced-resilience/src/main/java/dev/caskeleton/grpc/advanced/discovery/GrpcResolverSafetyPolicy.java rename to src/grpc-advanced/grpc-advanced/src/main/java/dev/caskeleton/grpc/advanced/discovery/GrpcResolverSafetyPolicy.java diff --git a/src/grpc-advanced/grpc-advanced-resilience/src/main/java/dev/caskeleton/grpc/advanced/discovery/GrpcResolverUpdate.java b/src/grpc-advanced/grpc-advanced/src/main/java/dev/caskeleton/grpc/advanced/discovery/GrpcResolverUpdate.java similarity index 100% rename from src/grpc-advanced/grpc-advanced-resilience/src/main/java/dev/caskeleton/grpc/advanced/discovery/GrpcResolverUpdate.java rename to src/grpc-advanced/grpc-advanced/src/main/java/dev/caskeleton/grpc/advanced/discovery/GrpcResolverUpdate.java diff --git a/src/grpc-advanced/grpc-advanced-edition/src/main/java/dev/caskeleton/grpc/advanced/edition/GrpcEdition2024Policy.java b/src/grpc-advanced/grpc-advanced/src/main/java/dev/caskeleton/grpc/advanced/edition/GrpcEdition2024Policy.java similarity index 100% rename from src/grpc-advanced/grpc-advanced-edition/src/main/java/dev/caskeleton/grpc/advanced/edition/GrpcEdition2024Policy.java rename to src/grpc-advanced/grpc-advanced/src/main/java/dev/caskeleton/grpc/advanced/edition/GrpcEdition2024Policy.java diff --git a/src/grpc-advanced/grpc-advanced-edition/src/main/java/dev/caskeleton/grpc/advanced/edition/GrpcEdition2026Status.java b/src/grpc-advanced/grpc-advanced/src/main/java/dev/caskeleton/grpc/advanced/edition/GrpcEdition2026Status.java similarity index 100% rename from src/grpc-advanced/grpc-advanced-edition/src/main/java/dev/caskeleton/grpc/advanced/edition/GrpcEdition2026Status.java rename to src/grpc-advanced/grpc-advanced/src/main/java/dev/caskeleton/grpc/advanced/edition/GrpcEdition2026Status.java diff --git a/src/grpc-advanced/grpc-advanced-edition/src/main/java/dev/caskeleton/grpc/advanced/edition/GrpcEdition2026WatchReport.java b/src/grpc-advanced/grpc-advanced/src/main/java/dev/caskeleton/grpc/advanced/edition/GrpcEdition2026WatchReport.java similarity index 100% rename from src/grpc-advanced/grpc-advanced-edition/src/main/java/dev/caskeleton/grpc/advanced/edition/GrpcEdition2026WatchReport.java rename to src/grpc-advanced/grpc-advanced/src/main/java/dev/caskeleton/grpc/advanced/edition/GrpcEdition2026WatchReport.java diff --git a/src/grpc-advanced/grpc-advanced-edition/src/main/java/dev/caskeleton/grpc/advanced/edition/GrpcEditionCompatibilityReport.java b/src/grpc-advanced/grpc-advanced/src/main/java/dev/caskeleton/grpc/advanced/edition/GrpcEditionCompatibilityReport.java similarity index 100% rename from src/grpc-advanced/grpc-advanced-edition/src/main/java/dev/caskeleton/grpc/advanced/edition/GrpcEditionCompatibilityReport.java rename to src/grpc-advanced/grpc-advanced/src/main/java/dev/caskeleton/grpc/advanced/edition/GrpcEditionCompatibilityReport.java diff --git a/src/grpc-advanced/grpc-advanced-bootstrap/src/main/java/dev/caskeleton/grpc/advanced/release/GrpcAdvancedPromotionDecision.java b/src/grpc-advanced/grpc-advanced/src/main/java/dev/caskeleton/grpc/advanced/release/GrpcAdvancedPromotionDecision.java similarity index 100% rename from src/grpc-advanced/grpc-advanced-bootstrap/src/main/java/dev/caskeleton/grpc/advanced/release/GrpcAdvancedPromotionDecision.java rename to src/grpc-advanced/grpc-advanced/src/main/java/dev/caskeleton/grpc/advanced/release/GrpcAdvancedPromotionDecision.java diff --git a/src/grpc-advanced/grpc-advanced-bootstrap/src/main/java/dev/caskeleton/grpc/advanced/release/GrpcAdvancedPromotionEvidence.java b/src/grpc-advanced/grpc-advanced/src/main/java/dev/caskeleton/grpc/advanced/release/GrpcAdvancedPromotionEvidence.java similarity index 100% rename from src/grpc-advanced/grpc-advanced-bootstrap/src/main/java/dev/caskeleton/grpc/advanced/release/GrpcAdvancedPromotionEvidence.java rename to src/grpc-advanced/grpc-advanced/src/main/java/dev/caskeleton/grpc/advanced/release/GrpcAdvancedPromotionEvidence.java diff --git a/src/grpc-advanced/grpc-advanced-bootstrap/src/main/java/dev/caskeleton/grpc/advanced/release/GrpcAdvancedPromotionGate.java b/src/grpc-advanced/grpc-advanced/src/main/java/dev/caskeleton/grpc/advanced/release/GrpcAdvancedPromotionGate.java similarity index 100% rename from src/grpc-advanced/grpc-advanced-bootstrap/src/main/java/dev/caskeleton/grpc/advanced/release/GrpcAdvancedPromotionGate.java rename to src/grpc-advanced/grpc-advanced/src/main/java/dev/caskeleton/grpc/advanced/release/GrpcAdvancedPromotionGate.java diff --git a/src/grpc-advanced/grpc-advanced-bootstrap/src/main/java/dev/caskeleton/grpc/advanced/release/GrpcAdvancedSupportMatrix.java b/src/grpc-advanced/grpc-advanced/src/main/java/dev/caskeleton/grpc/advanced/release/GrpcAdvancedSupportMatrix.java similarity index 100% rename from src/grpc-advanced/grpc-advanced-bootstrap/src/main/java/dev/caskeleton/grpc/advanced/release/GrpcAdvancedSupportMatrix.java rename to src/grpc-advanced/grpc-advanced/src/main/java/dev/caskeleton/grpc/advanced/release/GrpcAdvancedSupportMatrix.java diff --git a/src/grpc-advanced/grpc-advanced-resilience/src/main/java/dev/caskeleton/grpc/advanced/resilience/GrpcHedgingBudget.java b/src/grpc-advanced/grpc-advanced/src/main/java/dev/caskeleton/grpc/advanced/resilience/GrpcHedgingBudget.java similarity index 100% rename from src/grpc-advanced/grpc-advanced-resilience/src/main/java/dev/caskeleton/grpc/advanced/resilience/GrpcHedgingBudget.java rename to src/grpc-advanced/grpc-advanced/src/main/java/dev/caskeleton/grpc/advanced/resilience/GrpcHedgingBudget.java diff --git a/src/grpc-advanced/grpc-advanced-resilience/src/main/java/dev/caskeleton/grpc/advanced/resilience/GrpcHedgingEligibility.java b/src/grpc-advanced/grpc-advanced/src/main/java/dev/caskeleton/grpc/advanced/resilience/GrpcHedgingEligibility.java similarity index 100% rename from src/grpc-advanced/grpc-advanced-resilience/src/main/java/dev/caskeleton/grpc/advanced/resilience/GrpcHedgingEligibility.java rename to src/grpc-advanced/grpc-advanced/src/main/java/dev/caskeleton/grpc/advanced/resilience/GrpcHedgingEligibility.java diff --git a/src/grpc-advanced/grpc-advanced-resilience/src/main/java/dev/caskeleton/grpc/advanced/resilience/GrpcHedgingPolicy.java b/src/grpc-advanced/grpc-advanced/src/main/java/dev/caskeleton/grpc/advanced/resilience/GrpcHedgingPolicy.java similarity index 100% rename from src/grpc-advanced/grpc-advanced-resilience/src/main/java/dev/caskeleton/grpc/advanced/resilience/GrpcHedgingPolicy.java rename to src/grpc-advanced/grpc-advanced/src/main/java/dev/caskeleton/grpc/advanced/resilience/GrpcHedgingPolicy.java diff --git a/src/grpc-advanced/grpc-advanced-resilience/src/main/java/dev/caskeleton/grpc/advanced/resilience/GrpcHedgingResult.java b/src/grpc-advanced/grpc-advanced/src/main/java/dev/caskeleton/grpc/advanced/resilience/GrpcHedgingResult.java similarity index 100% rename from src/grpc-advanced/grpc-advanced-resilience/src/main/java/dev/caskeleton/grpc/advanced/resilience/GrpcHedgingResult.java rename to src/grpc-advanced/grpc-advanced/src/main/java/dev/caskeleton/grpc/advanced/resilience/GrpcHedgingResult.java diff --git a/src/grpc-advanced/grpc-advanced-streaming/src/main/java/dev/caskeleton/grpc/advanced/streaming/GrpcBidiDirectionState.java b/src/grpc-advanced/grpc-advanced/src/main/java/dev/caskeleton/grpc/advanced/streaming/GrpcBidiDirectionState.java similarity index 100% rename from src/grpc-advanced/grpc-advanced-streaming/src/main/java/dev/caskeleton/grpc/advanced/streaming/GrpcBidiDirectionState.java rename to src/grpc-advanced/grpc-advanced/src/main/java/dev/caskeleton/grpc/advanced/streaming/GrpcBidiDirectionState.java diff --git a/src/grpc-advanced/grpc-advanced-streaming/src/main/java/dev/caskeleton/grpc/advanced/streaming/GrpcBidiResumeState.java b/src/grpc-advanced/grpc-advanced/src/main/java/dev/caskeleton/grpc/advanced/streaming/GrpcBidiResumeState.java similarity index 100% rename from src/grpc-advanced/grpc-advanced-streaming/src/main/java/dev/caskeleton/grpc/advanced/streaming/GrpcBidiResumeState.java rename to src/grpc-advanced/grpc-advanced/src/main/java/dev/caskeleton/grpc/advanced/streaming/GrpcBidiResumeState.java diff --git a/src/grpc-advanced/grpc-advanced-streaming/src/main/java/dev/caskeleton/grpc/advanced/streaming/GrpcBidiSequenceTracker.java b/src/grpc-advanced/grpc-advanced/src/main/java/dev/caskeleton/grpc/advanced/streaming/GrpcBidiSequenceTracker.java similarity index 100% rename from src/grpc-advanced/grpc-advanced-streaming/src/main/java/dev/caskeleton/grpc/advanced/streaming/GrpcBidiSequenceTracker.java rename to src/grpc-advanced/grpc-advanced/src/main/java/dev/caskeleton/grpc/advanced/streaming/GrpcBidiSequenceTracker.java diff --git a/src/grpc-advanced/grpc-advanced-streaming/src/main/java/dev/caskeleton/grpc/advanced/streaming/GrpcBidiSession.java b/src/grpc-advanced/grpc-advanced/src/main/java/dev/caskeleton/grpc/advanced/streaming/GrpcBidiSession.java similarity index 100% rename from src/grpc-advanced/grpc-advanced-streaming/src/main/java/dev/caskeleton/grpc/advanced/streaming/GrpcBidiSession.java rename to src/grpc-advanced/grpc-advanced/src/main/java/dev/caskeleton/grpc/advanced/streaming/GrpcBidiSession.java diff --git a/src/grpc-advanced/grpc-advanced-streaming/src/main/java/dev/caskeleton/grpc/advanced/streaming/GrpcClientMessageDeduplicator.java b/src/grpc-advanced/grpc-advanced/src/main/java/dev/caskeleton/grpc/advanced/streaming/GrpcClientMessageDeduplicator.java similarity index 100% rename from src/grpc-advanced/grpc-advanced-streaming/src/main/java/dev/caskeleton/grpc/advanced/streaming/GrpcClientMessageDeduplicator.java rename to src/grpc-advanced/grpc-advanced/src/main/java/dev/caskeleton/grpc/advanced/streaming/GrpcClientMessageDeduplicator.java diff --git a/src/grpc-advanced/grpc-advanced-streaming/src/main/java/dev/caskeleton/grpc/advanced/streaming/GrpcClientStreamCheckpoint.java b/src/grpc-advanced/grpc-advanced/src/main/java/dev/caskeleton/grpc/advanced/streaming/GrpcClientStreamCheckpoint.java similarity index 100% rename from src/grpc-advanced/grpc-advanced-streaming/src/main/java/dev/caskeleton/grpc/advanced/streaming/GrpcClientStreamCheckpoint.java rename to src/grpc-advanced/grpc-advanced/src/main/java/dev/caskeleton/grpc/advanced/streaming/GrpcClientStreamCheckpoint.java diff --git a/src/grpc-advanced/grpc-advanced-streaming/src/main/java/dev/caskeleton/grpc/advanced/streaming/GrpcClientStreamMessage.java b/src/grpc-advanced/grpc-advanced/src/main/java/dev/caskeleton/grpc/advanced/streaming/GrpcClientStreamMessage.java similarity index 100% rename from src/grpc-advanced/grpc-advanced-streaming/src/main/java/dev/caskeleton/grpc/advanced/streaming/GrpcClientStreamMessage.java rename to src/grpc-advanced/grpc-advanced/src/main/java/dev/caskeleton/grpc/advanced/streaming/GrpcClientStreamMessage.java diff --git a/src/grpc-advanced/grpc-advanced-streaming/src/main/java/dev/caskeleton/grpc/advanced/streaming/GrpcClientStreamPolicy.java b/src/grpc-advanced/grpc-advanced/src/main/java/dev/caskeleton/grpc/advanced/streaming/GrpcClientStreamPolicy.java similarity index 100% rename from src/grpc-advanced/grpc-advanced-streaming/src/main/java/dev/caskeleton/grpc/advanced/streaming/GrpcClientStreamPolicy.java rename to src/grpc-advanced/grpc-advanced/src/main/java/dev/caskeleton/grpc/advanced/streaming/GrpcClientStreamPolicy.java diff --git a/src/grpc-advanced/grpc-advanced-streaming/src/main/java/dev/caskeleton/grpc/advanced/streaming/GrpcClientStreamResumeDecision.java b/src/grpc-advanced/grpc-advanced/src/main/java/dev/caskeleton/grpc/advanced/streaming/GrpcClientStreamResumeDecision.java similarity index 100% rename from src/grpc-advanced/grpc-advanced-streaming/src/main/java/dev/caskeleton/grpc/advanced/streaming/GrpcClientStreamResumeDecision.java rename to src/grpc-advanced/grpc-advanced/src/main/java/dev/caskeleton/grpc/advanced/streaming/GrpcClientStreamResumeDecision.java diff --git a/src/grpc-advanced/grpc-advanced-streaming/src/main/java/dev/caskeleton/grpc/advanced/streaming/GrpcClientStreamSessionId.java b/src/grpc-advanced/grpc-advanced/src/main/java/dev/caskeleton/grpc/advanced/streaming/GrpcClientStreamSessionId.java similarity index 100% rename from src/grpc-advanced/grpc-advanced-streaming/src/main/java/dev/caskeleton/grpc/advanced/streaming/GrpcClientStreamSessionId.java rename to src/grpc-advanced/grpc-advanced/src/main/java/dev/caskeleton/grpc/advanced/streaming/GrpcClientStreamSessionId.java diff --git a/src/grpc-advanced/grpc-advanced-streaming/src/main/java/dev/caskeleton/grpc/advanced/streaming/GrpcClientStreamState.java b/src/grpc-advanced/grpc-advanced/src/main/java/dev/caskeleton/grpc/advanced/streaming/GrpcClientStreamState.java similarity index 100% rename from src/grpc-advanced/grpc-advanced-streaming/src/main/java/dev/caskeleton/grpc/advanced/streaming/GrpcClientStreamState.java rename to src/grpc-advanced/grpc-advanced/src/main/java/dev/caskeleton/grpc/advanced/streaming/GrpcClientStreamState.java diff --git a/src/grpc-advanced/grpc-advanced-streaming/src/main/java/dev/caskeleton/grpc/advanced/streaming/GrpcDemandController.java b/src/grpc-advanced/grpc-advanced/src/main/java/dev/caskeleton/grpc/advanced/streaming/GrpcDemandController.java similarity index 100% rename from src/grpc-advanced/grpc-advanced-streaming/src/main/java/dev/caskeleton/grpc/advanced/streaming/GrpcDemandController.java rename to src/grpc-advanced/grpc-advanced/src/main/java/dev/caskeleton/grpc/advanced/streaming/GrpcDemandController.java diff --git a/src/grpc-advanced/grpc-advanced-streaming/src/main/java/dev/caskeleton/grpc/advanced/streaming/GrpcDemandDecision.java b/src/grpc-advanced/grpc-advanced/src/main/java/dev/caskeleton/grpc/advanced/streaming/GrpcDemandDecision.java similarity index 100% rename from src/grpc-advanced/grpc-advanced-streaming/src/main/java/dev/caskeleton/grpc/advanced/streaming/GrpcDemandDecision.java rename to src/grpc-advanced/grpc-advanced/src/main/java/dev/caskeleton/grpc/advanced/streaming/GrpcDemandDecision.java diff --git a/src/grpc-advanced/grpc-advanced-streaming/src/main/java/dev/caskeleton/grpc/advanced/streaming/GrpcManualFlowControlPolicy.java b/src/grpc-advanced/grpc-advanced/src/main/java/dev/caskeleton/grpc/advanced/streaming/GrpcManualFlowControlPolicy.java similarity index 100% rename from src/grpc-advanced/grpc-advanced-streaming/src/main/java/dev/caskeleton/grpc/advanced/streaming/GrpcManualFlowControlPolicy.java rename to src/grpc-advanced/grpc-advanced/src/main/java/dev/caskeleton/grpc/advanced/streaming/GrpcManualFlowControlPolicy.java diff --git a/src/grpc-advanced/grpc-advanced-resilience/src/main/java/dev/caskeleton/grpc/advanced/xds/GrpcXdsFailurePolicy.java b/src/grpc-advanced/grpc-advanced/src/main/java/dev/caskeleton/grpc/advanced/xds/GrpcXdsFailurePolicy.java similarity index 100% rename from src/grpc-advanced/grpc-advanced-resilience/src/main/java/dev/caskeleton/grpc/advanced/xds/GrpcXdsFailurePolicy.java rename to src/grpc-advanced/grpc-advanced/src/main/java/dev/caskeleton/grpc/advanced/xds/GrpcXdsFailurePolicy.java diff --git a/src/grpc-advanced/grpc-advanced-resilience/src/main/java/dev/caskeleton/grpc/advanced/xds/GrpcXdsProfile.java b/src/grpc-advanced/grpc-advanced/src/main/java/dev/caskeleton/grpc/advanced/xds/GrpcXdsProfile.java similarity index 100% rename from src/grpc-advanced/grpc-advanced-resilience/src/main/java/dev/caskeleton/grpc/advanced/xds/GrpcXdsProfile.java rename to src/grpc-advanced/grpc-advanced/src/main/java/dev/caskeleton/grpc/advanced/xds/GrpcXdsProfile.java diff --git a/src/grpc-advanced/grpc-advanced-resilience/src/main/java/dev/caskeleton/grpc/advanced/xds/GrpcXdsResourceSnapshot.java b/src/grpc-advanced/grpc-advanced/src/main/java/dev/caskeleton/grpc/advanced/xds/GrpcXdsResourceSnapshot.java similarity index 100% rename from src/grpc-advanced/grpc-advanced-resilience/src/main/java/dev/caskeleton/grpc/advanced/xds/GrpcXdsResourceSnapshot.java rename to src/grpc-advanced/grpc-advanced/src/main/java/dev/caskeleton/grpc/advanced/xds/GrpcXdsResourceSnapshot.java diff --git a/src/grpc-advanced/grpc-advanced-bootstrap/src/test/java/dev/caskeleton/grpc/advanced/bootstrap/GrpcAdvancedModuleGuardTest.java b/src/grpc-advanced/grpc-advanced/src/test/java/dev/caskeleton/grpc/advanced/bootstrap/GrpcAdvancedModuleGuardTest.java similarity index 100% rename from src/grpc-advanced/grpc-advanced-bootstrap/src/test/java/dev/caskeleton/grpc/advanced/bootstrap/GrpcAdvancedModuleGuardTest.java rename to src/grpc-advanced/grpc-advanced/src/test/java/dev/caskeleton/grpc/advanced/bootstrap/GrpcAdvancedModuleGuardTest.java diff --git a/src/grpc-advanced/grpc-advanced-diagnostics/src/test/java/dev/caskeleton/grpc/advanced/diagnostics/GrpcChannelDiagnosticsPolicyTest.java b/src/grpc-advanced/grpc-advanced/src/test/java/dev/caskeleton/grpc/advanced/diagnostics/GrpcChannelDiagnosticsPolicyTest.java similarity index 100% rename from src/grpc-advanced/grpc-advanced-diagnostics/src/test/java/dev/caskeleton/grpc/advanced/diagnostics/GrpcChannelDiagnosticsPolicyTest.java rename to src/grpc-advanced/grpc-advanced/src/test/java/dev/caskeleton/grpc/advanced/diagnostics/GrpcChannelDiagnosticsPolicyTest.java diff --git a/src/grpc-advanced/grpc-advanced-diagnostics/src/test/java/dev/caskeleton/grpc/advanced/diagnostics/GrpcDiagnosticsRedactorIdempotenceTest.java b/src/grpc-advanced/grpc-advanced/src/test/java/dev/caskeleton/grpc/advanced/diagnostics/GrpcDiagnosticsRedactorIdempotenceTest.java similarity index 100% rename from src/grpc-advanced/grpc-advanced-diagnostics/src/test/java/dev/caskeleton/grpc/advanced/diagnostics/GrpcDiagnosticsRedactorIdempotenceTest.java rename to src/grpc-advanced/grpc-advanced/src/test/java/dev/caskeleton/grpc/advanced/diagnostics/GrpcDiagnosticsRedactorIdempotenceTest.java diff --git a/src/grpc-advanced/grpc-advanced-edition/src/test/java/dev/caskeleton/grpc/advanced/edition/GrpcEdition2024PolicyTest.java b/src/grpc-advanced/grpc-advanced/src/test/java/dev/caskeleton/grpc/advanced/edition/GrpcEdition2024PolicyTest.java similarity index 82% rename from src/grpc-advanced/grpc-advanced-edition/src/test/java/dev/caskeleton/grpc/advanced/edition/GrpcEdition2024PolicyTest.java rename to src/grpc-advanced/grpc-advanced/src/test/java/dev/caskeleton/grpc/advanced/edition/GrpcEdition2024PolicyTest.java index 79cd037f..00b6f3e3 100644 --- a/src/grpc-advanced/grpc-advanced-edition/src/test/java/dev/caskeleton/grpc/advanced/edition/GrpcEdition2024PolicyTest.java +++ b/src/grpc-advanced/grpc-advanced/src/test/java/dev/caskeleton/grpc/advanced/edition/GrpcEdition2024PolicyTest.java @@ -24,10 +24,10 @@ class GrpcEdition2024PolicyTest { void editionIsOptInPerModule() { GrpcEdition2024Policy policy = GrpcEdition2024Policy.notAdopted(); - assertThat(policy.allowedIn("grpc-proto-contract")).isFalse(); + assertThat(policy.allowedIn("grpc-contract")).isFalse(); assertThat( - new GrpcEdition2024Policy(Set.of("grpc-advanced-edition"), Set.of(), false) - .allowedIn("grpc-advanced-edition")) + new GrpcEdition2024Policy(Set.of("grpc-advanced"), Set.of(), false) + .allowedIn("grpc-advanced")) .isTrue(); } @@ -36,18 +36,14 @@ class GrpcEdition2024PolicyTest { void publicServicesNeedAPromotion() { GrpcEdition2024Policy withoutPromotion = new GrpcEdition2024Policy( - Set.of("grpc-advanced-edition"), - Set.of("hyeonworks.document.v1.DocumentService"), - false); + Set.of("grpc-advanced"), Set.of("caskeleton.document.v1.DocumentService"), false); GrpcEdition2024Policy withPromotion = new GrpcEdition2024Policy( - Set.of("grpc-advanced-edition"), - Set.of("hyeonworks.document.v1.DocumentService"), - true); + Set.of("grpc-advanced"), Set.of("caskeleton.document.v1.DocumentService"), true); - assertThat(withoutPromotion.serviceMayMove("hyeonworks.document.v1.DocumentService")).isFalse(); - assertThat(withPromotion.serviceMayMove("hyeonworks.document.v1.DocumentService")).isTrue(); - assertThat(withoutPromotion.serviceMayMove("hyeonworks.internal.v1.ScratchService")).isTrue(); + assertThat(withoutPromotion.serviceMayMove("caskeleton.document.v1.DocumentService")).isFalse(); + assertThat(withPromotion.serviceMayMove("caskeleton.document.v1.DocumentService")).isTrue(); + assertThat(withoutPromotion.serviceMayMove("caskeleton.internal.v1.ScratchService")).isTrue(); } @Test diff --git a/src/grpc-advanced/grpc-advanced-edition/src/test/java/dev/caskeleton/grpc/advanced/edition/GrpcEdition2026WatchReportTest.java b/src/grpc-advanced/grpc-advanced/src/test/java/dev/caskeleton/grpc/advanced/edition/GrpcEdition2026WatchReportTest.java similarity index 100% rename from src/grpc-advanced/grpc-advanced-edition/src/test/java/dev/caskeleton/grpc/advanced/edition/GrpcEdition2026WatchReportTest.java rename to src/grpc-advanced/grpc-advanced/src/test/java/dev/caskeleton/grpc/advanced/edition/GrpcEdition2026WatchReportTest.java diff --git a/src/grpc-advanced/grpc-advanced-bootstrap/src/test/java/dev/caskeleton/grpc/advanced/release/GrpcAdvancedPromotionGateTest.java b/src/grpc-advanced/grpc-advanced/src/test/java/dev/caskeleton/grpc/advanced/release/GrpcAdvancedPromotionGateTest.java similarity index 100% rename from src/grpc-advanced/grpc-advanced-bootstrap/src/test/java/dev/caskeleton/grpc/advanced/release/GrpcAdvancedPromotionGateTest.java rename to src/grpc-advanced/grpc-advanced/src/test/java/dev/caskeleton/grpc/advanced/release/GrpcAdvancedPromotionGateTest.java diff --git a/src/grpc-advanced/grpc-advanced-resilience/src/test/java/dev/caskeleton/grpc/advanced/resilience/GrpcHedgingEligibilityTest.java b/src/grpc-advanced/grpc-advanced/src/test/java/dev/caskeleton/grpc/advanced/resilience/GrpcHedgingEligibilityTest.java similarity index 96% rename from src/grpc-advanced/grpc-advanced-resilience/src/test/java/dev/caskeleton/grpc/advanced/resilience/GrpcHedgingEligibilityTest.java rename to src/grpc-advanced/grpc-advanced/src/test/java/dev/caskeleton/grpc/advanced/resilience/GrpcHedgingEligibilityTest.java index c0350c4d..f9068f89 100644 --- a/src/grpc-advanced/grpc-advanced-resilience/src/test/java/dev/caskeleton/grpc/advanced/resilience/GrpcHedgingEligibilityTest.java +++ b/src/grpc-advanced/grpc-advanced/src/test/java/dev/caskeleton/grpc/advanced/resilience/GrpcHedgingEligibilityTest.java @@ -17,11 +17,11 @@ import org.junit.jupiter.api.Test; class GrpcHedgingEligibilityTest { private static final GrpcMethodName GET = - GrpcMethodName.parse("hyeonworks.document.v1.DocumentService/GetDocument"); + GrpcMethodName.parse("caskeleton.document.v1.DocumentService/GetDocument"); private static final GrpcMethodName CREATE = - GrpcMethodName.parse("hyeonworks.document.v1.DocumentService/CreateDocument"); + GrpcMethodName.parse("caskeleton.document.v1.DocumentService/CreateDocument"); private static final GrpcMethodName WATCH = - GrpcMethodName.parse("hyeonworks.document.v1.DocumentService/WatchDocuments"); + GrpcMethodName.parse("caskeleton.document.v1.DocumentService/WatchDocuments"); private static final GrpcDeadlineProfile TWO_SECONDS = GrpcDeadlineProfile.of(Duration.ofSeconds(2)); diff --git a/src/grpc-advanced/grpc-advanced-resilience/src/test/java/dev/caskeleton/grpc/advanced/resilience/GrpcLoadBalancerSafetyPolicyTest.java b/src/grpc-advanced/grpc-advanced/src/test/java/dev/caskeleton/grpc/advanced/resilience/GrpcLoadBalancerSafetyPolicyTest.java similarity index 100% rename from src/grpc-advanced/grpc-advanced-resilience/src/test/java/dev/caskeleton/grpc/advanced/resilience/GrpcLoadBalancerSafetyPolicyTest.java rename to src/grpc-advanced/grpc-advanced/src/test/java/dev/caskeleton/grpc/advanced/resilience/GrpcLoadBalancerSafetyPolicyTest.java diff --git a/src/grpc-advanced/grpc-advanced-resilience/src/test/java/dev/caskeleton/grpc/advanced/resilience/GrpcResolverSafetyPolicyTest.java b/src/grpc-advanced/grpc-advanced/src/test/java/dev/caskeleton/grpc/advanced/resilience/GrpcResolverSafetyPolicyTest.java similarity index 100% rename from src/grpc-advanced/grpc-advanced-resilience/src/test/java/dev/caskeleton/grpc/advanced/resilience/GrpcResolverSafetyPolicyTest.java rename to src/grpc-advanced/grpc-advanced/src/test/java/dev/caskeleton/grpc/advanced/resilience/GrpcResolverSafetyPolicyTest.java diff --git a/src/grpc-advanced/grpc-advanced-resilience/src/test/java/dev/caskeleton/grpc/advanced/resilience/GrpcXdsProfileTest.java b/src/grpc-advanced/grpc-advanced/src/test/java/dev/caskeleton/grpc/advanced/resilience/GrpcXdsProfileTest.java similarity index 98% rename from src/grpc-advanced/grpc-advanced-resilience/src/test/java/dev/caskeleton/grpc/advanced/resilience/GrpcXdsProfileTest.java rename to src/grpc-advanced/grpc-advanced/src/test/java/dev/caskeleton/grpc/advanced/resilience/GrpcXdsProfileTest.java index 6d2ffd75..4e899891 100644 --- a/src/grpc-advanced/grpc-advanced-resilience/src/test/java/dev/caskeleton/grpc/advanced/resilience/GrpcXdsProfileTest.java +++ b/src/grpc-advanced/grpc-advanced/src/test/java/dev/caskeleton/grpc/advanced/resilience/GrpcXdsProfileTest.java @@ -30,7 +30,7 @@ class GrpcXdsProfileTest { @Test @DisplayName("an xDS profile requires an xds target, a namespace, mesh retries and mTLS") void anXdsProfileRequiresItsFourConditions() { - assertThat(profile("hyeonworks/documents").target().getScheme()).isEqualTo("xds"); + assertThat(profile("caskeleton/documents").target().getScheme()).isEqualTo("xds"); assertThatThrownBy( () -> new GrpcXdsProfile( diff --git a/src/grpc-advanced/grpc-advanced-streaming/src/test/java/dev/caskeleton/grpc/advanced/streaming/GrpcBidiSequenceTrackerTest.java b/src/grpc-advanced/grpc-advanced/src/test/java/dev/caskeleton/grpc/advanced/streaming/GrpcBidiSequenceTrackerTest.java similarity index 100% rename from src/grpc-advanced/grpc-advanced-streaming/src/test/java/dev/caskeleton/grpc/advanced/streaming/GrpcBidiSequenceTrackerTest.java rename to src/grpc-advanced/grpc-advanced/src/test/java/dev/caskeleton/grpc/advanced/streaming/GrpcBidiSequenceTrackerTest.java diff --git a/src/grpc-advanced/grpc-advanced-streaming/src/test/java/dev/caskeleton/grpc/advanced/streaming/GrpcClientMessageDeduplicatorTest.java b/src/grpc-advanced/grpc-advanced/src/test/java/dev/caskeleton/grpc/advanced/streaming/GrpcClientMessageDeduplicatorTest.java similarity index 100% rename from src/grpc-advanced/grpc-advanced-streaming/src/test/java/dev/caskeleton/grpc/advanced/streaming/GrpcClientMessageDeduplicatorTest.java rename to src/grpc-advanced/grpc-advanced/src/test/java/dev/caskeleton/grpc/advanced/streaming/GrpcClientMessageDeduplicatorTest.java diff --git a/src/grpc-advanced/grpc-advanced-streaming/src/test/java/dev/caskeleton/grpc/advanced/streaming/GrpcClientStreamPolicyTest.java b/src/grpc-advanced/grpc-advanced/src/test/java/dev/caskeleton/grpc/advanced/streaming/GrpcClientStreamPolicyTest.java similarity index 100% rename from src/grpc-advanced/grpc-advanced-streaming/src/test/java/dev/caskeleton/grpc/advanced/streaming/GrpcClientStreamPolicyTest.java rename to src/grpc-advanced/grpc-advanced/src/test/java/dev/caskeleton/grpc/advanced/streaming/GrpcClientStreamPolicyTest.java diff --git a/src/grpc-advanced/grpc-advanced-streaming/src/test/java/dev/caskeleton/grpc/advanced/streaming/GrpcDemandControllerTest.java b/src/grpc-advanced/grpc-advanced/src/test/java/dev/caskeleton/grpc/advanced/streaming/GrpcDemandControllerTest.java similarity index 100% rename from src/grpc-advanced/grpc-advanced-streaming/src/test/java/dev/caskeleton/grpc/advanced/streaming/GrpcDemandControllerTest.java rename to src/grpc-advanced/grpc-advanced/src/test/java/dev/caskeleton/grpc/advanced/streaming/GrpcDemandControllerTest.java diff --git a/src/grpc-advanced/grpc-advanced-edition/src/main/resources/proto/edition2024/compatibility.proto b/src/grpc-advanced/grpc-advanced/src/test/resources/proto/edition2024/compatibility.proto similarity index 90% rename from src/grpc-advanced/grpc-advanced-edition/src/main/resources/proto/edition2024/compatibility.proto rename to src/grpc-advanced/grpc-advanced/src/test/resources/proto/edition2024/compatibility.proto index a01b6524..0791ab30 100644 --- a/src/grpc-advanced/grpc-advanced-edition/src/main/resources/proto/edition2024/compatibility.proto +++ b/src/grpc-advanced/grpc-advanced/src/test/resources/proto/edition2024/compatibility.proto @@ -1,9 +1,9 @@ edition = "2024"; -package hyeonworks.grpc.edition.v1; +package caskeleton.grpc.edition.v1; option java_multiple_files = true; -option java_package = "hyeonworks.grpc.edition.v1.generated"; +option java_package = "caskeleton.grpc.edition.v1.generated"; // The Edition 2024 comparison fixture. // diff --git a/src/grpc-advanced/grpc-advanced-diagnostics/src/test/resources/xds/control-plane-snapshot.json b/src/grpc-advanced/grpc-advanced/src/test/resources/xds/control-plane-snapshot.json similarity index 100% rename from src/grpc-advanced/grpc-advanced-diagnostics/src/test/resources/xds/control-plane-snapshot.json rename to src/grpc-advanced/grpc-advanced/src/test/resources/xds/control-plane-snapshot.json diff --git a/src/grpc/CLAUDE.md b/src/grpc/CLAUDE.md index 604eb246..7bb05da0 100644 --- a/src/grpc/CLAUDE.md +++ b/src/grpc/CLAUDE.md @@ -20,13 +20,8 @@ leaf의 정확한 id는 registry에서 읽는다. | Family | 역할 | 허용 framework | | --- | --- | --- | | `grpc-core-api` | 식별자, method policy, 실행 증거, 실패 모델, deadline, request context, operation ledger port | **Java stdlib만.** io.grpc / Spring / protobuf / DB 타입 금지 | -| `grpc-proto-contract` | `.proto` 스키마 소스와 style/schema 규칙 검증기 | Java stdlib만 | -| `grpc-codegen` | Buf governance, codegen manifest, descriptor 릴리스 아티팩트 | Java stdlib만 | -| `grpc-policy` | validation, context, status/rich error, TLS/credential, deadline/cancellation, retry, idempotency, streaming, size/compression | `io.grpc:grpc-api`, `grpc-stub`. Spring 금지 | -| `grpc-server` | application boundary rule, typed service adapter SPI, interceptor 순서, Netty profile | `io.grpc:grpc-api`, `grpc-stub`. Netty 자체 금지 — profile은 설정 모델이다 | -| `grpc-client` | named channel, runtime generation, typed stub factory, client metadata/credentials | `io.grpc:grpc-api`, `grpc-stub` | -| `grpc-discovery` | Static/DNS resolver, pick_first/round_robin, Kubernetes routing profile | Java stdlib만 | -| `grpc-admin` | health, reflection, drain, secret-free policy snapshot | Java stdlib만 | +| `grpc-contract` | `.proto` 스키마 소스(`src/main/proto`)와 protoc 생성 message. lint/breaking은 Buf(`buf.yaml`, CI job `grpc-proto-buf`) | `protobuf-java`(생성 코드 runtime)만. 규칙을 Java로 재구현하지 않는다 | +| `grpc-runtime` | policy(validation, context, status/rich error, TLS/credential, deadline/cancellation, retry, idempotency, streaming, size/compression) · server(typed service adapter SPI, interceptor 순서, Netty profile) · client(named channel, runtime generation, typed stub factory) · discovery(Static/DNS, pick_first/round_robin, Kubernetes routing) · admin(health, reflection, drain, policy snapshot) | `io.grpc:grpc-api`, `grpc-stub`. Spring·Netty 자체 금지 — Netty profile은 설정 모델이다 | | `grpc-observability` | bounded metric/trace convention | `io.micrometer:micrometer-core`만 | | `grpc-operation-ledger-jpa` | mutation idempotency의 durable 저장 | `jakarta.persistence`, `spring-data-jpa`. **port는 core-api에 있다** | | `grpc-spring-boot-starter` | 조립 경계, typed properties, startup validator | Spring Boot autoconfigure. 여기서만 | @@ -35,7 +30,16 @@ leaf의 정확한 id는 registry에서 읽는다. `grpc-core-api`가 io.grpc를 이름조차 부르지 않는다는 것이 이 family의 핵심 제약이다. 실행 증거와 실패 모델은 "전송이 무엇을 했는가"를 기술하는 계약이고, 그 계약 안에 전송 타입이 들어가면 계약이 전송의 일부가 된다. `GrpcStatusCode`가 io.grpc의 코드를 미러링하는 이유가 이것이고, 양방향 번역은 -`grpc-policy`의 `GrpcStatusMapping`이 단독으로 소유한다. +`grpc-runtime`의 `GrpcStatusMapping`이 단독으로 소유한다. + +기본 전송 한도(메시지 1 MiB, metadata 8 KiB)는 `grpc-core-api`의 `GrpcTransportLimits` 한 곳에 있고, +server profile·named channel profile·method size profile·method policy 기본값·metadata budget이 모두 +그 상수를 쓴다. `GrpcPlatformStartupValidator`는 method의 inbound 한도가 server profile 한도보다 크면 +기동을 거부한다. + +`.proto`의 proto 조직 이름은 `caskeleton`이다(`package caskeleton.grpc.common.v1`, 생성 Java 패키지 +`caskeleton.grpc.common.v1.generated` — 손으로 쓴 `dev.caskeleton`과 겹치지 않는다). 템플릿을 재사용할 +때 바꾸는 방법은 `AGENTS.md` 「템플릿 재사용 체크리스트」에 있다. ## 증거 등급 — testkit이 하나의 leaf인 이유 @@ -72,7 +76,7 @@ capability flag 뒤에 있다. `GrpcPlatformStartupValidator`가 Stable catalog ## Optional build에 있다는 것의 의미 `grpc:*`와 `grpc-advanced:*`는 기본 `ca-skeleton` settings에 include되지 않는다. 따라서 일반 -`:app-bootstrap:build`는 이 18개 project를 configure하지 않는다. 플랫폼 자체는 +`:app-bootstrap:build`는 이 project들을 configure하지 않는다(목록은 registry의 `"build": "optional-grpc"`). 플랫폼 자체는 `./gradlew -p optional-platforms ci`로 검증하고, application runtime에 실제 채택하려면 composition root가 명시적으로 dependency를 가져오는 별도 변경이 필요하다. @@ -85,7 +89,7 @@ soak/performance baseline을 자동으로 의미하지 않는다. 지원 범위 `messaging:*`의 MSG-015(bridge 부재)를 반복하지 않는 것이 이 family의 목표다. 계약상의 경로는 ```text -application-owned port → adapter:inbound:grpc (typed service adapter) → :grpc:grpc-server SPI +application-owned port → adapter:inbound:grpc (typed service adapter) → :grpc:grpc-runtime SPI ``` 이고 `GrpcServiceAdapter`가 그 SPI를 소유한다. inbound adapter가 outbound adapter·persistence에 diff --git a/src/grpc/grpc-admin/build.gradle b/src/grpc/grpc-admin/build.gradle deleted file mode 100644 index fafabf09..00000000 --- a/src/grpc/grpc-admin/build.gradle +++ /dev/null @@ -1,10 +0,0 @@ -plugins { - id 'ca.platform-module' -} - -// Operational surface: the standard health registry, the reflection exposure policy, the drain -// coordinator, and the secret-free runtime policy snapshot an administrator reads. -dependencies { - api project(':grpc:grpc-core-api') - api project(':grpc:grpc-server') -} diff --git a/src/grpc/grpc-admin/gradle.lockfile b/src/grpc/grpc-admin/gradle.lockfile deleted file mode 100644 index 9369e831..00000000 --- a/src/grpc/grpc-admin/gradle.lockfile +++ /dev/null @@ -1,91 +0,0 @@ -# This is a Gradle generated file for dependency locking. -# Manual edits can break the build and are not advised. -# This file is expected to be part of source control. -com.github.ben-manes.caffeine:caffeine:3.2.4=annotationProcessor,testAnnotationProcessor -com.github.kevinstern:software-and-algorithms:1.0=annotationProcessor,testAnnotationProcessor -com.github.spotbugs:spotbugs-annotations:4.10.2=spotbugs -com.github.spotbugs:spotbugs:4.10.2=spotbugs -com.github.stephenc.jcip:jcip-annotations:1.0-1=spotbugs -com.google.auto.service:auto-service-annotations:1.0.1=annotationProcessor,testAnnotationProcessor -com.google.auto.value:auto-value-annotations:1.9=annotationProcessor,testAnnotationProcessor -com.google.auto:auto-common:1.2.2=annotationProcessor,testAnnotationProcessor -com.google.code.findbugs:jsr305:3.0.2=checkstyle,compileClasspath,runtimeClasspath,spotbugs,testCompileClasspath,testRuntimeClasspath -com.google.code.gson:gson:2.13.2=spotbugs -com.google.errorprone:error_prone_annotation:2.49.0=annotationProcessor,testAnnotationProcessor -com.google.errorprone:error_prone_annotations:2.28.0=compileClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath -com.google.errorprone:error_prone_annotations:2.41.0=spotbugs -com.google.errorprone:error_prone_annotations:2.47.0=checkstyle -com.google.errorprone:error_prone_annotations:2.49.0=annotationProcessor,testAnnotationProcessor -com.google.errorprone:error_prone_check_api:2.49.0=annotationProcessor,testAnnotationProcessor -com.google.errorprone:error_prone_core:2.49.0=annotationProcessor,testAnnotationProcessor -com.google.googlejavaformat:google-java-format:1.35.0=annotationProcessor,testAnnotationProcessor -com.google.guava:failureaccess:1.0.2=compileClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath -com.google.guava:failureaccess:1.0.3=annotationProcessor,checkstyle,testAnnotationProcessor -com.google.guava:guava:33.2.1-android=compileClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath -com.google.guava:guava:33.5.0-jre=annotationProcessor,testAnnotationProcessor -com.google.guava:guava:33.6.0-jre=checkstyle -com.google.guava:listenablefuture:9999.0-empty-to-avoid-conflict-with-guava=annotationProcessor,checkstyle,compileClasspath,runtimeClasspath,testAnnotationProcessor,testCompileClasspath,testRuntimeClasspath -com.google.j2objc:j2objc-annotations:3.0.0=compileClasspath,testCompileClasspath -com.google.j2objc:j2objc-annotations:3.1=annotationProcessor,checkstyle,testAnnotationProcessor -com.google.protobuf:protobuf-java:4.33.2=annotationProcessor,testAnnotationProcessor -com.h3xstream.findsecbugs:findsecbugs-plugin:1.14.0=spotbugsPlugins -com.puppycrawl.tools:checkstyle:13.5.0=checkstyle -commons-beanutils:commons-beanutils:1.11.0=checkstyle -commons-collections:commons-collections:3.2.2=checkstyle -commons-io:commons-io:2.21.0=spotbugs -info.picocli:picocli:4.7.7=checkstyle -io.github.eisop:dataflow-errorprone:3.41.0-eisop1=annotationProcessor,testAnnotationProcessor -io.github.java-diff-utils:java-diff-utils:4.12=annotationProcessor,testAnnotationProcessor -io.grpc:grpc-api:1.68.1=compileClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath -io.grpc:grpc-stub:1.68.1=compileClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath -javax.inject:javax.inject:1=annotationProcessor,testAnnotationProcessor -jaxen:jaxen:2.0.6=spotbugs -net.bytebuddy:byte-buddy:1.17.8=testCompileClasspath,testRuntimeClasspath -net.sf.saxon:Saxon-HE:12.9=checkstyle,spotbugs -org.antlr:antlr4-runtime:4.13.2=checkstyle -org.apache.bcel:bcel:6.12.0=spotbugs -org.apache.commons:commons-lang3:3.20.0=checkstyle,spotbugs -org.apache.commons:commons-text:1.15.0=spotbugs -org.apache.commons:commons-text:1.3=checkstyle -org.apache.httpcomponents:httpclient:4.5.13=checkstyle -org.apache.httpcomponents:httpcore:4.4.16=checkstyle -org.apache.logging.log4j:log4j-api:2.25.5=spotbugs -org.apache.logging.log4j:log4j-core:2.25.5=spotbugs -org.apache.maven.doxia:doxia-core:1.12.0=checkstyle -org.apache.maven.doxia:doxia-logging-api:1.12.0=checkstyle -org.apache.maven.doxia:doxia-module-xdoc:1.12.0=checkstyle -org.apache.maven.doxia:doxia-sink-api:1.12.0=checkstyle -org.apache.xbean:xbean-reflect:3.7=checkstyle -org.apiguardian:apiguardian-api:1.1.2=testCompileClasspath -org.assertj:assertj-core:3.27.7=testCompileClasspath,testRuntimeClasspath -org.checkerframework:checker-qual:3.42.0=compileClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath -org.codehaus.plexus:plexus-classworlds:2.6.0=checkstyle -org.codehaus.plexus:plexus-component-annotations:2.1.0=checkstyle -org.codehaus.plexus:plexus-container-default:2.1.0=checkstyle -org.codehaus.plexus:plexus-utils:3.3.0=checkstyle -org.dom4j:dom4j:2.2.0=spotbugs -org.javassist:javassist:3.28.0-GA=checkstyle -org.jspecify:jspecify:1.0.1=annotationProcessor,checkstyle,testAnnotationProcessor,testCompileClasspath -org.junit.jupiter:junit-jupiter-api:6.0.3=testCompileClasspath,testRuntimeClasspath -org.junit.jupiter:junit-jupiter-engine:6.0.3=testRuntimeClasspath -org.junit.jupiter:junit-jupiter-params:6.0.3=testCompileClasspath,testRuntimeClasspath -org.junit.jupiter:junit-jupiter:6.0.3=testCompileClasspath,testRuntimeClasspath -org.junit.platform:junit-platform-commons:6.0.3=testCompileClasspath,testRuntimeClasspath -org.junit.platform:junit-platform-engine:6.0.3=testRuntimeClasspath -org.junit.platform:junit-platform-launcher:6.0.3=testRuntimeClasspath -org.junit:junit-bom:6.0.3=testCompileClasspath,testRuntimeClasspath -org.junit:junit-bom:6.1.0=spotbugs -org.mockito:mockito-core:5.20.0=mockitoAgent -org.opentest4j:opentest4j:1.3.0=testCompileClasspath,testRuntimeClasspath -org.ow2.asm:asm-analysis:9.10.1=spotbugs -org.ow2.asm:asm-commons:9.10.1=spotbugs -org.ow2.asm:asm-tree:9.10.1=spotbugs -org.ow2.asm:asm-util:9.10.1=spotbugs -org.ow2.asm:asm:9.10.1=spotbugs -org.pcollections:pcollections:4.0.1=annotationProcessor,testAnnotationProcessor -org.reflections:reflections:0.10.2=checkstyle -org.slf4j:slf4j-api:2.0.18=spotbugs,spotbugsSlf4j -org.slf4j:slf4j-simple:2.0.17=spotbugsSlf4j -org.slf4j:slf4j-simple:2.0.18=checkstyle -org.xmlresolver:xmlresolver:5.3.3=checkstyle,spotbugs -empty= diff --git a/src/grpc/grpc-client/build.gradle b/src/grpc/grpc-client/build.gradle deleted file mode 100644 index 3ea3d8d4..00000000 --- a/src/grpc/grpc-client/build.gradle +++ /dev/null @@ -1,14 +0,0 @@ -plugins { - id 'ca.grpc-platform-module' -} - -// Client runtime: named channel profiles, channel runtime generations with drain, the typed stub -// factory that refuses to hand a raw Channel to application code, and client metadata/credentials. - -dependencies { - api project(':grpc:grpc-core-api') - api project(':grpc:grpc-policy') - - api "io.grpc:grpc-api" - api "io.grpc:grpc-stub" -} diff --git a/src/grpc/grpc-client/gradle.lockfile b/src/grpc/grpc-client/gradle.lockfile deleted file mode 100644 index 9369e831..00000000 --- a/src/grpc/grpc-client/gradle.lockfile +++ /dev/null @@ -1,91 +0,0 @@ -# This is a Gradle generated file for dependency locking. -# Manual edits can break the build and are not advised. -# This file is expected to be part of source control. -com.github.ben-manes.caffeine:caffeine:3.2.4=annotationProcessor,testAnnotationProcessor -com.github.kevinstern:software-and-algorithms:1.0=annotationProcessor,testAnnotationProcessor -com.github.spotbugs:spotbugs-annotations:4.10.2=spotbugs -com.github.spotbugs:spotbugs:4.10.2=spotbugs -com.github.stephenc.jcip:jcip-annotations:1.0-1=spotbugs -com.google.auto.service:auto-service-annotations:1.0.1=annotationProcessor,testAnnotationProcessor -com.google.auto.value:auto-value-annotations:1.9=annotationProcessor,testAnnotationProcessor -com.google.auto:auto-common:1.2.2=annotationProcessor,testAnnotationProcessor -com.google.code.findbugs:jsr305:3.0.2=checkstyle,compileClasspath,runtimeClasspath,spotbugs,testCompileClasspath,testRuntimeClasspath -com.google.code.gson:gson:2.13.2=spotbugs -com.google.errorprone:error_prone_annotation:2.49.0=annotationProcessor,testAnnotationProcessor -com.google.errorprone:error_prone_annotations:2.28.0=compileClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath -com.google.errorprone:error_prone_annotations:2.41.0=spotbugs -com.google.errorprone:error_prone_annotations:2.47.0=checkstyle -com.google.errorprone:error_prone_annotations:2.49.0=annotationProcessor,testAnnotationProcessor -com.google.errorprone:error_prone_check_api:2.49.0=annotationProcessor,testAnnotationProcessor -com.google.errorprone:error_prone_core:2.49.0=annotationProcessor,testAnnotationProcessor -com.google.googlejavaformat:google-java-format:1.35.0=annotationProcessor,testAnnotationProcessor -com.google.guava:failureaccess:1.0.2=compileClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath -com.google.guava:failureaccess:1.0.3=annotationProcessor,checkstyle,testAnnotationProcessor -com.google.guava:guava:33.2.1-android=compileClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath -com.google.guava:guava:33.5.0-jre=annotationProcessor,testAnnotationProcessor -com.google.guava:guava:33.6.0-jre=checkstyle -com.google.guava:listenablefuture:9999.0-empty-to-avoid-conflict-with-guava=annotationProcessor,checkstyle,compileClasspath,runtimeClasspath,testAnnotationProcessor,testCompileClasspath,testRuntimeClasspath -com.google.j2objc:j2objc-annotations:3.0.0=compileClasspath,testCompileClasspath -com.google.j2objc:j2objc-annotations:3.1=annotationProcessor,checkstyle,testAnnotationProcessor -com.google.protobuf:protobuf-java:4.33.2=annotationProcessor,testAnnotationProcessor -com.h3xstream.findsecbugs:findsecbugs-plugin:1.14.0=spotbugsPlugins -com.puppycrawl.tools:checkstyle:13.5.0=checkstyle -commons-beanutils:commons-beanutils:1.11.0=checkstyle -commons-collections:commons-collections:3.2.2=checkstyle -commons-io:commons-io:2.21.0=spotbugs -info.picocli:picocli:4.7.7=checkstyle -io.github.eisop:dataflow-errorprone:3.41.0-eisop1=annotationProcessor,testAnnotationProcessor -io.github.java-diff-utils:java-diff-utils:4.12=annotationProcessor,testAnnotationProcessor -io.grpc:grpc-api:1.68.1=compileClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath -io.grpc:grpc-stub:1.68.1=compileClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath -javax.inject:javax.inject:1=annotationProcessor,testAnnotationProcessor -jaxen:jaxen:2.0.6=spotbugs -net.bytebuddy:byte-buddy:1.17.8=testCompileClasspath,testRuntimeClasspath -net.sf.saxon:Saxon-HE:12.9=checkstyle,spotbugs -org.antlr:antlr4-runtime:4.13.2=checkstyle -org.apache.bcel:bcel:6.12.0=spotbugs -org.apache.commons:commons-lang3:3.20.0=checkstyle,spotbugs -org.apache.commons:commons-text:1.15.0=spotbugs -org.apache.commons:commons-text:1.3=checkstyle -org.apache.httpcomponents:httpclient:4.5.13=checkstyle -org.apache.httpcomponents:httpcore:4.4.16=checkstyle -org.apache.logging.log4j:log4j-api:2.25.5=spotbugs -org.apache.logging.log4j:log4j-core:2.25.5=spotbugs -org.apache.maven.doxia:doxia-core:1.12.0=checkstyle -org.apache.maven.doxia:doxia-logging-api:1.12.0=checkstyle -org.apache.maven.doxia:doxia-module-xdoc:1.12.0=checkstyle -org.apache.maven.doxia:doxia-sink-api:1.12.0=checkstyle -org.apache.xbean:xbean-reflect:3.7=checkstyle -org.apiguardian:apiguardian-api:1.1.2=testCompileClasspath -org.assertj:assertj-core:3.27.7=testCompileClasspath,testRuntimeClasspath -org.checkerframework:checker-qual:3.42.0=compileClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath -org.codehaus.plexus:plexus-classworlds:2.6.0=checkstyle -org.codehaus.plexus:plexus-component-annotations:2.1.0=checkstyle -org.codehaus.plexus:plexus-container-default:2.1.0=checkstyle -org.codehaus.plexus:plexus-utils:3.3.0=checkstyle -org.dom4j:dom4j:2.2.0=spotbugs -org.javassist:javassist:3.28.0-GA=checkstyle -org.jspecify:jspecify:1.0.1=annotationProcessor,checkstyle,testAnnotationProcessor,testCompileClasspath -org.junit.jupiter:junit-jupiter-api:6.0.3=testCompileClasspath,testRuntimeClasspath -org.junit.jupiter:junit-jupiter-engine:6.0.3=testRuntimeClasspath -org.junit.jupiter:junit-jupiter-params:6.0.3=testCompileClasspath,testRuntimeClasspath -org.junit.jupiter:junit-jupiter:6.0.3=testCompileClasspath,testRuntimeClasspath -org.junit.platform:junit-platform-commons:6.0.3=testCompileClasspath,testRuntimeClasspath -org.junit.platform:junit-platform-engine:6.0.3=testRuntimeClasspath -org.junit.platform:junit-platform-launcher:6.0.3=testRuntimeClasspath -org.junit:junit-bom:6.0.3=testCompileClasspath,testRuntimeClasspath -org.junit:junit-bom:6.1.0=spotbugs -org.mockito:mockito-core:5.20.0=mockitoAgent -org.opentest4j:opentest4j:1.3.0=testCompileClasspath,testRuntimeClasspath -org.ow2.asm:asm-analysis:9.10.1=spotbugs -org.ow2.asm:asm-commons:9.10.1=spotbugs -org.ow2.asm:asm-tree:9.10.1=spotbugs -org.ow2.asm:asm-util:9.10.1=spotbugs -org.ow2.asm:asm:9.10.1=spotbugs -org.pcollections:pcollections:4.0.1=annotationProcessor,testAnnotationProcessor -org.reflections:reflections:0.10.2=checkstyle -org.slf4j:slf4j-api:2.0.18=spotbugs,spotbugsSlf4j -org.slf4j:slf4j-simple:2.0.17=spotbugsSlf4j -org.slf4j:slf4j-simple:2.0.18=checkstyle -org.xmlresolver:xmlresolver:5.3.3=checkstyle,spotbugs -empty= diff --git a/src/grpc/grpc-codegen/build.gradle b/src/grpc/grpc-codegen/build.gradle deleted file mode 100644 index f45471ab..00000000 --- a/src/grpc/grpc-codegen/build.gradle +++ /dev/null @@ -1,14 +0,0 @@ -plugins { - id 'ca.platform-module' -} - -// Contract governance: Buf format/lint/breaking policy, the single codegen owner declaration, and -// the descriptor/schema-hash release artifact with its consumer-compile gate. -// -// The Buf rules are implemented here rather than shelled out to the Buf CLI (adaptation D5): the -// CLI is not present in this toolchain, and a gate that silently no-ops when a binary is missing is -// worse than one that computes the same judgement from the committed schema. -dependencies { - api project(':grpc:grpc-core-api') - api project(':grpc:grpc-proto-contract') -} diff --git a/src/grpc/grpc-codegen/gradle.lockfile b/src/grpc/grpc-codegen/gradle.lockfile deleted file mode 100644 index e2c95854..00000000 --- a/src/grpc/grpc-codegen/gradle.lockfile +++ /dev/null @@ -1,84 +0,0 @@ -# This is a Gradle generated file for dependency locking. -# Manual edits can break the build and are not advised. -# This file is expected to be part of source control. -com.github.ben-manes.caffeine:caffeine:3.2.4=annotationProcessor,testAnnotationProcessor -com.github.kevinstern:software-and-algorithms:1.0=annotationProcessor,testAnnotationProcessor -com.github.spotbugs:spotbugs-annotations:4.10.2=spotbugs -com.github.spotbugs:spotbugs:4.10.2=spotbugs -com.github.stephenc.jcip:jcip-annotations:1.0-1=spotbugs -com.google.auto.service:auto-service-annotations:1.0.1=annotationProcessor,testAnnotationProcessor -com.google.auto.value:auto-value-annotations:1.9=annotationProcessor,testAnnotationProcessor -com.google.auto:auto-common:1.2.2=annotationProcessor,testAnnotationProcessor -com.google.code.findbugs:jsr305:3.0.2=checkstyle,spotbugs -com.google.code.gson:gson:2.13.2=spotbugs -com.google.errorprone:error_prone_annotation:2.49.0=annotationProcessor,testAnnotationProcessor -com.google.errorprone:error_prone_annotations:2.41.0=spotbugs -com.google.errorprone:error_prone_annotations:2.47.0=checkstyle -com.google.errorprone:error_prone_annotations:2.49.0=annotationProcessor,testAnnotationProcessor -com.google.errorprone:error_prone_check_api:2.49.0=annotationProcessor,testAnnotationProcessor -com.google.errorprone:error_prone_core:2.49.0=annotationProcessor,testAnnotationProcessor -com.google.googlejavaformat:google-java-format:1.35.0=annotationProcessor,testAnnotationProcessor -com.google.guava:failureaccess:1.0.3=annotationProcessor,checkstyle,testAnnotationProcessor -com.google.guava:guava:33.5.0-jre=annotationProcessor,testAnnotationProcessor -com.google.guava:guava:33.6.0-jre=checkstyle -com.google.guava:listenablefuture:9999.0-empty-to-avoid-conflict-with-guava=annotationProcessor,checkstyle,testAnnotationProcessor -com.google.j2objc:j2objc-annotations:3.1=annotationProcessor,checkstyle,testAnnotationProcessor -com.google.protobuf:protobuf-java:4.33.2=annotationProcessor,testAnnotationProcessor -com.h3xstream.findsecbugs:findsecbugs-plugin:1.14.0=spotbugsPlugins -com.puppycrawl.tools:checkstyle:13.5.0=checkstyle -commons-beanutils:commons-beanutils:1.11.0=checkstyle -commons-collections:commons-collections:3.2.2=checkstyle -commons-io:commons-io:2.21.0=spotbugs -info.picocli:picocli:4.7.7=checkstyle -io.github.eisop:dataflow-errorprone:3.41.0-eisop1=annotationProcessor,testAnnotationProcessor -io.github.java-diff-utils:java-diff-utils:4.12=annotationProcessor,testAnnotationProcessor -javax.inject:javax.inject:1=annotationProcessor,testAnnotationProcessor -jaxen:jaxen:2.0.6=spotbugs -net.bytebuddy:byte-buddy:1.17.8=testCompileClasspath,testRuntimeClasspath -net.sf.saxon:Saxon-HE:12.9=checkstyle,spotbugs -org.antlr:antlr4-runtime:4.13.2=checkstyle -org.apache.bcel:bcel:6.12.0=spotbugs -org.apache.commons:commons-lang3:3.20.0=checkstyle,spotbugs -org.apache.commons:commons-text:1.15.0=spotbugs -org.apache.commons:commons-text:1.3=checkstyle -org.apache.httpcomponents:httpclient:4.5.13=checkstyle -org.apache.httpcomponents:httpcore:4.4.16=checkstyle -org.apache.logging.log4j:log4j-api:2.25.5=spotbugs -org.apache.logging.log4j:log4j-core:2.25.5=spotbugs -org.apache.maven.doxia:doxia-core:1.12.0=checkstyle -org.apache.maven.doxia:doxia-logging-api:1.12.0=checkstyle -org.apache.maven.doxia:doxia-module-xdoc:1.12.0=checkstyle -org.apache.maven.doxia:doxia-sink-api:1.12.0=checkstyle -org.apache.xbean:xbean-reflect:3.7=checkstyle -org.apiguardian:apiguardian-api:1.1.2=testCompileClasspath -org.assertj:assertj-core:3.27.7=testCompileClasspath,testRuntimeClasspath -org.codehaus.plexus:plexus-classworlds:2.6.0=checkstyle -org.codehaus.plexus:plexus-component-annotations:2.1.0=checkstyle -org.codehaus.plexus:plexus-container-default:2.1.0=checkstyle -org.codehaus.plexus:plexus-utils:3.3.0=checkstyle -org.dom4j:dom4j:2.2.0=spotbugs -org.javassist:javassist:3.28.0-GA=checkstyle -org.jspecify:jspecify:1.0.1=annotationProcessor,checkstyle,testAnnotationProcessor,testCompileClasspath -org.junit.jupiter:junit-jupiter-api:6.0.3=testCompileClasspath,testRuntimeClasspath -org.junit.jupiter:junit-jupiter-engine:6.0.3=testRuntimeClasspath -org.junit.jupiter:junit-jupiter-params:6.0.3=testCompileClasspath,testRuntimeClasspath -org.junit.jupiter:junit-jupiter:6.0.3=testCompileClasspath,testRuntimeClasspath -org.junit.platform:junit-platform-commons:6.0.3=testCompileClasspath,testRuntimeClasspath -org.junit.platform:junit-platform-engine:6.0.3=testRuntimeClasspath -org.junit.platform:junit-platform-launcher:6.0.3=testRuntimeClasspath -org.junit:junit-bom:6.0.3=testCompileClasspath,testRuntimeClasspath -org.junit:junit-bom:6.1.0=spotbugs -org.mockito:mockito-core:5.20.0=mockitoAgent -org.opentest4j:opentest4j:1.3.0=testCompileClasspath,testRuntimeClasspath -org.ow2.asm:asm-analysis:9.10.1=spotbugs -org.ow2.asm:asm-commons:9.10.1=spotbugs -org.ow2.asm:asm-tree:9.10.1=spotbugs -org.ow2.asm:asm-util:9.10.1=spotbugs -org.ow2.asm:asm:9.10.1=spotbugs -org.pcollections:pcollections:4.0.1=annotationProcessor,testAnnotationProcessor -org.reflections:reflections:0.10.2=checkstyle -org.slf4j:slf4j-api:2.0.18=spotbugs,spotbugsSlf4j -org.slf4j:slf4j-simple:2.0.17=spotbugsSlf4j -org.slf4j:slf4j-simple:2.0.18=checkstyle -org.xmlresolver:xmlresolver:5.3.3=checkstyle,spotbugs -empty=compileClasspath,runtimeClasspath diff --git a/src/grpc/grpc-codegen/src/main/java/dev/caskeleton/grpc/codegen/GrpcBreakingCategory.java b/src/grpc/grpc-codegen/src/main/java/dev/caskeleton/grpc/codegen/GrpcBreakingCategory.java deleted file mode 100644 index cdff6618..00000000 --- a/src/grpc/grpc-codegen/src/main/java/dev/caskeleton/grpc/codegen/GrpcBreakingCategory.java +++ /dev/null @@ -1,43 +0,0 @@ -package dev.caskeleton.grpc.codegen; - -/** - * The Buf breaking-change categories, ordered from strictest to loosest. - * - *

The Stable gate is {@link #FILE}, and the reason is the pair of properties below: only FILE - * and PACKAGE detect a change that keeps the wire format identical while breaking every generated - * consumer's compile. A team that gates on WIRE ships a field rename, watches its own integration - * tests pass, and finds out at the consumer's next build. - */ -public enum GrpcBreakingCategory { - /** Strictest: also catches file moves, package moves and Java option changes. */ - FILE(true, true), - /** Catches type and field source breaks within a package, but not a file move. */ - PACKAGE(true, false), - /** Wire plus JSON name compatibility. Source breaks pass. */ - WIRE_JSON(false, false), - /** Binary wire compatibility only. Source breaks pass. */ - WIRE(false, false); - - private final boolean detectsSourceBreak; - private final boolean detectsFileMove; - - GrpcBreakingCategory(boolean detectsSourceBreak, boolean detectsFileMove) { - this.detectsSourceBreak = detectsSourceBreak; - this.detectsFileMove = detectsFileMove; - } - - /** Whether this category fails a change that stops a generated consumer compiling. */ - public boolean detectsSourceBreak() { - return detectsSourceBreak; - } - - /** Whether this category fails a file or package relocation. */ - public boolean detectsFileMove() { - return detectsFileMove; - } - - /** The category the Stable public API is gated on. */ - public static GrpcBreakingCategory stableGate() { - return FILE; - } -} diff --git a/src/grpc/grpc-codegen/src/main/java/dev/caskeleton/grpc/codegen/GrpcBufPolicy.java b/src/grpc/grpc-codegen/src/main/java/dev/caskeleton/grpc/codegen/GrpcBufPolicy.java deleted file mode 100644 index 113fd662..00000000 --- a/src/grpc/grpc-codegen/src/main/java/dev/caskeleton/grpc/codegen/GrpcBufPolicy.java +++ /dev/null @@ -1,75 +0,0 @@ -package dev.caskeleton.grpc.codegen; - -import java.util.List; -import java.util.Set; - -/** - * The schema governance this repository runs, as a value the build and the tests both read. - * - *

Buf's CLI is not part of this toolchain (adaptation D5), so the four lifecycle task names - * below are the contract a CI environment fulfils and {@code GrpcProtoContractValidator} is what - * actually fails a build here. Keeping the task names in the policy rather than only in a workflow - * file means a missing stage is a test failure rather than a stage nobody noticed was gone. - */ -public record GrpcBufPolicy( - GrpcBreakingCategory breakingCategory, - boolean formatEnforced, - boolean lintEnforced, - GrpcSchemaBaseline baseline) { - - /** The lifecycle stages a compliant schema pipeline runs, in order. */ - private static final List REQUIRED_TASKS = - List.of("bufFormatCheck", "bufLint", "bufBuild", "bufBreaking"); - - /** Refuses a policy that would let a source break through. */ - public GrpcBufPolicy { - if (breakingCategory == null) { - throw new IllegalArgumentException("a Buf policy needs a breaking category"); - } - if (baseline == null) { - throw new IllegalArgumentException( - "a Buf policy needs a released baseline to compare against"); - } - if (!breakingCategory.detectsSourceBreak()) { - throw new IllegalArgumentException( - "the Stable public API may not be gated on " - + breakingCategory - + ": wire compatibility alone lets a rename through as compatible while every " - + "generated consumer stops compiling"); - } - if (!formatEnforced || !lintEnforced) { - throw new IllegalArgumentException( - "format and lint are not optional; a schema that is not linted is a schema whose style " - + "rules are whatever the last author preferred"); - } - } - - /** The Stable policy: FILE breaking, format and lint enforced. */ - public static GrpcBufPolicy stable(GrpcSchemaBaseline baseline) { - return new GrpcBufPolicy(GrpcBreakingCategory.stableGate(), true, true, baseline); - } - - /** The lifecycle task names a compliant pipeline registers. */ - public static List requiredTasks() { - return REQUIRED_TASKS; - } - - /** - * The task names missing from {@code registeredTasks}. - * - * @return an empty set when the pipeline is complete - */ - public static Set missingTasks(Set registeredTasks) { - if (registeredTasks == null) { - throw new IllegalArgumentException("the registered task set must not be null"); - } - return REQUIRED_TASKS.stream() - .filter(task -> !registeredTasks.contains(task)) - .collect(java.util.stream.Collectors.toUnmodifiableSet()); - } - - /** Whether a candidate schema hash may be released without a breaking review. */ - public boolean unchangedFromBaseline(String candidateSchemaHash) { - return baseline.matches(candidateSchemaHash); - } -} diff --git a/src/grpc/grpc-codegen/src/main/java/dev/caskeleton/grpc/codegen/GrpcCodegenManifest.java b/src/grpc/grpc-codegen/src/main/java/dev/caskeleton/grpc/codegen/GrpcCodegenManifest.java deleted file mode 100644 index 38fb194b..00000000 --- a/src/grpc/grpc-codegen/src/main/java/dev/caskeleton/grpc/codegen/GrpcCodegenManifest.java +++ /dev/null @@ -1,81 +0,0 @@ -package dev.caskeleton.grpc.codegen; - -/** - * Who generates Java from the schema, with what versions, into where. - * - *

One owner, named. Two generators for one schema is the state in which a type exists twice with - * different options and the classpath decides which one a consumer gets; refusing a second owner is - * cheaper than diagnosing that. - * - *

Both version sources are required to be the managed BOM rather than a literal. A pinned - * protobuf version beside a BOM-managed gRPC version is how the runtime and the generator drift - * into a combination nobody tested, and the symptom is a {@code NoSuchMethodError} in generated - * code. - */ -public record GrpcCodegenManifest( - String codegenOwner, - String protobufVersionSource, - String grpcJavaVersionSource, - GrpcCodegenOutput output, - GrpcGeneratedPackagePolicy packagePolicy) { - - /** The only accepted version source: whatever the build's managed platform resolves. */ - public static final String MANAGED_VERSION_SOURCE = "managed-platform"; - - /** Refuses a second owner, a literal version, or overlapping package namespaces. */ - public GrpcCodegenManifest { - if (codegenOwner == null || codegenOwner.isBlank()) { - throw new IllegalArgumentException("code generation needs exactly one named owner"); - } - if (output == null || packagePolicy == null) { - throw new IllegalArgumentException("a codegen manifest needs an output and a package policy"); - } - requireManagedVersion(protobufVersionSource, "protobuf"); - requireManagedVersion(grpcJavaVersionSource, "grpc-java"); - packagePolicy.requireDisjoint(); - } - - private static void requireManagedVersion(String source, String what) { - if (!MANAGED_VERSION_SOURCE.equals(source)) { - throw new IllegalArgumentException( - what - + " version must come from the managed platform, not from a literal declaration; got '" - + source - + "'. A pinned generator beside a managed runtime is a combination nobody tested."); - } - } - - /** - * This repository's manifest. - * - *

The owner is the Gradle protobuf plugin. It does not run in this build yet — adaptation D6 - * records why, and this manifest is what a future decision to turn it on has to satisfy rather - * than replace. - */ - public static GrpcCodegenManifest caSkeleton() { - return new GrpcCodegenManifest( - "gradle-protobuf-plugin", - MANAGED_VERSION_SOURCE, - MANAGED_VERSION_SOURCE, - GrpcCodegenOutput.standard(), - new GrpcGeneratedPackagePolicy( - java.util.Set.of("dev.caskeleton"), - java.util.Set.of("hyeonworks.grpc.common.v1.generated"))); - } - - /** - * Fails when a second generator claims the same schema. - * - * @throws IllegalStateException when {@code otherOwner} is not this manifest's owner - */ - public void requireSoleOwner(String otherOwner) { - if (!codegenOwner.equals(otherOwner)) { - throw new IllegalStateException( - "Java code generation for this schema is owned by '" - + codegenOwner - + "'; '" - + otherOwner - + "' may not also generate it"); - } - } -} diff --git a/src/grpc/grpc-codegen/src/main/java/dev/caskeleton/grpc/codegen/GrpcCodegenOutput.java b/src/grpc/grpc-codegen/src/main/java/dev/caskeleton/grpc/codegen/GrpcCodegenOutput.java deleted file mode 100644 index 719efddc..00000000 --- a/src/grpc/grpc-codegen/src/main/java/dev/caskeleton/grpc/codegen/GrpcCodegenOutput.java +++ /dev/null @@ -1,58 +0,0 @@ -package dev.caskeleton.grpc.codegen; - -/** - * Where generated artifacts land. - * - *

Everything here is required to be inside a build directory. A generator that writes into a - * source tree produces files that get committed, then edited, then silently reverted by the next - * regeneration — and the diff that reverts them looks like the generator working correctly. - */ -public record GrpcCodegenOutput( - String javaOutputDirectory, - String grpcJavaOutputDirectory, - String descriptorSetPath, - boolean includeSourceInfo) { - - private static final String BUILD_ROOT = "build/"; - - /** Requires every path to be build-directory relative. */ - public GrpcCodegenOutput { - requireBuildRelative(javaOutputDirectory, "java output directory"); - requireBuildRelative(grpcJavaOutputDirectory, "grpc-java output directory"); - requireBuildRelative(descriptorSetPath, "descriptor set path"); - if (!descriptorSetPath.endsWith(".desc") && !descriptorSetPath.endsWith(".binpb")) { - throw new IllegalArgumentException( - "a descriptor set is a serialized FileDescriptorSet; expected a .desc or .binpb path, got '" - + descriptorSetPath - + "'"); - } - } - - private static void requireBuildRelative(String path, String what) { - if (path == null || path.isBlank()) { - throw new IllegalArgumentException(what + " must not be blank"); - } - if (path.startsWith("/") || path.contains("..")) { - throw new IllegalArgumentException( - what + " must be a project-relative path without '..'; got '" + path + "'"); - } - if (!path.startsWith(BUILD_ROOT)) { - throw new IllegalArgumentException( - what - + " must be under '" - + BUILD_ROOT - + "'; generated sources in a source tree get committed and then edited. Got '" - + path - + "'"); - } - } - - /** This repository's layout. */ - public static GrpcCodegenOutput standard() { - return new GrpcCodegenOutput( - "build/generated/source/proto/main/java", - "build/generated/source/proto/main/grpc", - "build/generated/descriptor/stable-schema.desc", - true); - } -} diff --git a/src/grpc/grpc-codegen/src/main/java/dev/caskeleton/grpc/codegen/GrpcConsumerFixture.java b/src/grpc/grpc-codegen/src/main/java/dev/caskeleton/grpc/codegen/GrpcConsumerFixture.java deleted file mode 100644 index 189cbfef..00000000 --- a/src/grpc/grpc-codegen/src/main/java/dev/caskeleton/grpc/codegen/GrpcConsumerFixture.java +++ /dev/null @@ -1,158 +0,0 @@ -package dev.caskeleton.grpc.codegen; - -import java.util.ArrayList; -import java.util.LinkedHashSet; -import java.util.List; -import java.util.Set; - -/** - * A previously released consumer, described by exactly what it compiles against. - * - *

This is the check a wire-compatibility gate cannot make. A field rename, a service move to a - * new package, or a change to {@code java_package} keeps every serialized message valid and stops - * every generated client compiling — and the only way to notice before the consumer does is to keep - * a record of what the consumer names and compare a candidate schema against it. - */ -public record GrpcConsumerFixture( - String name, - String schemaVersion, - Set requiredServicePaths, - Set requiredMethodPaths, - Set requiredJavaPackages) { - - /** What kind of source break a consumer hit. Reported separately, never merged into one count. */ - public enum BreakKind { - /** A service the consumer names is gone or moved. */ - SERVICE_PATH, - /** A method the consumer calls is gone or renamed. */ - METHOD_PATH, - /** The Java package the consumer imports from moved. */ - JAVA_PACKAGE - } - - /** One thing a consumer needs that a candidate schema no longer provides. */ - public record SourceBreak(BreakKind kind, String missing) { - /** Requires both halves. */ - public SourceBreak { - if (kind == null || missing == null || missing.isBlank()) { - throw new IllegalArgumentException("a source break names its kind and what went missing"); - } - } - } - - /** Copies every requirement set. */ - public GrpcConsumerFixture { - if (name == null || name.isBlank()) { - throw new IllegalArgumentException("a consumer fixture needs a name"); - } - if (schemaVersion == null || schemaVersion.isBlank()) { - throw new IllegalArgumentException( - "a consumer fixture names the schema version it was built against"); - } - if (requiredServicePaths == null - || requiredMethodPaths == null - || requiredJavaPackages == null) { - throw new IllegalArgumentException("a consumer fixture states all three requirement sets"); - } - requiredServicePaths = Set.copyOf(requiredServicePaths); - requiredMethodPaths = Set.copyOf(requiredMethodPaths); - requiredJavaPackages = Set.copyOf(requiredJavaPackages); - } - - /** - * Derives a fixture from a released consumer's own source. - * - *

Read from the consumer rather than declared beside it, because a hand-written requirement - * list is a second copy of what the client already says and the copy is the one that stops being - * updated. Three rules, all mechanical: - * - *

    - *
  • a generated Java package is any package a {@code fixture} class imports from; - *
  • a service is a {@code Grpc} import, mapped back to {@code .} with - * the generated-package suffix removed; - *
  • a method is a {@code stub.(} call, mapped to {@code /}. - *
- * - *

It is an approximation of compiling the fixture, which is what the plan asks for and what - * ADR-GRPC-002 records this repository cannot do yet. It is a useful approximation because it - * fails on exactly the changes a compile would fail on: a renamed method, a moved service, a - * relocated Java package. - * - * @param generatedPackageSuffix the segment appended to a proto package for generated code, e.g. - * {@code generated}; removed to recover the schema's own service path - */ - public static GrpcConsumerFixture fromJavaSource( - String name, String schemaVersion, String javaSource, String generatedPackageSuffix) { - if (javaSource == null || javaSource.isBlank()) { - throw new IllegalArgumentException("a consumer fixture needs its source text"); - } - if (generatedPackageSuffix == null || generatedPackageSuffix.isBlank()) { - throw new IllegalArgumentException("the generated package suffix is required"); - } - - java.util.Set javaPackages = new LinkedHashSet<>(); - java.util.Set servicePaths = new LinkedHashSet<>(); - java.util.regex.Matcher imports = - java.util.regex.Pattern.compile( - "^\\s*import\\s+([\\w.]+)\\.(\\w+);", java.util.regex.Pattern.MULTILINE) - .matcher(javaSource); - while (imports.find()) { - String importedPackage = imports.group(1); - String importedType = imports.group(2); - if (!importedPackage.endsWith("." + generatedPackageSuffix)) { - continue; - } - javaPackages.add(importedPackage); - if (importedType.endsWith("Grpc")) { - String protoPackage = - importedPackage.substring( - 0, importedPackage.length() - generatedPackageSuffix.length() - 1); - servicePaths.add( - protoPackage - + "." - + importedType.substring(0, importedType.length() - "Grpc".length())); - } - } - - java.util.Set methodPaths = new LinkedHashSet<>(); - java.util.regex.Matcher calls = - java.util.regex.Pattern.compile("\\bstub\\.(\\w+)\\s*\\(").matcher(javaSource); - while (calls.find()) { - String method = calls.group(1); - String upperCamel = Character.toUpperCase(method.charAt(0)) + method.substring(1); - servicePaths.forEach(service -> methodPaths.add(service + "/" + upperCamel)); - } - - if (servicePaths.isEmpty() || methodPaths.isEmpty()) { - throw new IllegalArgumentException( - "no service or method could be derived from '" - + name - + "'; a fixture that requires nothing cannot detect a break"); - } - return new GrpcConsumerFixture(name, schemaVersion, servicePaths, methodPaths, javaPackages); - } - - /** - * What this consumer would fail to compile against {@code candidate}. - * - * @return an empty list when the consumer still compiles - */ - public List breaksAgainst(GrpcDescriptorArtifact candidate) { - if (candidate == null) { - throw new IllegalArgumentException("a compatibility check needs a candidate artifact"); - } - List breaks = new ArrayList<>(); - collect(breaks, BreakKind.SERVICE_PATH, requiredServicePaths, candidate.servicePaths()); - collect(breaks, BreakKind.METHOD_PATH, requiredMethodPaths, candidate.methodPaths()); - collect( - breaks, BreakKind.JAVA_PACKAGE, requiredJavaPackages, candidate.generatedJavaPackages()); - return List.copyOf(breaks); - } - - private static void collect( - List breaks, BreakKind kind, Set required, Set available) { - Set missing = new LinkedHashSet<>(required); - missing.removeAll(available); - missing.stream().sorted().forEach(entry -> breaks.add(new SourceBreak(kind, entry))); - } -} diff --git a/src/grpc/grpc-codegen/src/main/java/dev/caskeleton/grpc/codegen/GrpcDescriptorArtifact.java b/src/grpc/grpc-codegen/src/main/java/dev/caskeleton/grpc/codegen/GrpcDescriptorArtifact.java deleted file mode 100644 index c6a1c39f..00000000 --- a/src/grpc/grpc-codegen/src/main/java/dev/caskeleton/grpc/codegen/GrpcDescriptorArtifact.java +++ /dev/null @@ -1,59 +0,0 @@ -package dev.caskeleton.grpc.codegen; - -import java.util.Set; - -/** - * One immutable release of the schema: what it contains, and the hashes that prove which bytes it - * was built from. - * - *

Service and method paths are carried explicitly, not derived on demand, because they are what - * a consumer compatibility check compares. A descriptor that only carries a digest can say - * "something changed" and nothing else, which is the answer least useful to the person who has to - * decide whether to release. - */ -public record GrpcDescriptorArtifact( - String schemaVersion, - String schemaHash, - String descriptorSetDigest, - String bufImageDigest, - String policyVersion, - Set servicePaths, - Set methodPaths, - Set generatedJavaPackages) { - - /** Requires an immutable version, three digests and a non-empty surface. */ - public GrpcDescriptorArtifact { - if (schemaVersion == null || schemaVersion.isBlank() || schemaVersion.endsWith("-SNAPSHOT")) { - throw new IllegalArgumentException( - "a schema artifact publishes an immutable version; got '" + schemaVersion + "'"); - } - requireDigest(schemaHash, "schema hash"); - requireDigest(descriptorSetDigest, "descriptor set digest"); - requireDigest(bufImageDigest, "buf image digest"); - if (policyVersion == null || policyVersion.isBlank()) { - throw new IllegalArgumentException( - "a schema artifact records the policy version it was judged under"); - } - if (servicePaths == null || methodPaths == null || generatedJavaPackages == null) { - throw new IllegalArgumentException( - "a schema artifact carries its service, method and package surface"); - } - if (methodPaths.isEmpty()) { - throw new IllegalArgumentException("a schema artifact with no methods describes nothing"); - } - servicePaths = Set.copyOf(servicePaths); - methodPaths = Set.copyOf(methodPaths); - generatedJavaPackages = Set.copyOf(generatedJavaPackages); - } - - private static void requireDigest(String digest, String what) { - if (digest == null || !digest.startsWith("sha256:") || digest.length() < 15) { - throw new IllegalArgumentException(what + " must be 'sha256:'; got '" + digest + "'"); - } - } - - /** Whether this artifact is byte-identical to {@code baseline}. */ - public boolean unchangedFrom(GrpcSchemaBaseline baseline) { - return baseline.matches(schemaHash); - } -} diff --git a/src/grpc/grpc-codegen/src/main/java/dev/caskeleton/grpc/codegen/GrpcGeneratedPackagePolicy.java b/src/grpc/grpc-codegen/src/main/java/dev/caskeleton/grpc/codegen/GrpcGeneratedPackagePolicy.java deleted file mode 100644 index fd74568d..00000000 --- a/src/grpc/grpc-codegen/src/main/java/dev/caskeleton/grpc/codegen/GrpcGeneratedPackagePolicy.java +++ /dev/null @@ -1,68 +0,0 @@ -package dev.caskeleton.grpc.codegen; - -import java.util.ArrayList; -import java.util.List; -import java.util.Set; - -/** - * Keeps generated Java packages and hand-written ones apart. - * - *

An overlap is not a style problem. Generated code is deleted and rewritten on every build, so - * a hand-written class that shares its package is one clean build away from being either - * overwritten or, more often, from making the generator's output unbuildable in a way that reads as - * a compiler bug. Splitting the namespaces makes the ownership of every file legible from its - * package alone. - */ -public record GrpcGeneratedPackagePolicy( - Set handWrittenPackages, Set generatedPackages) { - - /** Copies both sets. */ - public GrpcGeneratedPackagePolicy { - if (handWrittenPackages == null || generatedPackages == null) { - throw new IllegalArgumentException("both package sets must be present"); - } - if (generatedPackages.isEmpty()) { - throw new IllegalArgumentException("a codegen policy names at least one generated package"); - } - handWrittenPackages = Set.copyOf(handWrittenPackages); - generatedPackages = Set.copyOf(generatedPackages); - } - - /** - * Every overlap between the two namespaces, described. - * - * @return an empty list when the namespaces are disjoint - */ - public List overlaps() { - List overlaps = new ArrayList<>(); - for (String generated : generatedPackages) { - for (String handWritten : handWrittenPackages) { - if (generated.equals(handWritten) - || generated.startsWith(handWritten + ".") - || handWritten.startsWith(generated + ".")) { - overlaps.add( - "generated package '" - + generated - + "' overlaps hand-written package '" - + handWritten - + "'"); - } - } - } - overlaps.sort(java.util.Comparator.naturalOrder()); - return List.copyOf(overlaps); - } - - /** - * Fails when the namespaces overlap. - * - * @throws IllegalStateException naming every overlap - */ - public void requireDisjoint() { - List overlaps = overlaps(); - if (!overlaps.isEmpty()) { - throw new IllegalStateException( - "generated and hand-written Java packages must be disjoint: " + overlaps); - } - } -} diff --git a/src/grpc/grpc-codegen/src/main/java/dev/caskeleton/grpc/codegen/GrpcSchemaArtifactPublisher.java b/src/grpc/grpc-codegen/src/main/java/dev/caskeleton/grpc/codegen/GrpcSchemaArtifactPublisher.java deleted file mode 100644 index 225894c3..00000000 --- a/src/grpc/grpc-codegen/src/main/java/dev/caskeleton/grpc/codegen/GrpcSchemaArtifactPublisher.java +++ /dev/null @@ -1,113 +0,0 @@ -package dev.caskeleton.grpc.codegen; - -import java.util.ArrayList; -import java.util.LinkedHashMap; -import java.util.List; -import java.util.Map; - -/** - * Decides whether a candidate schema may be published, and refuses to let a released version change - * underneath its consumers. - * - *

Two rules, and the second is the one that gets skipped in a hurry: a consumer fixture that no - * longer compiles blocks the release. Publishing anyway and telling the consumers is not the same - * thing — by then the artifact exists, somebody has resolved it, and the fix is a new version - * rather than a decision not to make the change. - */ -public final class GrpcSchemaArtifactPublisher { - - private final GrpcBufPolicy policy; - private final Map publishedHashesByVersion = new LinkedHashMap<>(); - - /** Binds a publisher to the governance policy it enforces. */ - public GrpcSchemaArtifactPublisher(GrpcBufPolicy policy) { - if (policy == null) { - throw new IllegalArgumentException("a publisher needs a Buf policy"); - } - this.policy = policy; - } - - /** Whether a candidate may be published, and if not, why not. */ - public record PublishDecision(boolean allowed, List blockers) { - /** Copies the blocker list. */ - public PublishDecision { - if (blockers == null) { - throw new IllegalArgumentException( - "a publish decision lists its blockers, even when empty"); - } - blockers = List.copyOf(blockers); - if (allowed && !blockers.isEmpty()) { - throw new IllegalArgumentException("an allowed publish has no blockers"); - } - if (!allowed && blockers.isEmpty()) { - throw new IllegalArgumentException("a refused publish says why"); - } - } - } - - /** - * Evaluates a candidate against the policy and every consumer fixture. - * - * @param fixtures the previously released consumers this schema must keep compiling - */ - public PublishDecision evaluate( - GrpcDescriptorArtifact candidate, List fixtures) { - if (candidate == null || fixtures == null) { - throw new IllegalArgumentException("evaluation needs a candidate and a fixture list"); - } - List blockers = new ArrayList<>(); - - String alreadyPublished = publishedHashesByVersion.get(candidate.schemaVersion()); - if (alreadyPublished != null && !alreadyPublished.equals(candidate.schemaHash())) { - blockers.add( - "version '" - + candidate.schemaVersion() - + "' is already published with a different schema hash; a released schema version is " - + "immutable"); - } - if (!policy.breakingCategory().detectsSourceBreak()) { - blockers.add("the active breaking category does not detect source breaks"); - } - for (GrpcConsumerFixture fixture : fixtures) { - for (GrpcConsumerFixture.SourceBreak sourceBreak : fixture.breaksAgainst(candidate)) { - blockers.add( - "consumer '" - + fixture.name() - + "' (" - + fixture.schemaVersion() - + ") loses " - + sourceBreak.kind() - + " '" - + sourceBreak.missing() - + "'"); - } - } - return new PublishDecision(blockers.isEmpty(), blockers); - } - - /** - * Records a successful publish. - * - * @throws IllegalStateException when the decision refused it - */ - public void publish(GrpcDescriptorArtifact candidate, PublishDecision decision) { - if (decision == null || !decision.allowed()) { - throw new IllegalStateException( - "refusing to publish '" - + (candidate == null ? "null" : candidate.schemaVersion()) - + "': " - + (decision == null ? "no decision" : decision.blockers())); - } - publishedHashesByVersion.put(candidate.schemaVersion(), candidate.schemaHash()); - } - - /** The hash published for {@code version}, or null when nothing was. */ - public String publishedHash(String version) { - return publishedHashesByVersion.get(version); - } - - /** The governance policy in force. */ - public GrpcBufPolicy policy() { - return policy; - } -} diff --git a/src/grpc/grpc-codegen/src/main/java/dev/caskeleton/grpc/codegen/GrpcSchemaBaseline.java b/src/grpc/grpc-codegen/src/main/java/dev/caskeleton/grpc/codegen/GrpcSchemaBaseline.java deleted file mode 100644 index c0468ba0..00000000 --- a/src/grpc/grpc-codegen/src/main/java/dev/caskeleton/grpc/codegen/GrpcSchemaBaseline.java +++ /dev/null @@ -1,37 +0,0 @@ -package dev.caskeleton.grpc.codegen; - -import java.time.Instant; - -/** - * The released schema a breaking check compares against. - * - *

Pinned to a released artifact rather than to a branch, and that is the whole point. Comparing - * against the previous commit answers "did this commit break anything", which is not the question: - * a breaking change introduced two commits ago and refined since then passes every commit-to-commit - * check while being broken against everything that has actually been deployed. - */ -public record GrpcSchemaBaseline(String version, String schemaHash, Instant releasedAt) { - - /** Requires an immutable version, a hash and a release moment. */ - public GrpcSchemaBaseline { - if (version == null || version.isBlank()) { - throw new IllegalArgumentException("a schema baseline needs a released version"); - } - if (version.endsWith("-SNAPSHOT")) { - throw new IllegalArgumentException( - "a breaking baseline must be an immutable release, not '" + version + "'"); - } - if (schemaHash == null || !schemaHash.startsWith("sha256:") || schemaHash.length() < 15) { - throw new IllegalArgumentException( - "a schema baseline needs a 'sha256:' hash; got '" + schemaHash + "'"); - } - if (releasedAt == null) { - throw new IllegalArgumentException("a schema baseline needs a release timestamp"); - } - } - - /** Whether {@code candidateHash} is byte-identical to this baseline. */ - public boolean matches(String candidateHash) { - return schemaHash.equals(candidateHash); - } -} diff --git a/src/grpc/grpc-codegen/src/test/java/dev/caskeleton/grpc/codegen/GrpcBufPolicyTest.java b/src/grpc/grpc-codegen/src/test/java/dev/caskeleton/grpc/codegen/GrpcBufPolicyTest.java deleted file mode 100644 index efb27560..00000000 --- a/src/grpc/grpc-codegen/src/test/java/dev/caskeleton/grpc/codegen/GrpcBufPolicyTest.java +++ /dev/null @@ -1,88 +0,0 @@ -package dev.caskeleton.grpc.codegen; - -import static org.assertj.core.api.Assertions.assertThat; -import static org.assertj.core.api.Assertions.assertThatThrownBy; - -import java.time.Instant; -import java.util.Set; -import org.junit.jupiter.api.DisplayName; -import org.junit.jupiter.api.Test; - -class GrpcBufPolicyTest { - - private static final GrpcSchemaBaseline BASELINE = - new GrpcSchemaBaseline( - "1.4.0", - "sha256:0f1e2d3c4b5a69788796a5b4c3d2e1f00f1e2d3c4b5a69788796a5b4c3d2e1f0", - Instant.parse("2026-08-01T00:00:00Z")); - - @Test - @DisplayName("the Stable public API is gated on the FILE breaking category") - void stablePublicApiUsesTheFileCategory() { - GrpcBufPolicy policy = GrpcBufPolicy.stable(BASELINE); - - assertThat(policy.breakingCategory()).isEqualTo(GrpcBreakingCategory.FILE); - assertThat(GrpcBreakingCategory.stableGate()).isEqualTo(GrpcBreakingCategory.FILE); - assertThat(policy.breakingCategory().detectsSourceBreak()).isTrue(); - assertThat(policy.breakingCategory().detectsFileMove()).isTrue(); - } - - @Test - @DisplayName("wire-only compatibility may not gate the Stable public API") - void wireOnlyCompatibilityIsRefused() { - assertThatThrownBy(() -> new GrpcBufPolicy(GrpcBreakingCategory.WIRE, true, true, BASELINE)) - .isInstanceOf(IllegalArgumentException.class) - .hasMessageContaining("stops compiling"); - assertThatThrownBy( - () -> new GrpcBufPolicy(GrpcBreakingCategory.WIRE_JSON, true, true, BASELINE)) - .isInstanceOf(IllegalArgumentException.class); - assertThat(GrpcBreakingCategory.WIRE.detectsSourceBreak()).isFalse(); - assertThat(GrpcBreakingCategory.PACKAGE.detectsFileMove()).isFalse(); - } - - @Test - @DisplayName("format and lint are not optional") - void formatAndLintAreNotOptional() { - assertThatThrownBy(() -> new GrpcBufPolicy(GrpcBreakingCategory.FILE, false, true, BASELINE)) - .isInstanceOf(IllegalArgumentException.class); - assertThatThrownBy(() -> new GrpcBufPolicy(GrpcBreakingCategory.FILE, true, false, BASELINE)) - .isInstanceOf(IllegalArgumentException.class); - } - - @Test - @DisplayName("the four lifecycle stages are named, and a missing one is reported") - void lifecycleStagesAreNamedAndChecked() { - assertThat(GrpcBufPolicy.requiredTasks()) - .containsExactly("bufFormatCheck", "bufLint", "bufBuild", "bufBreaking"); - assertThat(GrpcBufPolicy.missingTasks(Set.of("bufFormatCheck", "bufLint", "bufBuild"))) - .containsExactly("bufBreaking"); - assertThat(GrpcBufPolicy.missingTasks(Set.copyOf(GrpcBufPolicy.requiredTasks()))).isEmpty(); - } - - @Test - @DisplayName("the breaking baseline is a released version, never a snapshot") - void baselineIsAnImmutableRelease() { - assertThatThrownBy( - () -> - new GrpcSchemaBaseline( - "1.5.0-SNAPSHOT", - "sha256:0f1e2d3c4b5a69788796a5b4c3d2e1f00f1e2d3c4b5a69788796a5b4c3d2e1f0", - Instant.parse("2026-08-01T00:00:00Z"))) - .isInstanceOf(IllegalArgumentException.class) - .hasMessageContaining("immutable release"); - assertThatThrownBy( - () -> - new GrpcSchemaBaseline( - "1.5.0", "not-a-digest", Instant.parse("2026-08-01T00:00:00Z"))) - .isInstanceOf(IllegalArgumentException.class); - } - - @Test - @DisplayName("an unchanged schema hash needs no breaking review") - void unchangedSchemaNeedsNoBreakingReview() { - GrpcBufPolicy policy = GrpcBufPolicy.stable(BASELINE); - - assertThat(policy.unchangedFromBaseline(BASELINE.schemaHash())).isTrue(); - assertThat(policy.unchangedFromBaseline("sha256:ffffffffffffffffffffffffffffffff")).isFalse(); - } -} diff --git a/src/grpc/grpc-codegen/src/test/java/dev/caskeleton/grpc/codegen/GrpcCodegenManifestTest.java b/src/grpc/grpc-codegen/src/test/java/dev/caskeleton/grpc/codegen/GrpcCodegenManifestTest.java deleted file mode 100644 index c579df37..00000000 --- a/src/grpc/grpc-codegen/src/test/java/dev/caskeleton/grpc/codegen/GrpcCodegenManifestTest.java +++ /dev/null @@ -1,78 +0,0 @@ -package dev.caskeleton.grpc.codegen; - -import static org.assertj.core.api.Assertions.assertThat; -import static org.assertj.core.api.Assertions.assertThatThrownBy; - -import java.util.Set; -import org.junit.jupiter.api.DisplayName; -import org.junit.jupiter.api.Test; - -class GrpcCodegenManifestTest { - - @Test - @DisplayName("Java code generation has exactly one owner, and a second is refused") - void codeGenerationHasOneOwner() { - GrpcCodegenManifest manifest = GrpcCodegenManifest.caSkeleton(); - - manifest.requireSoleOwner("gradle-protobuf-plugin"); - assertThatThrownBy(() -> manifest.requireSoleOwner("hand-rolled-protoc-exec")) - .isInstanceOf(IllegalStateException.class) - .hasMessageContaining("hand-rolled-protoc-exec"); - } - - @Test - @DisplayName("generator versions come from the managed platform, never from a literal") - void generatorVersionsComeFromTheManagedPlatform() { - assertThatThrownBy( - () -> - new GrpcCodegenManifest( - "gradle-protobuf-plugin", - "3.25.5", - GrpcCodegenManifest.MANAGED_VERSION_SOURCE, - GrpcCodegenOutput.standard(), - new GrpcGeneratedPackagePolicy( - Set.of("dev.caskeleton"), Set.of("hyeonworks.grpc.common.v1.generated")))) - .isInstanceOf(IllegalArgumentException.class) - .hasMessageContaining("protobuf version must come from the managed platform"); - } - - @Test - @DisplayName("generated sources land under build/, never in a source tree") - void generatedSourcesLandUnderBuild() { - assertThatThrownBy( - () -> new GrpcCodegenOutput("src/main/java", "build/g", "build/x.desc", true)) - .isInstanceOf(IllegalArgumentException.class) - .hasMessageContaining("must be under 'build/'"); - assertThatThrownBy(() -> new GrpcCodegenOutput("build/a", "build/b", "build/schema.txt", true)) - .isInstanceOf(IllegalArgumentException.class) - .hasMessageContaining("FileDescriptorSet"); - assertThat(GrpcCodegenOutput.standard().includeSourceInfo()).isTrue(); - } - - @Test - @DisplayName("a generated package inside a hand-written one fails the manifest") - void generatedAndHandWrittenPackagesMustBeDisjoint() { - GrpcGeneratedPackagePolicy overlapping = - new GrpcGeneratedPackagePolicy( - Set.of("dev.caskeleton"), Set.of("dev.caskeleton.grpc.generated")); - - assertThat(overlapping.overlaps()).hasSize(1); - assertThatThrownBy(overlapping::requireDisjoint) - .isInstanceOf(IllegalStateException.class) - .hasMessageContaining("dev.caskeleton.grpc.generated"); - assertThat( - new GrpcGeneratedPackagePolicy( - Set.of("dev.caskeleton"), Set.of("hyeonworks.grpc.common.v1.generated")) - .overlaps()) - .isEmpty(); - } - - @Test - @DisplayName("an overlap is caught in both directions") - void overlapIsSymmetric() { - GrpcGeneratedPackagePolicy generatedIsAnAncestor = - new GrpcGeneratedPackagePolicy(Set.of("hyeonworks.grpc.hand"), Set.of("hyeonworks.grpc")); - - assertThat(generatedIsAnAncestor.overlaps()).hasSize(1); - } -} diff --git a/src/grpc/grpc-codegen/src/test/java/dev/caskeleton/grpc/codegen/GrpcDescriptorArtifactTest.java b/src/grpc/grpc-codegen/src/test/java/dev/caskeleton/grpc/codegen/GrpcDescriptorArtifactTest.java deleted file mode 100644 index fb25a9a7..00000000 --- a/src/grpc/grpc-codegen/src/test/java/dev/caskeleton/grpc/codegen/GrpcDescriptorArtifactTest.java +++ /dev/null @@ -1,248 +0,0 @@ -package dev.caskeleton.grpc.codegen; - -import static org.assertj.core.api.Assertions.assertThat; -import static org.assertj.core.api.Assertions.assertThatThrownBy; - -import java.time.Instant; -import java.util.List; -import java.util.Set; -import org.junit.jupiter.api.DisplayName; -import org.junit.jupiter.api.Test; - -class GrpcDescriptorArtifactTest { - - private static final String DIGEST_A = - "sha256:0f1e2d3c4b5a69788796a5b4c3d2e1f00f1e2d3c4b5a69788796a5b4c3d2e1f0"; - private static final String DIGEST_B = - "sha256:1122334455667788990011223344556677889900112233445566778899001122"; - - private static final GrpcSchemaBaseline BASELINE = - new GrpcSchemaBaseline("1.4.0", DIGEST_A, Instant.parse("2026-08-01T00:00:00Z")); - - private static GrpcDescriptorArtifact artifact( - String version, String hash, Set methods, Set javaPackages) { - return new GrpcDescriptorArtifact( - version, - hash, - DIGEST_A, - DIGEST_B, - "grpc-stable-policy-1", - Set.of("hyeonworks.document.v1.DocumentService"), - methods, - javaPackages); - } - - private static final Set METHODS = - Set.of( - "hyeonworks.document.v1.DocumentService/GetDocument", - "hyeonworks.document.v1.DocumentService/CreateDocument"); - private static final Set PACKAGES = Set.of("hyeonworks.document.v1.generated"); - - private static String resource(String path) { - try (java.io.InputStream stream = - GrpcDescriptorArtifactTest.class.getClassLoader().getResourceAsStream(path)) { - if (stream == null) { - throw new IllegalStateException("missing test resource " + path); - } - return new String(stream.readAllBytes(), java.nio.charset.StandardCharsets.UTF_8); - } catch (java.io.IOException e) { - throw new java.io.UncheckedIOException(e); - } - } - - @Test - @DisplayName("a schema artifact publishes an immutable version and three digests") - void artifactCarriesAnImmutableVersionAndDigests() { - GrpcDescriptorArtifact candidate = artifact("1.5.0", DIGEST_B, METHODS, PACKAGES); - - assertThat(candidate.schemaVersion()).isEqualTo("1.5.0"); - assertThat(candidate.unchangedFrom(BASELINE)).isFalse(); - assertThat(artifact("1.4.0", DIGEST_A, METHODS, PACKAGES).unchangedFrom(BASELINE)).isTrue(); - assertThatThrownBy(() -> artifact("1.5.0-SNAPSHOT", DIGEST_B, METHODS, PACKAGES)) - .isInstanceOf(IllegalArgumentException.class) - .hasMessageContaining("immutable version"); - assertThatThrownBy(() -> artifact("1.5.0", "nope", METHODS, PACKAGES)) - .isInstanceOf(IllegalArgumentException.class); - } - - @Test - @DisplayName("service, method and Java package breaks are reported separately") - void sourceBreaksAreReportedByKind() { - GrpcConsumerFixture consumer = - new GrpcConsumerFixture( - "document-client-v1", - "1.4.0", - Set.of("hyeonworks.document.v1.DocumentService"), - METHODS, - PACKAGES); - GrpcDescriptorArtifact renamedEverything = - new GrpcDescriptorArtifact( - "1.5.0", - DIGEST_B, - DIGEST_A, - DIGEST_B, - "grpc-stable-policy-1", - Set.of("hyeonworks.document.v2.DocumentService"), - Set.of("hyeonworks.document.v2.DocumentService/GetDocument"), - Set.of("hyeonworks.document.v2.generated")); - - List breaks = consumer.breaksAgainst(renamedEverything); - - assertThat(breaks) - .extracting(GrpcConsumerFixture.SourceBreak::kind) - .containsExactlyInAnyOrder( - GrpcConsumerFixture.BreakKind.SERVICE_PATH, - GrpcConsumerFixture.BreakKind.METHOD_PATH, - GrpcConsumerFixture.BreakKind.METHOD_PATH, - GrpcConsumerFixture.BreakKind.JAVA_PACKAGE); - } - - @Test - @DisplayName("a consumer that still compiles reports no break") - void compatibleSchemaBreaksNothing() { - GrpcConsumerFixture consumer = - new GrpcConsumerFixture( - "document-client-v1", - "1.4.0", - Set.of("hyeonworks.document.v1.DocumentService"), - METHODS, - PACKAGES); - Set widened = - Set.of( - "hyeonworks.document.v1.DocumentService/GetDocument", - "hyeonworks.document.v1.DocumentService/CreateDocument", - "hyeonworks.document.v1.DocumentService/ArchiveDocument"); - - assertThat(consumer.breaksAgainst(artifact("1.5.0", DIGEST_B, widened, PACKAGES))).isEmpty(); - } - - @Test - @DisplayName("the committed v1 consumer fixture states its own requirements") - void theCommittedFixtureStatesItsOwnRequirements() { - GrpcConsumerFixture derived = - GrpcConsumerFixture.fromJavaSource( - "document-client-v1", - "1.4.0", - resource("consumer-fixtures/v1/src/main/java/fixture/DocumentClientFixture.java"), - "generated"); - - assertThat(derived.requiredServicePaths()) - .containsExactly("hyeonworks.document.v1.DocumentService"); - assertThat(derived.requiredMethodPaths()) - .containsExactlyInAnyOrder( - "hyeonworks.document.v1.DocumentService/GetDocument", - "hyeonworks.document.v1.DocumentService/CreateDocument"); - assertThat(derived.requiredJavaPackages()).containsExactly("hyeonworks.document.v1.generated"); - } - - @Test - @DisplayName("a schema that renames a method the committed fixture calls blocks the release") - void renamingAMethodTheFixtureCallsBlocksTheRelease() { - GrpcConsumerFixture derived = - GrpcConsumerFixture.fromJavaSource( - "document-client-v1", - "1.4.0", - resource("consumer-fixtures/v1/src/main/java/fixture/DocumentClientFixture.java"), - "generated"); - GrpcDescriptorArtifact renamed = - new GrpcDescriptorArtifact( - "1.5.0", - DIGEST_B, - DIGEST_A, - DIGEST_B, - "grpc-stable-policy-1", - Set.of("hyeonworks.document.v1.DocumentService"), - Set.of( - "hyeonworks.document.v1.DocumentService/GetDocument", - "hyeonworks.document.v1.DocumentService/CreateDocumentV2"), - Set.of("hyeonworks.document.v1.generated")); - - GrpcSchemaArtifactPublisher publisher = - new GrpcSchemaArtifactPublisher(GrpcBufPolicy.stable(BASELINE)); - - assertThat(publisher.evaluate(renamed, List.of(derived)).blockers()) - .anySatisfy(blocker -> assertThat(blocker).contains("CreateDocument")); - } - - @Test - @DisplayName("a fixture that requires nothing is refused rather than passing every schema") - void aFixtureThatRequiresNothingIsRefused() { - assertThatThrownBy( - () -> - GrpcConsumerFixture.fromJavaSource( - "empty-client", "1.4.0", "package fixture;\n\nclass Empty {}\n", "generated")) - .isInstanceOf(IllegalArgumentException.class) - .hasMessageContaining("cannot detect a break"); - } - - @Test - @DisplayName("the fixture's own build file pins the schema version it was built against") - void theFixturePinsItsSchemaVersion() { - assertThat(resource("consumer-fixtures/v1/build.gradle.kts")) - .contains("grpc-schema-artifact:1.4.0") - .contains("floats to the latest version"); - } - - @Test - @DisplayName("a consumer fixture failure blocks the release") - void consumerFixtureFailureBlocksTheRelease() { - GrpcSchemaArtifactPublisher publisher = - new GrpcSchemaArtifactPublisher(GrpcBufPolicy.stable(BASELINE)); - GrpcConsumerFixture consumer = - new GrpcConsumerFixture( - "document-client-v1", - "1.4.0", - Set.of("hyeonworks.document.v1.DocumentService"), - METHODS, - PACKAGES); - GrpcDescriptorArtifact dropsAMethod = - artifact( - "1.5.0", - DIGEST_B, - Set.of("hyeonworks.document.v1.DocumentService/GetDocument"), - PACKAGES); - - GrpcSchemaArtifactPublisher.PublishDecision decision = - publisher.evaluate(dropsAMethod, List.of(consumer)); - - assertThat(decision.allowed()).isFalse(); - assertThat(decision.blockers()) - .anySatisfy( - blocker -> - assertThat(blocker).contains("document-client-v1").contains("CreateDocument")); - assertThatThrownBy(() -> publisher.publish(dropsAMethod, decision)) - .isInstanceOf(IllegalStateException.class); - } - - @Test - @DisplayName("a released version may not be republished with different bytes") - void releasedVersionsAreImmutable() { - GrpcSchemaArtifactPublisher publisher = - new GrpcSchemaArtifactPublisher(GrpcBufPolicy.stable(BASELINE)); - GrpcDescriptorArtifact first = artifact("1.5.0", DIGEST_B, METHODS, PACKAGES); - - GrpcSchemaArtifactPublisher.PublishDecision allowed = publisher.evaluate(first, List.of()); - assertThat(allowed.allowed()).isTrue(); - publisher.publish(first, allowed); - assertThat(publisher.publishedHash("1.5.0")).isEqualTo(DIGEST_B); - - GrpcDescriptorArtifact sameVersionDifferentBytes = - artifact("1.5.0", DIGEST_A, METHODS, PACKAGES); - - assertThat(publisher.evaluate(sameVersionDifferentBytes, List.of()).blockers()) - .anySatisfy(blocker -> assertThat(blocker).contains("immutable")); - } - - @Test - @DisplayName("republishing identical bytes under the same version is allowed") - void identicalRepublishIsAllowed() { - GrpcSchemaArtifactPublisher publisher = - new GrpcSchemaArtifactPublisher(GrpcBufPolicy.stable(BASELINE)); - GrpcDescriptorArtifact artifact = artifact("1.5.0", DIGEST_B, METHODS, PACKAGES); - - publisher.publish(artifact, publisher.evaluate(artifact, List.of())); - - assertThat(publisher.evaluate(artifact, List.of()).allowed()).isTrue(); - assertThat(publisher.policy().breakingCategory()).isEqualTo(GrpcBreakingCategory.FILE); - } -} diff --git a/src/grpc/grpc-codegen/src/test/resources/consumer-fixtures/v1/build.gradle.kts b/src/grpc/grpc-codegen/src/test/resources/consumer-fixtures/v1/build.gradle.kts deleted file mode 100644 index 3351027c..00000000 --- a/src/grpc/grpc-codegen/src/test/resources/consumer-fixtures/v1/build.gradle.kts +++ /dev/null @@ -1,17 +0,0 @@ -// The v1 consumer fixture's own build file, kept as a test resource. -// -// It is not part of this repository's Gradle build. Its purpose is to record what a released -// consumer actually depended on — the schema artifact version and nothing else — so that when -// protoc generation is switched on (ADR-GRPC-002) this directory can be compiled as-is against a -// candidate schema, which is the check GrpcConsumerFixture currently approximates from source text. -plugins { - `java-library` -} - -dependencies { - // The released schema artifact, pinned. A fixture that floats to the latest version cannot - // detect a break, because it is always built against the schema it is meant to be testing. - implementation("dev.caskeleton.grpc:grpc-schema-artifact:1.4.0") - implementation("io.grpc:grpc-stub") - implementation("io.grpc:grpc-protobuf") -} diff --git a/src/grpc/grpc-codegen/src/test/resources/consumer-fixtures/v1/src/main/java/fixture/DocumentClientFixture.java b/src/grpc/grpc-codegen/src/test/resources/consumer-fixtures/v1/src/main/java/fixture/DocumentClientFixture.java deleted file mode 100644 index 45394dc9..00000000 --- a/src/grpc/grpc-codegen/src/test/resources/consumer-fixtures/v1/src/main/java/fixture/DocumentClientFixture.java +++ /dev/null @@ -1,33 +0,0 @@ -package fixture; - -import hyeonworks.document.v1.generated.CreateDocumentRequest; -import hyeonworks.document.v1.generated.DocumentServiceGrpc; -import hyeonworks.document.v1.generated.GetDocumentRequest; - -/** - * A previously released consumer, kept as a fixture rather than as a dependency. - * - *

This file is a test resource, not a compiled source. It records exactly what the v1 client - * named — the generated package it imported from, the service class it referenced and the methods it - * called — so a candidate schema can be checked against a real client's surface instead of against a - * requirement list somebody typed by hand and will forget to update. - * - *

{@code GrpcConsumerFixture.fromJavaSource} derives those three sets from this text. Adding a - * call here widens what a release must keep; that is the intent. - */ -public final class DocumentClientFixture { - - private final DocumentServiceGrpc.DocumentServiceBlockingStub stub; - - public DocumentClientFixture(DocumentServiceGrpc.DocumentServiceBlockingStub stub) { - this.stub = stub; - } - - public String read(String documentId) { - return stub.getDocument(GetDocumentRequest.newBuilder().setId(documentId).build()).getTitle(); - } - - public String create(String title) { - return stub.createDocument(CreateDocumentRequest.newBuilder().setTitle(title).build()).getId(); - } -} diff --git a/src/grpc/grpc-contract/buf.yaml b/src/grpc/grpc-contract/buf.yaml new file mode 100644 index 00000000..5565f6e5 --- /dev/null +++ b/src/grpc/grpc-contract/buf.yaml @@ -0,0 +1,22 @@ +# Buf module configuration for the Stable gRPC schema. +# +# Buf owns lint and breaking-change policy for src/main/proto; protoc (the Gradle protobuf plugin in +# build.gradle) owns compilation. CI runs both `buf lint` and `buf breaking` from this directory — +# see the `grpc-proto-buf` job in .github/workflows/ci-quality-gates.yml. +# +# cd src/grpc/grpc-contract +# buf lint +# buf breaking --against '#subdir=src/grpc/grpc-contract' +# +# No dependencies: the only imports are protoc's own well-known types (google/protobuf/*.proto). +version: v2 +modules: + - path: src/main/proto +lint: + use: + - STANDARD +breaking: + # FILE, not WIRE or WIRE_JSON. Wire compatibility alone would let a field rename or a Java package + # move through as "compatible" while every generated consumer stops compiling. + use: + - FILE diff --git a/src/grpc/grpc-contract/build.gradle b/src/grpc/grpc-contract/build.gradle new file mode 100644 index 00000000..8e93d9a6 --- /dev/null +++ b/src/grpc/grpc-contract/build.gradle @@ -0,0 +1,47 @@ +plugins { + id 'ca.platform-module' + alias(libs.plugins.protobuf) +} + +// The Stable schema: the `.proto` sources under src/main/proto and the Java that protoc generates +// from them. +// +// protoc, not a hand-written parser, decides whether the schema is valid, and Buf (buf.yaml next to +// this file) owns lint and breaking-change policy. Buf runs in CI — `.github/workflows/ +// ci-quality-gates.yml` job `grpc-proto-buf` — because it is a native binary and not a Maven +// artifact; this build does not re-implement its rules. Until 2026-09-28 this leaf was +// grpc-proto-contract + grpc-codegen, which did both with regular expressions (owner decision 18). +// +// Generated code lands under build/, in the package each file's `java_package` names +// (`caskeleton.*.generated`), which is disjoint from the hand-written `dev.caskeleton` root. +// Messages only: the schema declares no service yet, so there is no grpc-java stub to generate. +dependencies { + // api: every generated message extends com.google.protobuf.GeneratedMessageV3. + api libs.protobuf.java.grpc +} + +protobuf { + protoc { + artifact = libs.protoc.get().toString() + } +} + +// The plugin resolves protoc through a configuration it creates when generateProto runs, after +// resolveAndLockAll has taken its snapshot. The coordinate is an exact catalog version (libs.protoc), +// so a lock entry would restate it; locking is switched off for that tool locator only. +configurations.matching { it.name.startsWith('protobufToolsLocator_') }.configureEach { + resolutionStrategy.deactivateDependencyLocking() +} + +// Generated sources answer to protoc, not to the repository's formatter, lint or bug patterns. +spotless { + java { + target 'src/*/java/**/*.java' + } +} +tasks.named('checkstyleMain') { + exclude '**/generated/**' +} +tasks.withType(JavaCompile).configureEach { + options.errorprone.excludedPaths = '.*/build/generated/.*' +} diff --git a/src/grpc-advanced/grpc-advanced-edition/gradle.lockfile b/src/grpc/grpc-contract/gradle.lockfile similarity index 83% rename from src/grpc-advanced/grpc-advanced-edition/gradle.lockfile rename to src/grpc/grpc-contract/gradle.lockfile index e2c95854..beb6fc2c 100644 --- a/src/grpc-advanced/grpc-advanced-edition/gradle.lockfile +++ b/src/grpc/grpc-contract/gradle.lockfile @@ -23,6 +23,7 @@ com.google.guava:guava:33.5.0-jre=annotationProcessor,testAnnotationProcessor com.google.guava:guava:33.6.0-jre=checkstyle com.google.guava:listenablefuture:9999.0-empty-to-avoid-conflict-with-guava=annotationProcessor,checkstyle,testAnnotationProcessor com.google.j2objc:j2objc-annotations:3.1=annotationProcessor,checkstyle,testAnnotationProcessor +com.google.protobuf:protobuf-java:3.25.5=compileClasspath,compileProtoPath,runtimeClasspath,testCompileClasspath,testCompileProtoPath,testRuntimeClasspath com.google.protobuf:protobuf-java:4.33.2=annotationProcessor,testAnnotationProcessor com.h3xstream.findsecbugs:findsecbugs-plugin:1.14.0=spotbugsPlugins com.puppycrawl.tools:checkstyle:13.5.0=checkstyle @@ -34,7 +35,7 @@ io.github.eisop:dataflow-errorprone:3.41.0-eisop1=annotationProcessor,testAnnota io.github.java-diff-utils:java-diff-utils:4.12=annotationProcessor,testAnnotationProcessor javax.inject:javax.inject:1=annotationProcessor,testAnnotationProcessor jaxen:jaxen:2.0.6=spotbugs -net.bytebuddy:byte-buddy:1.17.8=testCompileClasspath,testRuntimeClasspath +net.bytebuddy:byte-buddy:1.17.8=testCompileClasspath,testCompileProtoPath,testRuntimeClasspath net.sf.saxon:Saxon-HE:12.9=checkstyle,spotbugs org.antlr:antlr4-runtime:4.13.2=checkstyle org.apache.bcel:bcel:6.12.0=spotbugs @@ -51,7 +52,7 @@ org.apache.maven.doxia:doxia-module-xdoc:1.12.0=checkstyle org.apache.maven.doxia:doxia-sink-api:1.12.0=checkstyle org.apache.xbean:xbean-reflect:3.7=checkstyle org.apiguardian:apiguardian-api:1.1.2=testCompileClasspath -org.assertj:assertj-core:3.27.7=testCompileClasspath,testRuntimeClasspath +org.assertj:assertj-core:3.27.7=testCompileClasspath,testCompileProtoPath,testRuntimeClasspath org.codehaus.plexus:plexus-classworlds:2.6.0=checkstyle org.codehaus.plexus:plexus-component-annotations:2.1.0=checkstyle org.codehaus.plexus:plexus-container-default:2.1.0=checkstyle @@ -59,17 +60,17 @@ org.codehaus.plexus:plexus-utils:3.3.0=checkstyle org.dom4j:dom4j:2.2.0=spotbugs org.javassist:javassist:3.28.0-GA=checkstyle org.jspecify:jspecify:1.0.1=annotationProcessor,checkstyle,testAnnotationProcessor,testCompileClasspath -org.junit.jupiter:junit-jupiter-api:6.0.3=testCompileClasspath,testRuntimeClasspath -org.junit.jupiter:junit-jupiter-engine:6.0.3=testRuntimeClasspath -org.junit.jupiter:junit-jupiter-params:6.0.3=testCompileClasspath,testRuntimeClasspath -org.junit.jupiter:junit-jupiter:6.0.3=testCompileClasspath,testRuntimeClasspath -org.junit.platform:junit-platform-commons:6.0.3=testCompileClasspath,testRuntimeClasspath -org.junit.platform:junit-platform-engine:6.0.3=testRuntimeClasspath +org.junit.jupiter:junit-jupiter-api:6.0.3=testCompileClasspath,testCompileProtoPath,testRuntimeClasspath +org.junit.jupiter:junit-jupiter-engine:6.0.3=testCompileProtoPath,testRuntimeClasspath +org.junit.jupiter:junit-jupiter-params:6.0.3=testCompileClasspath,testCompileProtoPath,testRuntimeClasspath +org.junit.jupiter:junit-jupiter:6.0.3=testCompileClasspath,testCompileProtoPath,testRuntimeClasspath +org.junit.platform:junit-platform-commons:6.0.3=testCompileClasspath,testCompileProtoPath,testRuntimeClasspath +org.junit.platform:junit-platform-engine:6.0.3=testCompileProtoPath,testRuntimeClasspath org.junit.platform:junit-platform-launcher:6.0.3=testRuntimeClasspath -org.junit:junit-bom:6.0.3=testCompileClasspath,testRuntimeClasspath +org.junit:junit-bom:6.0.3=testCompileClasspath,testCompileProtoPath,testRuntimeClasspath org.junit:junit-bom:6.1.0=spotbugs org.mockito:mockito-core:5.20.0=mockitoAgent -org.opentest4j:opentest4j:1.3.0=testCompileClasspath,testRuntimeClasspath +org.opentest4j:opentest4j:1.3.0=testCompileClasspath,testCompileProtoPath,testRuntimeClasspath org.ow2.asm:asm-analysis:9.10.1=spotbugs org.ow2.asm:asm-commons:9.10.1=spotbugs org.ow2.asm:asm-tree:9.10.1=spotbugs @@ -81,4 +82,4 @@ org.slf4j:slf4j-api:2.0.18=spotbugs,spotbugsSlf4j org.slf4j:slf4j-simple:2.0.17=spotbugsSlf4j org.slf4j:slf4j-simple:2.0.18=checkstyle org.xmlresolver:xmlresolver:5.3.3=checkstyle,spotbugs -empty=compileClasspath,runtimeClasspath +empty=protobuf,testProtobuf diff --git a/src/grpc/grpc-proto-contract/src/main/resources/proto/hyeonworks/grpc/common/v1/error.proto b/src/grpc/grpc-contract/src/main/proto/caskeleton/grpc/common/v1/error.proto similarity index 95% rename from src/grpc/grpc-proto-contract/src/main/resources/proto/hyeonworks/grpc/common/v1/error.proto rename to src/grpc/grpc-contract/src/main/proto/caskeleton/grpc/common/v1/error.proto index e28a0289..b8324ee2 100644 --- a/src/grpc/grpc-proto-contract/src/main/resources/proto/hyeonworks/grpc/common/v1/error.proto +++ b/src/grpc/grpc-contract/src/main/proto/caskeleton/grpc/common/v1/error.proto @@ -1,9 +1,9 @@ syntax = "proto3"; -package hyeonworks.grpc.common.v1; +package caskeleton.grpc.common.v1; option java_multiple_files = true; -option java_package = "hyeonworks.grpc.common.v1.generated"; +option java_package = "caskeleton.grpc.common.v1.generated"; option java_outer_classname = "ErrorProto"; import "google/protobuf/duration.proto"; diff --git a/src/grpc/grpc-proto-contract/src/main/resources/proto/hyeonworks/grpc/common/v1/stream.proto b/src/grpc/grpc-contract/src/main/proto/caskeleton/grpc/common/v1/stream.proto similarity index 95% rename from src/grpc/grpc-proto-contract/src/main/resources/proto/hyeonworks/grpc/common/v1/stream.proto rename to src/grpc/grpc-contract/src/main/proto/caskeleton/grpc/common/v1/stream.proto index 67bf8a3d..f2c5e814 100644 --- a/src/grpc/grpc-proto-contract/src/main/resources/proto/hyeonworks/grpc/common/v1/stream.proto +++ b/src/grpc/grpc-contract/src/main/proto/caskeleton/grpc/common/v1/stream.proto @@ -1,9 +1,9 @@ syntax = "proto3"; -package hyeonworks.grpc.common.v1; +package caskeleton.grpc.common.v1; option java_multiple_files = true; -option java_package = "hyeonworks.grpc.common.v1.generated"; +option java_package = "caskeleton.grpc.common.v1.generated"; option java_outer_classname = "StreamProto"; // The Stable server-streaming envelope. diff --git a/src/grpc/grpc-contract/src/test/java/dev/caskeleton/grpc/contract/GrpcContractGeneratedCodeTest.java b/src/grpc/grpc-contract/src/test/java/dev/caskeleton/grpc/contract/GrpcContractGeneratedCodeTest.java new file mode 100644 index 00000000..0a67e169 --- /dev/null +++ b/src/grpc/grpc-contract/src/test/java/dev/caskeleton/grpc/contract/GrpcContractGeneratedCodeTest.java @@ -0,0 +1,46 @@ +package dev.caskeleton.grpc.contract; + +import static org.assertj.core.api.Assertions.assertThat; + +import caskeleton.grpc.common.v1.generated.StreamEnvelope; +import caskeleton.grpc.common.v1.generated.StreamMessageKind; +import caskeleton.grpc.common.v1.generated.StreamTerminationReason; +import org.junit.jupiter.api.DisplayName; +import org.junit.jupiter.api.Test; + +class GrpcContractGeneratedCodeTest { + + @Test + @DisplayName("protoc가 생성한 stream envelope은 wire bytes로 왕복하고 명시적 presence를 유지한다") + void generatedStreamEnvelopeRoundTripsThroughWireBytesKeepingExplicitPresence() throws Exception { + // given + StreamEnvelope sent = + StreamEnvelope.newBuilder() + .setStreamId("stream-1") + .setSequence(7L) + .setKind(StreamMessageKind.STREAM_MESSAGE_KIND_TERMINATION) + .setTerminationReason(StreamTerminationReason.STREAM_TERMINATION_REASON_SERVER_DRAIN) + .build(); + + // when + StreamEnvelope received = StreamEnvelope.parseFrom(sent.toByteArray()); + + // then + assertThat(received).isEqualTo(sent); + assertThat(received.hasTerminationReason()).isTrue(); + assertThat(received.hasResumeToken()).isFalse(); + } + + @Test + @DisplayName("생성 코드의 proto 패키지와 Java 패키지는 조직 이름 caskeleton 아래에 있고 손으로 쓴 dev.caskeleton과 겹치지 않는다") + void generatedCodeLivesUnderTheCaskeletonProtoPackageAndOutsideTheHandWrittenRoot() { + // when + String protoPackage = StreamEnvelope.getDescriptor().getFile().getPackage(); + + // then + assertThat(protoPackage).isEqualTo("caskeleton.grpc.common.v1"); + assertThat(StreamEnvelope.class.getPackageName()) + .isEqualTo("caskeleton.grpc.common.v1.generated") + .doesNotStartWith("dev.caskeleton"); + } +} diff --git a/src/grpc/grpc-core-api/src/main/java/dev/caskeleton/grpc/api/context/GrpcMetadataBudget.java b/src/grpc/grpc-core-api/src/main/java/dev/caskeleton/grpc/api/context/GrpcMetadataBudget.java index 99befcd2..865f061d 100644 --- a/src/grpc/grpc-core-api/src/main/java/dev/caskeleton/grpc/api/context/GrpcMetadataBudget.java +++ b/src/grpc/grpc-core-api/src/main/java/dev/caskeleton/grpc/api/context/GrpcMetadataBudget.java @@ -1,5 +1,6 @@ package dev.caskeleton.grpc.api.context; +import dev.caskeleton.grpc.api.policy.GrpcTransportLimits; import java.util.Map; /** @@ -30,7 +31,7 @@ public record GrpcMetadataBudget(int maxTotalBytes, int maxUserDefinedBytes, int /** The platform default: 8 KiB total, 4 KiB of it user-defined, at most 32 entries. */ public static GrpcMetadataBudget standard() { - return new GrpcMetadataBudget(8192, 4096, 32); + return new GrpcMetadataBudget(GrpcTransportLimits.DEFAULT_MAX_METADATA_BYTES, 4096, 32); } /** diff --git a/src/grpc/grpc-core-api/src/main/java/dev/caskeleton/grpc/api/policy/GrpcMethodPolicy.java b/src/grpc/grpc-core-api/src/main/java/dev/caskeleton/grpc/api/policy/GrpcMethodPolicy.java index 019a69d5..3a6f8728 100644 --- a/src/grpc/grpc-core-api/src/main/java/dev/caskeleton/grpc/api/policy/GrpcMethodPolicy.java +++ b/src/grpc/grpc-core-api/src/main/java/dev/caskeleton/grpc/api/policy/GrpcMethodPolicy.java @@ -75,8 +75,8 @@ public record GrpcMethodPolicy( deadline, WaitForReadyPolicy.DISABLED, true, - 4 * 1024 * 1024, - 4 * 1024 * 1024); + GrpcTransportLimits.DEFAULT_MAX_MESSAGE_BYTES, + GrpcTransportLimits.DEFAULT_MAX_MESSAGE_BYTES); } /** A state-changing unary method that refuses explicit retry. */ @@ -89,8 +89,8 @@ public record GrpcMethodPolicy( deadline, WaitForReadyPolicy.DISABLED, false, - 4 * 1024 * 1024, - 4 * 1024 * 1024); + GrpcTransportLimits.DEFAULT_MAX_MESSAGE_BYTES, + GrpcTransportLimits.DEFAULT_MAX_MESSAGE_BYTES); } /** Whether this method may be hedged. */ diff --git a/src/grpc/grpc-core-api/src/main/java/dev/caskeleton/grpc/api/policy/GrpcTransportLimits.java b/src/grpc/grpc-core-api/src/main/java/dev/caskeleton/grpc/api/policy/GrpcTransportLimits.java new file mode 100644 index 00000000..c8eab4d3 --- /dev/null +++ b/src/grpc/grpc-core-api/src/main/java/dev/caskeleton/grpc/api/policy/GrpcTransportLimits.java @@ -0,0 +1,21 @@ +package dev.caskeleton.grpc.api.policy; + +/** + * The platform's default transport bounds, stated once. + * + *

The server profile, the named channel profiles, the per-method size profile, the method policy + * defaults and the metadata budget all start from these numbers. They used to be five copies of the + * same literals, and a copy that drifts is a method that promises a message size its server + * rejects; {@code GrpcPlatformStartupValidator} refuses that combination, and it can only do so + * cheaply when the defaults agree by construction. + */ +public final class GrpcTransportLimits { + + /** Largest message a Stable method accepts or sends by default: 1 MiB. */ + public static final int DEFAULT_MAX_MESSAGE_BYTES = 1024 * 1024; + + /** Hard total for one call's metadata: 8 KiB. */ + public static final int DEFAULT_MAX_METADATA_BYTES = 8192; + + private GrpcTransportLimits() {} +} diff --git a/src/grpc/grpc-core-api/src/main/java/dev/caskeleton/grpc/core/GrpcMethodName.java b/src/grpc/grpc-core-api/src/main/java/dev/caskeleton/grpc/core/GrpcMethodName.java index 1db06d28..26528fb0 100644 --- a/src/grpc/grpc-core-api/src/main/java/dev/caskeleton/grpc/core/GrpcMethodName.java +++ b/src/grpc/grpc-core-api/src/main/java/dev/caskeleton/grpc/core/GrpcMethodName.java @@ -25,6 +25,16 @@ public record GrpcMethodName(GrpcServiceName service, String method) { throw new IllegalArgumentException( "method must be an UpperCamelCase proto method name; got '" + method + "'"); } + // The same bound parse() applies to the whole name, so both ways of making a method name + // accept exactly the same set of names. + int fullLength = service.value().length() + 1 + method.length(); + if (fullLength > GrpcIdentifiers.MAX_LENGTH) { + throw new IllegalArgumentException( + "full method name must be at most " + + GrpcIdentifiers.MAX_LENGTH + + " characters; got " + + fullLength); + } } /** diff --git a/src/grpc/grpc-core-api/src/main/java/dev/caskeleton/grpc/core/GrpcStatusCode.java b/src/grpc/grpc-core-api/src/main/java/dev/caskeleton/grpc/core/GrpcStatusCode.java index 23e44d9f..3c1a6328 100644 --- a/src/grpc/grpc-core-api/src/main/java/dev/caskeleton/grpc/core/GrpcStatusCode.java +++ b/src/grpc/grpc-core-api/src/main/java/dev/caskeleton/grpc/core/GrpcStatusCode.java @@ -5,7 +5,7 @@ package dev.caskeleton.grpc.core; * *

The mirror is the point. The Stable plan requires the evidence and failure model to be * framework-free, and a failure context that names {@code io.grpc.Status} would put the transport - * inside the contract that exists to describe what the transport did. {@code grpc-policy} owns the + * inside the contract that exists to describe what the transport did. {@code grpc-runtime} owns the * translation in both directions and is tested against the real enum. */ public enum GrpcStatusCode { diff --git a/src/grpc/grpc-core-api/src/test/java/dev/caskeleton/grpc/api/context/GrpcMetadataBudgetTest.java b/src/grpc/grpc-core-api/src/test/java/dev/caskeleton/grpc/api/context/GrpcMetadataBudgetTest.java index 4a4851df..8241a1dc 100644 --- a/src/grpc/grpc-core-api/src/test/java/dev/caskeleton/grpc/api/context/GrpcMetadataBudgetTest.java +++ b/src/grpc/grpc-core-api/src/test/java/dev/caskeleton/grpc/api/context/GrpcMetadataBudgetTest.java @@ -18,7 +18,7 @@ import org.junit.jupiter.api.Test; class GrpcMetadataBudgetTest { private static final GrpcMethodName GET = - GrpcMethodName.parse("hyeonworks.document.v1.DocumentService/GetDocument"); + GrpcMethodName.parse("caskeleton.document.v1.DocumentService/GetDocument"); private static final GrpcMetadataKey CORRELATION = GrpcMetadataKey.ascii("x-correlation-id"); private static final GrpcMetadataKey IDEMPOTENCY = GrpcMetadataKey.ascii("x-idempotency-key"); diff --git a/src/grpc/grpc-core-api/src/test/java/dev/caskeleton/grpc/api/error/GrpcFailureContextTest.java b/src/grpc/grpc-core-api/src/test/java/dev/caskeleton/grpc/api/error/GrpcFailureContextTest.java index 930a7431..c56aff7a 100644 --- a/src/grpc/grpc-core-api/src/test/java/dev/caskeleton/grpc/api/error/GrpcFailureContextTest.java +++ b/src/grpc/grpc-core-api/src/test/java/dev/caskeleton/grpc/api/error/GrpcFailureContextTest.java @@ -18,9 +18,9 @@ import org.junit.jupiter.api.Test; class GrpcFailureContextTest { private static final GrpcMethodName CREATE = - GrpcMethodName.parse("hyeonworks.document.v1.DocumentService/CreateDocument"); + GrpcMethodName.parse("caskeleton.document.v1.DocumentService/CreateDocument"); private static final GrpcMethodName WATCH = - GrpcMethodName.parse("hyeonworks.document.v1.DocumentService/WatchDocuments"); + GrpcMethodName.parse("caskeleton.document.v1.DocumentService/WatchDocuments"); private static GrpcExecutionEvidence sentButUnanswered() { return new GrpcExecutionEvidence( @@ -99,7 +99,7 @@ class GrpcFailureContextTest { String summary = context.redactedSummary(); assertThat(summary) - .contains("hyeonworks.document.v1.DocumentService/CreateDocument") + .contains("caskeleton.document.v1.DocumentService/CreateDocument") .contains("DEADLINE_EXCEEDED") .contains("COMPLETION_UNKNOWN") .contains("RESOLVE_FIRST") diff --git a/src/grpc/grpc-core-api/src/test/java/dev/caskeleton/grpc/api/ledger/GrpcOperationIdentityTest.java b/src/grpc/grpc-core-api/src/test/java/dev/caskeleton/grpc/api/ledger/GrpcOperationIdentityTest.java index c210e211..2701a083 100644 --- a/src/grpc/grpc-core-api/src/test/java/dev/caskeleton/grpc/api/ledger/GrpcOperationIdentityTest.java +++ b/src/grpc/grpc-core-api/src/test/java/dev/caskeleton/grpc/api/ledger/GrpcOperationIdentityTest.java @@ -10,7 +10,7 @@ import org.junit.jupiter.api.Test; class GrpcOperationIdentityTest { private static final GrpcMethodName CREATE = - GrpcMethodName.parse("hyeonworks.document.v1.DocumentService/CreateDocument"); + GrpcMethodName.parse("caskeleton.document.v1.DocumentService/CreateDocument"); private static final String KEY_HASH = "sha256:aabbccddeeff00112233445566778899aabbccddeeff00112233445566778899"; diff --git a/src/grpc/grpc-core-api/src/test/java/dev/caskeleton/grpc/api/policy/GrpcMethodPolicyCatalogTest.java b/src/grpc/grpc-core-api/src/test/java/dev/caskeleton/grpc/api/policy/GrpcMethodPolicyCatalogTest.java index fc526431..738c8718 100644 --- a/src/grpc/grpc-core-api/src/test/java/dev/caskeleton/grpc/api/policy/GrpcMethodPolicyCatalogTest.java +++ b/src/grpc/grpc-core-api/src/test/java/dev/caskeleton/grpc/api/policy/GrpcMethodPolicyCatalogTest.java @@ -14,11 +14,11 @@ import org.junit.jupiter.api.Test; class GrpcMethodPolicyCatalogTest { private static final GrpcMethodName GET = - GrpcMethodName.parse("hyeonworks.document.v1.DocumentService/GetDocument"); + GrpcMethodName.parse("caskeleton.document.v1.DocumentService/GetDocument"); private static final GrpcMethodName CREATE = - GrpcMethodName.parse("hyeonworks.document.v1.DocumentService/CreateDocument"); + GrpcMethodName.parse("caskeleton.document.v1.DocumentService/CreateDocument"); private static final GrpcMethodName WATCH = - GrpcMethodName.parse("hyeonworks.document.v1.DocumentService/WatchDocuments"); + GrpcMethodName.parse("caskeleton.document.v1.DocumentService/WatchDocuments"); private static final GrpcDeadlineProfile TWO_SECONDS = GrpcDeadlineProfile.of(Duration.ofSeconds(2)); @@ -178,6 +178,6 @@ class GrpcMethodPolicyCatalogTest { assertThat(catalog.methods()) .extracting(GrpcMethodName::canonical) - .containsExactly("hyeonworks.document.v1.DocumentService/GetDocument"); + .containsExactly("caskeleton.document.v1.DocumentService/GetDocument"); } } diff --git a/src/grpc/grpc-core-api/src/test/java/dev/caskeleton/grpc/core/GrpcCoreIdentifiersTest.java b/src/grpc/grpc-core-api/src/test/java/dev/caskeleton/grpc/core/GrpcCoreIdentifiersTest.java index 08ce0a83..7940d71a 100644 --- a/src/grpc/grpc-core-api/src/test/java/dev/caskeleton/grpc/core/GrpcCoreIdentifiersTest.java +++ b/src/grpc/grpc-core-api/src/test/java/dev/caskeleton/grpc/core/GrpcCoreIdentifiersTest.java @@ -2,6 +2,7 @@ package dev.caskeleton.grpc.core; import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThatThrownBy; +import static org.assertj.core.api.Assertions.catchThrowable; import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.Test; @@ -14,12 +15,12 @@ class GrpcCoreIdentifiersTest { @DisplayName("a full method name round-trips through its canonical form") void methodNameRoundTripsThroughCanonicalForm() { GrpcMethodName parsed = - GrpcMethodName.parse("hyeonworks.document.v1.DocumentService/GetDocument"); + GrpcMethodName.parse("caskeleton.document.v1.DocumentService/GetDocument"); - assertThat(parsed.canonical()).isEqualTo("hyeonworks.document.v1.DocumentService/GetDocument"); + assertThat(parsed.canonical()).isEqualTo("caskeleton.document.v1.DocumentService/GetDocument"); assertThat(parsed.method()).isEqualTo("GetDocument"); assertThat(parsed.service().simpleName()).isEqualTo("DocumentService"); - assertThat(parsed.service().protoPackage()).isEqualTo("hyeonworks.document.v1"); + assertThat(parsed.service().protoPackage()).isEqualTo("caskeleton.document.v1"); assertThat(GrpcMethodName.parse(parsed.canonical())).isEqualTo(parsed); } @@ -27,9 +28,9 @@ class GrpcCoreIdentifiersTest { @ValueSource( strings = { "DocumentService/Get", - "hyeonworks.document.v1.DocumentService", - "hyeonworks.document.v1.DocumentService/Get/Extra", - "hyeonworks.document.v1.DocumentService/getDocument" + "caskeleton.document.v1.DocumentService", + "caskeleton.document.v1.DocumentService/Get/Extra", + "caskeleton.document.v1.DocumentService/getDocument" }) @DisplayName("a name that is not exactly package.Service/Method is refused") void nonCanonicalMethodNamesAreRefused(String candidate) { @@ -37,6 +38,22 @@ class GrpcCoreIdentifiersTest { .isInstanceOf(IllegalArgumentException.class); } + @Test + @DisplayName("생성자로 만든 full method name도 parse와 같은 256자 한도를 넘으면 거부된다") + void constructedMethodNameLongerThanTheParseLimitIsRefused() { + // given + GrpcServiceName service = new GrpcServiceName("pkg.v1." + "S".repeat(200)); + String method = "M".repeat(100); + + // when + Throwable thrown = catchThrowable(() -> new GrpcMethodName(service, method)); + + // then + assertThat(thrown) + .isInstanceOf(IllegalArgumentException.class) + .hasMessage("full method name must be at most 256 characters; got 308"); + } + @ParameterizedTest @ValueSource(strings = {"", "svc name", "Has Space", "tab\tseparated"}) @DisplayName("blank, whitespace and control-character identifiers are refused") diff --git a/src/grpc/grpc-core-api/src/test/java/dev/caskeleton/grpc/evidence/GrpcExecutionEvidenceTest.java b/src/grpc/grpc-core-api/src/test/java/dev/caskeleton/grpc/evidence/GrpcExecutionEvidenceTest.java index c2cbf52b..4b3b5283 100644 --- a/src/grpc/grpc-core-api/src/test/java/dev/caskeleton/grpc/evidence/GrpcExecutionEvidenceTest.java +++ b/src/grpc/grpc-core-api/src/test/java/dev/caskeleton/grpc/evidence/GrpcExecutionEvidenceTest.java @@ -11,9 +11,9 @@ import org.junit.jupiter.api.Test; class GrpcExecutionEvidenceTest { private static final GrpcMethodName CREATE = - GrpcMethodName.parse("hyeonworks.document.v1.DocumentService/CreateDocument"); + GrpcMethodName.parse("caskeleton.document.v1.DocumentService/CreateDocument"); private static final GrpcMethodName WATCH = - GrpcMethodName.parse("hyeonworks.document.v1.DocumentService/WatchDocuments"); + GrpcMethodName.parse("caskeleton.document.v1.DocumentService/WatchDocuments"); @Test @DisplayName("seeing response headers never promotes the business axis to a confirmed commit") diff --git a/src/grpc/grpc-core-api/src/testFixtures/java/dev/caskeleton/grpc/api/ledger/GrpcOperationLedgerContract.java b/src/grpc/grpc-core-api/src/testFixtures/java/dev/caskeleton/grpc/api/ledger/GrpcOperationLedgerContract.java index ebc1110c..1ff769cc 100644 --- a/src/grpc/grpc-core-api/src/testFixtures/java/dev/caskeleton/grpc/api/ledger/GrpcOperationLedgerContract.java +++ b/src/grpc/grpc-core-api/src/testFixtures/java/dev/caskeleton/grpc/api/ledger/GrpcOperationLedgerContract.java @@ -26,7 +26,7 @@ public abstract class GrpcOperationLedgerContract { private static final GrpcOperationIdentity ID = new GrpcOperationIdentity( "tenant-1.actor-1", - GrpcMethodName.parse("hyeonworks.document.v1.DocumentService/CreateDocument"), + GrpcMethodName.parse("caskeleton.document.v1.DocumentService/CreateDocument"), "sha256:aabbccddeeff00112233445566778899aabbccddeeff00112233445566778899"); private static final String FINGERPRINT = "sha256:0f1e2d3c4b5a69788796a5b4c3d2e1f00f1e2d3c4b5a69788796a5b4c3d2e1f0"; diff --git a/src/grpc/grpc-discovery/build.gradle b/src/grpc/grpc-discovery/build.gradle deleted file mode 100644 index bee89e7a..00000000 --- a/src/grpc/grpc-discovery/build.gradle +++ /dev/null @@ -1,11 +0,0 @@ -plugins { - id 'ca.platform-module' -} - -// Stable discovery: Static/DNS resolvers, pick_first/round_robin load balancing, and the -// Kubernetes VIP / headless / mesh routing profiles. Custom resolvers, custom load balancers and -// xDS are Advanced and are refused here by GrpcDiscoveryPolicyValidator. -dependencies { - api project(':grpc:grpc-core-api') - api project(':grpc:grpc-client') -} diff --git a/src/grpc/grpc-discovery/gradle.lockfile b/src/grpc/grpc-discovery/gradle.lockfile deleted file mode 100644 index 9369e831..00000000 --- a/src/grpc/grpc-discovery/gradle.lockfile +++ /dev/null @@ -1,91 +0,0 @@ -# This is a Gradle generated file for dependency locking. -# Manual edits can break the build and are not advised. -# This file is expected to be part of source control. -com.github.ben-manes.caffeine:caffeine:3.2.4=annotationProcessor,testAnnotationProcessor -com.github.kevinstern:software-and-algorithms:1.0=annotationProcessor,testAnnotationProcessor -com.github.spotbugs:spotbugs-annotations:4.10.2=spotbugs -com.github.spotbugs:spotbugs:4.10.2=spotbugs -com.github.stephenc.jcip:jcip-annotations:1.0-1=spotbugs -com.google.auto.service:auto-service-annotations:1.0.1=annotationProcessor,testAnnotationProcessor -com.google.auto.value:auto-value-annotations:1.9=annotationProcessor,testAnnotationProcessor -com.google.auto:auto-common:1.2.2=annotationProcessor,testAnnotationProcessor -com.google.code.findbugs:jsr305:3.0.2=checkstyle,compileClasspath,runtimeClasspath,spotbugs,testCompileClasspath,testRuntimeClasspath -com.google.code.gson:gson:2.13.2=spotbugs -com.google.errorprone:error_prone_annotation:2.49.0=annotationProcessor,testAnnotationProcessor -com.google.errorprone:error_prone_annotations:2.28.0=compileClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath -com.google.errorprone:error_prone_annotations:2.41.0=spotbugs -com.google.errorprone:error_prone_annotations:2.47.0=checkstyle -com.google.errorprone:error_prone_annotations:2.49.0=annotationProcessor,testAnnotationProcessor -com.google.errorprone:error_prone_check_api:2.49.0=annotationProcessor,testAnnotationProcessor -com.google.errorprone:error_prone_core:2.49.0=annotationProcessor,testAnnotationProcessor -com.google.googlejavaformat:google-java-format:1.35.0=annotationProcessor,testAnnotationProcessor -com.google.guava:failureaccess:1.0.2=compileClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath -com.google.guava:failureaccess:1.0.3=annotationProcessor,checkstyle,testAnnotationProcessor -com.google.guava:guava:33.2.1-android=compileClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath -com.google.guava:guava:33.5.0-jre=annotationProcessor,testAnnotationProcessor -com.google.guava:guava:33.6.0-jre=checkstyle -com.google.guava:listenablefuture:9999.0-empty-to-avoid-conflict-with-guava=annotationProcessor,checkstyle,compileClasspath,runtimeClasspath,testAnnotationProcessor,testCompileClasspath,testRuntimeClasspath -com.google.j2objc:j2objc-annotations:3.0.0=compileClasspath,testCompileClasspath -com.google.j2objc:j2objc-annotations:3.1=annotationProcessor,checkstyle,testAnnotationProcessor -com.google.protobuf:protobuf-java:4.33.2=annotationProcessor,testAnnotationProcessor -com.h3xstream.findsecbugs:findsecbugs-plugin:1.14.0=spotbugsPlugins -com.puppycrawl.tools:checkstyle:13.5.0=checkstyle -commons-beanutils:commons-beanutils:1.11.0=checkstyle -commons-collections:commons-collections:3.2.2=checkstyle -commons-io:commons-io:2.21.0=spotbugs -info.picocli:picocli:4.7.7=checkstyle -io.github.eisop:dataflow-errorprone:3.41.0-eisop1=annotationProcessor,testAnnotationProcessor -io.github.java-diff-utils:java-diff-utils:4.12=annotationProcessor,testAnnotationProcessor -io.grpc:grpc-api:1.68.1=compileClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath -io.grpc:grpc-stub:1.68.1=compileClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath -javax.inject:javax.inject:1=annotationProcessor,testAnnotationProcessor -jaxen:jaxen:2.0.6=spotbugs -net.bytebuddy:byte-buddy:1.17.8=testCompileClasspath,testRuntimeClasspath -net.sf.saxon:Saxon-HE:12.9=checkstyle,spotbugs -org.antlr:antlr4-runtime:4.13.2=checkstyle -org.apache.bcel:bcel:6.12.0=spotbugs -org.apache.commons:commons-lang3:3.20.0=checkstyle,spotbugs -org.apache.commons:commons-text:1.15.0=spotbugs -org.apache.commons:commons-text:1.3=checkstyle -org.apache.httpcomponents:httpclient:4.5.13=checkstyle -org.apache.httpcomponents:httpcore:4.4.16=checkstyle -org.apache.logging.log4j:log4j-api:2.25.5=spotbugs -org.apache.logging.log4j:log4j-core:2.25.5=spotbugs -org.apache.maven.doxia:doxia-core:1.12.0=checkstyle -org.apache.maven.doxia:doxia-logging-api:1.12.0=checkstyle -org.apache.maven.doxia:doxia-module-xdoc:1.12.0=checkstyle -org.apache.maven.doxia:doxia-sink-api:1.12.0=checkstyle -org.apache.xbean:xbean-reflect:3.7=checkstyle -org.apiguardian:apiguardian-api:1.1.2=testCompileClasspath -org.assertj:assertj-core:3.27.7=testCompileClasspath,testRuntimeClasspath -org.checkerframework:checker-qual:3.42.0=compileClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath -org.codehaus.plexus:plexus-classworlds:2.6.0=checkstyle -org.codehaus.plexus:plexus-component-annotations:2.1.0=checkstyle -org.codehaus.plexus:plexus-container-default:2.1.0=checkstyle -org.codehaus.plexus:plexus-utils:3.3.0=checkstyle -org.dom4j:dom4j:2.2.0=spotbugs -org.javassist:javassist:3.28.0-GA=checkstyle -org.jspecify:jspecify:1.0.1=annotationProcessor,checkstyle,testAnnotationProcessor,testCompileClasspath -org.junit.jupiter:junit-jupiter-api:6.0.3=testCompileClasspath,testRuntimeClasspath -org.junit.jupiter:junit-jupiter-engine:6.0.3=testRuntimeClasspath -org.junit.jupiter:junit-jupiter-params:6.0.3=testCompileClasspath,testRuntimeClasspath -org.junit.jupiter:junit-jupiter:6.0.3=testCompileClasspath,testRuntimeClasspath -org.junit.platform:junit-platform-commons:6.0.3=testCompileClasspath,testRuntimeClasspath -org.junit.platform:junit-platform-engine:6.0.3=testRuntimeClasspath -org.junit.platform:junit-platform-launcher:6.0.3=testRuntimeClasspath -org.junit:junit-bom:6.0.3=testCompileClasspath,testRuntimeClasspath -org.junit:junit-bom:6.1.0=spotbugs -org.mockito:mockito-core:5.20.0=mockitoAgent -org.opentest4j:opentest4j:1.3.0=testCompileClasspath,testRuntimeClasspath -org.ow2.asm:asm-analysis:9.10.1=spotbugs -org.ow2.asm:asm-commons:9.10.1=spotbugs -org.ow2.asm:asm-tree:9.10.1=spotbugs -org.ow2.asm:asm-util:9.10.1=spotbugs -org.ow2.asm:asm:9.10.1=spotbugs -org.pcollections:pcollections:4.0.1=annotationProcessor,testAnnotationProcessor -org.reflections:reflections:0.10.2=checkstyle -org.slf4j:slf4j-api:2.0.18=spotbugs,spotbugsSlf4j -org.slf4j:slf4j-simple:2.0.17=spotbugsSlf4j -org.slf4j:slf4j-simple:2.0.18=checkstyle -org.xmlresolver:xmlresolver:5.3.3=checkstyle,spotbugs -empty= diff --git a/src/grpc/grpc-observability/src/test/java/dev/caskeleton/grpc/observability/GrpcMetricCardinalityPolicyTest.java b/src/grpc/grpc-observability/src/test/java/dev/caskeleton/grpc/observability/GrpcMetricCardinalityPolicyTest.java index f8231bd7..6cb5ebd2 100644 --- a/src/grpc/grpc-observability/src/test/java/dev/caskeleton/grpc/observability/GrpcMetricCardinalityPolicyTest.java +++ b/src/grpc/grpc-observability/src/test/java/dev/caskeleton/grpc/observability/GrpcMetricCardinalityPolicyTest.java @@ -17,7 +17,7 @@ import org.junit.jupiter.api.Test; class GrpcMetricCardinalityPolicyTest { private static final GrpcMethodName GET = - GrpcMethodName.parse("hyeonworks.document.v1.DocumentService/GetDocument"); + GrpcMethodName.parse("caskeleton.document.v1.DocumentService/GetDocument"); private static GrpcRpcObservation observation(int attempts, GrpcCompletionOutcome outcome) { return new GrpcRpcObservation( diff --git a/src/grpc/grpc-operation-ledger-jpa/src/integrationTest/java/dev/caskeleton/grpc/ledger/JpaGrpcOperationLedgerContractIT.java b/src/grpc/grpc-operation-ledger-jpa/src/integrationTest/java/dev/caskeleton/grpc/ledger/JpaGrpcOperationLedgerContractIT.java index 0a172794..2d1e6b20 100644 --- a/src/grpc/grpc-operation-ledger-jpa/src/integrationTest/java/dev/caskeleton/grpc/ledger/JpaGrpcOperationLedgerContractIT.java +++ b/src/grpc/grpc-operation-ledger-jpa/src/integrationTest/java/dev/caskeleton/grpc/ledger/JpaGrpcOperationLedgerContractIT.java @@ -98,7 +98,7 @@ class JpaGrpcOperationLedgerContractIT extends GrpcOperationLedgerContract { GrpcOperationIdentity id = new GrpcOperationIdentity( "tenant-1.actor-1", - GrpcMethodName.parse("hyeonworks.document.v1.DocumentService/CreateDocument"), + GrpcMethodName.parse("caskeleton.document.v1.DocumentService/CreateDocument"), "sha256:aabbccddeeff00112233445566778899aabbccddeeff00112233445566778899"); String fingerprint = "sha256:0f1e2d3c4b5a69788796a5b4c3d2e1f00f1e2d3c4b5a69788796a5b4c3d2e1f0"; Instant now = Instant.parse("2026-09-25T10:00:00Z"); diff --git a/src/grpc/grpc-operation-ledger-jpa/src/test/java/dev/caskeleton/grpc/ledger/GrpcOperationLedgerRepositoryTest.java b/src/grpc/grpc-operation-ledger-jpa/src/test/java/dev/caskeleton/grpc/ledger/GrpcOperationLedgerRepositoryTest.java index 84862d5d..8da7c640 100644 --- a/src/grpc/grpc-operation-ledger-jpa/src/test/java/dev/caskeleton/grpc/ledger/GrpcOperationLedgerRepositoryTest.java +++ b/src/grpc/grpc-operation-ledger-jpa/src/test/java/dev/caskeleton/grpc/ledger/GrpcOperationLedgerRepositoryTest.java @@ -24,7 +24,7 @@ import org.junit.jupiter.api.Test; class GrpcOperationLedgerRepositoryTest { private static final GrpcMethodName CREATE = - GrpcMethodName.parse("hyeonworks.document.v1.DocumentService/CreateDocument"); + GrpcMethodName.parse("caskeleton.document.v1.DocumentService/CreateDocument"); private static final Instant NOW = Instant.parse("2026-08-30T10:00:00Z"); private static final String FINGERPRINT = "sha256:0f1e2d3c4b5a69788796a5b4c3d2e1f00f1e2d3c4b5a69788796a5b4c3d2e1f0"; diff --git a/src/grpc/grpc-policy/build.gradle b/src/grpc/grpc-policy/build.gradle deleted file mode 100644 index 6d3694ea..00000000 --- a/src/grpc/grpc-policy/build.gradle +++ /dev/null @@ -1,19 +0,0 @@ -plugins { - id 'ca.grpc-platform-module' -} - -// Validation, context propagation, status/rich-error mapping, TLS/credential profiles, deadline -// and cancellation, retry ownership and eligibility, idempotency and completion recovery, server -// streaming, payload size and compression. - -dependencies { - api project(':grpc:grpc-core-api') - - // api: interceptors, context binders and the error mapper name io.grpc types in public - // signatures, so an adopter cannot compile against this module without them. - api "io.grpc:grpc-api" - api "io.grpc:grpc-stub" - - // The shared operation-ledger fake, held to the same contract as the JPA adapter. - testImplementation testFixtures(project(':grpc:grpc-core-api')) -} diff --git a/src/grpc/grpc-policy/gradle.lockfile b/src/grpc/grpc-policy/gradle.lockfile deleted file mode 100644 index 9369e831..00000000 --- a/src/grpc/grpc-policy/gradle.lockfile +++ /dev/null @@ -1,91 +0,0 @@ -# This is a Gradle generated file for dependency locking. -# Manual edits can break the build and are not advised. -# This file is expected to be part of source control. -com.github.ben-manes.caffeine:caffeine:3.2.4=annotationProcessor,testAnnotationProcessor -com.github.kevinstern:software-and-algorithms:1.0=annotationProcessor,testAnnotationProcessor -com.github.spotbugs:spotbugs-annotations:4.10.2=spotbugs -com.github.spotbugs:spotbugs:4.10.2=spotbugs -com.github.stephenc.jcip:jcip-annotations:1.0-1=spotbugs -com.google.auto.service:auto-service-annotations:1.0.1=annotationProcessor,testAnnotationProcessor -com.google.auto.value:auto-value-annotations:1.9=annotationProcessor,testAnnotationProcessor -com.google.auto:auto-common:1.2.2=annotationProcessor,testAnnotationProcessor -com.google.code.findbugs:jsr305:3.0.2=checkstyle,compileClasspath,runtimeClasspath,spotbugs,testCompileClasspath,testRuntimeClasspath -com.google.code.gson:gson:2.13.2=spotbugs -com.google.errorprone:error_prone_annotation:2.49.0=annotationProcessor,testAnnotationProcessor -com.google.errorprone:error_prone_annotations:2.28.0=compileClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath -com.google.errorprone:error_prone_annotations:2.41.0=spotbugs -com.google.errorprone:error_prone_annotations:2.47.0=checkstyle -com.google.errorprone:error_prone_annotations:2.49.0=annotationProcessor,testAnnotationProcessor -com.google.errorprone:error_prone_check_api:2.49.0=annotationProcessor,testAnnotationProcessor -com.google.errorprone:error_prone_core:2.49.0=annotationProcessor,testAnnotationProcessor -com.google.googlejavaformat:google-java-format:1.35.0=annotationProcessor,testAnnotationProcessor -com.google.guava:failureaccess:1.0.2=compileClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath -com.google.guava:failureaccess:1.0.3=annotationProcessor,checkstyle,testAnnotationProcessor -com.google.guava:guava:33.2.1-android=compileClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath -com.google.guava:guava:33.5.0-jre=annotationProcessor,testAnnotationProcessor -com.google.guava:guava:33.6.0-jre=checkstyle -com.google.guava:listenablefuture:9999.0-empty-to-avoid-conflict-with-guava=annotationProcessor,checkstyle,compileClasspath,runtimeClasspath,testAnnotationProcessor,testCompileClasspath,testRuntimeClasspath -com.google.j2objc:j2objc-annotations:3.0.0=compileClasspath,testCompileClasspath -com.google.j2objc:j2objc-annotations:3.1=annotationProcessor,checkstyle,testAnnotationProcessor -com.google.protobuf:protobuf-java:4.33.2=annotationProcessor,testAnnotationProcessor -com.h3xstream.findsecbugs:findsecbugs-plugin:1.14.0=spotbugsPlugins -com.puppycrawl.tools:checkstyle:13.5.0=checkstyle -commons-beanutils:commons-beanutils:1.11.0=checkstyle -commons-collections:commons-collections:3.2.2=checkstyle -commons-io:commons-io:2.21.0=spotbugs -info.picocli:picocli:4.7.7=checkstyle -io.github.eisop:dataflow-errorprone:3.41.0-eisop1=annotationProcessor,testAnnotationProcessor -io.github.java-diff-utils:java-diff-utils:4.12=annotationProcessor,testAnnotationProcessor -io.grpc:grpc-api:1.68.1=compileClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath -io.grpc:grpc-stub:1.68.1=compileClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath -javax.inject:javax.inject:1=annotationProcessor,testAnnotationProcessor -jaxen:jaxen:2.0.6=spotbugs -net.bytebuddy:byte-buddy:1.17.8=testCompileClasspath,testRuntimeClasspath -net.sf.saxon:Saxon-HE:12.9=checkstyle,spotbugs -org.antlr:antlr4-runtime:4.13.2=checkstyle -org.apache.bcel:bcel:6.12.0=spotbugs -org.apache.commons:commons-lang3:3.20.0=checkstyle,spotbugs -org.apache.commons:commons-text:1.15.0=spotbugs -org.apache.commons:commons-text:1.3=checkstyle -org.apache.httpcomponents:httpclient:4.5.13=checkstyle -org.apache.httpcomponents:httpcore:4.4.16=checkstyle -org.apache.logging.log4j:log4j-api:2.25.5=spotbugs -org.apache.logging.log4j:log4j-core:2.25.5=spotbugs -org.apache.maven.doxia:doxia-core:1.12.0=checkstyle -org.apache.maven.doxia:doxia-logging-api:1.12.0=checkstyle -org.apache.maven.doxia:doxia-module-xdoc:1.12.0=checkstyle -org.apache.maven.doxia:doxia-sink-api:1.12.0=checkstyle -org.apache.xbean:xbean-reflect:3.7=checkstyle -org.apiguardian:apiguardian-api:1.1.2=testCompileClasspath -org.assertj:assertj-core:3.27.7=testCompileClasspath,testRuntimeClasspath -org.checkerframework:checker-qual:3.42.0=compileClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath -org.codehaus.plexus:plexus-classworlds:2.6.0=checkstyle -org.codehaus.plexus:plexus-component-annotations:2.1.0=checkstyle -org.codehaus.plexus:plexus-container-default:2.1.0=checkstyle -org.codehaus.plexus:plexus-utils:3.3.0=checkstyle -org.dom4j:dom4j:2.2.0=spotbugs -org.javassist:javassist:3.28.0-GA=checkstyle -org.jspecify:jspecify:1.0.1=annotationProcessor,checkstyle,testAnnotationProcessor,testCompileClasspath -org.junit.jupiter:junit-jupiter-api:6.0.3=testCompileClasspath,testRuntimeClasspath -org.junit.jupiter:junit-jupiter-engine:6.0.3=testRuntimeClasspath -org.junit.jupiter:junit-jupiter-params:6.0.3=testCompileClasspath,testRuntimeClasspath -org.junit.jupiter:junit-jupiter:6.0.3=testCompileClasspath,testRuntimeClasspath -org.junit.platform:junit-platform-commons:6.0.3=testCompileClasspath,testRuntimeClasspath -org.junit.platform:junit-platform-engine:6.0.3=testRuntimeClasspath -org.junit.platform:junit-platform-launcher:6.0.3=testRuntimeClasspath -org.junit:junit-bom:6.0.3=testCompileClasspath,testRuntimeClasspath -org.junit:junit-bom:6.1.0=spotbugs -org.mockito:mockito-core:5.20.0=mockitoAgent -org.opentest4j:opentest4j:1.3.0=testCompileClasspath,testRuntimeClasspath -org.ow2.asm:asm-analysis:9.10.1=spotbugs -org.ow2.asm:asm-commons:9.10.1=spotbugs -org.ow2.asm:asm-tree:9.10.1=spotbugs -org.ow2.asm:asm-util:9.10.1=spotbugs -org.ow2.asm:asm:9.10.1=spotbugs -org.pcollections:pcollections:4.0.1=annotationProcessor,testAnnotationProcessor -org.reflections:reflections:0.10.2=checkstyle -org.slf4j:slf4j-api:2.0.18=spotbugs,spotbugsSlf4j -org.slf4j:slf4j-simple:2.0.17=spotbugsSlf4j -org.slf4j:slf4j-simple:2.0.18=checkstyle -org.xmlresolver:xmlresolver:5.3.3=checkstyle,spotbugs -empty= diff --git a/src/grpc/grpc-policy/src/main/java/dev/caskeleton/grpc/streaming/GrpcStreamProfile.java b/src/grpc/grpc-policy/src/main/java/dev/caskeleton/grpc/streaming/GrpcStreamProfile.java deleted file mode 100644 index f999c26c..00000000 --- a/src/grpc/grpc-policy/src/main/java/dev/caskeleton/grpc/streaming/GrpcStreamProfile.java +++ /dev/null @@ -1,47 +0,0 @@ -package dev.caskeleton.grpc.streaming; - -/** - * How one streaming method behaves before any message is sent. - * - *

{@code liveEventsBeforeSnapshotComplete} is the setting worth arguing about. Delivering live - * events while the snapshot is still being sent gives the client fresher data and an ordering it - * cannot reconstruct: it may see the update to a row before the row itself. Buffering them is - * correct and costs memory bounded by the snapshot duration. Neither is right for every method, - * which is why this is a per-method decision rather than a platform default. - */ -public record GrpcStreamProfile( - boolean snapshotFirst, - boolean liveEventsBeforeSnapshotComplete, - boolean resumable, - int maxBufferedMessages, - long maxBufferedBytes) { - - /** Refuses an incoherent profile. */ - public GrpcStreamProfile { - if (maxBufferedMessages < 1) { - throw new IllegalArgumentException("a stream buffers at least one message"); - } - if (maxBufferedBytes < 1L) { - throw new IllegalArgumentException("a stream needs a positive byte bound"); - } - if (liveEventsBeforeSnapshotComplete && !snapshotFirst) { - throw new IllegalArgumentException( - "a profile without a snapshot cannot describe what happens before the snapshot completes"); - } - } - - /** - * The Stable default: snapshot first, live events buffered until it completes, resumable. - * - *

Buffering is the default because the alternative delivers an update to a row before the row, - * and a client that has to tolerate that is a client doing the platform's ordering work. - */ - public static GrpcStreamProfile snapshotThenLive() { - return new GrpcStreamProfile(true, false, true, 256, 8L * 1024L * 1024L); - } - - /** A live-only stream with no snapshot phase. */ - public static GrpcStreamProfile liveOnly() { - return new GrpcStreamProfile(false, false, true, 256, 8L * 1024L * 1024L); - } -} diff --git a/src/grpc/grpc-proto-contract/build.gradle b/src/grpc/grpc-proto-contract/build.gradle deleted file mode 100644 index d2c9d361..00000000 --- a/src/grpc/grpc-proto-contract/build.gradle +++ /dev/null @@ -1,14 +0,0 @@ -plugins { - id 'ca.platform-module' -} - -// Schema source of truth: the `.proto` files plus the rule engine that judges them. -// -// No protobuf plugin and no protoc invocation here — see -// docs/superpowers/specs/2026-08-30-grpc-platform-adaptation-design.md D6. The validator reads -// `.proto` text and enforces the Stable style manifest (proto3 + explicit optional, package -// versioning, reserved history, enum zero suffix, WKT allowlist), which is the invariant the plan -// owns; running protoc is a separate, gated decision. -dependencies { - api project(':grpc:grpc-core-api') -} diff --git a/src/grpc/grpc-proto-contract/gradle.lockfile b/src/grpc/grpc-proto-contract/gradle.lockfile deleted file mode 100644 index e2c95854..00000000 --- a/src/grpc/grpc-proto-contract/gradle.lockfile +++ /dev/null @@ -1,84 +0,0 @@ -# This is a Gradle generated file for dependency locking. -# Manual edits can break the build and are not advised. -# This file is expected to be part of source control. -com.github.ben-manes.caffeine:caffeine:3.2.4=annotationProcessor,testAnnotationProcessor -com.github.kevinstern:software-and-algorithms:1.0=annotationProcessor,testAnnotationProcessor -com.github.spotbugs:spotbugs-annotations:4.10.2=spotbugs -com.github.spotbugs:spotbugs:4.10.2=spotbugs -com.github.stephenc.jcip:jcip-annotations:1.0-1=spotbugs -com.google.auto.service:auto-service-annotations:1.0.1=annotationProcessor,testAnnotationProcessor -com.google.auto.value:auto-value-annotations:1.9=annotationProcessor,testAnnotationProcessor -com.google.auto:auto-common:1.2.2=annotationProcessor,testAnnotationProcessor -com.google.code.findbugs:jsr305:3.0.2=checkstyle,spotbugs -com.google.code.gson:gson:2.13.2=spotbugs -com.google.errorprone:error_prone_annotation:2.49.0=annotationProcessor,testAnnotationProcessor -com.google.errorprone:error_prone_annotations:2.41.0=spotbugs -com.google.errorprone:error_prone_annotations:2.47.0=checkstyle -com.google.errorprone:error_prone_annotations:2.49.0=annotationProcessor,testAnnotationProcessor -com.google.errorprone:error_prone_check_api:2.49.0=annotationProcessor,testAnnotationProcessor -com.google.errorprone:error_prone_core:2.49.0=annotationProcessor,testAnnotationProcessor -com.google.googlejavaformat:google-java-format:1.35.0=annotationProcessor,testAnnotationProcessor -com.google.guava:failureaccess:1.0.3=annotationProcessor,checkstyle,testAnnotationProcessor -com.google.guava:guava:33.5.0-jre=annotationProcessor,testAnnotationProcessor -com.google.guava:guava:33.6.0-jre=checkstyle -com.google.guava:listenablefuture:9999.0-empty-to-avoid-conflict-with-guava=annotationProcessor,checkstyle,testAnnotationProcessor -com.google.j2objc:j2objc-annotations:3.1=annotationProcessor,checkstyle,testAnnotationProcessor -com.google.protobuf:protobuf-java:4.33.2=annotationProcessor,testAnnotationProcessor -com.h3xstream.findsecbugs:findsecbugs-plugin:1.14.0=spotbugsPlugins -com.puppycrawl.tools:checkstyle:13.5.0=checkstyle -commons-beanutils:commons-beanutils:1.11.0=checkstyle -commons-collections:commons-collections:3.2.2=checkstyle -commons-io:commons-io:2.21.0=spotbugs -info.picocli:picocli:4.7.7=checkstyle -io.github.eisop:dataflow-errorprone:3.41.0-eisop1=annotationProcessor,testAnnotationProcessor -io.github.java-diff-utils:java-diff-utils:4.12=annotationProcessor,testAnnotationProcessor -javax.inject:javax.inject:1=annotationProcessor,testAnnotationProcessor -jaxen:jaxen:2.0.6=spotbugs -net.bytebuddy:byte-buddy:1.17.8=testCompileClasspath,testRuntimeClasspath -net.sf.saxon:Saxon-HE:12.9=checkstyle,spotbugs -org.antlr:antlr4-runtime:4.13.2=checkstyle -org.apache.bcel:bcel:6.12.0=spotbugs -org.apache.commons:commons-lang3:3.20.0=checkstyle,spotbugs -org.apache.commons:commons-text:1.15.0=spotbugs -org.apache.commons:commons-text:1.3=checkstyle -org.apache.httpcomponents:httpclient:4.5.13=checkstyle -org.apache.httpcomponents:httpcore:4.4.16=checkstyle -org.apache.logging.log4j:log4j-api:2.25.5=spotbugs -org.apache.logging.log4j:log4j-core:2.25.5=spotbugs -org.apache.maven.doxia:doxia-core:1.12.0=checkstyle -org.apache.maven.doxia:doxia-logging-api:1.12.0=checkstyle -org.apache.maven.doxia:doxia-module-xdoc:1.12.0=checkstyle -org.apache.maven.doxia:doxia-sink-api:1.12.0=checkstyle -org.apache.xbean:xbean-reflect:3.7=checkstyle -org.apiguardian:apiguardian-api:1.1.2=testCompileClasspath -org.assertj:assertj-core:3.27.7=testCompileClasspath,testRuntimeClasspath -org.codehaus.plexus:plexus-classworlds:2.6.0=checkstyle -org.codehaus.plexus:plexus-component-annotations:2.1.0=checkstyle -org.codehaus.plexus:plexus-container-default:2.1.0=checkstyle -org.codehaus.plexus:plexus-utils:3.3.0=checkstyle -org.dom4j:dom4j:2.2.0=spotbugs -org.javassist:javassist:3.28.0-GA=checkstyle -org.jspecify:jspecify:1.0.1=annotationProcessor,checkstyle,testAnnotationProcessor,testCompileClasspath -org.junit.jupiter:junit-jupiter-api:6.0.3=testCompileClasspath,testRuntimeClasspath -org.junit.jupiter:junit-jupiter-engine:6.0.3=testRuntimeClasspath -org.junit.jupiter:junit-jupiter-params:6.0.3=testCompileClasspath,testRuntimeClasspath -org.junit.jupiter:junit-jupiter:6.0.3=testCompileClasspath,testRuntimeClasspath -org.junit.platform:junit-platform-commons:6.0.3=testCompileClasspath,testRuntimeClasspath -org.junit.platform:junit-platform-engine:6.0.3=testRuntimeClasspath -org.junit.platform:junit-platform-launcher:6.0.3=testRuntimeClasspath -org.junit:junit-bom:6.0.3=testCompileClasspath,testRuntimeClasspath -org.junit:junit-bom:6.1.0=spotbugs -org.mockito:mockito-core:5.20.0=mockitoAgent -org.opentest4j:opentest4j:1.3.0=testCompileClasspath,testRuntimeClasspath -org.ow2.asm:asm-analysis:9.10.1=spotbugs -org.ow2.asm:asm-commons:9.10.1=spotbugs -org.ow2.asm:asm-tree:9.10.1=spotbugs -org.ow2.asm:asm-util:9.10.1=spotbugs -org.ow2.asm:asm:9.10.1=spotbugs -org.pcollections:pcollections:4.0.1=annotationProcessor,testAnnotationProcessor -org.reflections:reflections:0.10.2=checkstyle -org.slf4j:slf4j-api:2.0.18=spotbugs,spotbugsSlf4j -org.slf4j:slf4j-simple:2.0.17=spotbugsSlf4j -org.slf4j:slf4j-simple:2.0.18=checkstyle -org.xmlresolver:xmlresolver:5.3.3=checkstyle,spotbugs -empty=compileClasspath,runtimeClasspath diff --git a/src/grpc/grpc-proto-contract/src/main/java/dev/caskeleton/grpc/contract/GrpcProtoContractValidator.java b/src/grpc/grpc-proto-contract/src/main/java/dev/caskeleton/grpc/contract/GrpcProtoContractValidator.java deleted file mode 100644 index 94dd6318..00000000 --- a/src/grpc/grpc-proto-contract/src/main/java/dev/caskeleton/grpc/contract/GrpcProtoContractValidator.java +++ /dev/null @@ -1,447 +0,0 @@ -package dev.caskeleton.grpc.contract; - -import java.util.ArrayDeque; -import java.util.ArrayList; -import java.util.Deque; -import java.util.LinkedHashMap; -import java.util.LinkedHashSet; -import java.util.List; -import java.util.Map; -import java.util.Set; -import java.util.regex.Matcher; -import java.util.regex.Pattern; - -/** - * Judges committed {@code .proto} sources against {@link GrpcProtoStyleManifest} and the schema's - * own removal history. - * - *

A line scanner, not a Protobuf parser, and that is a deliberate limit rather than a shortcut. - * Everything this checks is a property of the source text a reviewer reads — the syntax line, the - * package, the two Java options, the zero enum value, the {@code reserved} declarations, the - * imports, the {@code map} fields, explicit presence. Semantics that need a compiled descriptor - * belong to {@code grpc-codegen}'s descriptor artifact, which is where a real {@code protoc} run - * would be consumed. - * - *

The removal history is an input rather than something inferred, because it cannot be inferred: - * a field that is simply gone from the current source is indistinguishable from one that never - * existed. Recording removals and checking them against {@code reserved} is the only way the "do - * not reuse a field number" rule survives the commit that deletes the field. - */ -public final class GrpcProtoContractValidator { - - /** Rule ids, so a build log and a review checklist use the same names. */ - public static final String RULE_PROTO3_SYNTAX = "PROTO3_SYNTAX"; - - /** The package must be {@code organization.domain.vMAJOR}. */ - public static final String RULE_PACKAGE_VERSIONED = "PACKAGE_VERSIONED"; - - /** {@code option java_multiple_files = true} must be present. */ - public static final String RULE_JAVA_MULTIPLE_FILES = "JAVA_MULTIPLE_FILES"; - - /** The generated Java package must not collide with a hand-written one. */ - public static final String RULE_JAVA_PACKAGE_SEPARATE = "JAVA_PACKAGE_SEPARATE"; - - /** An enum's zero value must end in {@code _UNSPECIFIED}. */ - public static final String RULE_ENUM_ZERO_UNSPECIFIED = "ENUM_ZERO_UNSPECIFIED"; - - /** A removed field number or name must be {@code reserved}. */ - public static final String RULE_RESERVED_HISTORY = "RESERVED_HISTORY"; - - /** A {@code google.protobuf} import must be on the allowlist. */ - public static final String RULE_WELL_KNOWN_TYPE_ALLOWLIST = "WELL_KNOWN_TYPE_ALLOWLIST"; - - /** A {@code map} field must be on the allowlist. */ - public static final String RULE_MAP_ALLOWLIST = "MAP_ALLOWLIST"; - - /** A field the manifest marks presence-required must be declared {@code optional}. */ - public static final String RULE_EXPLICIT_PRESENCE = "EXPLICIT_PRESENCE"; - - private static final Pattern SYNTAX = Pattern.compile("^\\s*syntax\\s*=\\s*\"([^\"]+)\"\\s*;"); - private static final Pattern PACKAGE = Pattern.compile("^\\s*package\\s+([A-Za-z0-9_.]+)\\s*;"); - private static final Pattern IMPORT = - Pattern.compile("^\\s*import\\s+(?:public\\s+|weak\\s+)?\"([^\"]+)\"\\s*;"); - private static final Pattern OPTION = - Pattern.compile("^\\s*option\\s+([A-Za-z0-9_]+)\\s*=\\s*(.+?)\\s*;"); - private static final Pattern SCOPE_OPEN = - Pattern.compile("^\\s*(message|enum|service|oneof)\\s+([A-Za-z0-9_]+)\\s*\\{"); - private static final Pattern ENUM_VALUE = - Pattern.compile("^\\s*([A-Za-z0-9_]+)\\s*=\\s*(-?\\d+)\\s*(?:\\[[^\\]]*\\])?\\s*;"); - private static final Pattern MAP_FIELD = - Pattern.compile("^\\s*map\\s*<[^>]+>\\s+([A-Za-z0-9_]+)\\s*=\\s*(\\d+)"); - private static final Pattern FIELD = - Pattern.compile( - "^\\s*(optional\\s+|repeated\\s+)?([A-Za-z0-9_.]+)\\s+([A-Za-z0-9_]+)\\s*=\\s*(\\d+)"); - private static final Pattern RESERVED_NUMBERS = - Pattern.compile("^\\s*reserved\\s+([^\";]*\\d[^\";]*);"); - private static final Pattern RESERVED_NAMES = - Pattern.compile("^\\s*reserved\\s+(\"[^;]*\")\\s*;"); - private static final Pattern QUOTED_NAME = Pattern.compile("\"([A-Za-z0-9_]+)\""); - private static final Pattern NUMBER = Pattern.compile("\\d+"); - private static final Pattern LINE_COMMENT = Pattern.compile("//.*$"); - - private final GrpcProtoStyleManifest manifest; - - /** Binds a validator to the manifest it judges against. */ - public GrpcProtoContractValidator(GrpcProtoStyleManifest manifest) { - if (manifest == null) { - throw new IllegalArgumentException("a validator needs a style manifest"); - } - this.manifest = manifest; - } - - /** - * What was removed from a schema, and therefore what must stay reserved. - * - *

Keys are message names as written in the file, nested ones qualified with a dot — {@code - * PreconditionFailure.Violation}. - */ - public record SchemaHistory( - Map> removedFieldNumbers, Map> removedFieldNames) { - - /** Copies both maps. */ - public SchemaHistory { - if (removedFieldNumbers == null || removedFieldNames == null) { - throw new IllegalArgumentException("a schema history needs both removal maps"); - } - removedFieldNumbers = copyOf(removedFieldNumbers); - removedFieldNames = copyOf(removedFieldNames); - } - - private static Map> copyOf(Map> source) { - Map> copy = new LinkedHashMap<>(); - source.forEach((key, value) -> copy.put(key, Set.copyOf(value))); - return Map.copyOf(copy); - } - - /** A schema nothing has been removed from yet. */ - public static SchemaHistory empty() { - return new SchemaHistory(Map.of(), Map.of()); - } - } - - /** Validates one file against the manifest, with no removal history to check. */ - public List validate(String fileName, String source) { - return validate(fileName, source, SchemaHistory.empty()); - } - - /** - * Validates one file against the manifest and its removal history. - * - * @return every violation found, in source order; empty when the file is compliant - */ - public List validate( - String fileName, String source, SchemaHistory history) { - if (fileName == null || fileName.isBlank()) { - throw new IllegalArgumentException("a proto file needs a name"); - } - if (source == null) { - throw new IllegalArgumentException("a proto file needs source text"); - } - if (history == null) { - throw new IllegalArgumentException("a schema history must be present; use empty()"); - } - - List violations = new ArrayList<>(); - Scan scan = scan(fileName, source, violations); - - checkFileHeader(fileName, scan, violations); - checkRemovalHistory(fileName, scan, history, violations); - return List.copyOf(violations); - } - - private void checkFileHeader( - String fileName, Scan scan, List violations) { - if (!"proto3".equals(scan.syntax)) { - violations.add( - GrpcProtoRuleViolation.ofFile( - RULE_PROTO3_SYNTAX, - fileName, - "Stable schema source must declare syntax = \"proto3\"; found " - + (scan.syntax == null ? "no syntax declaration" : "'" + scan.syntax + "'"))); - } - String expectedPrefix = manifest.organization() + "."; - if (scan.protoPackage == null) { - violations.add( - GrpcProtoRuleViolation.ofFile( - RULE_PACKAGE_VERSIONED, fileName, "no package declaration")); - } else if (!scan.protoPackage.startsWith(expectedPrefix) - || !scan.protoPackage.matches(".*\\.v[1-9]\\d*$")) { - violations.add( - new GrpcProtoRuleViolation( - RULE_PACKAGE_VERSIONED, - fileName, - scan.packageLine, - "package must be '" - + manifest.organization() - + "..v'; got '" - + scan.protoPackage - + "'")); - } - if (!"true".equals(scan.options.get("java_multiple_files"))) { - violations.add( - GrpcProtoRuleViolation.ofFile( - RULE_JAVA_MULTIPLE_FILES, - fileName, - "option java_multiple_files = true is required; one outer class per file hides every " - + "generated type behind a name the schema never mentions")); - } - String javaPackage = unquote(scan.options.get("java_package")); - if (javaPackage == null || javaPackage.isBlank()) { - violations.add( - GrpcProtoRuleViolation.ofFile( - RULE_JAVA_PACKAGE_SEPARATE, fileName, "option java_package is required")); - } else { - for (String handWritten : manifest.handWrittenJavaPackages()) { - if (javaPackage.equals(handWritten) || javaPackage.startsWith(handWritten + ".")) { - violations.add( - GrpcProtoRuleViolation.ofFile( - RULE_JAVA_PACKAGE_SEPARATE, - fileName, - "generated java_package '" - + javaPackage - + "' is inside hand-written package '" - + handWritten - + "'; generated and hand-written types must not share a package")); - } - } - } - } - - private static void checkRemovalHistory( - String fileName, Scan scan, SchemaHistory history, List violations) { - history - .removedFieldNumbers() - .forEach( - (message, numbers) -> { - Set reserved = scan.reservedNumbers.getOrDefault(message, Set.of()); - Set missing = new LinkedHashSet<>(numbers); - missing.removeAll(reserved); - if (!missing.isEmpty()) { - violations.add( - GrpcProtoRuleViolation.ofFile( - RULE_RESERVED_HISTORY, - fileName, - "message '" - + message - + "' removed field numbers " - + missing.stream().sorted().toList() - + " without reserving them; the next field added would reuse a number " - + "an old client still writes")); - } - }); - history - .removedFieldNames() - .forEach( - (message, names) -> { - Set reserved = scan.reservedNames.getOrDefault(message, Set.of()); - Set missing = new LinkedHashSet<>(names); - missing.removeAll(reserved); - if (!missing.isEmpty()) { - violations.add( - GrpcProtoRuleViolation.ofFile( - RULE_RESERVED_HISTORY, - fileName, - "message '" - + message - + "' removed field names " - + missing.stream().sorted().toList() - + " without reserving them; reusing the name changes the JSON contract")); - } - }); - } - - private Scan scan(String fileName, String source, List violations) { - Scan scan = new Scan(); - Deque scopeKinds = new ArrayDeque<>(); - Deque scopeNames = new ArrayDeque<>(); - int lineNumber = 0; - - for (String rawLine : source.lines().toList()) { - lineNumber++; - String line = LINE_COMMENT.matcher(rawLine).replaceAll(""); - if (line.isBlank()) { - continue; - } - - Matcher syntax = SYNTAX.matcher(line); - if (syntax.find()) { - scan.syntax = syntax.group(1); - continue; - } - Matcher packageMatcher = PACKAGE.matcher(line); - if (packageMatcher.find()) { - scan.protoPackage = packageMatcher.group(1); - scan.packageLine = lineNumber; - continue; - } - Matcher importMatcher = IMPORT.matcher(line); - if (importMatcher.find()) { - String importPath = importMatcher.group(1); - if (!manifest.wellKnownTypeAllowed(importPath)) { - violations.add( - new GrpcProtoRuleViolation( - RULE_WELL_KNOWN_TYPE_ALLOWLIST, - fileName, - lineNumber, - "import '" - + importPath - + "' is not on the well-known type allowlist; Any and Struct erase the " - + "schema they are supposed to describe, so each use is granted by name")); - } - continue; - } - Matcher option = OPTION.matcher(line); - if (option.find() && scopeKinds.isEmpty()) { - scan.options.put(option.group(1), option.group(2)); - continue; - } - - Matcher scopeOpen = SCOPE_OPEN.matcher(line); - if (scopeOpen.find()) { - scopeKinds.push(scopeOpen.group(1)); - scopeNames.push(qualify(scopeNames, scopeOpen.group(2))); - continue; - } - if (line.strip().startsWith("}")) { - if (!scopeKinds.isEmpty()) { - scopeKinds.pop(); - scopeNames.pop(); - } - continue; - } - if (scopeKinds.isEmpty()) { - continue; - } - - String scopeKind = scopeKinds.peek(); - String scopeName = scopeNames.peek(); - if ("enum".equals(scopeKind)) { - scanEnumValue(fileName, line, lineNumber, scopeName, violations); - } else if ("message".equals(scopeKind) || "oneof".equals(scopeKind)) { - scanMessageMember(fileName, line, lineNumber, scopeName, scan, violations); - } - } - return scan; - } - - private static void scanEnumValue( - String fileName, - String line, - int lineNumber, - String enumName, - List violations) { - Matcher value = ENUM_VALUE.matcher(line); - if (!value.find()) { - return; - } - if (!"0".equals(value.group(2))) { - return; - } - String name = value.group(1); - if (!name.endsWith("_UNSPECIFIED")) { - violations.add( - new GrpcProtoRuleViolation( - RULE_ENUM_ZERO_UNSPECIFIED, - fileName, - lineNumber, - "enum '" - + enumName - + "' zero value is '" - + name - + "'; proto3 gives an unset field the zero value, so a meaningful name there is " - + "indistinguishable from a field nobody set")); - } - } - - private void scanMessageMember( - String fileName, - String line, - int lineNumber, - String messageName, - Scan scan, - List violations) { - Matcher reservedNames = RESERVED_NAMES.matcher(line); - if (reservedNames.find()) { - Matcher quoted = QUOTED_NAME.matcher(reservedNames.group(1)); - while (quoted.find()) { - scan.reservedNames - .computeIfAbsent(messageName, key -> new LinkedHashSet<>()) - .add(quoted.group(1)); - } - return; - } - Matcher reservedNumbers = RESERVED_NUMBERS.matcher(line); - if (reservedNumbers.find()) { - Matcher number = NUMBER.matcher(reservedNumbers.group(1)); - while (number.find()) { - scan.reservedNumbers - .computeIfAbsent(messageName, key -> new LinkedHashSet<>()) - .add(Integer.valueOf(number.group())); - } - return; - } - - Matcher mapField = MAP_FIELD.matcher(line); - if (mapField.find()) { - String qualified = messageName + "." + mapField.group(1); - if (!manifest.mapAllowed(qualified)) { - violations.add( - new GrpcProtoRuleViolation( - RULE_MAP_ALLOWLIST, - fileName, - lineNumber, - "map field '" - + qualified - + "' is not on the allowlist; a map is an unversioned key space that no " - + "breaking-change check can reason about")); - } - return; - } - - Matcher field = FIELD.matcher(line); - if (!field.find()) { - return; - } - String modifier = field.group(1) == null ? "" : field.group(1).strip(); - String fieldName = field.group(3); - if (manifest.presenceRequired(messageName, fieldName) && !"optional".equals(modifier)) { - violations.add( - new GrpcProtoRuleViolation( - RULE_EXPLICIT_PRESENCE, - fileName, - lineNumber, - "field '" - + messageName - + "." - + fieldName - + "' needs presence and must be declared optional; without it, absent and " - + "default-valued are the same message on the wire")); - } - } - - private static String qualify(Deque scopeNames, String name) { - String parent = scopeNames.peek(); - return parent == null ? name : parent + "." + name; - } - - private static String unquote(String value) { - if (value == null) { - return null; - } - String stripped = value.strip(); - if (stripped.length() >= 2 && stripped.startsWith("\"") && stripped.endsWith("\"")) { - return stripped.substring(1, stripped.length() - 1); - } - return stripped; - } - - /** Everything one pass over a file collected. */ - private static final class Scan { - private String syntax; - private String protoPackage; - private int packageLine; - private final Map options = new LinkedHashMap<>(); - private final Map> reservedNumbers = new LinkedHashMap<>(); - private final Map> reservedNames = new LinkedHashMap<>(); - } -} diff --git a/src/grpc/grpc-proto-contract/src/main/java/dev/caskeleton/grpc/contract/GrpcProtoRuleViolation.java b/src/grpc/grpc-proto-contract/src/main/java/dev/caskeleton/grpc/contract/GrpcProtoRuleViolation.java deleted file mode 100644 index d9b7ce97..00000000 --- a/src/grpc/grpc-proto-contract/src/main/java/dev/caskeleton/grpc/contract/GrpcProtoRuleViolation.java +++ /dev/null @@ -1,38 +0,0 @@ -package dev.caskeleton.grpc.contract; - -/** - * One schema rule broken, at one place. - * - *

Returned rather than thrown, and carrying a line number, because a schema review is a list. A - * validator that throws on the first violation turns "this file breaks four rules" into four - * separate runs, and the author fixes them one at a time without ever seeing the shape of the - * problem. - */ -public record GrpcProtoRuleViolation(String rule, String file, int line, String detail) { - - /** Requires a named rule, a file and a one-based line. */ - public GrpcProtoRuleViolation { - if (rule == null || rule.isBlank()) { - throw new IllegalArgumentException("a violation names the rule it broke"); - } - if (file == null || file.isBlank()) { - throw new IllegalArgumentException("a violation names the file it is in"); - } - if (detail == null || detail.isBlank()) { - throw new IllegalArgumentException("a violation explains itself"); - } - if (line < 0) { - throw new IllegalArgumentException("line must not be negative"); - } - } - - /** A violation about a whole file rather than a line in it. */ - public static GrpcProtoRuleViolation ofFile(String rule, String file, String detail) { - return new GrpcProtoRuleViolation(rule, file, 0, detail); - } - - /** {@code file:line rule — detail}, the form a build log is read in. */ - public String describe() { - return file + (line > 0 ? ":" + line : "") + " " + rule + " — " + detail; - } -} diff --git a/src/grpc/grpc-proto-contract/src/main/java/dev/caskeleton/grpc/contract/GrpcProtoStyleManifest.java b/src/grpc/grpc-proto-contract/src/main/java/dev/caskeleton/grpc/contract/GrpcProtoStyleManifest.java deleted file mode 100644 index 7e4040dc..00000000 --- a/src/grpc/grpc-proto-contract/src/main/java/dev/caskeleton/grpc/contract/GrpcProtoStyleManifest.java +++ /dev/null @@ -1,120 +0,0 @@ -package dev.caskeleton.grpc.contract; - -import java.util.Map; -import java.util.Set; - -/** - * The schema rules this repository has decided on, as data rather than as prose in a review - * checklist. - * - *

Three of the five fields are allowlists, and that shape is the decision: {@code Any}, {@code - * Struct} and {@code map} are not banned, they are things you have to ask for by name. A ban gets - * worked around; an allowlist entry gets read by the next person to open the manifest and carries - * the field it was granted for. - */ -public record GrpcProtoStyleManifest( - String organization, - Set handWrittenJavaPackages, - Set wellKnownTypeAllowlist, - Set mapFieldAllowlist, - Map> presenceRequiredFields) { - - /** The well-known types every schema may use without asking. */ - private static final Set ALWAYS_ALLOWED_WELL_KNOWN_TYPES = - Set.of( - "google/protobuf/timestamp.proto", - "google/protobuf/duration.proto", - "google/protobuf/field_mask.proto", - "google/protobuf/empty.proto", - "google/protobuf/wrappers.proto"); - - /** Copies every collection so a manifest cannot widen after it has been reviewed. */ - public GrpcProtoStyleManifest { - if (organization == null || organization.isBlank()) { - throw new IllegalArgumentException("a style manifest names the owning organization"); - } - if (handWrittenJavaPackages == null - || wellKnownTypeAllowlist == null - || mapFieldAllowlist == null - || presenceRequiredFields == null) { - throw new IllegalArgumentException("every manifest allowlist must be present"); - } - handWrittenJavaPackages = Set.copyOf(handWrittenJavaPackages); - wellKnownTypeAllowlist = Set.copyOf(wellKnownTypeAllowlist); - mapFieldAllowlist = Set.copyOf(mapFieldAllowlist); - presenceRequiredFields = - presenceRequiredFields.entrySet().stream() - .collect( - java.util.stream.Collectors.toUnmodifiableMap( - Map.Entry::getKey, entry -> Set.copyOf(entry.getValue()))); - } - - /** - * This repository's manifest. - * - *

The hand-written package is {@code dev.caskeleton.grpc}: generated code must land somewhere - * else, because a generated class and a hand-written one in the same package are - * indistinguishable to a reader and the generated one gets edited exactly once before somebody - * regenerates. - */ - public static GrpcProtoStyleManifest caSkeleton() { - return new GrpcProtoStyleManifest( - "hyeonworks", - Set.of("dev.caskeleton"), - ALWAYS_ALLOWED_WELL_KNOWN_TYPES, - Set.of(), - Map.of()); - } - - /** Whether {@code importPath} may be imported. */ - public boolean wellKnownTypeAllowed(String importPath) { - return !importPath.startsWith("google/protobuf/") - || wellKnownTypeAllowlist.contains(importPath); - } - - /** Whether a {@code map} field is allowed at {@code message.field}. */ - public boolean mapAllowed(String qualifiedField) { - return mapFieldAllowlist.contains(qualifiedField); - } - - /** Whether {@code field} of {@code message} must be declared {@code optional}. */ - public boolean presenceRequired(String message, String field) { - return presenceRequiredFields.getOrDefault(message, Set.of()).contains(field); - } - - /** A copy of this manifest that also allows the given well-known type imports. */ - public GrpcProtoStyleManifest allowingWellKnownTypes(Set additionalImports) { - java.util.Set widened = new java.util.LinkedHashSet<>(wellKnownTypeAllowlist); - widened.addAll(additionalImports); - return new GrpcProtoStyleManifest( - organization, handWrittenJavaPackages, widened, mapFieldAllowlist, presenceRequiredFields); - } - - /** A copy of this manifest that also allows the given {@code message.field} map fields. */ - public GrpcProtoStyleManifest allowingMapFields(Set qualifiedFields) { - java.util.Set widened = new java.util.LinkedHashSet<>(mapFieldAllowlist); - widened.addAll(qualifiedFields); - return new GrpcProtoStyleManifest( - organization, - handWrittenJavaPackages, - wellKnownTypeAllowlist, - widened, - presenceRequiredFields); - } - - /** A copy of this manifest that also requires explicit presence on the given fields. */ - public GrpcProtoStyleManifest requiringPresence(String message, Set fields) { - java.util.Map> widened = - new java.util.LinkedHashMap<>(presenceRequiredFields); - widened.merge( - message, - Set.copyOf(fields), - (existing, added) -> { - java.util.Set merged = new java.util.LinkedHashSet<>(existing); - merged.addAll(added); - return merged; - }); - return new GrpcProtoStyleManifest( - organization, handWrittenJavaPackages, wellKnownTypeAllowlist, mapFieldAllowlist, widened); - } -} diff --git a/src/grpc/grpc-proto-contract/src/main/resources/proto/buf.gen.yaml b/src/grpc/grpc-proto-contract/src/main/resources/proto/buf.gen.yaml deleted file mode 100644 index a357d276..00000000 --- a/src/grpc/grpc-proto-contract/src/main/resources/proto/buf.gen.yaml +++ /dev/null @@ -1,23 +0,0 @@ -# What a Buf-driven generation would emit, recorded even though this build does not run it. -# -# No protoc runs here (ADR-GRPC-002), so this file is a specification rather than a step. It exists -# because the three decisions it encodes are the ones GrpcCodegenManifest enforces from Java, and a -# reader who wants to know what "the single codegen owner produces" means should find one answer -# rather than two: -# -# - generated Java lands under build/, never in a source tree; -# - the generated package is disjoint from the hand-written dev.caskeleton root; -# - plugin versions come from the managed platform, so no version literal appears below. -version: v2 -managed: - enabled: true - override: - - file_option: java_multiple_files - value: true - - file_option: java_package_suffix - value: generated -plugins: - - remote: buf.build/protocolbuffers/java - out: build/generated/source/proto/main/java - - remote: buf.build/grpc/java - out: build/generated/source/proto/main/grpc diff --git a/src/grpc/grpc-proto-contract/src/main/resources/proto/buf.lock b/src/grpc/grpc-proto-contract/src/main/resources/proto/buf.lock deleted file mode 100644 index dc72df55..00000000 --- a/src/grpc/grpc-proto-contract/src/main/resources/proto/buf.lock +++ /dev/null @@ -1,11 +0,0 @@ -# Buf dependency lock. -# -# Empty by design: the Stable schema imports nothing outside itself. The well-known types this -# platform allows (timestamp, duration, field_mask, empty, wrappers) ship with protoc rather than -# coming from a Buf module, and GrpcProtoStyleManifest refuses any other google.protobuf import -# without an explicit allowlist entry. -# -# The file is committed rather than omitted so that adding a first dependency is a visible diff in a -# file that already exists, instead of a new file nobody reviews. -version: v2 -deps: [] diff --git a/src/grpc/grpc-proto-contract/src/main/resources/proto/buf.yaml b/src/grpc/grpc-proto-contract/src/main/resources/proto/buf.yaml deleted file mode 100644 index 22b2a1d2..00000000 --- a/src/grpc/grpc-proto-contract/src/main/resources/proto/buf.yaml +++ /dev/null @@ -1,18 +0,0 @@ -# Buf module configuration for the Stable schema. -# -# The rules named here are also implemented in GrpcProtoContractValidator, which is what actually -# fails this repository's build: the Buf CLI is not part of this toolchain, and a gate that silently -# passes when a binary is missing is worse than one that computes the same judgement from the -# committed schema. This file stays accurate so that running `buf lint` / `buf breaking` in an -# environment that has the CLI reaches the same verdict. -version: v2 -modules: - - path: . -lint: - use: - - STANDARD -breaking: - # FILE, not WIRE or WIRE_JSON. Wire compatibility alone would let a field rename or a Java package - # move through as "compatible" while every generated consumer stops compiling. - use: - - FILE diff --git a/src/grpc/grpc-proto-contract/src/test/java/dev/caskeleton/grpc/contract/GrpcProtoContractValidatorTest.java b/src/grpc/grpc-proto-contract/src/test/java/dev/caskeleton/grpc/contract/GrpcProtoContractValidatorTest.java deleted file mode 100644 index 6d190909..00000000 --- a/src/grpc/grpc-proto-contract/src/test/java/dev/caskeleton/grpc/contract/GrpcProtoContractValidatorTest.java +++ /dev/null @@ -1,324 +0,0 @@ -package dev.caskeleton.grpc.contract; - -import static org.assertj.core.api.Assertions.assertThat; - -import java.io.IOException; -import java.io.InputStream; -import java.io.UncheckedIOException; -import java.nio.charset.StandardCharsets; -import java.util.List; -import java.util.Map; -import java.util.Set; -import org.junit.jupiter.api.DisplayName; -import org.junit.jupiter.api.Test; - -class GrpcProtoContractValidatorTest { - - private final GrpcProtoContractValidator validator = - new GrpcProtoContractValidator(GrpcProtoStyleManifest.caSkeleton()); - - private static String committedSchema(String resourcePath) { - try (InputStream stream = - GrpcProtoContractValidatorTest.class.getClassLoader().getResourceAsStream(resourcePath)) { - if (stream == null) { - throw new IllegalStateException("missing committed schema resource: " + resourcePath); - } - return new String(stream.readAllBytes(), StandardCharsets.UTF_8); - } catch (IOException e) { - throw new UncheckedIOException(e); - } - } - - @Test - @DisplayName("the committed Stable schema passes every style rule") - void committedSchemaIsCompliant() { - List files = - List.of( - "proto/hyeonworks/grpc/common/v1/error.proto", - "proto/hyeonworks/grpc/common/v1/stream.proto"); - - for (String file : files) { - List violations = validator.validate(file, committedSchema(file)); - assertThat(violations) - .describedAs( - "violations in %s: %s", - file, violations.stream().map(GrpcProtoRuleViolation::describe).toList()) - .isEmpty(); - } - } - - @Test - @DisplayName("the committed Buf configuration states the same rules the validator enforces") - void theBufConfigurationAgreesWithTheValidator() { - String bufYaml = committedSchema("proto/buf.yaml"); - String bufGen = committedSchema("proto/buf.gen.yaml"); - String bufLock = committedSchema("proto/buf.lock"); - - // FILE, not WIRE: the category the Stable gate is fixed at. - assertThat(bufYaml).contains("use:").contains("- FILE").contains("- STANDARD"); - // Generation lands under build/ and into a package the hand-written root does not occupy. - assertThat(bufGen) - .contains("build/generated/source/proto/main/java") - .contains("build/generated/source/proto/main/grpc") - .contains("java_package_suffix") - // Never into a source tree: generated code that lands in src/ gets committed and then - // edited. The prose above the plugins block names dev.caskeleton as the package to stay out - // of, so the check is on the emitted paths rather than on the word. - .doesNotContain("out: src/"); - // No version literal: the managed platform owns plugin versions. - assertThat(bufGen).doesNotContain("version: v1"); - assertThat(bufLock).contains("deps: []"); - } - - @Test - @DisplayName("proto2 source is refused") - void proto2SourceIsRefused() { - String source = - """ - syntax = "proto2"; - package hyeonworks.document.v1; - option java_multiple_files = true; - option java_package = "hyeonworks.document.v1.generated"; - """; - - assertThat(validator.validate("legacy.proto", source)) - .extracting(GrpcProtoRuleViolation::rule) - .contains(GrpcProtoContractValidator.RULE_PROTO3_SYNTAX); - } - - @Test - @DisplayName("an unversioned package is refused") - void unversionedPackageIsRefused() { - String source = - """ - syntax = "proto3"; - package hyeonworks.document; - option java_multiple_files = true; - option java_package = "hyeonworks.document.generated"; - """; - - assertThat(validator.validate("document.proto", source)) - .extracting(GrpcProtoRuleViolation::rule) - .contains(GrpcProtoContractValidator.RULE_PACKAGE_VERSIONED); - } - - @Test - @DisplayName("a generated java_package inside a hand-written package is refused") - void generatedPackageMayNotCollideWithHandWrittenCode() { - String source = - """ - syntax = "proto3"; - package hyeonworks.document.v1; - option java_multiple_files = true; - option java_package = "dev.caskeleton.grpc.document"; - """; - - assertThat(validator.validate("document.proto", source)) - .extracting(GrpcProtoRuleViolation::rule) - .contains(GrpcProtoContractValidator.RULE_JAVA_PACKAGE_SEPARATE); - } - - @Test - @DisplayName("a missing java_multiple_files option is refused") - void javaMultipleFilesIsRequired() { - String source = - """ - syntax = "proto3"; - package hyeonworks.document.v1; - option java_package = "hyeonworks.document.v1.generated"; - """; - - assertThat(validator.validate("document.proto", source)) - .extracting(GrpcProtoRuleViolation::rule) - .contains(GrpcProtoContractValidator.RULE_JAVA_MULTIPLE_FILES); - } - - @Test - @DisplayName("an enum zero value without the _UNSPECIFIED suffix is refused, with its line") - void enumZeroValueNeedsTheUnspecifiedSuffix() { - String source = - """ - syntax = "proto3"; - package hyeonworks.document.v1; - option java_multiple_files = true; - option java_package = "hyeonworks.document.v1.generated"; - - enum DocumentState { - DRAFT = 0; - PUBLISHED = 1; - } - """; - - List violations = validator.validate("document.proto", source); - - assertThat(violations) - .singleElement() - .satisfies( - violation -> { - assertThat(violation.rule()) - .isEqualTo(GrpcProtoContractValidator.RULE_ENUM_ZERO_UNSPECIFIED); - assertThat(violation.line()).isEqualTo(7); - assertThat(violation.detail()).contains("DocumentState").contains("DRAFT"); - }); - } - - @Test - @DisplayName("a removed field number that is not reserved fails, and reserving it passes") - void removedFieldNumbersMustStayReserved() { - String withoutReserved = - """ - syntax = "proto3"; - package hyeonworks.document.v1; - option java_multiple_files = true; - option java_package = "hyeonworks.document.v1.generated"; - - message Document { - string id = 1; - string title = 4; - } - """; - GrpcProtoContractValidator.SchemaHistory history = - new GrpcProtoContractValidator.SchemaHistory( - Map.of("Document", Set.of(2, 3)), Map.of("Document", Set.of("legacy_body"))); - - assertThat(validator.validate("document.proto", withoutReserved, history)) - .extracting(GrpcProtoRuleViolation::rule) - .containsOnly(GrpcProtoContractValidator.RULE_RESERVED_HISTORY); - - String withReserved = - """ - syntax = "proto3"; - package hyeonworks.document.v1; - option java_multiple_files = true; - option java_package = "hyeonworks.document.v1.generated"; - - message Document { - reserved 2, 3; - reserved "legacy_body"; - string id = 1; - string title = 4; - } - """; - - assertThat(validator.validate("document.proto", withReserved, history)).isEmpty(); - } - - @Test - @DisplayName("Any and Struct need an explicit allowlist entry; Timestamp does not") - void anyAndStructAreAllowlistedByName() { - String source = - """ - syntax = "proto3"; - package hyeonworks.document.v1; - import "google/protobuf/timestamp.proto"; - import "google/protobuf/any.proto"; - option java_multiple_files = true; - option java_package = "hyeonworks.document.v1.generated"; - """; - - assertThat(validator.validate("document.proto", source)) - .singleElement() - .satisfies( - violation -> { - assertThat(violation.rule()) - .isEqualTo(GrpcProtoContractValidator.RULE_WELL_KNOWN_TYPE_ALLOWLIST); - assertThat(violation.detail()).contains("google/protobuf/any.proto"); - }); - - GrpcProtoContractValidator widened = - new GrpcProtoContractValidator( - GrpcProtoStyleManifest.caSkeleton() - .allowingWellKnownTypes(Set.of("google/protobuf/any.proto"))); - assertThat(widened.validate("document.proto", source)).isEmpty(); - } - - @Test - @DisplayName("a map field needs an allowlist entry naming the message and field") - void mapFieldsAreAllowlistedByName() { - String source = - """ - syntax = "proto3"; - package hyeonworks.document.v1; - option java_multiple_files = true; - option java_package = "hyeonworks.document.v1.generated"; - - message Document { - map labels = 1; - } - """; - - assertThat(validator.validate("document.proto", source)) - .extracting(GrpcProtoRuleViolation::rule) - .containsOnly(GrpcProtoContractValidator.RULE_MAP_ALLOWLIST); - - GrpcProtoContractValidator widened = - new GrpcProtoContractValidator( - GrpcProtoStyleManifest.caSkeleton().allowingMapFields(Set.of("Document.labels"))); - assertThat(widened.validate("document.proto", source)).isEmpty(); - } - - @Test - @DisplayName("a presence-required field must be declared optional") - void presenceRequiredFieldsMustBeOptional() { - String source = - """ - syntax = "proto3"; - package hyeonworks.document.v1; - option java_multiple_files = true; - option java_package = "hyeonworks.document.v1.generated"; - - message Document { - string id = 1; - string title = 2; - } - """; - GrpcProtoContractValidator strict = - new GrpcProtoContractValidator( - GrpcProtoStyleManifest.caSkeleton().requiringPresence("Document", Set.of("title"))); - - assertThat(strict.validate("document.proto", source)) - .singleElement() - .satisfies( - violation -> { - assertThat(violation.rule()) - .isEqualTo(GrpcProtoContractValidator.RULE_EXPLICIT_PRESENCE); - assertThat(violation.detail()).contains("Document.title"); - }); - - String withOptional = source.replace(" string title = 2;", " optional string title = 2;"); - assertThat(strict.validate("document.proto", withOptional)).isEmpty(); - } - - @Test - @DisplayName("nested messages are qualified, so a rule names the type it means") - void nestedMessagesAreQualified() { - String source = - """ - syntax = "proto3"; - package hyeonworks.document.v1; - option java_multiple_files = true; - option java_package = "hyeonworks.document.v1.generated"; - - message Outer { - message Inner { - map labels = 1; - } - } - """; - - assertThat(validator.validate("document.proto", source)) - .singleElement() - .satisfies(violation -> assertThat(violation.detail()).contains("Outer.Inner.labels")); - } - - @Test - @DisplayName("a violation renders as file:line rule — detail") - void violationRendersForABuildLog() { - GrpcProtoRuleViolation violation = - new GrpcProtoRuleViolation("RULE_X", "document.proto", 12, "something is wrong"); - - assertThat(violation.describe()).isEqualTo("document.proto:12 RULE_X — something is wrong"); - assertThat(GrpcProtoRuleViolation.ofFile("RULE_Y", "document.proto", "whole file").describe()) - .isEqualTo("document.proto RULE_Y — whole file"); - } -} diff --git a/src/grpc/grpc-runtime/build.gradle b/src/grpc/grpc-runtime/build.gradle new file mode 100644 index 00000000..350747d0 --- /dev/null +++ b/src/grpc/grpc-runtime/build.gradle @@ -0,0 +1,31 @@ +plugins { + id 'ca.grpc-platform-module' +} + +// The Stable runtime: one leaf for one dependency boundary (io.grpc api/stub). +// +// policy validation, context propagation, status/rich-error mapping, TLS/credential profiles, +// deadline and cancellation, retry ownership, idempotency and completion recovery, +// server streaming, payload size and compression +// server the typed service adapter SPI, the interceptor order contract, and the Netty +// server/executor/admission profiles (configuration models, not Netty wiring) +// client named channel profiles, channel runtime generations with drain, the typed stub +// factory that refuses to hand a raw Channel to application code +// discovery Static/DNS resolvers, pick_first/round_robin, Kubernetes routing profiles +// admin health registry, reflection exposure policy, drain coordinator, policy snapshot +// +// These were five leaves until 2026-09-28; they shared one framework boundary and depended on each +// other in a line, so the split bought no enforceable rule. Package names were kept so no import +// changed. Real Netty lives in `grpc-testkit`'s certification lanes. + +dependencies { + api project(':grpc:grpc-core-api') + + // api: interceptors, context binders, the error mapper and the stub factory name io.grpc types + // in public signatures, so an adopter cannot compile against this module without them. + api "io.grpc:grpc-api" + api "io.grpc:grpc-stub" + + // The shared operation-ledger fake, held to the same contract as the JPA adapter. + testImplementation testFixtures(project(':grpc:grpc-core-api')) +} diff --git a/src/grpc-advanced/grpc-advanced-resilience/gradle.lockfile b/src/grpc/grpc-runtime/gradle.lockfile similarity index 100% rename from src/grpc-advanced/grpc-advanced-resilience/gradle.lockfile rename to src/grpc/grpc-runtime/gradle.lockfile diff --git a/src/grpc/grpc-admin/src/main/java/dev/caskeleton/grpc/admin/GrpcAdminExposurePolicy.java b/src/grpc/grpc-runtime/src/main/java/dev/caskeleton/grpc/admin/GrpcAdminExposurePolicy.java similarity index 100% rename from src/grpc/grpc-admin/src/main/java/dev/caskeleton/grpc/admin/GrpcAdminExposurePolicy.java rename to src/grpc/grpc-runtime/src/main/java/dev/caskeleton/grpc/admin/GrpcAdminExposurePolicy.java diff --git a/src/grpc/grpc-admin/src/main/java/dev/caskeleton/grpc/admin/GrpcDrainCoordinator.java b/src/grpc/grpc-runtime/src/main/java/dev/caskeleton/grpc/admin/GrpcDrainCoordinator.java similarity index 100% rename from src/grpc/grpc-admin/src/main/java/dev/caskeleton/grpc/admin/GrpcDrainCoordinator.java rename to src/grpc/grpc-runtime/src/main/java/dev/caskeleton/grpc/admin/GrpcDrainCoordinator.java diff --git a/src/grpc/grpc-admin/src/main/java/dev/caskeleton/grpc/admin/GrpcDrainPhase.java b/src/grpc/grpc-runtime/src/main/java/dev/caskeleton/grpc/admin/GrpcDrainPhase.java similarity index 100% rename from src/grpc/grpc-admin/src/main/java/dev/caskeleton/grpc/admin/GrpcDrainPhase.java rename to src/grpc/grpc-runtime/src/main/java/dev/caskeleton/grpc/admin/GrpcDrainPhase.java diff --git a/src/grpc/grpc-admin/src/main/java/dev/caskeleton/grpc/admin/GrpcDrainPolicy.java b/src/grpc/grpc-runtime/src/main/java/dev/caskeleton/grpc/admin/GrpcDrainPolicy.java similarity index 100% rename from src/grpc/grpc-admin/src/main/java/dev/caskeleton/grpc/admin/GrpcDrainPolicy.java rename to src/grpc/grpc-runtime/src/main/java/dev/caskeleton/grpc/admin/GrpcDrainPolicy.java diff --git a/src/grpc/grpc-admin/src/main/java/dev/caskeleton/grpc/admin/GrpcDrainResult.java b/src/grpc/grpc-runtime/src/main/java/dev/caskeleton/grpc/admin/GrpcDrainResult.java similarity index 100% rename from src/grpc/grpc-admin/src/main/java/dev/caskeleton/grpc/admin/GrpcDrainResult.java rename to src/grpc/grpc-runtime/src/main/java/dev/caskeleton/grpc/admin/GrpcDrainResult.java diff --git a/src/grpc/grpc-admin/src/main/java/dev/caskeleton/grpc/admin/GrpcHealthPolicy.java b/src/grpc/grpc-runtime/src/main/java/dev/caskeleton/grpc/admin/GrpcHealthPolicy.java similarity index 100% rename from src/grpc/grpc-admin/src/main/java/dev/caskeleton/grpc/admin/GrpcHealthPolicy.java rename to src/grpc/grpc-runtime/src/main/java/dev/caskeleton/grpc/admin/GrpcHealthPolicy.java diff --git a/src/grpc/grpc-admin/src/main/java/dev/caskeleton/grpc/admin/GrpcHealthState.java b/src/grpc/grpc-runtime/src/main/java/dev/caskeleton/grpc/admin/GrpcHealthState.java similarity index 100% rename from src/grpc/grpc-admin/src/main/java/dev/caskeleton/grpc/admin/GrpcHealthState.java rename to src/grpc/grpc-runtime/src/main/java/dev/caskeleton/grpc/admin/GrpcHealthState.java diff --git a/src/grpc/grpc-admin/src/main/java/dev/caskeleton/grpc/admin/GrpcPlatformSnapshot.java b/src/grpc/grpc-runtime/src/main/java/dev/caskeleton/grpc/admin/GrpcPlatformSnapshot.java similarity index 100% rename from src/grpc/grpc-admin/src/main/java/dev/caskeleton/grpc/admin/GrpcPlatformSnapshot.java rename to src/grpc/grpc-runtime/src/main/java/dev/caskeleton/grpc/admin/GrpcPlatformSnapshot.java diff --git a/src/grpc/grpc-admin/src/main/java/dev/caskeleton/grpc/admin/GrpcPlatformSnapshotService.java b/src/grpc/grpc-runtime/src/main/java/dev/caskeleton/grpc/admin/GrpcPlatformSnapshotService.java similarity index 100% rename from src/grpc/grpc-admin/src/main/java/dev/caskeleton/grpc/admin/GrpcPlatformSnapshotService.java rename to src/grpc/grpc-runtime/src/main/java/dev/caskeleton/grpc/admin/GrpcPlatformSnapshotService.java diff --git a/src/grpc/grpc-admin/src/main/java/dev/caskeleton/grpc/admin/GrpcReflectionAccessDecision.java b/src/grpc/grpc-runtime/src/main/java/dev/caskeleton/grpc/admin/GrpcReflectionAccessDecision.java similarity index 100% rename from src/grpc/grpc-admin/src/main/java/dev/caskeleton/grpc/admin/GrpcReflectionAccessDecision.java rename to src/grpc/grpc-runtime/src/main/java/dev/caskeleton/grpc/admin/GrpcReflectionAccessDecision.java diff --git a/src/grpc/grpc-admin/src/main/java/dev/caskeleton/grpc/admin/GrpcReflectionMode.java b/src/grpc/grpc-runtime/src/main/java/dev/caskeleton/grpc/admin/GrpcReflectionMode.java similarity index 100% rename from src/grpc/grpc-admin/src/main/java/dev/caskeleton/grpc/admin/GrpcReflectionMode.java rename to src/grpc/grpc-runtime/src/main/java/dev/caskeleton/grpc/admin/GrpcReflectionMode.java diff --git a/src/grpc/grpc-admin/src/main/java/dev/caskeleton/grpc/admin/GrpcReflectionPolicy.java b/src/grpc/grpc-runtime/src/main/java/dev/caskeleton/grpc/admin/GrpcReflectionPolicy.java similarity index 100% rename from src/grpc/grpc-admin/src/main/java/dev/caskeleton/grpc/admin/GrpcReflectionPolicy.java rename to src/grpc/grpc-runtime/src/main/java/dev/caskeleton/grpc/admin/GrpcReflectionPolicy.java diff --git a/src/grpc/grpc-admin/src/main/java/dev/caskeleton/grpc/admin/GrpcServiceHealthRegistry.java b/src/grpc/grpc-runtime/src/main/java/dev/caskeleton/grpc/admin/GrpcServiceHealthRegistry.java similarity index 100% rename from src/grpc/grpc-admin/src/main/java/dev/caskeleton/grpc/admin/GrpcServiceHealthRegistry.java rename to src/grpc/grpc-runtime/src/main/java/dev/caskeleton/grpc/admin/GrpcServiceHealthRegistry.java diff --git a/src/grpc/grpc-client/src/main/java/dev/caskeleton/grpc/client/GrpcCallCredentialProvider.java b/src/grpc/grpc-runtime/src/main/java/dev/caskeleton/grpc/client/GrpcCallCredentialProvider.java similarity index 100% rename from src/grpc/grpc-client/src/main/java/dev/caskeleton/grpc/client/GrpcCallCredentialProvider.java rename to src/grpc/grpc-runtime/src/main/java/dev/caskeleton/grpc/client/GrpcCallCredentialProvider.java diff --git a/src/grpc/grpc-client/src/main/java/dev/caskeleton/grpc/client/GrpcChannelDrainPolicy.java b/src/grpc/grpc-runtime/src/main/java/dev/caskeleton/grpc/client/GrpcChannelDrainPolicy.java similarity index 100% rename from src/grpc/grpc-client/src/main/java/dev/caskeleton/grpc/client/GrpcChannelDrainPolicy.java rename to src/grpc/grpc-runtime/src/main/java/dev/caskeleton/grpc/client/GrpcChannelDrainPolicy.java diff --git a/src/grpc/grpc-client/src/main/java/dev/caskeleton/grpc/client/GrpcChannelGeneration.java b/src/grpc/grpc-runtime/src/main/java/dev/caskeleton/grpc/client/GrpcChannelGeneration.java similarity index 100% rename from src/grpc/grpc-client/src/main/java/dev/caskeleton/grpc/client/GrpcChannelGeneration.java rename to src/grpc/grpc-runtime/src/main/java/dev/caskeleton/grpc/client/GrpcChannelGeneration.java diff --git a/src/grpc/grpc-client/src/main/java/dev/caskeleton/grpc/client/GrpcChannelProfileValidator.java b/src/grpc/grpc-runtime/src/main/java/dev/caskeleton/grpc/client/GrpcChannelProfileValidator.java similarity index 100% rename from src/grpc/grpc-client/src/main/java/dev/caskeleton/grpc/client/GrpcChannelProfileValidator.java rename to src/grpc/grpc-runtime/src/main/java/dev/caskeleton/grpc/client/GrpcChannelProfileValidator.java diff --git a/src/grpc/grpc-client/src/main/java/dev/caskeleton/grpc/client/GrpcChannelRuntime.java b/src/grpc/grpc-runtime/src/main/java/dev/caskeleton/grpc/client/GrpcChannelRuntime.java similarity index 100% rename from src/grpc/grpc-client/src/main/java/dev/caskeleton/grpc/client/GrpcChannelRuntime.java rename to src/grpc/grpc-runtime/src/main/java/dev/caskeleton/grpc/client/GrpcChannelRuntime.java diff --git a/src/grpc/grpc-client/src/main/java/dev/caskeleton/grpc/client/GrpcChannelRuntimeRegistry.java b/src/grpc/grpc-runtime/src/main/java/dev/caskeleton/grpc/client/GrpcChannelRuntimeRegistry.java similarity index 100% rename from src/grpc/grpc-client/src/main/java/dev/caskeleton/grpc/client/GrpcChannelRuntimeRegistry.java rename to src/grpc/grpc-runtime/src/main/java/dev/caskeleton/grpc/client/GrpcChannelRuntimeRegistry.java diff --git a/src/grpc/grpc-client/src/main/java/dev/caskeleton/grpc/client/GrpcClientCallContext.java b/src/grpc/grpc-runtime/src/main/java/dev/caskeleton/grpc/client/GrpcClientCallContext.java similarity index 100% rename from src/grpc/grpc-client/src/main/java/dev/caskeleton/grpc/client/GrpcClientCallContext.java rename to src/grpc/grpc-runtime/src/main/java/dev/caskeleton/grpc/client/GrpcClientCallContext.java diff --git a/src/grpc/grpc-client/src/main/java/dev/caskeleton/grpc/client/GrpcClientMetadataPolicy.java b/src/grpc/grpc-runtime/src/main/java/dev/caskeleton/grpc/client/GrpcClientMetadataPolicy.java similarity index 100% rename from src/grpc/grpc-client/src/main/java/dev/caskeleton/grpc/client/GrpcClientMetadataPolicy.java rename to src/grpc/grpc-runtime/src/main/java/dev/caskeleton/grpc/client/GrpcClientMetadataPolicy.java diff --git a/src/grpc/grpc-client/src/main/java/dev/caskeleton/grpc/client/GrpcLoadBalancingPolicy.java b/src/grpc/grpc-runtime/src/main/java/dev/caskeleton/grpc/client/GrpcLoadBalancingPolicy.java similarity index 100% rename from src/grpc/grpc-client/src/main/java/dev/caskeleton/grpc/client/GrpcLoadBalancingPolicy.java rename to src/grpc/grpc-runtime/src/main/java/dev/caskeleton/grpc/client/GrpcLoadBalancingPolicy.java diff --git a/src/grpc/grpc-client/src/main/java/dev/caskeleton/grpc/client/GrpcNamedChannelProfile.java b/src/grpc/grpc-runtime/src/main/java/dev/caskeleton/grpc/client/GrpcNamedChannelProfile.java similarity index 93% rename from src/grpc/grpc-client/src/main/java/dev/caskeleton/grpc/client/GrpcNamedChannelProfile.java rename to src/grpc/grpc-runtime/src/main/java/dev/caskeleton/grpc/client/GrpcNamedChannelProfile.java index 959d2f4d..1a2075a7 100644 --- a/src/grpc/grpc-client/src/main/java/dev/caskeleton/grpc/client/GrpcNamedChannelProfile.java +++ b/src/grpc/grpc-runtime/src/main/java/dev/caskeleton/grpc/client/GrpcNamedChannelProfile.java @@ -1,5 +1,6 @@ package dev.caskeleton.grpc.client; +import dev.caskeleton.grpc.api.policy.GrpcTransportLimits; import dev.caskeleton.grpc.core.GrpcChannelProfileName; import dev.caskeleton.grpc.resilience.GrpcRetryOwner; import dev.caskeleton.grpc.security.GrpcTlsProfile; @@ -77,8 +78,8 @@ public record GrpcNamedChannelProfile( GrpcLoadBalancingPolicy.PICK_FIRST, retryOwner, tls, - 1024L * 1024L, - 8192, + GrpcTransportLimits.DEFAULT_MAX_MESSAGE_BYTES, + GrpcTransportLimits.DEFAULT_MAX_METADATA_BYTES, Duration.ofSeconds(30), false); } @@ -92,8 +93,8 @@ public record GrpcNamedChannelProfile( GrpcLoadBalancingPolicy.ROUND_ROBIN, retryOwner, tls, - 1024L * 1024L, - 8192, + GrpcTransportLimits.DEFAULT_MAX_MESSAGE_BYTES, + GrpcTransportLimits.DEFAULT_MAX_METADATA_BYTES, Duration.ofSeconds(30), false); } diff --git a/src/grpc/grpc-client/src/main/java/dev/caskeleton/grpc/client/GrpcStubDescriptor.java b/src/grpc/grpc-runtime/src/main/java/dev/caskeleton/grpc/client/GrpcStubDescriptor.java similarity index 100% rename from src/grpc/grpc-client/src/main/java/dev/caskeleton/grpc/client/GrpcStubDescriptor.java rename to src/grpc/grpc-runtime/src/main/java/dev/caskeleton/grpc/client/GrpcStubDescriptor.java diff --git a/src/grpc/grpc-client/src/main/java/dev/caskeleton/grpc/client/GrpcStubPolicyApplier.java b/src/grpc/grpc-runtime/src/main/java/dev/caskeleton/grpc/client/GrpcStubPolicyApplier.java similarity index 100% rename from src/grpc/grpc-client/src/main/java/dev/caskeleton/grpc/client/GrpcStubPolicyApplier.java rename to src/grpc/grpc-runtime/src/main/java/dev/caskeleton/grpc/client/GrpcStubPolicyApplier.java diff --git a/src/grpc/grpc-client/src/main/java/dev/caskeleton/grpc/client/GrpcTypedStubFactory.java b/src/grpc/grpc-runtime/src/main/java/dev/caskeleton/grpc/client/GrpcTypedStubFactory.java similarity index 100% rename from src/grpc/grpc-client/src/main/java/dev/caskeleton/grpc/client/GrpcTypedStubFactory.java rename to src/grpc/grpc-runtime/src/main/java/dev/caskeleton/grpc/client/GrpcTypedStubFactory.java diff --git a/src/grpc/grpc-policy/src/main/java/dev/caskeleton/grpc/context/GrpcContextBinder.java b/src/grpc/grpc-runtime/src/main/java/dev/caskeleton/grpc/context/GrpcContextBinder.java similarity index 100% rename from src/grpc/grpc-policy/src/main/java/dev/caskeleton/grpc/context/GrpcContextBinder.java rename to src/grpc/grpc-runtime/src/main/java/dev/caskeleton/grpc/context/GrpcContextBinder.java diff --git a/src/grpc/grpc-policy/src/main/java/dev/caskeleton/grpc/context/GrpcContextPropagationPolicy.java b/src/grpc/grpc-runtime/src/main/java/dev/caskeleton/grpc/context/GrpcContextPropagationPolicy.java similarity index 100% rename from src/grpc/grpc-policy/src/main/java/dev/caskeleton/grpc/context/GrpcContextPropagationPolicy.java rename to src/grpc/grpc-runtime/src/main/java/dev/caskeleton/grpc/context/GrpcContextPropagationPolicy.java diff --git a/src/grpc/grpc-policy/src/main/java/dev/caskeleton/grpc/context/GrpcContextSnapshot.java b/src/grpc/grpc-runtime/src/main/java/dev/caskeleton/grpc/context/GrpcContextSnapshot.java similarity index 100% rename from src/grpc/grpc-policy/src/main/java/dev/caskeleton/grpc/context/GrpcContextSnapshot.java rename to src/grpc/grpc-runtime/src/main/java/dev/caskeleton/grpc/context/GrpcContextSnapshot.java diff --git a/src/grpc/grpc-policy/src/main/java/dev/caskeleton/grpc/deadline/GrpcCancellableOperation.java b/src/grpc/grpc-runtime/src/main/java/dev/caskeleton/grpc/deadline/GrpcCancellableOperation.java similarity index 100% rename from src/grpc/grpc-policy/src/main/java/dev/caskeleton/grpc/deadline/GrpcCancellableOperation.java rename to src/grpc/grpc-runtime/src/main/java/dev/caskeleton/grpc/deadline/GrpcCancellableOperation.java diff --git a/src/grpc/grpc-policy/src/main/java/dev/caskeleton/grpc/deadline/GrpcCancellationCoordinator.java b/src/grpc/grpc-runtime/src/main/java/dev/caskeleton/grpc/deadline/GrpcCancellationCoordinator.java similarity index 100% rename from src/grpc/grpc-policy/src/main/java/dev/caskeleton/grpc/deadline/GrpcCancellationCoordinator.java rename to src/grpc/grpc-runtime/src/main/java/dev/caskeleton/grpc/deadline/GrpcCancellationCoordinator.java diff --git a/src/grpc/grpc-policy/src/main/java/dev/caskeleton/grpc/deadline/GrpcCancellationReason.java b/src/grpc/grpc-runtime/src/main/java/dev/caskeleton/grpc/deadline/GrpcCancellationReason.java similarity index 100% rename from src/grpc/grpc-policy/src/main/java/dev/caskeleton/grpc/deadline/GrpcCancellationReason.java rename to src/grpc/grpc-runtime/src/main/java/dev/caskeleton/grpc/deadline/GrpcCancellationReason.java diff --git a/src/grpc/grpc-policy/src/main/java/dev/caskeleton/grpc/deadline/GrpcDeadlineCalculator.java b/src/grpc/grpc-runtime/src/main/java/dev/caskeleton/grpc/deadline/GrpcDeadlineCalculator.java similarity index 100% rename from src/grpc/grpc-policy/src/main/java/dev/caskeleton/grpc/deadline/GrpcDeadlineCalculator.java rename to src/grpc/grpc-runtime/src/main/java/dev/caskeleton/grpc/deadline/GrpcDeadlineCalculator.java diff --git a/src/grpc/grpc-policy/src/main/java/dev/caskeleton/grpc/deadline/GrpcDeadlinePolicyValidator.java b/src/grpc/grpc-runtime/src/main/java/dev/caskeleton/grpc/deadline/GrpcDeadlinePolicyValidator.java similarity index 100% rename from src/grpc/grpc-policy/src/main/java/dev/caskeleton/grpc/deadline/GrpcDeadlinePolicyValidator.java rename to src/grpc/grpc-runtime/src/main/java/dev/caskeleton/grpc/deadline/GrpcDeadlinePolicyValidator.java diff --git a/src/grpc/grpc-policy/src/main/java/dev/caskeleton/grpc/deadline/GrpcDependencyBudget.java b/src/grpc/grpc-runtime/src/main/java/dev/caskeleton/grpc/deadline/GrpcDependencyBudget.java similarity index 100% rename from src/grpc/grpc-policy/src/main/java/dev/caskeleton/grpc/deadline/GrpcDependencyBudget.java rename to src/grpc/grpc-runtime/src/main/java/dev/caskeleton/grpc/deadline/GrpcDependencyBudget.java diff --git a/src/grpc/grpc-discovery/src/main/java/dev/caskeleton/grpc/discovery/GrpcDiscoveryPolicyValidator.java b/src/grpc/grpc-runtime/src/main/java/dev/caskeleton/grpc/discovery/GrpcDiscoveryPolicyValidator.java similarity index 100% rename from src/grpc/grpc-discovery/src/main/java/dev/caskeleton/grpc/discovery/GrpcDiscoveryPolicyValidator.java rename to src/grpc/grpc-runtime/src/main/java/dev/caskeleton/grpc/discovery/GrpcDiscoveryPolicyValidator.java diff --git a/src/grpc/grpc-discovery/src/main/java/dev/caskeleton/grpc/discovery/GrpcKubernetesProfile.java b/src/grpc/grpc-runtime/src/main/java/dev/caskeleton/grpc/discovery/GrpcKubernetesProfile.java similarity index 100% rename from src/grpc/grpc-discovery/src/main/java/dev/caskeleton/grpc/discovery/GrpcKubernetesProfile.java rename to src/grpc/grpc-runtime/src/main/java/dev/caskeleton/grpc/discovery/GrpcKubernetesProfile.java diff --git a/src/grpc/grpc-discovery/src/main/java/dev/caskeleton/grpc/discovery/GrpcKubernetesProfileValidator.java b/src/grpc/grpc-runtime/src/main/java/dev/caskeleton/grpc/discovery/GrpcKubernetesProfileValidator.java similarity index 100% rename from src/grpc/grpc-discovery/src/main/java/dev/caskeleton/grpc/discovery/GrpcKubernetesProfileValidator.java rename to src/grpc/grpc-runtime/src/main/java/dev/caskeleton/grpc/discovery/GrpcKubernetesProfileValidator.java diff --git a/src/grpc/grpc-discovery/src/main/java/dev/caskeleton/grpc/discovery/GrpcKubernetesRoutingMode.java b/src/grpc/grpc-runtime/src/main/java/dev/caskeleton/grpc/discovery/GrpcKubernetesRoutingMode.java similarity index 100% rename from src/grpc/grpc-discovery/src/main/java/dev/caskeleton/grpc/discovery/GrpcKubernetesRoutingMode.java rename to src/grpc/grpc-runtime/src/main/java/dev/caskeleton/grpc/discovery/GrpcKubernetesRoutingMode.java diff --git a/src/grpc/grpc-discovery/src/main/java/dev/caskeleton/grpc/discovery/GrpcResolverProfile.java b/src/grpc/grpc-runtime/src/main/java/dev/caskeleton/grpc/discovery/GrpcResolverProfile.java similarity index 100% rename from src/grpc/grpc-discovery/src/main/java/dev/caskeleton/grpc/discovery/GrpcResolverProfile.java rename to src/grpc/grpc-runtime/src/main/java/dev/caskeleton/grpc/discovery/GrpcResolverProfile.java diff --git a/src/grpc/grpc-discovery/src/main/java/dev/caskeleton/grpc/discovery/GrpcResolverType.java b/src/grpc/grpc-runtime/src/main/java/dev/caskeleton/grpc/discovery/GrpcResolverType.java similarity index 100% rename from src/grpc/grpc-discovery/src/main/java/dev/caskeleton/grpc/discovery/GrpcResolverType.java rename to src/grpc/grpc-runtime/src/main/java/dev/caskeleton/grpc/discovery/GrpcResolverType.java diff --git a/src/grpc/grpc-discovery/src/main/java/dev/caskeleton/grpc/discovery/GrpcStableLoadBalancer.java b/src/grpc/grpc-runtime/src/main/java/dev/caskeleton/grpc/discovery/GrpcStableLoadBalancer.java similarity index 100% rename from src/grpc/grpc-discovery/src/main/java/dev/caskeleton/grpc/discovery/GrpcStableLoadBalancer.java rename to src/grpc/grpc-runtime/src/main/java/dev/caskeleton/grpc/discovery/GrpcStableLoadBalancer.java diff --git a/src/grpc/grpc-policy/src/main/java/dev/caskeleton/grpc/error/GrpcErrorExposurePolicy.java b/src/grpc/grpc-runtime/src/main/java/dev/caskeleton/grpc/error/GrpcErrorExposurePolicy.java similarity index 100% rename from src/grpc/grpc-policy/src/main/java/dev/caskeleton/grpc/error/GrpcErrorExposurePolicy.java rename to src/grpc/grpc-runtime/src/main/java/dev/caskeleton/grpc/error/GrpcErrorExposurePolicy.java diff --git a/src/grpc/grpc-policy/src/main/java/dev/caskeleton/grpc/error/GrpcErrorMapper.java b/src/grpc/grpc-runtime/src/main/java/dev/caskeleton/grpc/error/GrpcErrorMapper.java similarity index 100% rename from src/grpc/grpc-policy/src/main/java/dev/caskeleton/grpc/error/GrpcErrorMapper.java rename to src/grpc/grpc-runtime/src/main/java/dev/caskeleton/grpc/error/GrpcErrorMapper.java diff --git a/src/grpc/grpc-policy/src/main/java/dev/caskeleton/grpc/error/GrpcRichErrorDetail.java b/src/grpc/grpc-runtime/src/main/java/dev/caskeleton/grpc/error/GrpcRichErrorDetail.java similarity index 100% rename from src/grpc/grpc-policy/src/main/java/dev/caskeleton/grpc/error/GrpcRichErrorDetail.java rename to src/grpc/grpc-runtime/src/main/java/dev/caskeleton/grpc/error/GrpcRichErrorDetail.java diff --git a/src/grpc/grpc-policy/src/main/java/dev/caskeleton/grpc/error/GrpcStatusMapping.java b/src/grpc/grpc-runtime/src/main/java/dev/caskeleton/grpc/error/GrpcStatusMapping.java similarity index 100% rename from src/grpc/grpc-policy/src/main/java/dev/caskeleton/grpc/error/GrpcStatusMapping.java rename to src/grpc/grpc-runtime/src/main/java/dev/caskeleton/grpc/error/GrpcStatusMapping.java diff --git a/src/grpc/grpc-policy/src/main/java/dev/caskeleton/grpc/idempotency/GrpcCompletionReconciler.java b/src/grpc/grpc-runtime/src/main/java/dev/caskeleton/grpc/idempotency/GrpcCompletionReconciler.java similarity index 100% rename from src/grpc/grpc-policy/src/main/java/dev/caskeleton/grpc/idempotency/GrpcCompletionReconciler.java rename to src/grpc/grpc-runtime/src/main/java/dev/caskeleton/grpc/idempotency/GrpcCompletionReconciler.java diff --git a/src/grpc/grpc-policy/src/main/java/dev/caskeleton/grpc/idempotency/GrpcCompletionResolution.java b/src/grpc/grpc-runtime/src/main/java/dev/caskeleton/grpc/idempotency/GrpcCompletionResolution.java similarity index 100% rename from src/grpc/grpc-policy/src/main/java/dev/caskeleton/grpc/idempotency/GrpcCompletionResolution.java rename to src/grpc/grpc-runtime/src/main/java/dev/caskeleton/grpc/idempotency/GrpcCompletionResolution.java diff --git a/src/grpc/grpc-policy/src/main/java/dev/caskeleton/grpc/idempotency/GrpcIdempotencyDecision.java b/src/grpc/grpc-runtime/src/main/java/dev/caskeleton/grpc/idempotency/GrpcIdempotencyDecision.java similarity index 100% rename from src/grpc/grpc-policy/src/main/java/dev/caskeleton/grpc/idempotency/GrpcIdempotencyDecision.java rename to src/grpc/grpc-runtime/src/main/java/dev/caskeleton/grpc/idempotency/GrpcIdempotencyDecision.java diff --git a/src/grpc/grpc-policy/src/main/java/dev/caskeleton/grpc/idempotency/GrpcIdempotencyInterceptor.java b/src/grpc/grpc-runtime/src/main/java/dev/caskeleton/grpc/idempotency/GrpcIdempotencyInterceptor.java similarity index 100% rename from src/grpc/grpc-policy/src/main/java/dev/caskeleton/grpc/idempotency/GrpcIdempotencyInterceptor.java rename to src/grpc/grpc-runtime/src/main/java/dev/caskeleton/grpc/idempotency/GrpcIdempotencyInterceptor.java diff --git a/src/grpc/grpc-policy/src/main/java/dev/caskeleton/grpc/idempotency/GrpcOperationStatus.java b/src/grpc/grpc-runtime/src/main/java/dev/caskeleton/grpc/idempotency/GrpcOperationStatus.java similarity index 100% rename from src/grpc/grpc-policy/src/main/java/dev/caskeleton/grpc/idempotency/GrpcOperationStatus.java rename to src/grpc/grpc-runtime/src/main/java/dev/caskeleton/grpc/idempotency/GrpcOperationStatus.java diff --git a/src/grpc/grpc-policy/src/main/java/dev/caskeleton/grpc/idempotency/GrpcOperationStatusQuery.java b/src/grpc/grpc-runtime/src/main/java/dev/caskeleton/grpc/idempotency/GrpcOperationStatusQuery.java similarity index 100% rename from src/grpc/grpc-policy/src/main/java/dev/caskeleton/grpc/idempotency/GrpcOperationStatusQuery.java rename to src/grpc/grpc-runtime/src/main/java/dev/caskeleton/grpc/idempotency/GrpcOperationStatusQuery.java diff --git a/src/grpc/grpc-policy/src/main/java/dev/caskeleton/grpc/idempotency/GrpcOutcomeReplay.java b/src/grpc/grpc-runtime/src/main/java/dev/caskeleton/grpc/idempotency/GrpcOutcomeReplay.java similarity index 100% rename from src/grpc/grpc-policy/src/main/java/dev/caskeleton/grpc/idempotency/GrpcOutcomeReplay.java rename to src/grpc/grpc-runtime/src/main/java/dev/caskeleton/grpc/idempotency/GrpcOutcomeReplay.java diff --git a/src/grpc/grpc-policy/src/main/java/dev/caskeleton/grpc/idempotency/GrpcRequestFingerprint.java b/src/grpc/grpc-runtime/src/main/java/dev/caskeleton/grpc/idempotency/GrpcRequestFingerprint.java similarity index 100% rename from src/grpc/grpc-policy/src/main/java/dev/caskeleton/grpc/idempotency/GrpcRequestFingerprint.java rename to src/grpc/grpc-runtime/src/main/java/dev/caskeleton/grpc/idempotency/GrpcRequestFingerprint.java diff --git a/src/grpc/grpc-policy/src/main/java/dev/caskeleton/grpc/policy/GrpcCompressionProfile.java b/src/grpc/grpc-runtime/src/main/java/dev/caskeleton/grpc/policy/GrpcCompressionProfile.java similarity index 100% rename from src/grpc/grpc-policy/src/main/java/dev/caskeleton/grpc/policy/GrpcCompressionProfile.java rename to src/grpc/grpc-runtime/src/main/java/dev/caskeleton/grpc/policy/GrpcCompressionProfile.java diff --git a/src/grpc/grpc-policy/src/main/java/dev/caskeleton/grpc/policy/GrpcMessageSizeProfile.java b/src/grpc/grpc-runtime/src/main/java/dev/caskeleton/grpc/policy/GrpcMessageSizeProfile.java similarity index 85% rename from src/grpc/grpc-policy/src/main/java/dev/caskeleton/grpc/policy/GrpcMessageSizeProfile.java rename to src/grpc/grpc-runtime/src/main/java/dev/caskeleton/grpc/policy/GrpcMessageSizeProfile.java index 28fd2dee..6b7c5034 100644 --- a/src/grpc/grpc-policy/src/main/java/dev/caskeleton/grpc/policy/GrpcMessageSizeProfile.java +++ b/src/grpc/grpc-runtime/src/main/java/dev/caskeleton/grpc/policy/GrpcMessageSizeProfile.java @@ -1,5 +1,7 @@ package dev.caskeleton.grpc.policy; +import dev.caskeleton.grpc.api.policy.GrpcTransportLimits; + /** * A method's size bounds, chosen rather than inherited. * @@ -40,7 +42,13 @@ public record GrpcMessageSizeProfile( /** The Stable default for an ordinary RPC: 1 MiB messages, no compression. */ public static GrpcMessageSizeProfile standard() { return new GrpcMessageSizeProfile( - 1024L * 1024L, 1024L * 1024L, 8192L, 1000, 8192, 8, GrpcCompressionProfile.IDENTITY); + GrpcTransportLimits.DEFAULT_MAX_MESSAGE_BYTES, + GrpcTransportLimits.DEFAULT_MAX_MESSAGE_BYTES, + GrpcTransportLimits.DEFAULT_MAX_METADATA_BYTES, + 1000, + 8192, + 8, + GrpcCompressionProfile.IDENTITY); } /** An explicitly reviewed large-message profile: 8 MiB, gzip. */ @@ -48,7 +56,7 @@ public record GrpcMessageSizeProfile( return new GrpcMessageSizeProfile( 8L * 1024L * 1024L, 8L * 1024L * 1024L, - 8192L, + GrpcTransportLimits.DEFAULT_MAX_METADATA_BYTES, 10_000, 65_536, 12, diff --git a/src/grpc/grpc-policy/src/main/java/dev/caskeleton/grpc/policy/GrpcPayloadBoundaryPolicy.java b/src/grpc/grpc-runtime/src/main/java/dev/caskeleton/grpc/policy/GrpcPayloadBoundaryPolicy.java similarity index 100% rename from src/grpc/grpc-policy/src/main/java/dev/caskeleton/grpc/policy/GrpcPayloadBoundaryPolicy.java rename to src/grpc/grpc-runtime/src/main/java/dev/caskeleton/grpc/policy/GrpcPayloadBoundaryPolicy.java diff --git a/src/grpc/grpc-policy/src/main/java/dev/caskeleton/grpc/policy/GrpcSizeViolation.java b/src/grpc/grpc-runtime/src/main/java/dev/caskeleton/grpc/policy/GrpcSizeViolation.java similarity index 100% rename from src/grpc/grpc-policy/src/main/java/dev/caskeleton/grpc/policy/GrpcSizeViolation.java rename to src/grpc/grpc-runtime/src/main/java/dev/caskeleton/grpc/policy/GrpcSizeViolation.java diff --git a/src/grpc/grpc-policy/src/main/java/dev/caskeleton/grpc/resilience/GrpcMethodRetryConfig.java b/src/grpc/grpc-runtime/src/main/java/dev/caskeleton/grpc/resilience/GrpcMethodRetryConfig.java similarity index 100% rename from src/grpc/grpc-policy/src/main/java/dev/caskeleton/grpc/resilience/GrpcMethodRetryConfig.java rename to src/grpc/grpc-runtime/src/main/java/dev/caskeleton/grpc/resilience/GrpcMethodRetryConfig.java diff --git a/src/grpc/grpc-policy/src/main/java/dev/caskeleton/grpc/resilience/GrpcRetryBudget.java b/src/grpc/grpc-runtime/src/main/java/dev/caskeleton/grpc/resilience/GrpcRetryBudget.java similarity index 100% rename from src/grpc/grpc-policy/src/main/java/dev/caskeleton/grpc/resilience/GrpcRetryBudget.java rename to src/grpc/grpc-runtime/src/main/java/dev/caskeleton/grpc/resilience/GrpcRetryBudget.java diff --git a/src/grpc/grpc-policy/src/main/java/dev/caskeleton/grpc/resilience/GrpcRetryCoordinator.java b/src/grpc/grpc-runtime/src/main/java/dev/caskeleton/grpc/resilience/GrpcRetryCoordinator.java similarity index 100% rename from src/grpc/grpc-policy/src/main/java/dev/caskeleton/grpc/resilience/GrpcRetryCoordinator.java rename to src/grpc/grpc-runtime/src/main/java/dev/caskeleton/grpc/resilience/GrpcRetryCoordinator.java diff --git a/src/grpc/grpc-policy/src/main/java/dev/caskeleton/grpc/resilience/GrpcRetryDecision.java b/src/grpc/grpc-runtime/src/main/java/dev/caskeleton/grpc/resilience/GrpcRetryDecision.java similarity index 100% rename from src/grpc/grpc-policy/src/main/java/dev/caskeleton/grpc/resilience/GrpcRetryDecision.java rename to src/grpc/grpc-runtime/src/main/java/dev/caskeleton/grpc/resilience/GrpcRetryDecision.java diff --git a/src/grpc/grpc-policy/src/main/java/dev/caskeleton/grpc/resilience/GrpcRetryEligibility.java b/src/grpc/grpc-runtime/src/main/java/dev/caskeleton/grpc/resilience/GrpcRetryEligibility.java similarity index 100% rename from src/grpc/grpc-policy/src/main/java/dev/caskeleton/grpc/resilience/GrpcRetryEligibility.java rename to src/grpc/grpc-runtime/src/main/java/dev/caskeleton/grpc/resilience/GrpcRetryEligibility.java diff --git a/src/grpc/grpc-policy/src/main/java/dev/caskeleton/grpc/resilience/GrpcRetryOwner.java b/src/grpc/grpc-runtime/src/main/java/dev/caskeleton/grpc/resilience/GrpcRetryOwner.java similarity index 100% rename from src/grpc/grpc-policy/src/main/java/dev/caskeleton/grpc/resilience/GrpcRetryOwner.java rename to src/grpc/grpc-runtime/src/main/java/dev/caskeleton/grpc/resilience/GrpcRetryOwner.java diff --git a/src/grpc/grpc-policy/src/main/java/dev/caskeleton/grpc/resilience/GrpcRetryOwnershipValidator.java b/src/grpc/grpc-runtime/src/main/java/dev/caskeleton/grpc/resilience/GrpcRetryOwnershipValidator.java similarity index 100% rename from src/grpc/grpc-policy/src/main/java/dev/caskeleton/grpc/resilience/GrpcRetryOwnershipValidator.java rename to src/grpc/grpc-runtime/src/main/java/dev/caskeleton/grpc/resilience/GrpcRetryOwnershipValidator.java diff --git a/src/grpc/grpc-policy/src/main/java/dev/caskeleton/grpc/resilience/GrpcServiceConfigPolicy.java b/src/grpc/grpc-runtime/src/main/java/dev/caskeleton/grpc/resilience/GrpcServiceConfigPolicy.java similarity index 100% rename from src/grpc/grpc-policy/src/main/java/dev/caskeleton/grpc/resilience/GrpcServiceConfigPolicy.java rename to src/grpc/grpc-runtime/src/main/java/dev/caskeleton/grpc/resilience/GrpcServiceConfigPolicy.java diff --git a/src/grpc/grpc-policy/src/main/java/dev/caskeleton/grpc/resilience/GrpcWaitForReadyDecision.java b/src/grpc/grpc-runtime/src/main/java/dev/caskeleton/grpc/resilience/GrpcWaitForReadyDecision.java similarity index 100% rename from src/grpc/grpc-policy/src/main/java/dev/caskeleton/grpc/resilience/GrpcWaitForReadyDecision.java rename to src/grpc/grpc-runtime/src/main/java/dev/caskeleton/grpc/resilience/GrpcWaitForReadyDecision.java diff --git a/src/grpc/grpc-policy/src/main/java/dev/caskeleton/grpc/resilience/GrpcWaitForReadyProfile.java b/src/grpc/grpc-runtime/src/main/java/dev/caskeleton/grpc/resilience/GrpcWaitForReadyProfile.java similarity index 100% rename from src/grpc/grpc-policy/src/main/java/dev/caskeleton/grpc/resilience/GrpcWaitForReadyProfile.java rename to src/grpc/grpc-runtime/src/main/java/dev/caskeleton/grpc/resilience/GrpcWaitForReadyProfile.java diff --git a/src/grpc/grpc-policy/src/main/java/dev/caskeleton/grpc/resilience/GrpcWaitForReadyValidator.java b/src/grpc/grpc-runtime/src/main/java/dev/caskeleton/grpc/resilience/GrpcWaitForReadyValidator.java similarity index 100% rename from src/grpc/grpc-policy/src/main/java/dev/caskeleton/grpc/resilience/GrpcWaitForReadyValidator.java rename to src/grpc/grpc-runtime/src/main/java/dev/caskeleton/grpc/resilience/GrpcWaitForReadyValidator.java diff --git a/src/grpc/grpc-policy/src/main/java/dev/caskeleton/grpc/security/GrpcAuthenticationProfile.java b/src/grpc/grpc-runtime/src/main/java/dev/caskeleton/grpc/security/GrpcAuthenticationProfile.java similarity index 100% rename from src/grpc/grpc-policy/src/main/java/dev/caskeleton/grpc/security/GrpcAuthenticationProfile.java rename to src/grpc/grpc-runtime/src/main/java/dev/caskeleton/grpc/security/GrpcAuthenticationProfile.java diff --git a/src/grpc/grpc-policy/src/main/java/dev/caskeleton/grpc/security/GrpcCredentialGeneration.java b/src/grpc/grpc-runtime/src/main/java/dev/caskeleton/grpc/security/GrpcCredentialGeneration.java similarity index 100% rename from src/grpc/grpc-policy/src/main/java/dev/caskeleton/grpc/security/GrpcCredentialGeneration.java rename to src/grpc/grpc-runtime/src/main/java/dev/caskeleton/grpc/security/GrpcCredentialGeneration.java diff --git a/src/grpc/grpc-policy/src/main/java/dev/caskeleton/grpc/security/GrpcCredentialRotationManager.java b/src/grpc/grpc-runtime/src/main/java/dev/caskeleton/grpc/security/GrpcCredentialRotationManager.java similarity index 83% rename from src/grpc/grpc-policy/src/main/java/dev/caskeleton/grpc/security/GrpcCredentialRotationManager.java rename to src/grpc/grpc-runtime/src/main/java/dev/caskeleton/grpc/security/GrpcCredentialRotationManager.java index dc13a6c2..69991cf6 100644 --- a/src/grpc/grpc-policy/src/main/java/dev/caskeleton/grpc/security/GrpcCredentialRotationManager.java +++ b/src/grpc/grpc-runtime/src/main/java/dev/caskeleton/grpc/security/GrpcCredentialRotationManager.java @@ -121,8 +121,28 @@ public final class GrpcCredentialRotationManager { return observed.drainDeadline() != null && !now.isBefore(observed.drainDeadline()); } - /** Forgets the draining generation once its work has finished or been cancelled. */ - public void completeDrain() { - state.updateAndGet(observed -> new State(observed.current(), null, null)); + /** + * Forgets {@code drained} once its work has finished or been cancelled. + * + *

Names the generation because a drain completes asynchronously: by the time the caller that + * drained generation N reports back, a later rotation may already be draining N+1, and clearing + * "whatever is draining now" would end that newer drain before its calls finished. + * + * @return whether {@code drained} was the draining generation and has now been forgotten; false + * when a later rotation already replaced it + */ + public boolean completeDrain(GrpcCredentialGeneration drained) { + if (drained == null) { + throw new IllegalArgumentException("a completed drain names the generation it drained"); + } + while (true) { + State observed = state.get(); + if (observed.draining() == null || observed.draining().generation() != drained.generation()) { + return false; + } + if (state.compareAndSet(observed, new State(observed.current(), null, null))) { + return true; + } + } } } diff --git a/src/grpc/grpc-policy/src/main/java/dev/caskeleton/grpc/security/GrpcTlsProfile.java b/src/grpc/grpc-runtime/src/main/java/dev/caskeleton/grpc/security/GrpcTlsProfile.java similarity index 100% rename from src/grpc/grpc-policy/src/main/java/dev/caskeleton/grpc/security/GrpcTlsProfile.java rename to src/grpc/grpc-runtime/src/main/java/dev/caskeleton/grpc/security/GrpcTlsProfile.java diff --git a/src/grpc/grpc-server/src/main/java/dev/caskeleton/grpc/server/GrpcAdmissionController.java b/src/grpc/grpc-runtime/src/main/java/dev/caskeleton/grpc/server/GrpcAdmissionController.java similarity index 100% rename from src/grpc/grpc-server/src/main/java/dev/caskeleton/grpc/server/GrpcAdmissionController.java rename to src/grpc/grpc-runtime/src/main/java/dev/caskeleton/grpc/server/GrpcAdmissionController.java diff --git a/src/grpc/grpc-server/src/main/java/dev/caskeleton/grpc/server/GrpcApplicationInvocation.java b/src/grpc/grpc-runtime/src/main/java/dev/caskeleton/grpc/server/GrpcApplicationInvocation.java similarity index 100% rename from src/grpc/grpc-server/src/main/java/dev/caskeleton/grpc/server/GrpcApplicationInvocation.java rename to src/grpc/grpc-runtime/src/main/java/dev/caskeleton/grpc/server/GrpcApplicationInvocation.java diff --git a/src/grpc/grpc-server/src/main/java/dev/caskeleton/grpc/server/GrpcExecutorProfile.java b/src/grpc/grpc-runtime/src/main/java/dev/caskeleton/grpc/server/GrpcExecutorProfile.java similarity index 100% rename from src/grpc/grpc-server/src/main/java/dev/caskeleton/grpc/server/GrpcExecutorProfile.java rename to src/grpc/grpc-runtime/src/main/java/dev/caskeleton/grpc/server/GrpcExecutorProfile.java diff --git a/src/grpc/grpc-server/src/main/java/dev/caskeleton/grpc/server/GrpcNettyParityContract.java b/src/grpc/grpc-runtime/src/main/java/dev/caskeleton/grpc/server/GrpcNettyParityContract.java similarity index 100% rename from src/grpc/grpc-server/src/main/java/dev/caskeleton/grpc/server/GrpcNettyParityContract.java rename to src/grpc/grpc-runtime/src/main/java/dev/caskeleton/grpc/server/GrpcNettyParityContract.java diff --git a/src/grpc/grpc-server/src/main/java/dev/caskeleton/grpc/server/GrpcNettyVariant.java b/src/grpc/grpc-runtime/src/main/java/dev/caskeleton/grpc/server/GrpcNettyVariant.java similarity index 100% rename from src/grpc/grpc-server/src/main/java/dev/caskeleton/grpc/server/GrpcNettyVariant.java rename to src/grpc/grpc-runtime/src/main/java/dev/caskeleton/grpc/server/GrpcNettyVariant.java diff --git a/src/grpc/grpc-server/src/main/java/dev/caskeleton/grpc/server/GrpcNettyVariantSelector.java b/src/grpc/grpc-runtime/src/main/java/dev/caskeleton/grpc/server/GrpcNettyVariantSelector.java similarity index 100% rename from src/grpc/grpc-server/src/main/java/dev/caskeleton/grpc/server/GrpcNettyVariantSelector.java rename to src/grpc/grpc-runtime/src/main/java/dev/caskeleton/grpc/server/GrpcNettyVariantSelector.java diff --git a/src/grpc/grpc-server/src/main/java/dev/caskeleton/grpc/server/GrpcResponseMapper.java b/src/grpc/grpc-runtime/src/main/java/dev/caskeleton/grpc/server/GrpcResponseMapper.java similarity index 100% rename from src/grpc/grpc-server/src/main/java/dev/caskeleton/grpc/server/GrpcResponseMapper.java rename to src/grpc/grpc-runtime/src/main/java/dev/caskeleton/grpc/server/GrpcResponseMapper.java diff --git a/src/grpc/grpc-server/src/main/java/dev/caskeleton/grpc/server/GrpcServerInterceptorChain.java b/src/grpc/grpc-runtime/src/main/java/dev/caskeleton/grpc/server/GrpcServerInterceptorChain.java similarity index 100% rename from src/grpc/grpc-server/src/main/java/dev/caskeleton/grpc/server/GrpcServerInterceptorChain.java rename to src/grpc/grpc-runtime/src/main/java/dev/caskeleton/grpc/server/GrpcServerInterceptorChain.java diff --git a/src/grpc/grpc-server/src/main/java/dev/caskeleton/grpc/server/GrpcServerInterceptorOrder.java b/src/grpc/grpc-runtime/src/main/java/dev/caskeleton/grpc/server/GrpcServerInterceptorOrder.java similarity index 100% rename from src/grpc/grpc-server/src/main/java/dev/caskeleton/grpc/server/GrpcServerInterceptorOrder.java rename to src/grpc/grpc-runtime/src/main/java/dev/caskeleton/grpc/server/GrpcServerInterceptorOrder.java diff --git a/src/grpc/grpc-server/src/main/java/dev/caskeleton/grpc/server/GrpcServerInterceptorStage.java b/src/grpc/grpc-runtime/src/main/java/dev/caskeleton/grpc/server/GrpcServerInterceptorStage.java similarity index 100% rename from src/grpc/grpc-server/src/main/java/dev/caskeleton/grpc/server/GrpcServerInterceptorStage.java rename to src/grpc/grpc-runtime/src/main/java/dev/caskeleton/grpc/server/GrpcServerInterceptorStage.java diff --git a/src/grpc/grpc-server/src/main/java/dev/caskeleton/grpc/server/GrpcServerProfile.java b/src/grpc/grpc-runtime/src/main/java/dev/caskeleton/grpc/server/GrpcServerProfile.java similarity index 85% rename from src/grpc/grpc-server/src/main/java/dev/caskeleton/grpc/server/GrpcServerProfile.java rename to src/grpc/grpc-runtime/src/main/java/dev/caskeleton/grpc/server/GrpcServerProfile.java index 6c75ff8d..c6c03efe 100644 --- a/src/grpc/grpc-server/src/main/java/dev/caskeleton/grpc/server/GrpcServerProfile.java +++ b/src/grpc/grpc-runtime/src/main/java/dev/caskeleton/grpc/server/GrpcServerProfile.java @@ -1,5 +1,6 @@ package dev.caskeleton.grpc.server; +import dev.caskeleton.grpc.api.policy.GrpcTransportLimits; import java.time.Duration; /** @@ -65,10 +66,19 @@ public record GrpcServerProfile( /** The Stable default profile on shaded Netty. */ public static GrpcServerProfile stableNetty(GrpcExecutorProfile executor) { + return stable(GrpcServerTransport.NETTY_SHADED, executor); + } + + /** + * The Stable default profile on {@code transport}: the platform's default message and metadata + * bounds ({@link GrpcTransportLimits}) and keep-alive/connection-age settings. + */ + public static GrpcServerProfile stable( + GrpcServerTransport transport, GrpcExecutorProfile executor) { return new GrpcServerProfile( - GrpcServerTransport.NETTY_SHADED, - 1024L * 1024L, - 8192, + transport, + GrpcTransportLimits.DEFAULT_MAX_MESSAGE_BYTES, + GrpcTransportLimits.DEFAULT_MAX_METADATA_BYTES, Duration.ofSeconds(30), Duration.ofSeconds(10), Duration.ofSeconds(30), diff --git a/src/grpc/grpc-server/src/main/java/dev/caskeleton/grpc/server/GrpcServerTransport.java b/src/grpc/grpc-runtime/src/main/java/dev/caskeleton/grpc/server/GrpcServerTransport.java similarity index 100% rename from src/grpc/grpc-server/src/main/java/dev/caskeleton/grpc/server/GrpcServerTransport.java rename to src/grpc/grpc-runtime/src/main/java/dev/caskeleton/grpc/server/GrpcServerTransport.java diff --git a/src/grpc/grpc-server/src/main/java/dev/caskeleton/grpc/server/GrpcServiceAdapter.java b/src/grpc/grpc-runtime/src/main/java/dev/caskeleton/grpc/server/GrpcServiceAdapter.java similarity index 100% rename from src/grpc/grpc-server/src/main/java/dev/caskeleton/grpc/server/GrpcServiceAdapter.java rename to src/grpc/grpc-runtime/src/main/java/dev/caskeleton/grpc/server/GrpcServiceAdapter.java diff --git a/src/grpc/grpc-server/src/main/java/dev/caskeleton/grpc/server/GrpcServiceAdapterDescriptor.java b/src/grpc/grpc-runtime/src/main/java/dev/caskeleton/grpc/server/GrpcServiceAdapterDescriptor.java similarity index 100% rename from src/grpc/grpc-server/src/main/java/dev/caskeleton/grpc/server/GrpcServiceAdapterDescriptor.java rename to src/grpc/grpc-runtime/src/main/java/dev/caskeleton/grpc/server/GrpcServiceAdapterDescriptor.java diff --git a/src/grpc/grpc-policy/src/main/java/dev/caskeleton/grpc/streaming/GrpcFlowControlDecision.java b/src/grpc/grpc-runtime/src/main/java/dev/caskeleton/grpc/streaming/GrpcFlowControlDecision.java similarity index 100% rename from src/grpc/grpc-policy/src/main/java/dev/caskeleton/grpc/streaming/GrpcFlowControlDecision.java rename to src/grpc/grpc-runtime/src/main/java/dev/caskeleton/grpc/streaming/GrpcFlowControlDecision.java diff --git a/src/grpc/grpc-policy/src/main/java/dev/caskeleton/grpc/streaming/GrpcFlowControlPolicy.java b/src/grpc/grpc-runtime/src/main/java/dev/caskeleton/grpc/streaming/GrpcFlowControlPolicy.java similarity index 100% rename from src/grpc/grpc-policy/src/main/java/dev/caskeleton/grpc/streaming/GrpcFlowControlPolicy.java rename to src/grpc/grpc-runtime/src/main/java/dev/caskeleton/grpc/streaming/GrpcFlowControlPolicy.java diff --git a/src/grpc/grpc-policy/src/main/java/dev/caskeleton/grpc/streaming/GrpcResumeDecision.java b/src/grpc/grpc-runtime/src/main/java/dev/caskeleton/grpc/streaming/GrpcResumeDecision.java similarity index 100% rename from src/grpc/grpc-policy/src/main/java/dev/caskeleton/grpc/streaming/GrpcResumeDecision.java rename to src/grpc/grpc-runtime/src/main/java/dev/caskeleton/grpc/streaming/GrpcResumeDecision.java diff --git a/src/grpc/grpc-policy/src/main/java/dev/caskeleton/grpc/streaming/GrpcResumeToken.java b/src/grpc/grpc-runtime/src/main/java/dev/caskeleton/grpc/streaming/GrpcResumeToken.java similarity index 100% rename from src/grpc/grpc-policy/src/main/java/dev/caskeleton/grpc/streaming/GrpcResumeToken.java rename to src/grpc/grpc-runtime/src/main/java/dev/caskeleton/grpc/streaming/GrpcResumeToken.java diff --git a/src/grpc/grpc-policy/src/main/java/dev/caskeleton/grpc/streaming/GrpcResumeTokenCodec.java b/src/grpc/grpc-runtime/src/main/java/dev/caskeleton/grpc/streaming/GrpcResumeTokenCodec.java similarity index 100% rename from src/grpc/grpc-policy/src/main/java/dev/caskeleton/grpc/streaming/GrpcResumeTokenCodec.java rename to src/grpc/grpc-runtime/src/main/java/dev/caskeleton/grpc/streaming/GrpcResumeTokenCodec.java diff --git a/src/grpc/grpc-policy/src/main/java/dev/caskeleton/grpc/streaming/GrpcSerializedStreamWriter.java b/src/grpc/grpc-runtime/src/main/java/dev/caskeleton/grpc/streaming/GrpcSerializedStreamWriter.java similarity index 100% rename from src/grpc/grpc-policy/src/main/java/dev/caskeleton/grpc/streaming/GrpcSerializedStreamWriter.java rename to src/grpc/grpc-runtime/src/main/java/dev/caskeleton/grpc/streaming/GrpcSerializedStreamWriter.java diff --git a/src/grpc/grpc-policy/src/main/java/dev/caskeleton/grpc/streaming/GrpcSlowConsumerPolicy.java b/src/grpc/grpc-runtime/src/main/java/dev/caskeleton/grpc/streaming/GrpcSlowConsumerPolicy.java similarity index 100% rename from src/grpc/grpc-policy/src/main/java/dev/caskeleton/grpc/streaming/GrpcSlowConsumerPolicy.java rename to src/grpc/grpc-runtime/src/main/java/dev/caskeleton/grpc/streaming/GrpcSlowConsumerPolicy.java diff --git a/src/grpc/grpc-policy/src/main/java/dev/caskeleton/grpc/streaming/GrpcStreamAdmission.java b/src/grpc/grpc-runtime/src/main/java/dev/caskeleton/grpc/streaming/GrpcStreamAdmission.java similarity index 100% rename from src/grpc/grpc-policy/src/main/java/dev/caskeleton/grpc/streaming/GrpcStreamAdmission.java rename to src/grpc/grpc-runtime/src/main/java/dev/caskeleton/grpc/streaming/GrpcStreamAdmission.java diff --git a/src/grpc/grpc-policy/src/main/java/dev/caskeleton/grpc/streaming/GrpcStreamEnvelope.java b/src/grpc/grpc-runtime/src/main/java/dev/caskeleton/grpc/streaming/GrpcStreamEnvelope.java similarity index 100% rename from src/grpc/grpc-policy/src/main/java/dev/caskeleton/grpc/streaming/GrpcStreamEnvelope.java rename to src/grpc/grpc-runtime/src/main/java/dev/caskeleton/grpc/streaming/GrpcStreamEnvelope.java diff --git a/src/grpc/grpc-policy/src/main/java/dev/caskeleton/grpc/streaming/GrpcStreamGapDetector.java b/src/grpc/grpc-runtime/src/main/java/dev/caskeleton/grpc/streaming/GrpcStreamGapDetector.java similarity index 100% rename from src/grpc/grpc-policy/src/main/java/dev/caskeleton/grpc/streaming/GrpcStreamGapDetector.java rename to src/grpc/grpc-runtime/src/main/java/dev/caskeleton/grpc/streaming/GrpcStreamGapDetector.java diff --git a/src/grpc/grpc-policy/src/main/java/dev/caskeleton/grpc/streaming/GrpcStreamHeartbeat.java b/src/grpc/grpc-runtime/src/main/java/dev/caskeleton/grpc/streaming/GrpcStreamHeartbeat.java similarity index 100% rename from src/grpc/grpc-policy/src/main/java/dev/caskeleton/grpc/streaming/GrpcStreamHeartbeat.java rename to src/grpc/grpc-runtime/src/main/java/dev/caskeleton/grpc/streaming/GrpcStreamHeartbeat.java diff --git a/src/grpc/grpc-policy/src/main/java/dev/caskeleton/grpc/streaming/GrpcStreamId.java b/src/grpc/grpc-runtime/src/main/java/dev/caskeleton/grpc/streaming/GrpcStreamId.java similarity index 100% rename from src/grpc/grpc-policy/src/main/java/dev/caskeleton/grpc/streaming/GrpcStreamId.java rename to src/grpc/grpc-runtime/src/main/java/dev/caskeleton/grpc/streaming/GrpcStreamId.java diff --git a/src/grpc/grpc-policy/src/main/java/dev/caskeleton/grpc/streaming/GrpcStreamLifecycleCoordinator.java b/src/grpc/grpc-runtime/src/main/java/dev/caskeleton/grpc/streaming/GrpcStreamLifecycleCoordinator.java similarity index 100% rename from src/grpc/grpc-policy/src/main/java/dev/caskeleton/grpc/streaming/GrpcStreamLifecycleCoordinator.java rename to src/grpc/grpc-runtime/src/main/java/dev/caskeleton/grpc/streaming/GrpcStreamLifecycleCoordinator.java diff --git a/src/grpc/grpc-policy/src/main/java/dev/caskeleton/grpc/streaming/GrpcStreamLifetimePolicy.java b/src/grpc/grpc-runtime/src/main/java/dev/caskeleton/grpc/streaming/GrpcStreamLifetimePolicy.java similarity index 100% rename from src/grpc/grpc-policy/src/main/java/dev/caskeleton/grpc/streaming/GrpcStreamLifetimePolicy.java rename to src/grpc/grpc-runtime/src/main/java/dev/caskeleton/grpc/streaming/GrpcStreamLifetimePolicy.java diff --git a/src/grpc/grpc-policy/src/main/java/dev/caskeleton/grpc/streaming/GrpcStreamSequence.java b/src/grpc/grpc-runtime/src/main/java/dev/caskeleton/grpc/streaming/GrpcStreamSequence.java similarity index 100% rename from src/grpc/grpc-policy/src/main/java/dev/caskeleton/grpc/streaming/GrpcStreamSequence.java rename to src/grpc/grpc-runtime/src/main/java/dev/caskeleton/grpc/streaming/GrpcStreamSequence.java diff --git a/src/grpc/grpc-policy/src/main/java/dev/caskeleton/grpc/streaming/GrpcStreamTerminationReason.java b/src/grpc/grpc-runtime/src/main/java/dev/caskeleton/grpc/streaming/GrpcStreamTerminationReason.java similarity index 100% rename from src/grpc/grpc-policy/src/main/java/dev/caskeleton/grpc/streaming/GrpcStreamTerminationReason.java rename to src/grpc/grpc-runtime/src/main/java/dev/caskeleton/grpc/streaming/GrpcStreamTerminationReason.java diff --git a/src/grpc/grpc-policy/src/main/java/dev/caskeleton/grpc/streaming/GrpcStreamWriteResult.java b/src/grpc/grpc-runtime/src/main/java/dev/caskeleton/grpc/streaming/GrpcStreamWriteResult.java similarity index 100% rename from src/grpc/grpc-policy/src/main/java/dev/caskeleton/grpc/streaming/GrpcStreamWriteResult.java rename to src/grpc/grpc-runtime/src/main/java/dev/caskeleton/grpc/streaming/GrpcStreamWriteResult.java diff --git a/src/grpc/grpc-policy/src/main/java/dev/caskeleton/grpc/streaming/GrpcStreamWriterState.java b/src/grpc/grpc-runtime/src/main/java/dev/caskeleton/grpc/streaming/GrpcStreamWriterState.java similarity index 100% rename from src/grpc/grpc-policy/src/main/java/dev/caskeleton/grpc/streaming/GrpcStreamWriterState.java rename to src/grpc/grpc-runtime/src/main/java/dev/caskeleton/grpc/streaming/GrpcStreamWriterState.java diff --git a/src/grpc/grpc-policy/src/main/java/dev/caskeleton/grpc/validation/GrpcTransportValidator.java b/src/grpc/grpc-runtime/src/main/java/dev/caskeleton/grpc/validation/GrpcTransportValidator.java similarity index 100% rename from src/grpc/grpc-policy/src/main/java/dev/caskeleton/grpc/validation/GrpcTransportValidator.java rename to src/grpc/grpc-runtime/src/main/java/dev/caskeleton/grpc/validation/GrpcTransportValidator.java diff --git a/src/grpc/grpc-policy/src/main/java/dev/caskeleton/grpc/validation/GrpcValidationInterceptor.java b/src/grpc/grpc-runtime/src/main/java/dev/caskeleton/grpc/validation/GrpcValidationInterceptor.java similarity index 100% rename from src/grpc/grpc-policy/src/main/java/dev/caskeleton/grpc/validation/GrpcValidationInterceptor.java rename to src/grpc/grpc-runtime/src/main/java/dev/caskeleton/grpc/validation/GrpcValidationInterceptor.java diff --git a/src/grpc/grpc-policy/src/main/java/dev/caskeleton/grpc/validation/GrpcValidationViolation.java b/src/grpc/grpc-runtime/src/main/java/dev/caskeleton/grpc/validation/GrpcValidationViolation.java similarity index 100% rename from src/grpc/grpc-policy/src/main/java/dev/caskeleton/grpc/validation/GrpcValidationViolation.java rename to src/grpc/grpc-runtime/src/main/java/dev/caskeleton/grpc/validation/GrpcValidationViolation.java diff --git a/src/grpc/grpc-admin/src/test/java/dev/caskeleton/grpc/admin/GrpcDrainCoordinatorTest.java b/src/grpc/grpc-runtime/src/test/java/dev/caskeleton/grpc/admin/GrpcDrainCoordinatorTest.java similarity index 98% rename from src/grpc/grpc-admin/src/test/java/dev/caskeleton/grpc/admin/GrpcDrainCoordinatorTest.java rename to src/grpc/grpc-runtime/src/test/java/dev/caskeleton/grpc/admin/GrpcDrainCoordinatorTest.java index de930093..4f64728d 100644 --- a/src/grpc/grpc-admin/src/test/java/dev/caskeleton/grpc/admin/GrpcDrainCoordinatorTest.java +++ b/src/grpc/grpc-runtime/src/test/java/dev/caskeleton/grpc/admin/GrpcDrainCoordinatorTest.java @@ -13,7 +13,7 @@ import org.junit.jupiter.api.Test; class GrpcDrainCoordinatorTest { private static final Instant START = Instant.parse("2026-08-30T10:00:00Z"); - private static final String DOCUMENTS = "hyeonworks.document.v1.DocumentService"; + private static final String DOCUMENTS = "caskeleton.document.v1.DocumentService"; private final AtomicInteger unaryCalls = new AtomicInteger(); private final AtomicInteger streams = new AtomicInteger(); diff --git a/src/grpc/grpc-admin/src/test/java/dev/caskeleton/grpc/admin/GrpcPlatformSnapshotServiceTest.java b/src/grpc/grpc-runtime/src/test/java/dev/caskeleton/grpc/admin/GrpcPlatformSnapshotServiceTest.java similarity index 98% rename from src/grpc/grpc-admin/src/test/java/dev/caskeleton/grpc/admin/GrpcPlatformSnapshotServiceTest.java rename to src/grpc/grpc-runtime/src/test/java/dev/caskeleton/grpc/admin/GrpcPlatformSnapshotServiceTest.java index c512d491..cdc95fc6 100644 --- a/src/grpc/grpc-admin/src/test/java/dev/caskeleton/grpc/admin/GrpcPlatformSnapshotServiceTest.java +++ b/src/grpc/grpc-runtime/src/test/java/dev/caskeleton/grpc/admin/GrpcPlatformSnapshotServiceTest.java @@ -15,7 +15,7 @@ import org.junit.jupiter.api.Test; class GrpcPlatformSnapshotServiceTest { private static final Instant NOW = Instant.parse("2026-08-30T10:00:00Z"); - private static final String DOCUMENTS = "hyeonworks.document.v1.DocumentService"; + private static final String DOCUMENTS = "caskeleton.document.v1.DocumentService"; private final GrpcServiceHealthRegistry health = new GrpcServiceHealthRegistry(GrpcHealthPolicy.standalone()); diff --git a/src/grpc/grpc-admin/src/test/java/dev/caskeleton/grpc/admin/GrpcReflectionPolicyTest.java b/src/grpc/grpc-runtime/src/test/java/dev/caskeleton/grpc/admin/GrpcReflectionPolicyTest.java similarity index 100% rename from src/grpc/grpc-admin/src/test/java/dev/caskeleton/grpc/admin/GrpcReflectionPolicyTest.java rename to src/grpc/grpc-runtime/src/test/java/dev/caskeleton/grpc/admin/GrpcReflectionPolicyTest.java diff --git a/src/grpc/grpc-admin/src/test/java/dev/caskeleton/grpc/admin/GrpcServiceHealthRegistryTest.java b/src/grpc/grpc-runtime/src/test/java/dev/caskeleton/grpc/admin/GrpcServiceHealthRegistryTest.java similarity index 97% rename from src/grpc/grpc-admin/src/test/java/dev/caskeleton/grpc/admin/GrpcServiceHealthRegistryTest.java rename to src/grpc/grpc-runtime/src/test/java/dev/caskeleton/grpc/admin/GrpcServiceHealthRegistryTest.java index 7454b5ae..c3da8c32 100644 --- a/src/grpc/grpc-admin/src/test/java/dev/caskeleton/grpc/admin/GrpcServiceHealthRegistryTest.java +++ b/src/grpc/grpc-runtime/src/test/java/dev/caskeleton/grpc/admin/GrpcServiceHealthRegistryTest.java @@ -14,7 +14,7 @@ import org.junit.jupiter.api.Test; class GrpcServiceHealthRegistryTest { - private static final String DOCUMENTS = "hyeonworks.document.v1.DocumentService"; + private static final String DOCUMENTS = "caskeleton.document.v1.DocumentService"; @Test @DisplayName("an instance is not ready before its first check completes") @@ -42,7 +42,7 @@ class GrpcServiceHealthRegistryTest { GrpcServiceHealthRegistry registry = new GrpcServiceHealthRegistry(GrpcHealthPolicy.standalone()); - assertThat(registry.stateOf("hyeonworks.other.v1.OtherService")) + assertThat(registry.stateOf("caskeleton.other.v1.OtherService")) .isEqualTo(GrpcHealthState.SERVICE_UNKNOWN); } diff --git a/src/grpc/grpc-client/src/test/java/dev/caskeleton/grpc/client/GrpcChannelRuntimeRegistryTest.java b/src/grpc/grpc-runtime/src/test/java/dev/caskeleton/grpc/client/GrpcChannelRuntimeRegistryTest.java similarity index 100% rename from src/grpc/grpc-client/src/test/java/dev/caskeleton/grpc/client/GrpcChannelRuntimeRegistryTest.java rename to src/grpc/grpc-runtime/src/test/java/dev/caskeleton/grpc/client/GrpcChannelRuntimeRegistryTest.java diff --git a/src/grpc/grpc-client/src/test/java/dev/caskeleton/grpc/client/GrpcClientMetadataPolicyTest.java b/src/grpc/grpc-runtime/src/test/java/dev/caskeleton/grpc/client/GrpcClientMetadataPolicyTest.java similarity index 99% rename from src/grpc/grpc-client/src/test/java/dev/caskeleton/grpc/client/GrpcClientMetadataPolicyTest.java rename to src/grpc/grpc-runtime/src/test/java/dev/caskeleton/grpc/client/GrpcClientMetadataPolicyTest.java index 1d663b9a..04e973dc 100644 --- a/src/grpc/grpc-client/src/test/java/dev/caskeleton/grpc/client/GrpcClientMetadataPolicyTest.java +++ b/src/grpc/grpc-runtime/src/test/java/dev/caskeleton/grpc/client/GrpcClientMetadataPolicyTest.java @@ -23,7 +23,7 @@ class GrpcClientMetadataPolicyTest { private static final GrpcMetadataKey CORRELATION = GrpcMetadataKey.ascii("x-correlation-id"); private static final GrpcMetadataKey TENANT = GrpcMetadataKey.ascii("x-tenant-context"); private static final GrpcMethodName GET = - GrpcMethodName.parse("hyeonworks.document.v1.DocumentService/GetDocument"); + GrpcMethodName.parse("caskeleton.document.v1.DocumentService/GetDocument"); private static final Instant NOW = Instant.parse("2026-08-30T10:00:00Z"); private static GrpcClientMetadataPolicy policy(boolean crossesBoundary) { diff --git a/src/grpc/grpc-client/src/test/java/dev/caskeleton/grpc/client/GrpcNamedChannelProfileTest.java b/src/grpc/grpc-runtime/src/test/java/dev/caskeleton/grpc/client/GrpcNamedChannelProfileTest.java similarity index 100% rename from src/grpc/grpc-client/src/test/java/dev/caskeleton/grpc/client/GrpcNamedChannelProfileTest.java rename to src/grpc/grpc-runtime/src/test/java/dev/caskeleton/grpc/client/GrpcNamedChannelProfileTest.java diff --git a/src/grpc/grpc-client/src/test/java/dev/caskeleton/grpc/client/GrpcTypedStubFactoryTest.java b/src/grpc/grpc-runtime/src/test/java/dev/caskeleton/grpc/client/GrpcTypedStubFactoryTest.java similarity index 98% rename from src/grpc/grpc-client/src/test/java/dev/caskeleton/grpc/client/GrpcTypedStubFactoryTest.java rename to src/grpc/grpc-runtime/src/test/java/dev/caskeleton/grpc/client/GrpcTypedStubFactoryTest.java index 15cdf297..021d4e84 100644 --- a/src/grpc/grpc-client/src/test/java/dev/caskeleton/grpc/client/GrpcTypedStubFactoryTest.java +++ b/src/grpc/grpc-runtime/src/test/java/dev/caskeleton/grpc/client/GrpcTypedStubFactoryTest.java @@ -19,7 +19,7 @@ class GrpcTypedStubFactoryTest { private static final GrpcChannelProfileName PROFILE = new GrpcChannelProfileName("documents-read"); private static final GrpcMethodName GET = - GrpcMethodName.parse("hyeonworks.document.v1.DocumentService/GetDocument"); + GrpcMethodName.parse("caskeleton.document.v1.DocumentService/GetDocument"); private static final Instant NOW = Instant.parse("2026-08-30T10:00:00Z"); /** Stands in for a generated blocking stub. */ diff --git a/src/grpc/grpc-policy/src/test/java/dev/caskeleton/grpc/context/GrpcContextBinderTest.java b/src/grpc/grpc-runtime/src/test/java/dev/caskeleton/grpc/context/GrpcContextBinderTest.java similarity index 99% rename from src/grpc/grpc-policy/src/test/java/dev/caskeleton/grpc/context/GrpcContextBinderTest.java rename to src/grpc/grpc-runtime/src/test/java/dev/caskeleton/grpc/context/GrpcContextBinderTest.java index f45ecf23..1e1d115c 100644 --- a/src/grpc/grpc-policy/src/test/java/dev/caskeleton/grpc/context/GrpcContextBinderTest.java +++ b/src/grpc/grpc-runtime/src/test/java/dev/caskeleton/grpc/context/GrpcContextBinderTest.java @@ -28,7 +28,7 @@ import org.junit.jupiter.api.Test; class GrpcContextBinderTest { private static final GrpcMethodName GET = - GrpcMethodName.parse("hyeonworks.document.v1.DocumentService/GetDocument"); + GrpcMethodName.parse("caskeleton.document.v1.DocumentService/GetDocument"); private static GrpcContextSnapshot snapshot(Instant credentialExpiry) { GrpcRequestContext request = diff --git a/src/grpc/grpc-policy/src/test/java/dev/caskeleton/grpc/deadline/GrpcCancellationCoordinatorTest.java b/src/grpc/grpc-runtime/src/test/java/dev/caskeleton/grpc/deadline/GrpcCancellationCoordinatorTest.java similarity index 100% rename from src/grpc/grpc-policy/src/test/java/dev/caskeleton/grpc/deadline/GrpcCancellationCoordinatorTest.java rename to src/grpc/grpc-runtime/src/test/java/dev/caskeleton/grpc/deadline/GrpcCancellationCoordinatorTest.java diff --git a/src/grpc/grpc-policy/src/test/java/dev/caskeleton/grpc/deadline/GrpcDeadlineCalculatorTest.java b/src/grpc/grpc-runtime/src/test/java/dev/caskeleton/grpc/deadline/GrpcDeadlineCalculatorTest.java similarity index 97% rename from src/grpc/grpc-policy/src/test/java/dev/caskeleton/grpc/deadline/GrpcDeadlineCalculatorTest.java rename to src/grpc/grpc-runtime/src/test/java/dev/caskeleton/grpc/deadline/GrpcDeadlineCalculatorTest.java index b158c987..71826cc8 100644 --- a/src/grpc/grpc-policy/src/test/java/dev/caskeleton/grpc/deadline/GrpcDeadlineCalculatorTest.java +++ b/src/grpc/grpc-runtime/src/test/java/dev/caskeleton/grpc/deadline/GrpcDeadlineCalculatorTest.java @@ -17,7 +17,7 @@ import org.junit.jupiter.api.Test; class GrpcDeadlineCalculatorTest { private static final GrpcMethodName GET = - GrpcMethodName.parse("hyeonworks.document.v1.DocumentService/GetDocument"); + GrpcMethodName.parse("caskeleton.document.v1.DocumentService/GetDocument"); private static final GrpcDeadlineProfile TWO_SECONDS = GrpcDeadlineProfile.of(Duration.ofSeconds(2)); private static final GrpcMethodPolicy READ = GrpcMethodPolicy.readOnlyUnary(GET, TWO_SECONDS); @@ -86,7 +86,7 @@ class GrpcDeadlineCalculatorTest { GrpcMethodPolicyCatalog.builder() .register( GrpcMethodPolicy.readOnlyUnary( - GrpcMethodName.parse("hyeonworks.document.v1.DocumentService/ListDocuments"), + GrpcMethodName.parse("caskeleton.document.v1.DocumentService/ListDocuments"), TWO_SECONDS)) .build(); Map> dependencies = diff --git a/src/grpc/grpc-discovery/src/test/java/dev/caskeleton/grpc/discovery/GrpcDiscoveryPolicyValidatorTest.java b/src/grpc/grpc-runtime/src/test/java/dev/caskeleton/grpc/discovery/GrpcDiscoveryPolicyValidatorTest.java similarity index 100% rename from src/grpc/grpc-discovery/src/test/java/dev/caskeleton/grpc/discovery/GrpcDiscoveryPolicyValidatorTest.java rename to src/grpc/grpc-runtime/src/test/java/dev/caskeleton/grpc/discovery/GrpcDiscoveryPolicyValidatorTest.java diff --git a/src/grpc/grpc-discovery/src/test/java/dev/caskeleton/grpc/discovery/GrpcKubernetesProfileTest.java b/src/grpc/grpc-runtime/src/test/java/dev/caskeleton/grpc/discovery/GrpcKubernetesProfileTest.java similarity index 100% rename from src/grpc/grpc-discovery/src/test/java/dev/caskeleton/grpc/discovery/GrpcKubernetesProfileTest.java rename to src/grpc/grpc-runtime/src/test/java/dev/caskeleton/grpc/discovery/GrpcKubernetesProfileTest.java diff --git a/src/grpc/grpc-policy/src/test/java/dev/caskeleton/grpc/error/GrpcErrorMapperTest.java b/src/grpc/grpc-runtime/src/test/java/dev/caskeleton/grpc/error/GrpcErrorMapperTest.java similarity index 99% rename from src/grpc/grpc-policy/src/test/java/dev/caskeleton/grpc/error/GrpcErrorMapperTest.java rename to src/grpc/grpc-runtime/src/test/java/dev/caskeleton/grpc/error/GrpcErrorMapperTest.java index 9fc36034..86e01af5 100644 --- a/src/grpc/grpc-policy/src/test/java/dev/caskeleton/grpc/error/GrpcErrorMapperTest.java +++ b/src/grpc/grpc-runtime/src/test/java/dev/caskeleton/grpc/error/GrpcErrorMapperTest.java @@ -24,7 +24,7 @@ import org.junit.jupiter.api.Test; class GrpcErrorMapperTest { private static final GrpcMethodName CREATE = - GrpcMethodName.parse("hyeonworks.document.v1.DocumentService/CreateDocument"); + GrpcMethodName.parse("caskeleton.document.v1.DocumentService/CreateDocument"); private final GrpcErrorMapper mapper = new GrpcErrorMapper("document.v1", () -> "exec-0001"); diff --git a/src/grpc/grpc-policy/src/test/java/dev/caskeleton/grpc/idempotency/GrpcCompletionReconcilerTest.java b/src/grpc/grpc-runtime/src/test/java/dev/caskeleton/grpc/idempotency/GrpcCompletionReconcilerTest.java similarity index 98% rename from src/grpc/grpc-policy/src/test/java/dev/caskeleton/grpc/idempotency/GrpcCompletionReconcilerTest.java rename to src/grpc/grpc-runtime/src/test/java/dev/caskeleton/grpc/idempotency/GrpcCompletionReconcilerTest.java index 7bffcbca..972630e5 100644 --- a/src/grpc/grpc-policy/src/test/java/dev/caskeleton/grpc/idempotency/GrpcCompletionReconcilerTest.java +++ b/src/grpc/grpc-runtime/src/test/java/dev/caskeleton/grpc/idempotency/GrpcCompletionReconcilerTest.java @@ -12,7 +12,7 @@ import org.junit.jupiter.api.Test; class GrpcCompletionReconcilerTest { private static final GrpcMethodName CREATE = - GrpcMethodName.parse("hyeonworks.document.v1.DocumentService/CreateDocument"); + GrpcMethodName.parse("caskeleton.document.v1.DocumentService/CreateDocument"); private static final Instant NOW = Instant.parse("2026-08-30T10:00:00Z"); private static final String CALLER = "tenant-1|actor-1"; private static final String KEY = "order-2026-0001"; diff --git a/src/grpc/grpc-policy/src/test/java/dev/caskeleton/grpc/idempotency/GrpcIdempotencyInterceptorTest.java b/src/grpc/grpc-runtime/src/test/java/dev/caskeleton/grpc/idempotency/GrpcIdempotencyInterceptorTest.java similarity index 98% rename from src/grpc/grpc-policy/src/test/java/dev/caskeleton/grpc/idempotency/GrpcIdempotencyInterceptorTest.java rename to src/grpc/grpc-runtime/src/test/java/dev/caskeleton/grpc/idempotency/GrpcIdempotencyInterceptorTest.java index 7a09d605..6ed3d16b 100644 --- a/src/grpc/grpc-policy/src/test/java/dev/caskeleton/grpc/idempotency/GrpcIdempotencyInterceptorTest.java +++ b/src/grpc/grpc-runtime/src/test/java/dev/caskeleton/grpc/idempotency/GrpcIdempotencyInterceptorTest.java @@ -28,9 +28,9 @@ import org.junit.jupiter.api.Test; class GrpcIdempotencyInterceptorTest { private static final GrpcMethodName CREATE = - GrpcMethodName.parse("hyeonworks.document.v1.DocumentService/CreateDocument"); + GrpcMethodName.parse("caskeleton.document.v1.DocumentService/CreateDocument"); private static final GrpcMethodName GET = - GrpcMethodName.parse("hyeonworks.document.v1.DocumentService/GetDocument"); + GrpcMethodName.parse("caskeleton.document.v1.DocumentService/GetDocument"); private static final GrpcDeadlineProfile TEN_SECONDS = GrpcDeadlineProfile.of(Duration.ofSeconds(10)); private static final Instant NOW = Instant.parse("2026-08-30T10:00:00Z"); diff --git a/src/grpc/grpc-policy/src/test/java/dev/caskeleton/grpc/idempotency/GrpcOutcomeReplayBoundTest.java b/src/grpc/grpc-runtime/src/test/java/dev/caskeleton/grpc/idempotency/GrpcOutcomeReplayBoundTest.java similarity index 100% rename from src/grpc/grpc-policy/src/test/java/dev/caskeleton/grpc/idempotency/GrpcOutcomeReplayBoundTest.java rename to src/grpc/grpc-runtime/src/test/java/dev/caskeleton/grpc/idempotency/GrpcOutcomeReplayBoundTest.java diff --git a/src/grpc/grpc-policy/src/test/java/dev/caskeleton/grpc/policy/GrpcPayloadBoundaryPolicyTest.java b/src/grpc/grpc-runtime/src/test/java/dev/caskeleton/grpc/policy/GrpcPayloadBoundaryPolicyTest.java similarity index 100% rename from src/grpc/grpc-policy/src/test/java/dev/caskeleton/grpc/policy/GrpcPayloadBoundaryPolicyTest.java rename to src/grpc/grpc-runtime/src/test/java/dev/caskeleton/grpc/policy/GrpcPayloadBoundaryPolicyTest.java diff --git a/src/grpc/grpc-policy/src/test/java/dev/caskeleton/grpc/resilience/GrpcRetryEligibilityTest.java b/src/grpc/grpc-runtime/src/test/java/dev/caskeleton/grpc/resilience/GrpcRetryEligibilityTest.java similarity index 98% rename from src/grpc/grpc-policy/src/test/java/dev/caskeleton/grpc/resilience/GrpcRetryEligibilityTest.java rename to src/grpc/grpc-runtime/src/test/java/dev/caskeleton/grpc/resilience/GrpcRetryEligibilityTest.java index b3c1b95f..16c2078f 100644 --- a/src/grpc/grpc-policy/src/test/java/dev/caskeleton/grpc/resilience/GrpcRetryEligibilityTest.java +++ b/src/grpc/grpc-runtime/src/test/java/dev/caskeleton/grpc/resilience/GrpcRetryEligibilityTest.java @@ -22,11 +22,11 @@ import org.junit.jupiter.api.Test; class GrpcRetryEligibilityTest { private static final GrpcMethodName GET = - GrpcMethodName.parse("hyeonworks.document.v1.DocumentService/GetDocument"); + GrpcMethodName.parse("caskeleton.document.v1.DocumentService/GetDocument"); private static final GrpcMethodName CREATE = - GrpcMethodName.parse("hyeonworks.document.v1.DocumentService/CreateDocument"); + GrpcMethodName.parse("caskeleton.document.v1.DocumentService/CreateDocument"); private static final GrpcMethodName WATCH = - GrpcMethodName.parse("hyeonworks.document.v1.DocumentService/WatchDocuments"); + GrpcMethodName.parse("caskeleton.document.v1.DocumentService/WatchDocuments"); private static final GrpcDeadlineProfile TEN_SECONDS = GrpcDeadlineProfile.of(Duration.ofSeconds(10)); private static final GrpcMethodPolicy READ = GrpcMethodPolicy.readOnlyUnary(GET, TEN_SECONDS); diff --git a/src/grpc/grpc-policy/src/test/java/dev/caskeleton/grpc/resilience/GrpcRetryOwnershipValidatorTest.java b/src/grpc/grpc-runtime/src/test/java/dev/caskeleton/grpc/resilience/GrpcRetryOwnershipValidatorTest.java similarity index 96% rename from src/grpc/grpc-policy/src/test/java/dev/caskeleton/grpc/resilience/GrpcRetryOwnershipValidatorTest.java rename to src/grpc/grpc-runtime/src/test/java/dev/caskeleton/grpc/resilience/GrpcRetryOwnershipValidatorTest.java index 4eb597dd..b6905bdb 100644 --- a/src/grpc/grpc-policy/src/test/java/dev/caskeleton/grpc/resilience/GrpcRetryOwnershipValidatorTest.java +++ b/src/grpc/grpc-runtime/src/test/java/dev/caskeleton/grpc/resilience/GrpcRetryOwnershipValidatorTest.java @@ -20,11 +20,11 @@ import org.junit.jupiter.api.Test; class GrpcRetryOwnershipValidatorTest { private static final GrpcMethodName GET = - GrpcMethodName.parse("hyeonworks.document.v1.DocumentService/GetDocument"); + GrpcMethodName.parse("caskeleton.document.v1.DocumentService/GetDocument"); private static final GrpcMethodName CREATE = - GrpcMethodName.parse("hyeonworks.document.v1.DocumentService/CreateDocument"); + GrpcMethodName.parse("caskeleton.document.v1.DocumentService/CreateDocument"); private static final GrpcMethodName WATCH = - GrpcMethodName.parse("hyeonworks.document.v1.DocumentService/WatchDocuments"); + GrpcMethodName.parse("caskeleton.document.v1.DocumentService/WatchDocuments"); private static final GrpcDeadlineProfile TWO_SECONDS = GrpcDeadlineProfile.of(Duration.ofSeconds(2)); @@ -83,7 +83,7 @@ class GrpcRetryOwnershipValidatorTest { @DisplayName("a service config entry naming a method the catalog does not declare is reported") void aRenamedMethodLeavesItsEntryMatchingNothing() { GrpcMethodName renamed = - GrpcMethodName.parse("hyeonworks.document.v1.DocumentService/CreateDocumentV2"); + GrpcMethodName.parse("caskeleton.document.v1.DocumentService/CreateDocumentV2"); GrpcServiceConfigPolicy config = new GrpcServiceConfigPolicy( GrpcRetryOwner.GRPC_PLATFORM, diff --git a/src/grpc/grpc-policy/src/test/java/dev/caskeleton/grpc/resilience/GrpcWaitForReadyValidatorTest.java b/src/grpc/grpc-runtime/src/test/java/dev/caskeleton/grpc/resilience/GrpcWaitForReadyValidatorTest.java similarity index 98% rename from src/grpc/grpc-policy/src/test/java/dev/caskeleton/grpc/resilience/GrpcWaitForReadyValidatorTest.java rename to src/grpc/grpc-runtime/src/test/java/dev/caskeleton/grpc/resilience/GrpcWaitForReadyValidatorTest.java index 5bac289c..5608c70a 100644 --- a/src/grpc/grpc-policy/src/test/java/dev/caskeleton/grpc/resilience/GrpcWaitForReadyValidatorTest.java +++ b/src/grpc/grpc-runtime/src/test/java/dev/caskeleton/grpc/resilience/GrpcWaitForReadyValidatorTest.java @@ -17,7 +17,7 @@ import org.junit.jupiter.api.Test; class GrpcWaitForReadyValidatorTest { private static final GrpcMethodName GET = - GrpcMethodName.parse("hyeonworks.document.v1.DocumentService/GetDocument"); + GrpcMethodName.parse("caskeleton.document.v1.DocumentService/GetDocument"); private static final GrpcDeadlineProfile TEN_SECONDS = GrpcDeadlineProfile.of(Duration.ofSeconds(10)); diff --git a/src/grpc/grpc-policy/src/test/java/dev/caskeleton/grpc/security/GrpcCredentialRotationManagerTest.java b/src/grpc/grpc-runtime/src/test/java/dev/caskeleton/grpc/security/GrpcCredentialRotationManagerTest.java similarity index 81% rename from src/grpc/grpc-policy/src/test/java/dev/caskeleton/grpc/security/GrpcCredentialRotationManagerTest.java rename to src/grpc/grpc-runtime/src/test/java/dev/caskeleton/grpc/security/GrpcCredentialRotationManagerTest.java index 85c8cd0f..9da1db17 100644 --- a/src/grpc/grpc-policy/src/test/java/dev/caskeleton/grpc/security/GrpcCredentialRotationManagerTest.java +++ b/src/grpc/grpc-runtime/src/test/java/dev/caskeleton/grpc/security/GrpcCredentialRotationManagerTest.java @@ -9,6 +9,7 @@ import java.util.concurrent.ExecutorService; import java.util.concurrent.Executors; import java.util.concurrent.Future; import java.util.function.Consumer; +import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.Test; class GrpcCredentialRotationManagerTest { @@ -32,12 +33,28 @@ class GrpcCredentialRotationManagerTest { // when long lowest = lowestCurrentAfterRacing( - manager -> manager.rotate(gen(3L), NOW), GrpcCredentialRotationManager::completeDrain); + manager -> manager.rotate(gen(3L), NOW), manager -> manager.completeDrain(gen(1L))); // then assertThat(lowest).isEqualTo(3L); } + @Test + @DisplayName("이전 세대의 drain 완료 보고는 그 사이 새 rotation이 시작한 drain을 끝내지 않는다") + void completingAnOlderDrainLeavesTheNewerDrainInPlace() { + // given + GrpcCredentialRotationManager manager = + new GrpcCredentialRotationManager(gen(1L), Duration.ofSeconds(30)); + manager.rotate(gen(2L), NOW); + manager.rotate(gen(3L), NOW); + + // when + manager.completeDrain(gen(1L)); + + // then + assertThat(manager.draining()).contains(gen(2L)); + } + /** * Starts each round at generation 2 (draining 1), runs {@code first} and {@code second} at the * same moment, and returns the lowest generation left current over all rounds. diff --git a/src/grpc/grpc-policy/src/test/java/dev/caskeleton/grpc/security/GrpcTlsProfileTest.java b/src/grpc/grpc-runtime/src/test/java/dev/caskeleton/grpc/security/GrpcTlsProfileTest.java similarity index 99% rename from src/grpc/grpc-policy/src/test/java/dev/caskeleton/grpc/security/GrpcTlsProfileTest.java rename to src/grpc/grpc-runtime/src/test/java/dev/caskeleton/grpc/security/GrpcTlsProfileTest.java index dba6213d..4804462a 100644 --- a/src/grpc/grpc-policy/src/test/java/dev/caskeleton/grpc/security/GrpcTlsProfileTest.java +++ b/src/grpc/grpc-runtime/src/test/java/dev/caskeleton/grpc/security/GrpcTlsProfileTest.java @@ -140,7 +140,7 @@ class GrpcTlsProfileTest { assertThat(manager.drainExpired(now.plusSeconds(29))).isFalse(); assertThat(manager.drainExpired(now.plusSeconds(30))).isTrue(); - manager.completeDrain(); + manager.completeDrain(first); assertThat(manager.draining()).isEmpty(); } diff --git a/src/grpc/grpc-server/src/test/java/dev/caskeleton/grpc/server/GrpcAdmissionControllerTest.java b/src/grpc/grpc-runtime/src/test/java/dev/caskeleton/grpc/server/GrpcAdmissionControllerTest.java similarity index 100% rename from src/grpc/grpc-server/src/test/java/dev/caskeleton/grpc/server/GrpcAdmissionControllerTest.java rename to src/grpc/grpc-runtime/src/test/java/dev/caskeleton/grpc/server/GrpcAdmissionControllerTest.java diff --git a/src/grpc/grpc-server/src/test/java/dev/caskeleton/grpc/server/GrpcNettyVariantSelectorTest.java b/src/grpc/grpc-runtime/src/test/java/dev/caskeleton/grpc/server/GrpcNettyVariantSelectorTest.java similarity index 100% rename from src/grpc/grpc-server/src/test/java/dev/caskeleton/grpc/server/GrpcNettyVariantSelectorTest.java rename to src/grpc/grpc-runtime/src/test/java/dev/caskeleton/grpc/server/GrpcNettyVariantSelectorTest.java diff --git a/src/grpc/grpc-server/src/test/java/dev/caskeleton/grpc/server/GrpcServerInterceptorOrderTest.java b/src/grpc/grpc-runtime/src/test/java/dev/caskeleton/grpc/server/GrpcServerInterceptorOrderTest.java similarity index 100% rename from src/grpc/grpc-server/src/test/java/dev/caskeleton/grpc/server/GrpcServerInterceptorOrderTest.java rename to src/grpc/grpc-runtime/src/test/java/dev/caskeleton/grpc/server/GrpcServerInterceptorOrderTest.java diff --git a/src/grpc/grpc-server/src/test/java/dev/caskeleton/grpc/server/GrpcServerProfileTest.java b/src/grpc/grpc-runtime/src/test/java/dev/caskeleton/grpc/server/GrpcServerProfileTest.java similarity index 100% rename from src/grpc/grpc-server/src/test/java/dev/caskeleton/grpc/server/GrpcServerProfileTest.java rename to src/grpc/grpc-runtime/src/test/java/dev/caskeleton/grpc/server/GrpcServerProfileTest.java diff --git a/src/grpc/grpc-server/src/test/java/dev/caskeleton/grpc/server/GrpcServiceAdapterTest.java b/src/grpc/grpc-runtime/src/test/java/dev/caskeleton/grpc/server/GrpcServiceAdapterTest.java similarity index 99% rename from src/grpc/grpc-server/src/test/java/dev/caskeleton/grpc/server/GrpcServiceAdapterTest.java rename to src/grpc/grpc-runtime/src/test/java/dev/caskeleton/grpc/server/GrpcServiceAdapterTest.java index 997b4a29..b2022502 100644 --- a/src/grpc/grpc-server/src/test/java/dev/caskeleton/grpc/server/GrpcServiceAdapterTest.java +++ b/src/grpc/grpc-runtime/src/test/java/dev/caskeleton/grpc/server/GrpcServiceAdapterTest.java @@ -32,7 +32,7 @@ import org.junit.jupiter.api.Test; class GrpcServiceAdapterTest { private static final GrpcMethodName CREATE = - GrpcMethodName.parse("hyeonworks.document.v1.DocumentService/CreateDocument"); + GrpcMethodName.parse("caskeleton.document.v1.DocumentService/CreateDocument"); private record CreateRequest(String title) {} diff --git a/src/grpc/grpc-policy/src/test/java/dev/caskeleton/grpc/streaming/GrpcFlowControlPolicyTest.java b/src/grpc/grpc-runtime/src/test/java/dev/caskeleton/grpc/streaming/GrpcFlowControlPolicyTest.java similarity index 100% rename from src/grpc/grpc-policy/src/test/java/dev/caskeleton/grpc/streaming/GrpcFlowControlPolicyTest.java rename to src/grpc/grpc-runtime/src/test/java/dev/caskeleton/grpc/streaming/GrpcFlowControlPolicyTest.java diff --git a/src/grpc/grpc-policy/src/test/java/dev/caskeleton/grpc/streaming/GrpcResumeTokenCodecTest.java b/src/grpc/grpc-runtime/src/test/java/dev/caskeleton/grpc/streaming/GrpcResumeTokenCodecTest.java similarity index 100% rename from src/grpc/grpc-policy/src/test/java/dev/caskeleton/grpc/streaming/GrpcResumeTokenCodecTest.java rename to src/grpc/grpc-runtime/src/test/java/dev/caskeleton/grpc/streaming/GrpcResumeTokenCodecTest.java diff --git a/src/grpc/grpc-policy/src/test/java/dev/caskeleton/grpc/streaming/GrpcSerializedStreamWriterTest.java b/src/grpc/grpc-runtime/src/test/java/dev/caskeleton/grpc/streaming/GrpcSerializedStreamWriterTest.java similarity index 100% rename from src/grpc/grpc-policy/src/test/java/dev/caskeleton/grpc/streaming/GrpcSerializedStreamWriterTest.java rename to src/grpc/grpc-runtime/src/test/java/dev/caskeleton/grpc/streaming/GrpcSerializedStreamWriterTest.java diff --git a/src/grpc/grpc-policy/src/test/java/dev/caskeleton/grpc/streaming/GrpcStreamAdmissionConcurrencyTest.java b/src/grpc/grpc-runtime/src/test/java/dev/caskeleton/grpc/streaming/GrpcStreamAdmissionConcurrencyTest.java similarity index 100% rename from src/grpc/grpc-policy/src/test/java/dev/caskeleton/grpc/streaming/GrpcStreamAdmissionConcurrencyTest.java rename to src/grpc/grpc-runtime/src/test/java/dev/caskeleton/grpc/streaming/GrpcStreamAdmissionConcurrencyTest.java diff --git a/src/grpc/grpc-policy/src/test/java/dev/caskeleton/grpc/streaming/GrpcStreamEnvelopeTest.java b/src/grpc/grpc-runtime/src/test/java/dev/caskeleton/grpc/streaming/GrpcStreamEnvelopeTest.java similarity index 88% rename from src/grpc/grpc-policy/src/test/java/dev/caskeleton/grpc/streaming/GrpcStreamEnvelopeTest.java rename to src/grpc/grpc-runtime/src/test/java/dev/caskeleton/grpc/streaming/GrpcStreamEnvelopeTest.java index 9788b7f4..ccbaa457 100644 --- a/src/grpc/grpc-policy/src/test/java/dev/caskeleton/grpc/streaming/GrpcStreamEnvelopeTest.java +++ b/src/grpc/grpc-runtime/src/test/java/dev/caskeleton/grpc/streaming/GrpcStreamEnvelopeTest.java @@ -104,18 +104,6 @@ class GrpcStreamEnvelopeTest { .isInstanceOf(IllegalArgumentException.class); } - @Test - @DisplayName("a profile that buffers live events until the snapshot completes is the default") - void theDefaultProfileBuffersLiveEventsUntilTheSnapshotCompletes() { - GrpcStreamProfile profile = GrpcStreamProfile.snapshotThenLive(); - - assertThat(profile.snapshotFirst()).isTrue(); - assertThat(profile.liveEventsBeforeSnapshotComplete()).isFalse(); - assertThat(profile.resumable()).isTrue(); - assertThatThrownBy(() -> new GrpcStreamProfile(false, true, true, 10, 1024L)) - .isInstanceOf(IllegalArgumentException.class); - } - @Test @DisplayName("a termination reason says whether to reconnect and whether the position survives") void terminationReasonsSayWhatToDoNext() { diff --git a/src/grpc/grpc-policy/src/test/java/dev/caskeleton/grpc/streaming/GrpcStreamLifetimePolicyTest.java b/src/grpc/grpc-runtime/src/test/java/dev/caskeleton/grpc/streaming/GrpcStreamLifetimePolicyTest.java similarity index 100% rename from src/grpc/grpc-policy/src/test/java/dev/caskeleton/grpc/streaming/GrpcStreamLifetimePolicyTest.java rename to src/grpc/grpc-runtime/src/test/java/dev/caskeleton/grpc/streaming/GrpcStreamLifetimePolicyTest.java diff --git a/src/grpc/grpc-policy/src/test/java/dev/caskeleton/grpc/validation/GrpcValidationInterceptorTest.java b/src/grpc/grpc-runtime/src/test/java/dev/caskeleton/grpc/validation/GrpcValidationInterceptorTest.java similarity index 99% rename from src/grpc/grpc-policy/src/test/java/dev/caskeleton/grpc/validation/GrpcValidationInterceptorTest.java rename to src/grpc/grpc-runtime/src/test/java/dev/caskeleton/grpc/validation/GrpcValidationInterceptorTest.java index 73468e88..b7d328d3 100644 --- a/src/grpc/grpc-policy/src/test/java/dev/caskeleton/grpc/validation/GrpcValidationInterceptorTest.java +++ b/src/grpc/grpc-runtime/src/test/java/dev/caskeleton/grpc/validation/GrpcValidationInterceptorTest.java @@ -22,7 +22,7 @@ import org.junit.jupiter.api.Test; class GrpcValidationInterceptorTest { - private static final String FULL_METHOD = "hyeonworks.document.v1.DocumentService/CreateDocument"; + private static final String FULL_METHOD = "caskeleton.document.v1.DocumentService/CreateDocument"; /** A UTF-8 marshaller, so the descriptor needs no generated message type. */ private static final MethodDescriptor.Marshaller UTF8 = diff --git a/src/grpc/grpc-server/build.gradle b/src/grpc/grpc-server/build.gradle deleted file mode 100644 index 26c81421..00000000 --- a/src/grpc/grpc-server/build.gradle +++ /dev/null @@ -1,17 +0,0 @@ -plugins { - id 'ca.grpc-platform-module' -} - -// Server boundary: the ArchUnit-shaped application boundary rules, the typed service adapter SPI, -// the interceptor order contract, and the Netty server/executor/admission profiles. -// -// The Netty profiles are configuration models, not Netty wiring — no netty dependency here. Real -// Netty lives in `grpc-testkit`'s certification lane, which is where transport evidence is produced. - -dependencies { - api project(':grpc:grpc-core-api') - api project(':grpc:grpc-policy') - - api "io.grpc:grpc-api" - api "io.grpc:grpc-stub" -} diff --git a/src/grpc/grpc-server/gradle.lockfile b/src/grpc/grpc-server/gradle.lockfile deleted file mode 100644 index 9369e831..00000000 --- a/src/grpc/grpc-server/gradle.lockfile +++ /dev/null @@ -1,91 +0,0 @@ -# This is a Gradle generated file for dependency locking. -# Manual edits can break the build and are not advised. -# This file is expected to be part of source control. -com.github.ben-manes.caffeine:caffeine:3.2.4=annotationProcessor,testAnnotationProcessor -com.github.kevinstern:software-and-algorithms:1.0=annotationProcessor,testAnnotationProcessor -com.github.spotbugs:spotbugs-annotations:4.10.2=spotbugs -com.github.spotbugs:spotbugs:4.10.2=spotbugs -com.github.stephenc.jcip:jcip-annotations:1.0-1=spotbugs -com.google.auto.service:auto-service-annotations:1.0.1=annotationProcessor,testAnnotationProcessor -com.google.auto.value:auto-value-annotations:1.9=annotationProcessor,testAnnotationProcessor -com.google.auto:auto-common:1.2.2=annotationProcessor,testAnnotationProcessor -com.google.code.findbugs:jsr305:3.0.2=checkstyle,compileClasspath,runtimeClasspath,spotbugs,testCompileClasspath,testRuntimeClasspath -com.google.code.gson:gson:2.13.2=spotbugs -com.google.errorprone:error_prone_annotation:2.49.0=annotationProcessor,testAnnotationProcessor -com.google.errorprone:error_prone_annotations:2.28.0=compileClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath -com.google.errorprone:error_prone_annotations:2.41.0=spotbugs -com.google.errorprone:error_prone_annotations:2.47.0=checkstyle -com.google.errorprone:error_prone_annotations:2.49.0=annotationProcessor,testAnnotationProcessor -com.google.errorprone:error_prone_check_api:2.49.0=annotationProcessor,testAnnotationProcessor -com.google.errorprone:error_prone_core:2.49.0=annotationProcessor,testAnnotationProcessor -com.google.googlejavaformat:google-java-format:1.35.0=annotationProcessor,testAnnotationProcessor -com.google.guava:failureaccess:1.0.2=compileClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath -com.google.guava:failureaccess:1.0.3=annotationProcessor,checkstyle,testAnnotationProcessor -com.google.guava:guava:33.2.1-android=compileClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath -com.google.guava:guava:33.5.0-jre=annotationProcessor,testAnnotationProcessor -com.google.guava:guava:33.6.0-jre=checkstyle -com.google.guava:listenablefuture:9999.0-empty-to-avoid-conflict-with-guava=annotationProcessor,checkstyle,compileClasspath,runtimeClasspath,testAnnotationProcessor,testCompileClasspath,testRuntimeClasspath -com.google.j2objc:j2objc-annotations:3.0.0=compileClasspath,testCompileClasspath -com.google.j2objc:j2objc-annotations:3.1=annotationProcessor,checkstyle,testAnnotationProcessor -com.google.protobuf:protobuf-java:4.33.2=annotationProcessor,testAnnotationProcessor -com.h3xstream.findsecbugs:findsecbugs-plugin:1.14.0=spotbugsPlugins -com.puppycrawl.tools:checkstyle:13.5.0=checkstyle -commons-beanutils:commons-beanutils:1.11.0=checkstyle -commons-collections:commons-collections:3.2.2=checkstyle -commons-io:commons-io:2.21.0=spotbugs -info.picocli:picocli:4.7.7=checkstyle -io.github.eisop:dataflow-errorprone:3.41.0-eisop1=annotationProcessor,testAnnotationProcessor -io.github.java-diff-utils:java-diff-utils:4.12=annotationProcessor,testAnnotationProcessor -io.grpc:grpc-api:1.68.1=compileClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath -io.grpc:grpc-stub:1.68.1=compileClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath -javax.inject:javax.inject:1=annotationProcessor,testAnnotationProcessor -jaxen:jaxen:2.0.6=spotbugs -net.bytebuddy:byte-buddy:1.17.8=testCompileClasspath,testRuntimeClasspath -net.sf.saxon:Saxon-HE:12.9=checkstyle,spotbugs -org.antlr:antlr4-runtime:4.13.2=checkstyle -org.apache.bcel:bcel:6.12.0=spotbugs -org.apache.commons:commons-lang3:3.20.0=checkstyle,spotbugs -org.apache.commons:commons-text:1.15.0=spotbugs -org.apache.commons:commons-text:1.3=checkstyle -org.apache.httpcomponents:httpclient:4.5.13=checkstyle -org.apache.httpcomponents:httpcore:4.4.16=checkstyle -org.apache.logging.log4j:log4j-api:2.25.5=spotbugs -org.apache.logging.log4j:log4j-core:2.25.5=spotbugs -org.apache.maven.doxia:doxia-core:1.12.0=checkstyle -org.apache.maven.doxia:doxia-logging-api:1.12.0=checkstyle -org.apache.maven.doxia:doxia-module-xdoc:1.12.0=checkstyle -org.apache.maven.doxia:doxia-sink-api:1.12.0=checkstyle -org.apache.xbean:xbean-reflect:3.7=checkstyle -org.apiguardian:apiguardian-api:1.1.2=testCompileClasspath -org.assertj:assertj-core:3.27.7=testCompileClasspath,testRuntimeClasspath -org.checkerframework:checker-qual:3.42.0=compileClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath -org.codehaus.plexus:plexus-classworlds:2.6.0=checkstyle -org.codehaus.plexus:plexus-component-annotations:2.1.0=checkstyle -org.codehaus.plexus:plexus-container-default:2.1.0=checkstyle -org.codehaus.plexus:plexus-utils:3.3.0=checkstyle -org.dom4j:dom4j:2.2.0=spotbugs -org.javassist:javassist:3.28.0-GA=checkstyle -org.jspecify:jspecify:1.0.1=annotationProcessor,checkstyle,testAnnotationProcessor,testCompileClasspath -org.junit.jupiter:junit-jupiter-api:6.0.3=testCompileClasspath,testRuntimeClasspath -org.junit.jupiter:junit-jupiter-engine:6.0.3=testRuntimeClasspath -org.junit.jupiter:junit-jupiter-params:6.0.3=testCompileClasspath,testRuntimeClasspath -org.junit.jupiter:junit-jupiter:6.0.3=testCompileClasspath,testRuntimeClasspath -org.junit.platform:junit-platform-commons:6.0.3=testCompileClasspath,testRuntimeClasspath -org.junit.platform:junit-platform-engine:6.0.3=testRuntimeClasspath -org.junit.platform:junit-platform-launcher:6.0.3=testRuntimeClasspath -org.junit:junit-bom:6.0.3=testCompileClasspath,testRuntimeClasspath -org.junit:junit-bom:6.1.0=spotbugs -org.mockito:mockito-core:5.20.0=mockitoAgent -org.opentest4j:opentest4j:1.3.0=testCompileClasspath,testRuntimeClasspath -org.ow2.asm:asm-analysis:9.10.1=spotbugs -org.ow2.asm:asm-commons:9.10.1=spotbugs -org.ow2.asm:asm-tree:9.10.1=spotbugs -org.ow2.asm:asm-util:9.10.1=spotbugs -org.ow2.asm:asm:9.10.1=spotbugs -org.pcollections:pcollections:4.0.1=annotationProcessor,testAnnotationProcessor -org.reflections:reflections:0.10.2=checkstyle -org.slf4j:slf4j-api:2.0.18=spotbugs,spotbugsSlf4j -org.slf4j:slf4j-simple:2.0.17=spotbugsSlf4j -org.slf4j:slf4j-simple:2.0.18=checkstyle -org.xmlresolver:xmlresolver:5.3.3=checkstyle,spotbugs -empty= diff --git a/src/grpc/grpc-spring-boot-starter/build.gradle b/src/grpc/grpc-spring-boot-starter/build.gradle index b85f08b9..ad114e67 100644 --- a/src/grpc/grpc-spring-boot-starter/build.gradle +++ b/src/grpc/grpc-spring-boot-starter/build.gradle @@ -1,5 +1,7 @@ plugins { - id 'ca.platform-module' + // grpc-platform, not platform: grpc-runtime's io.grpc api dependencies are versionless and + // need the gRPC BOM on every classpath they reach. + id 'ca.grpc-platform-module' id 'ca.spring-config' } @@ -11,16 +13,9 @@ plugins { // enforces it, and GrpcPlatformStartupValidatorTest asserts the same rule from the Java side. dependencies { api project(':grpc:grpc-core-api') - api project(':grpc:grpc-policy') - api project(':grpc:grpc-server') - api project(':grpc:grpc-client') - api project(':grpc:grpc-discovery') - api project(':grpc:grpc-admin') + api project(':grpc:grpc-runtime') api project(':grpc:grpc-observability') - implementation project(':grpc:grpc-proto-contract') - implementation project(':grpc:grpc-codegen') - implementation 'org.springframework.boot:spring-boot-autoconfigure' } diff --git a/src/grpc/grpc-spring-boot-starter/src/main/java/dev/caskeleton/grpc/boot/GrpcPlatformAutoConfiguration.java b/src/grpc/grpc-spring-boot-starter/src/main/java/dev/caskeleton/grpc/boot/GrpcPlatformAutoConfiguration.java index 6e57e6be..5e17459d 100644 --- a/src/grpc/grpc-spring-boot-starter/src/main/java/dev/caskeleton/grpc/boot/GrpcPlatformAutoConfiguration.java +++ b/src/grpc/grpc-spring-boot-starter/src/main/java/dev/caskeleton/grpc/boot/GrpcPlatformAutoConfiguration.java @@ -14,7 +14,6 @@ import dev.caskeleton.grpc.security.GrpcTlsProfile; import dev.caskeleton.grpc.server.GrpcAdmissionController; import dev.caskeleton.grpc.server.GrpcExecutorProfile; import dev.caskeleton.grpc.server.GrpcServerProfile; -import java.time.Duration; import java.util.UUID; import org.springframework.beans.factory.ObjectProvider; import org.springframework.beans.factory.SmartInitializingSingleton; @@ -54,16 +53,7 @@ public class GrpcPlatformAutoConfiguration { @ConditionalOnMissingBean public GrpcServerProfile grpcServerProfile( GrpcPlatformProperties properties, GrpcExecutorProfile executorProfile) { - return new GrpcServerProfile( - properties.getTransport(), - 1024L * 1024L, - 8192, - Duration.ofSeconds(30), - Duration.ofSeconds(10), - Duration.ofSeconds(30), - Duration.ofMinutes(30), - Duration.ofSeconds(30), - executorProfile); + return GrpcServerProfile.stable(properties.getTransport(), executorProfile); } /** Admission control, sized from the executor. */ @@ -124,19 +114,21 @@ public class GrpcPlatformAutoConfiguration { * Runs the Stable startup validator against the bean graph after singleton assembly. * *

The Gradle architecture gate owns dependency-graph isolation. Runtime validation checks only - * inputs a running process can actually observe: typed properties, the method-policy catalog and - * named client channels. + * inputs a running process can actually observe: typed properties, the method-policy catalog, + * named client channels and the server transport profile. */ @Bean public SmartInitializingSingleton grpcPlatformStartupCheck( GrpcPlatformProperties properties, ObjectProvider catalogs, - ObjectProvider channelProfiles) { + ObjectProvider channelProfiles, + GrpcServerProfile serverProfile) { return () -> GrpcPlatformStartupValidator.requireValid( properties, catalogs.getIfAvailable(() -> GrpcMethodPolicyCatalog.builder().build()), - channelProfiles.orderedStream().toList()); + channelProfiles.orderedStream().toList(), + serverProfile); } /** The shared error mapper. Its execution ids are random and carry no derived content. */ diff --git a/src/grpc/grpc-spring-boot-starter/src/main/java/dev/caskeleton/grpc/boot/GrpcPlatformStartupValidator.java b/src/grpc/grpc-spring-boot-starter/src/main/java/dev/caskeleton/grpc/boot/GrpcPlatformStartupValidator.java index 24cf787a..f4024f9e 100644 --- a/src/grpc/grpc-spring-boot-starter/src/main/java/dev/caskeleton/grpc/boot/GrpcPlatformStartupValidator.java +++ b/src/grpc/grpc-spring-boot-starter/src/main/java/dev/caskeleton/grpc/boot/GrpcPlatformStartupValidator.java @@ -9,6 +9,7 @@ import dev.caskeleton.grpc.core.GrpcMethodName; import dev.caskeleton.grpc.core.RpcType; import dev.caskeleton.grpc.discovery.GrpcDiscoveryPolicyValidator; import dev.caskeleton.grpc.resilience.GrpcRetryOwner; +import dev.caskeleton.grpc.server.GrpcServerProfile; import java.util.ArrayList; import java.util.LinkedHashSet; import java.util.List; @@ -41,15 +42,16 @@ public final class GrpcPlatformStartupValidator { public static List violations( GrpcPlatformProperties properties, GrpcMethodPolicyCatalog catalog, - List channelProfiles) { - if (properties == null || catalog == null || channelProfiles == null) { + List channelProfiles, + GrpcServerProfile serverProfile) { + if (properties == null || catalog == null || channelProfiles == null || serverProfile == null) { throw new IllegalArgumentException("startup validation needs every input"); } List violations = new ArrayList<>(); validateTransportAndSecurity(properties, violations); validateExecutor(properties, violations); - validateMethods(properties, catalog, violations); + validateMethods(properties, catalog, serverProfile, violations); validateChannels(channelProfiles, violations); return List.copyOf(violations); } @@ -62,8 +64,9 @@ public final class GrpcPlatformStartupValidator { public static void requireValid( GrpcPlatformProperties properties, GrpcMethodPolicyCatalog catalog, - List channelProfiles) { - List violations = violations(properties, catalog, channelProfiles); + List channelProfiles, + GrpcServerProfile serverProfile) { + List violations = violations(properties, catalog, channelProfiles, serverProfile); if (!violations.isEmpty()) { throw new GrpcPlatformConfigurationException(violations); } @@ -113,9 +116,22 @@ public final class GrpcPlatformStartupValidator { } private static void validateMethods( - GrpcPlatformProperties properties, GrpcMethodPolicyCatalog catalog, List violations) { + GrpcPlatformProperties properties, + GrpcMethodPolicyCatalog catalog, + GrpcServerProfile serverProfile, + List violations) { for (GrpcMethodName method : sorted(catalog.methods())) { GrpcMethodPolicy policy = catalog.require(method); + if (policy.maxInboundMessageBytes() > serverProfile.maxInboundMessageBytes()) { + violations.add( + "method '" + + method.canonical() + + "' accepts " + + policy.maxInboundMessageBytes() + + "-byte messages but the server rejects anything over " + + serverProfile.maxInboundMessageBytes() + + "; the method's bound is a promise the transport breaks"); + } if (policy.rpcType() == RpcType.UNARY && policy.deadline().usable().isZero()) { violations.add( "Stable unary method '" diff --git a/src/grpc/grpc-spring-boot-starter/src/test/java/dev/caskeleton/grpc/boot/GrpcPlatformStartupValidatorTest.java b/src/grpc/grpc-spring-boot-starter/src/test/java/dev/caskeleton/grpc/boot/GrpcPlatformStartupValidatorTest.java index aaa4c269..dcffee91 100644 --- a/src/grpc/grpc-spring-boot-starter/src/test/java/dev/caskeleton/grpc/boot/GrpcPlatformStartupValidatorTest.java +++ b/src/grpc/grpc-spring-boot-starter/src/test/java/dev/caskeleton/grpc/boot/GrpcPlatformStartupValidatorTest.java @@ -7,6 +7,7 @@ import dev.caskeleton.grpc.admin.GrpcReflectionMode; import dev.caskeleton.grpc.api.deadline.GrpcDeadlineProfile; import dev.caskeleton.grpc.api.policy.GrpcMethodPolicy; import dev.caskeleton.grpc.api.policy.GrpcMethodPolicyCatalog; +import dev.caskeleton.grpc.api.policy.GrpcTransportLimits; import dev.caskeleton.grpc.api.policy.RpcIdempotencyProfile; import dev.caskeleton.grpc.api.policy.WaitForReadyPolicy; import dev.caskeleton.grpc.client.GrpcNamedChannelProfile; @@ -14,6 +15,8 @@ import dev.caskeleton.grpc.core.GrpcMethodName; import dev.caskeleton.grpc.core.RpcType; import dev.caskeleton.grpc.resilience.GrpcRetryOwner; import dev.caskeleton.grpc.security.GrpcTlsProfile; +import dev.caskeleton.grpc.server.GrpcExecutorProfile; +import dev.caskeleton.grpc.server.GrpcServerProfile; import dev.caskeleton.grpc.server.GrpcServerTransport; import java.io.IOException; import java.io.UncheckedIOException; @@ -29,9 +32,9 @@ import org.junit.jupiter.api.Test; class GrpcPlatformStartupValidatorTest { private static final GrpcMethodName GET = - GrpcMethodName.parse("hyeonworks.document.v1.DocumentService/GetDocument"); + GrpcMethodName.parse("caskeleton.document.v1.DocumentService/GetDocument"); private static final GrpcMethodName CREATE = - GrpcMethodName.parse("hyeonworks.document.v1.DocumentService/CreateDocument"); + GrpcMethodName.parse("caskeleton.document.v1.DocumentService/CreateDocument"); private static final GrpcTlsProfile PROD_TLS = GrpcTlsProfile.serverAuthenticated(GrpcTlsProfile.Environment.PROD, "trust-bundle"); @@ -64,15 +67,50 @@ class GrpcPlatformStartupValidatorTest { GrpcRetryOwner.GRPC_PLATFORM)); } + private static GrpcServerProfile stableServer() { + return GrpcServerProfile.stableNetty(GrpcExecutorProfile.boundedPool(32, 256)); + } + + @Test + @DisplayName("method의 inbound 한도가 서버 profile의 한도보다 크면 기동을 거부한다") + void aMethodBoundAboveTheServerBoundIsRefused() { + // given + GrpcMethodPolicyCatalog catalog = + GrpcMethodPolicyCatalog.builder() + .register( + new GrpcMethodPolicy( + GET, + RpcType.UNARY, + RpcIdempotencyProfile.READ_ONLY, + GrpcDeadlineProfile.of(Duration.ofSeconds(2)), + WaitForReadyPolicy.DISABLED, + false, + 2 * GrpcTransportLimits.DEFAULT_MAX_MESSAGE_BYTES, + 1024)) + .build(); + + // when + List violations = + GrpcPlatformStartupValidator.violations( + productionProperties(), catalog, oneChannel(), stableServer()); + + // then + assertThat(violations) + .containsExactly( + "method 'caskeleton.document.v1.DocumentService/GetDocument' accepts 2097152-byte" + + " messages but the server rejects anything over 1048576; the method's bound is a" + + " promise the transport breaks"); + } + @Test @DisplayName("a coherent production configuration starts") void aCoherentConfigurationStarts() { assertThat( GrpcPlatformStartupValidator.violations( - productionProperties(), healthyCatalog(), oneChannel())) + productionProperties(), healthyCatalog(), oneChannel(), stableServer())) .isEmpty(); GrpcPlatformStartupValidator.requireValid( - productionProperties(), healthyCatalog(), oneChannel()); + productionProperties(), healthyCatalog(), oneChannel(), stableServer()); } @Test @@ -87,7 +125,9 @@ class GrpcPlatformStartupValidatorTest { GrpcPlatformProperties properties = productionProperties(); properties.setTransport(GrpcServerTransport.IN_PROCESS); - assertThat(GrpcPlatformStartupValidator.violations(properties, healthyCatalog(), oneChannel())) + assertThat( + GrpcPlatformStartupValidator.violations( + properties, healthyCatalog(), oneChannel(), stableServer())) .anySatisfy(violation -> assertThat(violation).contains("not network evidence")); } @@ -99,9 +139,13 @@ class GrpcPlatformStartupValidatorTest { GrpcPlatformProperties trustAll = productionProperties(); trustAll.setTrustAllCertificates(true); - assertThat(GrpcPlatformStartupValidator.violations(noTls, healthyCatalog(), oneChannel())) + assertThat( + GrpcPlatformStartupValidator.violations( + noTls, healthyCatalog(), oneChannel(), stableServer())) .anySatisfy(violation -> assertThat(violation).contains("TLS is required")); - assertThat(GrpcPlatformStartupValidator.violations(trustAll, healthyCatalog(), oneChannel())) + assertThat( + GrpcPlatformStartupValidator.violations( + trustAll, healthyCatalog(), oneChannel(), stableServer())) .anySatisfy(violation -> assertThat(violation).contains("providing none")); } @@ -111,7 +155,9 @@ class GrpcPlatformStartupValidatorTest { GrpcPlatformProperties properties = productionProperties(); properties.setReflectionMode(GrpcReflectionMode.ENABLED); - assertThat(GrpcPlatformStartupValidator.violations(properties, healthyCatalog(), oneChannel())) + assertThat( + GrpcPlatformStartupValidator.violations( + properties, healthyCatalog(), oneChannel(), stableServer())) .anySatisfy(violation -> assertThat(violation).contains("published to anyone")); assertThat(productionProperties().effectiveReflectionMode()) .isEqualTo(GrpcReflectionMode.DISABLED); @@ -123,7 +169,9 @@ class GrpcPlatformStartupValidatorTest { GrpcPlatformProperties properties = productionProperties(); properties.setExecutorQueueCapacity(0); - assertThat(GrpcPlatformStartupValidator.violations(properties, healthyCatalog(), oneChannel())) + assertThat( + GrpcPlatformStartupValidator.violations( + properties, healthyCatalog(), oneChannel(), stableServer())) .anySatisfy(violation -> assertThat(violation).contains("unbounded latency")); } @@ -146,7 +194,9 @@ class GrpcPlatformStartupValidatorTest { 1024)) .build(); - assertThat(GrpcPlatformStartupValidator.violations(properties, catalog, oneChannel())) + assertThat( + GrpcPlatformStartupValidator.violations( + properties, catalog, oneChannel(), stableServer())) .anySatisfy(violation -> assertThat(violation).contains("never honoured")); } @@ -168,7 +218,8 @@ class GrpcPlatformStartupValidatorTest { .build(); assertThat( - GrpcPlatformStartupValidator.violations(productionProperties(), catalog, oneChannel())) + GrpcPlatformStartupValidator.violations( + productionProperties(), catalog, oneChannel(), stableServer())) .anySatisfy(violation -> assertThat(violation).contains("Advanced capability")); } @@ -190,7 +241,7 @@ class GrpcPlatformStartupValidatorTest { assertThat( GrpcPlatformStartupValidator.violations( - productionProperties(), healthyCatalog(), twoOwners)) + productionProperties(), healthyCatalog(), twoOwners, stableServer())) .anySatisfy(violation -> assertThat(violation).contains("multiply the load")); } @@ -203,7 +254,9 @@ class GrpcPlatformStartupValidatorTest { broken.setExecutorQueueCapacity(0); assertThatThrownBy( - () -> GrpcPlatformStartupValidator.requireValid(broken, healthyCatalog(), oneChannel())) + () -> + GrpcPlatformStartupValidator.requireValid( + broken, healthyCatalog(), oneChannel(), stableServer())) .isInstanceOf(GrpcPlatformConfigurationException.class) .satisfies( failure -> diff --git a/src/grpc/grpc-testkit/build.gradle b/src/grpc/grpc-testkit/build.gradle index fd9eb56a..3387707d 100644 --- a/src/grpc/grpc-testkit/build.gradle +++ b/src/grpc/grpc-testkit/build.gradle @@ -43,14 +43,8 @@ tasks.named('test') { dependencies { api project(':grpc:grpc-core-api') - api project(':grpc:grpc-policy') - api project(':grpc:grpc-server') - api project(':grpc:grpc-client') - api project(':grpc:grpc-discovery') - api project(':grpc:grpc-admin') + api project(':grpc:grpc-runtime') api project(':grpc:grpc-observability') - api project(':grpc:grpc-proto-contract') - api project(':grpc:grpc-codegen') api project(':grpc:grpc-operation-ledger-jpa') api "io.grpc:grpc-api" diff --git a/src/grpc/grpc-testkit/src/main/java/dev/caskeleton/grpc/release/GrpcStableReleaseGate.java b/src/grpc/grpc-testkit/src/main/java/dev/caskeleton/grpc/release/GrpcStableReleaseGate.java index 862f8d13..14913cfb 100644 --- a/src/grpc/grpc-testkit/src/main/java/dev/caskeleton/grpc/release/GrpcStableReleaseGate.java +++ b/src/grpc/grpc-testkit/src/main/java/dev/caskeleton/grpc/release/GrpcStableReleaseGate.java @@ -1,6 +1,5 @@ package dev.caskeleton.grpc.release; -import dev.caskeleton.grpc.codegen.GrpcSchemaArtifactPublisher; import dev.caskeleton.grpc.testkit.GrpcEvidenceGrade; import java.util.ArrayList; import java.util.List; @@ -30,13 +29,14 @@ public final class GrpcStableReleaseGate { /** * The release decision. * - * @param schemaDecision the schema publisher's verdict, which carries the consumer-compile result + * @param schemaBreakages what {@code buf breaking} reported against the released schema (the CI + * job {@code grpc-proto-buf}); empty when the schema is compatible */ public GrpcReleaseDecision evaluate( GrpcReleaseEvidence evidence, Map laneResults, - GrpcSchemaArtifactPublisher.PublishDecision schemaDecision) { - if (evidence == null || laneResults == null || schemaDecision == null) { + List schemaBreakages) { + if (evidence == null || laneResults == null || schemaBreakages == null) { throw new IllegalArgumentException( "a release decision needs evidence, lanes and the schema verdict"); } @@ -51,9 +51,7 @@ public final class GrpcStableReleaseGate { + " evidence was not produced; without it the release cannot claim " + grade.certifies().stream().sorted().toList())); - if (!schemaDecision.allowed()) { - schemaDecision.blockers().forEach(blocker -> blockers.add("schema: " + blocker)); - } + schemaBreakages.forEach(breakage -> blockers.add("schema: " + breakage)); if (!evidence.runbookPresent()) { blockers.add( "the operations runbook is missing; COMPLETION_UNKNOWN and FULL_RESYNC_REQUIRED are " diff --git a/src/grpc/grpc-testkit/src/test/java/dev/caskeleton/grpc/performance/GrpcPerformanceLaneTest.java b/src/grpc/grpc-testkit/src/test/java/dev/caskeleton/grpc/performance/GrpcPerformanceLaneTest.java index b1d18286..afe924bd 100644 --- a/src/grpc/grpc-testkit/src/test/java/dev/caskeleton/grpc/performance/GrpcPerformanceLaneTest.java +++ b/src/grpc/grpc-testkit/src/test/java/dev/caskeleton/grpc/performance/GrpcPerformanceLaneTest.java @@ -33,7 +33,7 @@ import org.junit.jupiter.api.Test; class GrpcPerformanceLaneTest { private static final MethodDescriptor ECHO = - GrpcTextCodec.unary("hyeonworks.document.v1.DocumentService/GetDocument"); + GrpcTextCodec.unary("caskeleton.document.v1.DocumentService/GetDocument"); private static final int SAMPLE_SIZE = 200; private static ServerServiceDefinition echoService() { @@ -43,7 +43,7 @@ class GrpcPerformanceLaneTest { observer.onNext(request); observer.onCompleted(); }); - return ServerServiceDefinition.builder("hyeonworks.document.v1.DocumentService") + return ServerServiceDefinition.builder("caskeleton.document.v1.DocumentService") .addMethod(ECHO, handler) .build(); } diff --git a/src/grpc/grpc-testkit/src/test/java/dev/caskeleton/grpc/release/GrpcStableReleaseGateTest.java b/src/grpc/grpc-testkit/src/test/java/dev/caskeleton/grpc/release/GrpcStableReleaseGateTest.java index b5012b50..ad2be8da 100644 --- a/src/grpc/grpc-testkit/src/test/java/dev/caskeleton/grpc/release/GrpcStableReleaseGateTest.java +++ b/src/grpc/grpc-testkit/src/test/java/dev/caskeleton/grpc/release/GrpcStableReleaseGateTest.java @@ -3,7 +3,6 @@ package dev.caskeleton.grpc.release; import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThatThrownBy; -import dev.caskeleton.grpc.codegen.GrpcSchemaArtifactPublisher; import dev.caskeleton.grpc.testkit.GrpcEvidenceGrade; import java.util.EnumSet; import java.util.LinkedHashMap; @@ -33,8 +32,8 @@ class GrpcStableReleaseGateTest { true); } - private static GrpcSchemaArtifactPublisher.PublishDecision schemaAllowed() { - return new GrpcSchemaArtifactPublisher.PublishDecision(true, List.of()); + private static List schemaAllowed() { + return List.of(); } @Test @@ -112,9 +111,9 @@ class GrpcStableReleaseGateTest { @Test @DisplayName("a schema that breaks a consumer blocks the release") void aBrokenConsumerBlocks() { - GrpcSchemaArtifactPublisher.PublishDecision refused = - new GrpcSchemaArtifactPublisher.PublishDecision( - false, List.of("consumer 'document-client-v1' loses METHOD_PATH 'CreateDocument'")); + List refused = + List.of( + "caskeleton/grpc/common/v1/stream.proto: Field \"3\" on message \"StreamEnvelope\" deleted."); assertThat(gate.evaluate(completeEvidence(), allLanesPassing(), refused).blockers()) .anySatisfy(blocker -> assertThat(blocker).startsWith("schema:")); diff --git a/src/grpc/grpc-testkit/src/test/java/dev/caskeleton/grpc/testkit/GrpcInProcessContractFixtureTest.java b/src/grpc/grpc-testkit/src/test/java/dev/caskeleton/grpc/testkit/GrpcInProcessContractFixtureTest.java index b7aa2ec3..70eceafe 100644 --- a/src/grpc/grpc-testkit/src/test/java/dev/caskeleton/grpc/testkit/GrpcInProcessContractFixtureTest.java +++ b/src/grpc/grpc-testkit/src/test/java/dev/caskeleton/grpc/testkit/GrpcInProcessContractFixtureTest.java @@ -24,10 +24,10 @@ class GrpcInProcessContractFixtureTest { private static final MethodDescriptor ECHO = GrpcInProcessContractFixture.unaryMethod( - "hyeonworks.document.v1.DocumentService/GetDocument"); + "caskeleton.document.v1.DocumentService/GetDocument"); private static final MethodDescriptor WATCH = GrpcInProcessContractFixture.streamingMethod( - "hyeonworks.document.v1.DocumentService/WatchDocuments"); + "caskeleton.document.v1.DocumentService/WatchDocuments"); /** Records the order interceptors actually ran in, which is the property under test. */ private record OrderRecordingInterceptor(String name, List log) diff --git a/src/grpc/grpc-testkit/src/test/java/dev/caskeleton/grpc/testkit/GrpcNettyContractProfileTest.java b/src/grpc/grpc-testkit/src/test/java/dev/caskeleton/grpc/testkit/GrpcNettyContractProfileTest.java index a73358a3..bfccd451 100644 --- a/src/grpc/grpc-testkit/src/test/java/dev/caskeleton/grpc/testkit/GrpcNettyContractProfileTest.java +++ b/src/grpc/grpc-testkit/src/test/java/dev/caskeleton/grpc/testkit/GrpcNettyContractProfileTest.java @@ -25,7 +25,7 @@ import org.junit.jupiter.api.Test; class GrpcNettyContractProfileTest { private static final MethodDescriptor ECHO = - GrpcTextCodec.unary("hyeonworks.document.v1.DocumentService/GetDocument"); + GrpcTextCodec.unary("caskeleton.document.v1.DocumentService/GetDocument"); private static ServerServiceDefinition echoService() { ServerCallHandler handler = @@ -34,7 +34,7 @@ class GrpcNettyContractProfileTest { observer.onNext("echo:" + request); observer.onCompleted(); }); - return ServerServiceDefinition.builder("hyeonworks.document.v1.DocumentService") + return ServerServiceDefinition.builder("caskeleton.document.v1.DocumentService") .addMethod(ECHO, handler) .build(); } diff --git a/src/grpc/grpc-testkit/src/test/java/dev/caskeleton/grpc/testkit/GrpcPackageOwnershipTest.java b/src/grpc/grpc-testkit/src/test/java/dev/caskeleton/grpc/testkit/GrpcPackageOwnershipTest.java index 22a48355..a5f460cb 100644 --- a/src/grpc/grpc-testkit/src/test/java/dev/caskeleton/grpc/testkit/GrpcPackageOwnershipTest.java +++ b/src/grpc/grpc-testkit/src/test/java/dev/caskeleton/grpc/testkit/GrpcPackageOwnershipTest.java @@ -17,7 +17,7 @@ class GrpcPackageOwnershipTest { @Test void corePolicyAndLedgerJpaDoNotSplitAJavaPackageAcrossLeaves() throws Exception { Path repo = repositoryRoot(); - List leaves = List.of("grpc-core-api", "grpc-policy", "grpc-operation-ledger-jpa"); + List leaves = List.of("grpc-core-api", "grpc-runtime", "grpc-operation-ledger-jpa"); Map> owners = new LinkedHashMap<>(); for (String leaf : leaves) { Path source = repo.resolve("src/grpc").resolve(leaf).resolve("src/main/java"); diff --git a/src/grpc/grpc-testkit/src/test/java/dev/caskeleton/grpc/testkit/GrpcTransportEvidenceClassifierTest.java b/src/grpc/grpc-testkit/src/test/java/dev/caskeleton/grpc/testkit/GrpcTransportEvidenceClassifierTest.java index 3b7c2240..41ef53e2 100644 --- a/src/grpc/grpc-testkit/src/test/java/dev/caskeleton/grpc/testkit/GrpcTransportEvidenceClassifierTest.java +++ b/src/grpc/grpc-testkit/src/test/java/dev/caskeleton/grpc/testkit/GrpcTransportEvidenceClassifierTest.java @@ -40,9 +40,9 @@ import org.junit.jupiter.api.Test; class GrpcTransportEvidenceClassifierTest { private static final GrpcMethodName CREATE = - GrpcMethodName.parse("hyeonworks.document.v1.DocumentService/CreateDocument"); + GrpcMethodName.parse("caskeleton.document.v1.DocumentService/CreateDocument"); private static final GrpcMethodName GET = - GrpcMethodName.parse("hyeonworks.document.v1.DocumentService/GetDocument"); + GrpcMethodName.parse("caskeleton.document.v1.DocumentService/GetDocument"); private static final MethodDescriptor CREATE_DESCRIPTOR = GrpcTextCodec.unary(CREATE.canonical()); private static final MethodDescriptor GET_DESCRIPTOR = @@ -349,7 +349,7 @@ class GrpcTransportEvidenceClassifierTest { return GrpcNettyTestServer.start( GrpcNettyContractProfile.plaintext(), List.of( - ServerServiceDefinition.builder("hyeonworks.document.v1.DocumentService") + ServerServiceDefinition.builder("caskeleton.document.v1.DocumentService") .addMethod(descriptor, handler) .build()), List.of(), diff --git a/src/grpc/grpc-testkit/src/test/java/dev/caskeleton/grpc/testkit/GrpcUnaryReliabilityContractTest.java b/src/grpc/grpc-testkit/src/test/java/dev/caskeleton/grpc/testkit/GrpcUnaryReliabilityContractTest.java index 164ff6f0..d27214fd 100644 --- a/src/grpc/grpc-testkit/src/test/java/dev/caskeleton/grpc/testkit/GrpcUnaryReliabilityContractTest.java +++ b/src/grpc/grpc-testkit/src/test/java/dev/caskeleton/grpc/testkit/GrpcUnaryReliabilityContractTest.java @@ -21,11 +21,11 @@ import org.junit.jupiter.api.Test; class GrpcUnaryReliabilityContractTest { private static final GrpcMethodName GET = - GrpcMethodName.parse("hyeonworks.document.v1.DocumentService/GetDocument"); + GrpcMethodName.parse("caskeleton.document.v1.DocumentService/GetDocument"); private static final GrpcMethodName CREATE = - GrpcMethodName.parse("hyeonworks.document.v1.DocumentService/CreateDocument"); + GrpcMethodName.parse("caskeleton.document.v1.DocumentService/CreateDocument"); private static final GrpcMethodName KEYED = - GrpcMethodName.parse("hyeonworks.document.v1.DocumentService/SubmitOrder"); + GrpcMethodName.parse("caskeleton.document.v1.DocumentService/SubmitOrder"); private final GrpcUnaryReliabilityContract contract = GrpcUnaryReliabilityContract.stable(GET, CREATE, KEYED); diff --git a/src/optional-platforms/README.md b/src/optional-platforms/README.md index cbd11f33..cd6ddebd 100644 --- a/src/optional-platforms/README.md +++ b/src/optional-platforms/README.md @@ -1,7 +1,7 @@ # Optional gRPC platforms -The default application does not depend on `grpc/*` or `grpc-advanced/*`, so those 18 projects are -kept out of the main multi-project build. This build preserves their existing project paths and +The default application does not depend on `grpc/*` or `grpc-advanced/*`, so those projects (the +registry entries with `"build": "optional-grpc"`) are kept out of the main multi-project build. This build preserves their existing project paths and internal project dependencies while making their configuration opt-in. ```bash diff --git a/src/sample-portfolio/src/main/java/dev/caskeleton/sample/portfolio/adapter/inbound/web/error/DomainExceptionHandler.java b/src/sample-portfolio/src/main/java/dev/caskeleton/sample/portfolio/adapter/inbound/web/error/DomainExceptionHandler.java index b6af9674..da063fe1 100644 --- a/src/sample-portfolio/src/main/java/dev/caskeleton/sample/portfolio/adapter/inbound/web/error/DomainExceptionHandler.java +++ b/src/sample-portfolio/src/main/java/dev/caskeleton/sample/portfolio/adapter/inbound/web/error/DomainExceptionHandler.java @@ -1,6 +1,7 @@ package dev.caskeleton.sample.portfolio.adapter.inbound.web.error; import dev.caskeleton.adapter.inbound.web.error.ErrorResponseFactory; +import dev.caskeleton.sample.portfolio.application.exception.PosterImageAlreadyPublishedException; import dev.caskeleton.sample.portfolio.application.exception.PosterNotFoundException; import dev.caskeleton.sample.portfolio.application.exception.PosterTitleAlreadyExistsException; import dev.caskeleton.sample.portfolio.application.exception.WorkLogNotFoundException; @@ -66,6 +67,16 @@ public class DomainExceptionHandler { null); } + /** An abort that lost to a publication that finished first → 409. */ + @ExceptionHandler(PosterImageAlreadyPublishedException.class) + public ResponseEntity> handlePosterImageAlreadyPublished( + PosterImageAlreadyPublishedException ex) { + return ErrorResponseFactory.envelope( + PortfolioErrorCode.POSTER_IMAGE_ALREADY_PUBLISHED, + PortfolioClientSafeErrorMessages.forCode(PortfolioErrorCode.POSTER_IMAGE_ALREADY_PUBLISHED), + null); + } + /** Maps the invariant's {@code reason()} to a specific code (finer-grained than WorkLog's). */ @ExceptionHandler(PosterInvariantException.class) public ResponseEntity> handlePosterInvariant(PosterInvariantException ex) { diff --git a/src/sample-portfolio/src/main/java/dev/caskeleton/sample/portfolio/adapter/inbound/web/error/PortfolioClientSafeErrorMessages.java b/src/sample-portfolio/src/main/java/dev/caskeleton/sample/portfolio/adapter/inbound/web/error/PortfolioClientSafeErrorMessages.java index 86c8aff4..759acfd8 100644 --- a/src/sample-portfolio/src/main/java/dev/caskeleton/sample/portfolio/adapter/inbound/web/error/PortfolioClientSafeErrorMessages.java +++ b/src/sample-portfolio/src/main/java/dev/caskeleton/sample/portfolio/adapter/inbound/web/error/PortfolioClientSafeErrorMessages.java @@ -10,6 +10,7 @@ final class PortfolioClientSafeErrorMessages { case WORKLOG_CONFLICT -> "Work log conflicts with the current state"; case POSTER_NOT_FOUND -> "Poster was not found"; case POSTER_ALREADY_EXISTS -> "Poster title is already in use"; + case POSTER_IMAGE_ALREADY_PUBLISHED -> "Poster image was already published"; case POSTER_INVALID_STATE -> "Poster is not valid in the current state"; case POSTER_IMAGE_REQUIRED -> "Poster image is required"; }; diff --git a/src/sample-portfolio/src/main/java/dev/caskeleton/sample/portfolio/adapter/inbound/web/error/PortfolioErrorCode.java b/src/sample-portfolio/src/main/java/dev/caskeleton/sample/portfolio/adapter/inbound/web/error/PortfolioErrorCode.java index eb0feb61..744c8600 100644 --- a/src/sample-portfolio/src/main/java/dev/caskeleton/sample/portfolio/adapter/inbound/web/error/PortfolioErrorCode.java +++ b/src/sample-portfolio/src/main/java/dev/caskeleton/sample/portfolio/adapter/inbound/web/error/PortfolioErrorCode.java @@ -12,6 +12,7 @@ public enum PortfolioErrorCode implements ApiErrorCode { WORKLOG_CONFLICT(Category.CONFLICT, 409, false), POSTER_NOT_FOUND(Category.NOT_FOUND, 404, false), POSTER_ALREADY_EXISTS(Category.CONFLICT, 409, false), + POSTER_IMAGE_ALREADY_PUBLISHED(Category.CONFLICT, 409, false), POSTER_INVALID_STATE(Category.VALIDATION, 400, false), POSTER_IMAGE_REQUIRED(Category.VALIDATION, 400, false); diff --git a/src/sample-portfolio/src/main/java/dev/caskeleton/sample/portfolio/application/exception/PosterImageAlreadyPublishedException.java b/src/sample-portfolio/src/main/java/dev/caskeleton/sample/portfolio/application/exception/PosterImageAlreadyPublishedException.java new file mode 100644 index 00000000..05aa705c --- /dev/null +++ b/src/sample-portfolio/src/main/java/dev/caskeleton/sample/portfolio/application/exception/PosterImageAlreadyPublishedException.java @@ -0,0 +1,14 @@ +package dev.caskeleton.sample.portfolio.application.exception; + +/** + * Raised when an abort reaches an upload whose image storage already published. The publication + * finished first and wins; reconcile attaches it. Web handler maps it to 409. + */ +public class PosterImageAlreadyPublishedException extends RuntimeException { + + private static final long serialVersionUID = 1L; + + public PosterImageAlreadyPublishedException() { + super("Poster image was already published and can no longer be aborted"); + } +} diff --git a/src/sample-portfolio/src/main/java/dev/caskeleton/sample/portfolio/application/poster/AbortPosterImageUploadUseCase.java b/src/sample-portfolio/src/main/java/dev/caskeleton/sample/portfolio/application/poster/AbortPosterImageUploadUseCase.java index 28f45c82..28bb840a 100644 --- a/src/sample-portfolio/src/main/java/dev/caskeleton/sample/portfolio/application/poster/AbortPosterImageUploadUseCase.java +++ b/src/sample-portfolio/src/main/java/dev/caskeleton/sample/portfolio/application/poster/AbortPosterImageUploadUseCase.java @@ -6,6 +6,8 @@ import dev.caskeleton.application.capability.UseCaseCapability; import dev.caskeleton.application.objectstorage.identity.ObjectDestinationId; import dev.caskeleton.application.objectstorage.identity.ObjectOperationEpoch; import dev.caskeleton.application.objectstorage.identity.ObjectOperationKey; +import dev.caskeleton.application.objectstorage.model.ObjectMutationOutcome; +import dev.caskeleton.application.objectstorage.model.ObjectMutationReceipt; import dev.caskeleton.application.objectstorage.port.ObjectPublicationHandoffPort; import dev.caskeleton.application.objectstorage.port.StagedObjectPublicationPort; import dev.caskeleton.application.objectstorage.request.ObjectAbortAuthorization; @@ -15,6 +17,7 @@ import dev.caskeleton.application.transaction.TransactionMode; import dev.caskeleton.application.transaction.TransactionPort; import dev.caskeleton.application.usecase.CommandUseCase; import dev.caskeleton.sample.portfolio.application.command.AbortPosterImageUploadCommand; +import dev.caskeleton.sample.portfolio.application.exception.PosterImageAlreadyPublishedException; import dev.caskeleton.sample.portfolio.application.posterimage.PosterImagePublicationStatus; import dev.caskeleton.sample.portfolio.application.posterimage.PosterImageUploadIntent; import dev.caskeleton.sample.portfolio.application.posterimage.PosterImageUploadIntentState; @@ -78,6 +81,11 @@ public class AbortPosterImageUploadUseCase current.authorizeAbort(current.revision(), clock.instant()); return intents.compareAndSet(current.revision(), replacement); }); + if (authorized.state() == PosterImageUploadIntentState.READY + || authorized.state() == PosterImageUploadIntentState.SUPERSEDED) { + // Published and settled already: the publication won, there is nothing left to abort. + throw new PosterImageAlreadyPublishedException(); + } if (authorized.state().terminal()) { return PosterImagePublicationStatus.from(authorized); } @@ -88,7 +96,13 @@ public class AbortPosterImageUploadUseCase authorized.exactVersion(), authorized.handoffFence(), clock.instant()); - handoffs.authorizeAbort(authorization); + ObjectMutationReceipt authorizedInStorage = handoffs.authorizeAbort(authorization); + if (authorizedInStorage.outcome() == ObjectMutationOutcome.REJECTED) { + // Storage published before it saw this abort. The publication finished first and wins + // (owner decision 22): the intent stays ABORT_AUTHORIZED for reconcile to attach the + // published object, and nothing is deleted. + throw new PosterImageAlreadyPublishedException(); + } publications.abort( new ObjectAbortRequest( key, diff --git a/src/sample-portfolio/src/main/java/dev/caskeleton/sample/portfolio/application/poster/ReconcilePosterImageUploadUseCase.java b/src/sample-portfolio/src/main/java/dev/caskeleton/sample/portfolio/application/poster/ReconcilePosterImageUploadUseCase.java index 7f756bdc..a5c0b0a5 100644 --- a/src/sample-portfolio/src/main/java/dev/caskeleton/sample/portfolio/application/poster/ReconcilePosterImageUploadUseCase.java +++ b/src/sample-portfolio/src/main/java/dev/caskeleton/sample/portfolio/application/poster/ReconcilePosterImageUploadUseCase.java @@ -97,7 +97,10 @@ public class ReconcilePosterImageUploadUseCase releaseIfPublished(intent, command); return PosterImagePublicationStatus.from(intent); } - if (intent.state() != PosterImageUploadIntentState.PENDING) { + // ABORT_AUTHORIZED is reconciled too: if storage published before it accepted the abort, the + // finalize below replays that publication and the object is attached; if storage accepted the + // abort first, the finalize is refused and the abort completes. First to finish wins. + if (!awaitingPublication(intent)) { throw new IllegalStateException("Poster image publication is not ready to reconcile"); } @@ -138,6 +141,12 @@ public class ReconcilePosterImageUploadUseCase command.cancellation())); } + /** PENDING, or ABORT_AUTHORIZED with an abort storage may not have accepted yet. */ + private static boolean awaitingPublication(PosterImageUploadIntent intent) { + return intent.state() == PosterImageUploadIntentState.PENDING + || intent.state() == PosterImageUploadIntentState.ABORT_AUTHORIZED; + } + /** The claimant {@link PublishPosterImageUseCase} claimed the handoff as. */ private static String claimant(PosterImageUploadIntent intent) { return "poster-image-" + intent.operationKey().operationId().value(); @@ -154,7 +163,7 @@ public class ReconcilePosterImageUploadUseCase if (current.state().terminal()) { return current; } - if (current.state() != PosterImageUploadIntentState.PENDING + if (!awaitingPublication(current) || current.handoffFence() == null || !current.stageHandle().equals(observed.stageHandle())) { throw new IllegalStateException("publication intent handoff changed before TX3"); diff --git a/src/sample-portfolio/src/main/java/dev/caskeleton/sample/portfolio/application/posterimage/PosterImageUploadIntent.java b/src/sample-portfolio/src/main/java/dev/caskeleton/sample/portfolio/application/posterimage/PosterImageUploadIntent.java index e244d9d7..5de89962 100644 --- a/src/sample-portfolio/src/main/java/dev/caskeleton/sample/portfolio/application/posterimage/PosterImageUploadIntent.java +++ b/src/sample-portfolio/src/main/java/dev/caskeleton/sample/portfolio/application/posterimage/PosterImageUploadIntent.java @@ -166,7 +166,7 @@ public record PosterImageUploadIntent( ObjectVersionToken version, PosterImageReference replaced, Instant now) { - require(expectedRevision, PosterImageUploadIntentState.PENDING); + requirePublishable(expectedRevision); return copy( PosterImageUploadIntentState.READY, stageHandle, @@ -216,7 +216,7 @@ public record PosterImageUploadIntent( PosterImageReference losingReference, ObjectVersionToken losingVersion, Instant now) { - require(expectedRevision, PosterImageUploadIntentState.PENDING); + requirePublishable(expectedRevision); return copy( PosterImageUploadIntentState.SUPERSEDED, stageHandle, @@ -320,6 +320,21 @@ public record PosterImageUploadIntent( revision + 1); } + /** + * A published object may settle an intent that is PENDING or ABORT_AUTHORIZED. + * + *

The second is the abort/publication race: the abort was authorized here while the finalize + * was already under way, and storage let the finalize through. Whichever finishes first wins + * (owner decision 22), and a published object is the publication finishing first. + */ + private void requirePublishable(long expectedRevision) { + if (revision != expectedRevision + || (state != PosterImageUploadIntentState.PENDING + && state != PosterImageUploadIntentState.ABORT_AUTHORIZED)) { + throw conflict(); + } + } + private void require(long expectedRevision, PosterImageUploadIntentState expectedState) { if (revision != expectedRevision || state != expectedState) { throw conflict(); diff --git a/src/sample-portfolio/src/test/java/dev/caskeleton/sample/portfolio/adapter/inbound/web/error/DomainExceptionHandlerTest.java b/src/sample-portfolio/src/test/java/dev/caskeleton/sample/portfolio/adapter/inbound/web/error/DomainExceptionHandlerTest.java index 66e802b9..d4a700b1 100644 --- a/src/sample-portfolio/src/test/java/dev/caskeleton/sample/portfolio/adapter/inbound/web/error/DomainExceptionHandlerTest.java +++ b/src/sample-portfolio/src/test/java/dev/caskeleton/sample/portfolio/adapter/inbound/web/error/DomainExceptionHandlerTest.java @@ -2,6 +2,7 @@ package dev.caskeleton.sample.portfolio.adapter.inbound.web.error; import static org.assertj.core.api.Assertions.assertThat; +import dev.caskeleton.sample.portfolio.application.exception.PosterImageAlreadyPublishedException; import dev.caskeleton.sample.portfolio.application.exception.PosterNotFoundException; import dev.caskeleton.sample.portfolio.application.exception.PosterTitleAlreadyExistsException; import dev.caskeleton.sample.portfolio.application.exception.WorkLogNotFoundException; @@ -11,6 +12,7 @@ import dev.caskeleton.sample.portfolio.domain.worklog.WorkLogId; import dev.caskeleton.sample.portfolio.domain.worklog.WorkLogInvariantException; import dev.caskeleton.shared.response.ApiError; import dev.caskeleton.shared.response.Envelope; +import java.util.List; import org.junit.jupiter.api.Test; import org.springframework.http.HttpStatus; import org.springframework.http.ResponseEntity; @@ -95,6 +97,17 @@ class DomainExceptionHandlerTest { .containsExactly("Poster title is already in use", false); } + @Test + void anAbortThatLostToThePublicationIsA409Conflict() { + // when + ResponseEntity> response = + handler.handlePosterImageAlreadyPublished(new PosterImageAlreadyPublishedException()); + + // then + assertThat(List.of(response.getStatusCode(), response.getBody().error().code())) + .containsExactly(HttpStatus.CONFLICT, "POSTER_IMAGE_ALREADY_PUBLISHED"); + } + @Test void posterImageInvariantUsesFixedCorrectiveMessage() { // when diff --git a/src/sample-portfolio/src/test/java/dev/caskeleton/sample/portfolio/application/poster/PosterImageAbortReconcileRaceTest.java b/src/sample-portfolio/src/test/java/dev/caskeleton/sample/portfolio/application/poster/PosterImageAbortReconcileRaceTest.java new file mode 100644 index 00000000..21881d2b --- /dev/null +++ b/src/sample-portfolio/src/test/java/dev/caskeleton/sample/portfolio/application/poster/PosterImageAbortReconcileRaceTest.java @@ -0,0 +1,288 @@ +package dev.caskeleton.sample.portfolio.application.poster; + +import static org.assertj.core.api.Assertions.assertThat; +import static org.assertj.core.api.Assertions.catchThrowable; + +import dev.caskeleton.application.idempotency.RequestFingerprint; +import dev.caskeleton.application.objectstorage.content.CancellationView; +import dev.caskeleton.application.objectstorage.content.ObjectContentProducer; +import dev.caskeleton.application.objectstorage.identity.ObjectDestinationId; +import dev.caskeleton.application.objectstorage.identity.ObjectOperationEpoch; +import dev.caskeleton.application.objectstorage.identity.ObjectOperationId; +import dev.caskeleton.application.objectstorage.identity.ObjectOperationKey; +import dev.caskeleton.application.objectstorage.identity.ObjectReference; +import dev.caskeleton.application.objectstorage.identity.ObjectStageHandle; +import dev.caskeleton.application.objectstorage.identity.ObjectVersionToken; +import dev.caskeleton.application.objectstorage.model.ObjectContentIdentity; +import dev.caskeleton.application.objectstorage.model.ObjectDigest; +import dev.caskeleton.application.objectstorage.model.ObjectHandoffReceipt; +import dev.caskeleton.application.objectstorage.model.ObjectMediaType; +import dev.caskeleton.application.objectstorage.model.ObjectMutationOutcome; +import dev.caskeleton.application.objectstorage.model.ObjectMutationReceipt; +import dev.caskeleton.application.objectstorage.model.ObjectOperationError; +import dev.caskeleton.application.objectstorage.model.ObjectPublishReceipt; +import dev.caskeleton.application.objectstorage.model.ObjectStageReceipt; +import dev.caskeleton.application.objectstorage.model.ObjectVerificationReceipt; +import dev.caskeleton.application.objectstorage.port.ObjectPublicationHandoffPort; +import dev.caskeleton.application.objectstorage.port.StagedObjectPublicationPort; +import dev.caskeleton.application.objectstorage.request.ObjectAbortAuthorization; +import dev.caskeleton.application.objectstorage.request.ObjectAbortRequest; +import dev.caskeleton.application.objectstorage.request.ObjectFinalizeRequest; +import dev.caskeleton.application.objectstorage.request.ObjectHandoffClaimRequest; +import dev.caskeleton.application.objectstorage.request.ObjectHandoffReleaseRequest; +import dev.caskeleton.application.objectstorage.request.ObjectHandoffRenewRequest; +import dev.caskeleton.application.objectstorage.request.ObjectStageRequest; +import dev.caskeleton.application.objectstorage.request.ObjectVerifyRequest; +import dev.caskeleton.application.outbound.CallBudget; +import dev.caskeleton.application.transaction.testkit.DirectTransactionPort; +import dev.caskeleton.sample.portfolio.application.command.AbortPosterImageUploadCommand; +import dev.caskeleton.sample.portfolio.application.command.ReconcilePosterImageUploadCommand; +import dev.caskeleton.sample.portfolio.application.event.PosterImagePublicationEventPublisher; +import dev.caskeleton.sample.portfolio.application.exception.PosterImageAlreadyPublishedException; +import dev.caskeleton.sample.portfolio.application.posterimage.PosterImageAttachmentCompareAndSetPort; +import dev.caskeleton.sample.portfolio.application.posterimage.PosterImageIdempotencyScopeDigest; +import dev.caskeleton.sample.portfolio.application.posterimage.PosterImageOperationIdFactory; +import dev.caskeleton.sample.portfolio.application.posterimage.PosterImageUploadIntent; +import dev.caskeleton.sample.portfolio.application.posterimage.PosterImageUploadIntentState; +import dev.caskeleton.sample.portfolio.application.posterimage.testkit.InMemoryPosterImageRetirementIntentStore; +import dev.caskeleton.sample.portfolio.application.posterimage.testkit.InMemoryPosterImageUploadIntentStore; +import dev.caskeleton.sample.portfolio.domain.poster.PosterId; +import dev.caskeleton.sample.portfolio.domain.poster.PosterImageReference; +import java.nio.charset.StandardCharsets; +import java.time.Clock; +import java.time.Duration; +import java.time.Instant; +import java.time.ZoneOffset; +import java.util.ArrayList; +import java.util.List; +import java.util.Optional; +import java.util.UUID; +import org.junit.jupiter.api.Test; + +/** + * Abort and reconcile of one upload intent: whichever finishes first wins (owner decision 22). + * + *

The race is an abort whose ABORT_AUTHORIZED row commits while the reconcile worker's finalize + * is already under way. Storage lets the finalize through — its own abort was not authorized yet — + * so the object is published, and the application must then attach it rather than leave the intent + * parked in ABORT_AUTHORIZED; the abort that arrives after the publication is a conflict. + */ +class PosterImageAbortReconcileRaceTest { + + private static final Instant NOW = Instant.parse("2026-07-29T00:00:00Z"); + private static final Clock CLOCK = Clock.fixed(NOW, ZoneOffset.UTC); + private static final PosterId POSTER = PosterId.of("0190bd6e-7c3e-7abc-8def-0123456789ab"); + private static final ObjectDestinationId DESTINATION = ObjectDestinationId.of("poster"); + private static final ObjectOperationEpoch EPOCH = ObjectOperationEpoch.of("poster-image-v1"); + private static final ObjectOperationId OPERATION = + ObjectOperationId.of("0190bd6e-7c3e-7abc-8def-012345678901"); + private static final ObjectOperationKey KEY = + new ObjectOperationKey(DESTINATION, EPOCH, OPERATION); + private static final ObjectContentIdentity CONTENT = + new ObjectContentIdentity(5, ObjectDigest.sha256("hello".getBytes(StandardCharsets.UTF_8))); + private static final ObjectStageHandle STAGE = + ObjectStageHandle.parse("osh1.0123456789ab.0123456789abcdefghjkmnpqrs.f3226a9833"); + private static final ObjectVersionToken VERSION = + ObjectVersionToken.parse("osv1.0123456789ab.0123456789abcdefghjkmnpqrs.6678c6821f"); + private static final String REFERENCE = "osr1.0123456789ab.0123456789abcdefghjkmnpqrs.d53d9429ac"; + + private final DirectTransactionPort transactions = DirectTransactionPort.rejectingNesting(); + private final InMemoryPosterImageUploadIntentStore intents = + new InMemoryPosterImageUploadIntentStore(); + private final Handoffs handoffs = new Handoffs(); + private final Publications publications = new Publications(); + private final List attached = new ArrayList<>(); + + @Test + void aPublicationThatFinishesAfterTheAbortWasAuthorizedIsAttached() { + // given + intents.createOrRead(pendingWithLapsedClaim()); + // The abort's first transaction commits while the finalize is on the wire. + publications.duringFinalize = () -> authorizeAbortInTheDatabase(); + + // when + reconcile().handle(reconcileCommand()); + + // then + assertThat(List.of(intents.only().state(), attached)) + .containsExactly( + PosterImageUploadIntentState.READY, List.of(PosterImageReference.of(REFERENCE))); + } + + @Test + void anAbortAuthorizedIntentWhoseObjectWasPublishedIsAttachedByTheNextReconcile() { + // given + intents.createOrRead(pendingWithLapsedClaim()); + authorizeAbortInTheDatabase(); + + // when + reconcile().handle(reconcileCommand()); + + // then + assertThat(intents.only().state()).isEqualTo(PosterImageUploadIntentState.READY); + } + + @Test + void anAbortThatArrivesAfterThePublicationIsAConflict() { + // given + intents.createOrRead(pendingWithLapsedClaim()); + handoffs.alreadyPublished = true; + + // when + Throwable thrown = catchThrowable(() -> abort().handle(abortCommand())); + + // then + assertThat(List.of(thrown.getClass(), publications.aborts)) + .containsExactly(PosterImageAlreadyPublishedException.class, 0); + } + + @Test + void anAbortOfAnUploadAlreadyAttachedIsAConflict() { + // given + intents.createOrRead(pendingWithLapsedClaim()); + reconcile().handle(reconcileCommand()); + + // when + Throwable thrown = catchThrowable(() -> abort().handle(abortCommand())); + + // then + assertThat(List.of(thrown.getClass(), intents.only().state())) + .containsExactly( + PosterImageAlreadyPublishedException.class, PosterImageUploadIntentState.READY); + } + + private void authorizeAbortInTheDatabase() { + PosterImageUploadIntent current = intents.only(); + intents.compareAndSet(current.revision(), current.authorizeAbort(current.revision(), NOW)); + } + + private static PosterImageUploadIntent pendingWithLapsedClaim() { + PosterImageUploadIntent reserved = + PosterImageUploadIntent.reserve( + UUID.fromString("0190bd6e-7c3e-7abc-8def-0123456789cd"), + POSTER, + KEY, + new PosterImageIdempotencyScopeDigest( + "key-v1", "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"), + new RequestFingerprint("a".repeat(64)), + 0, + CONTENT, + ObjectMediaType.of("image/png"), + NOW.minusSeconds(120), + NOW.plus(Duration.ofHours(1))); + // The claim lapsed a minute ago, which is what lets an abort be authorized at all. + return reserved.pending( + reserved.revision(), STAGE, VERSION, "c".repeat(64), 1, NOW.minusSeconds(60), NOW); + } + + private ReconcilePosterImageUploadUseCase reconcile() { + return new ReconcilePosterImageUploadUseCase( + intents, + new InMemoryPosterImageRetirementIntentStore(), + (posterId, expectedVersion, reference, now) -> { + attached.add(reference); + return new PosterImageAttachmentCompareAndSetPort.Result(true, null); + }, + () -> + new PosterImageOperationIdFactory.AllocatedOperation( + UUID.randomUUID(), ObjectOperationId.of(UUID.randomUUID().toString())), + new PosterImagePublicationEventPublisher( + event -> {}, () -> "0190bd6e-7c3e-7abc-8def-0123456789ff", Optional::empty, CLOCK), + transactions, + publications, + handoffs, + DESTINATION, + EPOCH, + Duration.ofDays(1), + CLOCK); + } + + private AbortPosterImageUploadUseCase abort() { + return new AbortPosterImageUploadUseCase( + intents, transactions, handoffs, publications, DESTINATION, EPOCH, CLOCK); + } + + private static ReconcilePosterImageUploadCommand reconcileCommand() { + return new ReconcilePosterImageUploadCommand( + POSTER, OPERATION, CallBudget.fromNow(Duration.ofMinutes(1)), CancellationView.never()); + } + + private static AbortPosterImageUploadCommand abortCommand() { + return new AbortPosterImageUploadCommand( + POSTER, OPERATION, CallBudget.fromNow(Duration.ofMinutes(1)), CancellationView.never()); + } + + /** Storage's handoff: refuses the abort, as a typed receipt, once the object is published. */ + private static final class Handoffs implements ObjectPublicationHandoffPort { + private boolean alreadyPublished; + + @Override + public ObjectHandoffReceipt claimForPublication(ObjectHandoffClaimRequest request) { + throw new UnsupportedOperationException(); + } + + @Override + public ObjectHandoffReceipt renewClaim(ObjectHandoffRenewRequest request) { + throw new UnsupportedOperationException(); + } + + @Override + public ObjectMutationReceipt releaseClaim(ObjectHandoffReleaseRequest request) { + return new ObjectMutationReceipt( + request.operationKey(), ObjectMutationOutcome.APPLIED, ObjectOperationError.NONE, NOW); + } + + @Override + public ObjectMutationReceipt authorizeAbort(ObjectAbortAuthorization authorization) { + return alreadyPublished + ? new ObjectMutationReceipt( + authorization.operationKey(), + ObjectMutationOutcome.REJECTED, + ObjectOperationError.CONFLICT, + NOW) + : new ObjectMutationReceipt( + authorization.operationKey(), + ObjectMutationOutcome.APPLIED, + ObjectOperationError.NONE, + NOW); + } + } + + /** Storage's publication: finalize publishes; a hook runs while it is in flight. */ + private static final class Publications implements StagedObjectPublicationPort { + private Runnable duringFinalize = () -> {}; + private int aborts; + + @Override + public ObjectStageReceipt stage(ObjectStageRequest request, ObjectContentProducer producer) { + throw new UnsupportedOperationException(); + } + + @Override + public ObjectVerificationReceipt verifyIntegrity(ObjectVerifyRequest request) { + throw new UnsupportedOperationException(); + } + + @Override + public ObjectPublishReceipt finalizePublication(ObjectFinalizeRequest request) { + duringFinalize.run(); + return new ObjectPublishReceipt( + request.operationKey(), + new RequestFingerprint("b".repeat(64)), + ObjectReference.parse(REFERENCE), + VERSION, + CONTENT, + ObjectMediaType.of("image/png"), + ObjectMutationOutcome.APPLIED, + NOW, + "capability-v1"); + } + + @Override + public ObjectMutationReceipt abort(ObjectAbortRequest request) { + aborts++; + return new ObjectMutationReceipt( + request.operationKey(), ObjectMutationOutcome.APPLIED, ObjectOperationError.NONE, NOW); + } + } +} diff --git a/src/sample-portfolio/src/testFixtures/java/dev/caskeleton/sample/portfolio/application/posterimage/testkit/InMemoryPosterImageUploadIntentStore.java b/src/sample-portfolio/src/testFixtures/java/dev/caskeleton/sample/portfolio/application/posterimage/testkit/InMemoryPosterImageUploadIntentStore.java new file mode 100644 index 00000000..8a9b8f9e --- /dev/null +++ b/src/sample-portfolio/src/testFixtures/java/dev/caskeleton/sample/portfolio/application/posterimage/testkit/InMemoryPosterImageUploadIntentStore.java @@ -0,0 +1,77 @@ +package dev.caskeleton.sample.portfolio.application.posterimage.testkit; + +import dev.caskeleton.application.objectstorage.identity.ObjectOperationKey; +import dev.caskeleton.sample.portfolio.application.posterimage.PosterImageIdempotencyScopeDigest; +import dev.caskeleton.sample.portfolio.application.posterimage.PosterImageUploadIntent; +import dev.caskeleton.sample.portfolio.application.posterimage.PosterImageUploadIntentClaim; +import dev.caskeleton.sample.portfolio.application.posterimage.PosterImageUploadIntentConflictException; +import dev.caskeleton.sample.portfolio.application.posterimage.PosterImageUploadIntentState; +import dev.caskeleton.sample.portfolio.application.posterimage.PosterImageUploadIntentStorePort; +import dev.caskeleton.sample.portfolio.domain.poster.PosterImageReference; +import java.time.Duration; +import java.time.Instant; +import java.util.Collection; +import java.util.LinkedHashMap; +import java.util.Map; +import java.util.Optional; + +/** + * In-memory {@link PosterImageUploadIntentStorePort} following the JPA adapter: create-or-read by + * operation, lookups by scope digest and by published reference, and a revision-checked + * compare-and-set. Claims are not modelled; {@code claimPending} finds nothing. + */ +public final class InMemoryPosterImageUploadIntentStore + implements PosterImageUploadIntentStorePort { + + private final Map rows = new LinkedHashMap<>(); + + /** The one intent a single-operation test stored. */ + public PosterImageUploadIntent only() { + return rows.values().iterator().next(); + } + + @Override + public PosterImageUploadIntent createOrRead(PosterImageUploadIntent proposed) { + return rows.computeIfAbsent(proposed.operationKey().operationId().value(), ignored -> proposed); + } + + @Override + public Optional findByOperation(ObjectOperationKey operation) { + return Optional.ofNullable(rows.get(operation.operationId().value())); + } + + @Override + public Optional findByAnyScopeDigest( + Collection retainedDigests) { + return rows.values().stream() + .filter(intent -> retainedDigests.contains(intent.idempotencyScope())) + .findFirst(); + } + + @Override + public Optional findReadyByPublishedReference( + PosterImageReference reference) { + return rows.values().stream() + .filter(intent -> intent.state() == PosterImageUploadIntentState.READY) + .filter(intent -> reference.equals(intent.publishedReference())) + .findFirst(); + } + + @Override + public PosterImageUploadIntent compareAndSet( + long expectedRevision, PosterImageUploadIntent replacement) { + String key = replacement.operationKey().operationId().value(); + PosterImageUploadIntent current = rows.get(key); + if (current == null || current.revision() != expectedRevision) { + throw new PosterImageUploadIntentConflictException("poster image upload revision conflicts"); + } + rows.put(key, replacement); + return replacement; + } + + @Override + public Optional claimPending( + String claimantDigest, Instant now, Duration leaseDuration) { + return Optional.empty(); + } +}