review-followup Wave 3 라운드 3(P28·P29): fileserver use case·file:* 권한, 보안 파일 primitive 공용화, jvm-test-suite
- 결정 32: fileserver transport 연산 21개를 `port.in` use case로, 쓰기·읽기에 `file:*` 권한(소유자·tenant 정책은 유지), inbound 서비스 이름 `*UseCase`, port 구현 이름 `<Tech><Port>` 규칙(S2-#13b, 24개) - 디렉터리 descriptor 파일 primitive를 `adapter:outbound:support`로(S4-lead-2 일부 — fileserver는 번역만), persistence-fileserver를 scan·클래스별 조건 대신 명시적 `@Bean` 설정으로(S2-#8a 일부), `FileVerifier`를 adapter로 - 호출자 0인 `poster.image-attached` 이벤트 삭제, SES SDK client를 레지스트리 종료 때 close, fileserver migration V1–V5 고정 - P29: auxiliary 레인 → Gradle `jvm-test-suite`(BUILD-O3-5, build-logic 16,768 → 5,851줄), redis-sdk가 runtime을 api로(P22-new-3) - 통합: JPA API surface 기준선 재승인(이름 규칙 변경), migration lane에 V19 반영, messaging 통합 테스트가 jar 안 migration 목록 조회(ORCH-new-5) - P28·P29 에이전트가 세션 재시작으로 중단 — 커밋된 것만 합치고 결과 파일은 오케스트레이터가 확정, S6-#10a는 P30으로 검증: ./gradlew ci verifyDependencyLocks --warning-mode=fail(714 task) · mainCheck architectureCheck verifyPublicPathSnapshot :app-bootstrap:verifyEnvKeys configContractCheck · :app-bootstrap:integrationTest :sample-portfolio:integrationTest :sample-portfolio:systemTest integrationCheck · -p build-logic test · -p optional-platforms ci · releaseCheck qualificationBootJar 통과 Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 5.5
parent
09e2dd63d6
commit
0579935746
@@ -43,7 +43,7 @@ dev.caskeleton.adapter.outbound.persistence.api.query.SortDirection
|
||||
dev.caskeleton.adapter.outbound.persistence.api.transaction.TransactionCompletionEvidence
|
||||
dev.caskeleton.adapter.outbound.persistence.audit.AuditContextPort
|
||||
dev.caskeleton.adapter.outbound.persistence.audit.AuditableEntity
|
||||
dev.caskeleton.adapter.outbound.persistence.audit.DomainContextAuditContextPort
|
||||
dev.caskeleton.adapter.outbound.persistence.audit.DomainContextAuditContext
|
||||
dev.caskeleton.adapter.outbound.persistence.cache.CacheConcurrencyStrategy
|
||||
dev.caskeleton.adapter.outbound.persistence.cache.CacheRegionCatalog
|
||||
dev.caskeleton.adapter.outbound.persistence.cache.HibernateCacheGuard
|
||||
@@ -103,12 +103,12 @@ dev.caskeleton.adapter.outbound.persistence.idempotency.jpa.IdempotencyReaper
|
||||
dev.caskeleton.adapter.outbound.persistence.idempotency.jpa.IdempotencyRecordJpaRepository
|
||||
dev.caskeleton.adapter.outbound.persistence.idempotency.jpa.entity.IdempotencyRecordEntity
|
||||
dev.caskeleton.adapter.outbound.persistence.idempotency.postgresql.IdempotencySchemaStream
|
||||
dev.caskeleton.adapter.outbound.persistence.idempotency.postgresql.PostgreSqlOwnerSafeIdempotencyStore
|
||||
dev.caskeleton.adapter.outbound.persistence.liveevent.JpaLiveEventReplayAdapter
|
||||
dev.caskeleton.adapter.outbound.persistence.idempotency.postgresql.PostgreSqlIdempotencyStore
|
||||
dev.caskeleton.adapter.outbound.persistence.liveevent.JpaLiveEventReplay
|
||||
dev.caskeleton.adapter.outbound.persistence.liveevent.LiveEventJpaRepository
|
||||
dev.caskeleton.adapter.outbound.persistence.liveevent.entity.LiveEventEntity
|
||||
dev.caskeleton.adapter.outbound.persistence.lock.DistributedLockPersistenceConfig
|
||||
dev.caskeleton.adapter.outbound.persistence.lock.LockRegistryDistributedLockAdapter
|
||||
dev.caskeleton.adapter.outbound.persistence.lock.LockRegistryDistributedLock
|
||||
dev.caskeleton.adapter.outbound.persistence.lock.LockSettings
|
||||
dev.caskeleton.adapter.outbound.persistence.migration.FlywaySchemaPolicy
|
||||
dev.caskeleton.adapter.outbound.persistence.migration.SchemaManagementMode
|
||||
@@ -117,13 +117,13 @@ dev.caskeleton.adapter.outbound.persistence.observation.LowCardinality
|
||||
dev.caskeleton.adapter.outbound.persistence.observation.MicrometerQueryObservation
|
||||
dev.caskeleton.adapter.outbound.persistence.observation.SqlDiagnosticRedactor
|
||||
dev.caskeleton.adapter.outbound.persistence.operation.DurableOperationJpaRepository
|
||||
dev.caskeleton.adapter.outbound.persistence.operation.DurableOperationStoreAdapter
|
||||
dev.caskeleton.adapter.outbound.persistence.operation.JpaDurableOperationStore
|
||||
dev.caskeleton.adapter.outbound.persistence.operation.entity.DurableOperationEntity
|
||||
dev.caskeleton.adapter.outbound.persistence.outbox.h2.H2OutboxClaimRepository
|
||||
dev.caskeleton.adapter.outbound.persistence.outbox.jpa.JpaOutboxStore
|
||||
dev.caskeleton.adapter.outbound.persistence.outbox.jpa.OutboxClaimRepository
|
||||
dev.caskeleton.adapter.outbound.persistence.outbox.jpa.OutboxEventJpaRepository
|
||||
dev.caskeleton.adapter.outbound.persistence.outbox.jpa.OutboxReaper
|
||||
dev.caskeleton.adapter.outbound.persistence.outbox.jpa.OutboxStoreAdapter
|
||||
dev.caskeleton.adapter.outbound.persistence.outbox.jpa.entity.OutboxEventEntity
|
||||
dev.caskeleton.adapter.outbound.persistence.outbox.postgresql.PostgreSqlOutboxClaimRepository
|
||||
dev.caskeleton.adapter.outbound.persistence.postgresql.PostgreSqlPersistenceConfig
|
||||
@@ -172,4 +172,4 @@ dev.caskeleton.adapter.outbound.persistence.springdata.SafeSortMapper
|
||||
dev.caskeleton.adapter.outbound.persistence.springdata.SafeSortRegistry
|
||||
dev.caskeleton.adapter.outbound.persistence.springdata.ScrollPolicy
|
||||
dev.caskeleton.adapter.outbound.persistence.transaction.CallerTransaction
|
||||
dev.caskeleton.adapter.outbound.persistence.transaction.SpringTransactionPort
|
||||
dev.caskeleton.adapter.outbound.persistence.transaction.SpringTransaction
|
||||
|
||||
@@ -8,13 +8,13 @@ dev.caskeleton.adapter.outbound.persistence.fileserver.FileserverJpaPersistenceC
|
||||
dev.caskeleton.adapter.outbound.persistence.fileserver.FileserverSchemaActivation
|
||||
dev.caskeleton.adapter.outbound.persistence.fileserver.JpaCleanupQueue
|
||||
dev.caskeleton.adapter.outbound.persistence.fileserver.JpaContentReferenceLedger
|
||||
dev.caskeleton.adapter.outbound.persistence.fileserver.JpaFileMetadataStore
|
||||
dev.caskeleton.adapter.outbound.persistence.fileserver.JpaFileQuotaService
|
||||
dev.caskeleton.adapter.outbound.persistence.fileserver.JpaQuotaCommitGateway
|
||||
dev.caskeleton.adapter.outbound.persistence.fileserver.JpaQuotaReclaimGateway
|
||||
dev.caskeleton.adapter.outbound.persistence.fileserver.JpaFileMetadata
|
||||
dev.caskeleton.adapter.outbound.persistence.fileserver.JpaFileQuota
|
||||
dev.caskeleton.adapter.outbound.persistence.fileserver.JpaQuotaCommit
|
||||
dev.caskeleton.adapter.outbound.persistence.fileserver.JpaQuotaReclaim
|
||||
dev.caskeleton.adapter.outbound.persistence.fileserver.JpaRecoveryQueue
|
||||
dev.caskeleton.adapter.outbound.persistence.fileserver.JpaStagingUploadLocator
|
||||
dev.caskeleton.adapter.outbound.persistence.fileserver.JpaUploadSessionStore
|
||||
dev.caskeleton.adapter.outbound.persistence.fileserver.JpaUploadSession
|
||||
dev.caskeleton.adapter.outbound.persistence.fileserver.entity.CleanupItemEntity
|
||||
dev.caskeleton.adapter.outbound.persistence.fileserver.entity.FileEntity
|
||||
dev.caskeleton.adapter.outbound.persistence.fileserver.entity.QuotaReservationEntity
|
||||
|
||||
@@ -508,3 +508,8 @@ web 경로의 `W/`는 `src/adapter/inbound/web/src/main/java/dev/caskeleton/adap
|
||||
| web `MdcKeys` | `src/adapter/inbound/web/src/main/java/dev/caskeleton/adapter/inbound/web/observability/MdcKeys.java` | `36ba0810` | shared-contract `observability.MdcKeys`로 이동(X2-P2-5) |
|
||||
| `DurableOperationJpaRepositoryShapeTest` | `src/adapter/outbound/persistence-jpa/src/test/java/dev/caskeleton/adapter/outbound/persistence/operation/DurableOperationJpaRepositoryShapeTest.java` | `36ba0810` | `ScopedRowRepositoryShapeTest`로 흡수(테스트) |
|
||||
| notification `UuidV7Generator` 비트 배치 구현 | `src/adapter/outbound/notification/src/main/java/dev/caskeleton/adapter/outbound/notification/platform/dispatch/UuidV7Generator.java` | `36ba0810` | 클래스는 남기고 구현을 uuid-creator로 교체(S1-lead-2) |
|
||||
| `poster.image-attached` v1 이벤트(`PosterEventPublisher.publishImageAttached`, `PosterImageAttached`, `PosterImageAttachedPayload`, `PortfolioEventContracts.POSTER_IMAGE_ATTACHED`, schema) | `src/sample-portfolio/src/main/java/dev/caskeleton/sample/portfolio/{domain/poster/PosterImageAttached.java,application/event/PosterImageAttachedPayload.java}`, `src/sample-portfolio/src/main/resources/contracts/messaging/poster.image-attached/` | `36ba0810` | legacy 업로드 삭제 뒤 호출자 0(P24-new-2·P25-new-2) |
|
||||
| fileserver inbound 서비스 인터페이스 6개(`UploadApplicationService`, `FinalizeUploadService`, `SingleShotUploadService`, `DownloadApplicationService`, `FileLifecycleService`, `FileserverAdminService`)와 구현 `DefaultUploadApplicationService`·`DefaultFinalizeUploadService`·`DefaultSingleShotUploadService`·`DefaultDownloadApplicationService`·`DefaultFileLifecycleService`·`DefaultFileserverAdminService`, `download/DownloadRequest` | `src/application-fileserver/src/main/java/dev/caskeleton/application/fileserver/{upload,download,lifecycle,admin}/` | `36ba0810` | 결정 32: 연산별 `port.in` use case로 대체(S1-#6b·S1-#18b) |
|
||||
| `FileserverDownloadLifecycleConfiguration`, `FileserverMaintenanceServiceConfiguration`의 admin 서비스 bean | `src/adapter/outbound/fileserver/src/main/java/dev/caskeleton/adapter/outbound/fileserver/platform/autoconfigure/` | `36ba0810` | application use case 조립을 composition root(`composition:fileserver-platform`)로 |
|
||||
| `FileserverUploadServiceConfiguration`(→ `FileserverUploadSupportConfiguration`로 개명, 서비스 bean은 use case 설정으로) | `src/composition/fileserver-platform/src/main/java/dev/caskeleton/composition/fileserver/` | `36ba0810` | 같음 |
|
||||
| `ca.auxiliary-source-set` 플러그인(`AuxiliarySourceSetPlugin`·`Extension`·`Spec`)과 `AuxiliarySourceSetConventionTest` | `src/build-logic/src/{main,test}/java/dev/caskeleton/buildlogic/auxiliary/` | `4f4bd1fd` | Gradle `jvm-test-suite`로 대체(BUILD-O3-5) |
|
||||
|
||||
@@ -45,6 +45,13 @@ Startup fails, rather than degrading, when any of these is missing or unsafe:
|
||||
| `write-roles` | `ROLE_FILE_WRITE` | grants create, append, finalize, delete, copy, move |
|
||||
| `admin-roles` | `ROLE_FILE_ADMIN` | grants reverify and force-delete, and gates `/internal/fileserver/**` at the servlet chain |
|
||||
|
||||
These roles decide the tier inside each operation. In front of it, every operation's use case
|
||||
carries a `file:*` permission that the web adapter's method security checks against
|
||||
`ca-skeleton.authz.role-permissions`; `security.yml` grants `file:read` to `ROLE_FILE_READ`,
|
||||
`file:upload`, `file:delete`, `file:copy` and `file:move` to `ROLE_FILE_WRITE`, and `file:admin` to
|
||||
`ROLE_FILE_ADMIN`. Renaming a tier role here means mapping the new name there as well, or the
|
||||
caller is refused before the tier is consulted (`docs/fileserver/design-deviations.md` §5).
|
||||
|
||||
There is no anonymous-read switch. Every Fileserver route is authenticated by the servlet chain
|
||||
before any application policy is consulted, so such a setting could only ever have described a
|
||||
permission the transport had already refused — a configuration that reads as if it grants access
|
||||
|
||||
@@ -12,7 +12,7 @@ A create that fails after the record exists must end in `FAILED`, but the table
|
||||
The record therefore walks `CREATED → UPLOADING → FAILED`, which is also the honest reading: the
|
||||
upload had been admitted before it failed.
|
||||
|
||||
Pinned by `UploadApplicationServiceTest` (application-core).
|
||||
Pinned by `ResumableUploadUseCasesTest` (application-fileserver).
|
||||
|
||||
### 2. `ContentKey`'s alphabet admits a leading separator
|
||||
|
||||
@@ -28,7 +28,7 @@ Deleting a file that is mid-verification has no legal transition. The lifecycle
|
||||
with `409 FILE_NOT_READY` rather than inventing an edge, which matches the allowed-state list the
|
||||
JPA `markDeleting` statement already enforced.
|
||||
|
||||
Pinned by `FileLifecycleServiceTest`.
|
||||
Pinned by `FileLifecycleUseCasesTest`.
|
||||
|
||||
### 4. `If-Match` is specified as an ETag but the lifecycle was designed around the row version
|
||||
|
||||
@@ -36,7 +36,7 @@ The HTTP contract sends an entity tag; the metadata store guards on a numeric ve
|
||||
takes `Optional<String> expectedEtag` and compares against the record's strong validator, so the
|
||||
precondition a client sends is the precondition that is checked.
|
||||
|
||||
Pinned by `FileLifecycleServiceTest`.
|
||||
Pinned by `FileLifecycleUseCasesTest`.
|
||||
|
||||
### 5. The filename policy left `:` intact
|
||||
|
||||
@@ -174,40 +174,44 @@ an extension point for a backend this template does not ship:
|
||||
`ContentStoreCapabilities` reports what the running store actually supports, so no unimplemented SPI
|
||||
is advertised as available.
|
||||
|
||||
## Known deviation from the repository's application-layer contract
|
||||
## The repository's application-layer contract
|
||||
|
||||
### 5. Fileserver application services are not `CommandUseCase` / `QueryUseCase`
|
||||
### 5. Fileserver operations are use cases (resolved, owner decision 32)
|
||||
|
||||
`src/application-core/CLAUDE.md` requires every inbound port implementation to extend
|
||||
`CommandUseCase` or `QueryUseCase` and to carry `@UseCaseCapability`, which declares its transaction
|
||||
mode, idempotency and repository access. The Fileserver instead exposes multi-method services —
|
||||
`UploadApplicationService`, `DownloadApplicationService`, `FileLifecycleService`,
|
||||
`FileserverAdminService` and their `Default*` implementations.
|
||||
Every operation the transport reaches is a `CommandUseCase` or `QueryUseCase` behind a one-method
|
||||
port in `application.fileserver.port.in` — create, append, status, cancel, finalize and the
|
||||
single-request upload; describe, prepare, open and transfer for downloads; delete, copy and move;
|
||||
and the eight management-plane operations. Each implementation (`*ApplicationUseCase`) declares its
|
||||
`@UseCaseCapability`, so the ArchUnit rules that check transaction mode, repository access and
|
||||
outbound calls now see the Fileserver like every other feature.
|
||||
|
||||
This is a real deviation, not an oversight, and it is unenforced: the ArchUnit rules
|
||||
`inbound_port_implementations_end_with_use_case` and
|
||||
`inbound_port_implementations_declare_capability` only match types that implement `UseCase`, so a
|
||||
service that never does is silently exempt. The capability contract that every other feature in
|
||||
this repository declares is therefore absent here.
|
||||
Two authorities guard a write, and both stay:
|
||||
|
||||
Two things follow from it. The transaction mode of each operation is expressed only by which
|
||||
`TransactionPort` method the body happens to call, rather than declared and checked. And the
|
||||
application layer holds transport policy it would not hold if each operation were a use case with
|
||||
its own command: HTTP status codes on `FileserverErrorCode`, `Range` and conditional-request
|
||||
parsing in `api.transfer`, and `Content-Disposition` construction.
|
||||
| Check | Where | Decides |
|
||||
| --- | --- | --- |
|
||||
| `@RequiresPermission("file:…")` | the use case's proxy, enforced by the web adapter's method security | whether the caller's roles grant the operation at all |
|
||||
| `FileAccessPolicyPort` | inside the use case, before any side effect | the tier (read/write/admin), and that the caller owns the file in its tenant |
|
||||
|
||||
The status mapping in particular is a deliberate trade rather than an accident. It lives in
|
||||
`application-core` so the servlet transport, the reactive transport and the Nginx delegation path
|
||||
cannot answer the same failure with three different statuses. Moving it to the transport layer
|
||||
resolves the layering complaint and reintroduces exactly that drift, which is why this is an
|
||||
architecture decision rather than a cleanup.
|
||||
The permissions are `file:read` (describe, download, upload status), `file:upload` (create,
|
||||
append, finalize, cancel, the single-request upload), `file:delete`, `file:copy`, `file:move` and
|
||||
`file:admin` (every management-plane operation). `security.yml` grants them to `ROLE_FILE_READ`,
|
||||
`ROLE_FILE_WRITE` and `ROLE_FILE_ADMIN` — the fileserver's own default tier roles — so a caller
|
||||
holding a tier holds its permissions. A deployment that renames the tier roles, or supplies its own
|
||||
`FileAccessPolicyPort` under other role names, maps those names in
|
||||
`ca-skeleton.authz.role-permissions` too; `security.access-policy: unenforced` relaxes only the
|
||||
tier and ownership check, never the permission gate.
|
||||
|
||||
**Status: open, deliberately unresolved in this change set.** Closing it means roughly thirty
|
||||
command/query use cases, a decision about where the shared status vocabulary lives, and a change to
|
||||
the ArchUnit rules so a service that bypasses the contract fails the build instead of being exempt
|
||||
from it. That belongs in its own ADR with its own review, and doing it inside a correctness patch
|
||||
would mix a large mechanical refactor into changes that need to be readable.
|
||||
The resumable transfers run on the transfer pool, and method security reads the security context
|
||||
of the calling thread, so `BlockingTransferExecutor` carries the request's context onto the worker
|
||||
(`BlockingTransferExecutorSecurityContextTest`). Without it an authenticated append was refused as
|
||||
anonymous.
|
||||
|
||||
Nothing here is pinned by a test, because the deviation is the absence of a constraint. The next
|
||||
step is the ADR, not another test.
|
||||
What is not a use case is what no transport calls: `CleanupService` and
|
||||
`FileReconciliationService` are driven by background workers with no caller identity, and a
|
||||
mutating use case must declare a permission a scheduler could not hold.
|
||||
`FileserverUseCaseContractDeviationTest` freezes that list.
|
||||
|
||||
The HTTP status vocabulary on `FileserverErrorCode` stays in the application layer, for the reason
|
||||
this section used to give: the servlet transport and the Nginx delegation path must not answer the
|
||||
same failure with different statuses.
|
||||
|
||||
|
||||
@@ -5,7 +5,7 @@ Design §37. What is measured, and what must never appear in a measurement.
|
||||
## What is emitted by default
|
||||
|
||||
Nothing JPA-specific. No composition constructs a `MeterRegistry`-backed observation for the
|
||||
platform, and `SpringTransactionPort` records no transaction metric. The `jpa.transaction.*` meters
|
||||
platform, and `SpringTransaction` records no transaction metric. The `jpa.transaction.*` meters
|
||||
this page used to list (`duration`, `rollback`, `timeout`, `completion.unknown`) were produced by
|
||||
`JpaTransactionObservation`, which nothing constructed; it was removed on 2026-09-25
|
||||
(`docs/capability-status.md`). Transaction outcomes are visible through the shared persistence error
|
||||
|
||||
@@ -27,7 +27,7 @@ reason.
|
||||
|
||||
**Signal:** `DB_DEADLOCK` / serialization failures rising in the persistence error codes.
|
||||
|
||||
`SpringTransactionPort` does not retry, so each one reaches the caller.
|
||||
`SpringTransaction` does not retry, so each one reaches the caller.
|
||||
|
||||
1. Group the failures by operation. A single operation dominating means a hot row or an
|
||||
inconsistent lock order.
|
||||
|
||||
@@ -6,7 +6,7 @@ Design §15-§20. What owns a transaction, what may be retried, and what must ne
|
||||
|
||||
Repository adapters do not open transactions. The use case does, through `TransactionPort`,
|
||||
because the unit of work is a business decision and only the use case knows where it starts and
|
||||
ends. `SpringTransactionPort` is the only implementation: one pre-built `TransactionTemplate` per
|
||||
ends. `SpringTransaction` is the only implementation: one pre-built `TransactionTemplate` per
|
||||
mode over Spring's `PlatformTransactionManager`, every mode pinned to `READ_COMMITTED`.
|
||||
|
||||
| Call | Propagation | When |
|
||||
@@ -28,7 +28,7 @@ maximumPoolSize >= (concurrent_threads x (1 + max_requires_new_depth)) + 1
|
||||
|
||||
## Nothing is retried by the port
|
||||
|
||||
`SpringTransactionPort` runs the action once. A failure rolls back and propagates, translated to
|
||||
`SpringTransaction` runs the action once. A failure rolls back and propagates, translated to
|
||||
the shared persistence error codes where the SQLSTATE is known. A caller that decides to retry must
|
||||
re-run the whole use case in a new transaction — never re-issue one statement — because an
|
||||
optimistic conflict or a serialization failure means the state the attempt computed against is no
|
||||
|
||||
@@ -0,0 +1,25 @@
|
||||
## 행 결과
|
||||
| ID | 결과 | 근거 |
|
||||
|---|---|---|
|
||||
| S1-#6b | 완료 | P28 W3 `b06b4166`(결정 32). transport가 부르는 21개 연산을 `application-fileserver/.../port/in/*UseCase`(연산 하나씩, `CommandUseCase`/`QueryUseCase`) + `*Command`/`*Query`로 선언하고 구현 `*ApplicationUseCase`(upload·download·lifecycle·admin 패키지)에 `@UseCaseCapability`를 단다. 권한: `file:read`(describe·prepare·open·transfer·upload status), `file:upload`(create·append·finalize·cancel·single-request upload), `file:delete`, `file:copy`, `file:move`, `file:admin`(관리 plane 8개). `FileAccessPolicyPort`(tier·소유자·tenant)는 각 use case 안에서 그대로(결정 32 "둘 다"). `security.yml` `"[ROLE_FILE_READ]": file:read`, `"[ROLE_FILE_WRITE]": file:upload,file:delete,file:copy,file:move`, `"[ROLE_FILE_ADMIN]": file:admin`(fileserver 기본 tier 역할 이름을 key로 — 한 역할이 권한과 tier를 함께 준다), dev Keycloak realm에 같은 client role 3개(`ROLE_FILE_ADMIN`은 서비스 계정에 미부여), `docs/fileserver/design-deviations.md` §5·`configuration.md`·`infra/keycloak/README.md`. 조립은 `composition:fileserver-platform`의 `FileserverUploadUseCaseConfiguration`·`FileserverFileUseCaseConfiguration`·`FileserverAdminReadUseCaseConfiguration`·`FileserverAdminActionUseCaseConfiguration`(BOOT-007 8-bean 한도), adapter의 download/lifecycle/admin 서비스 조립 삭제. 테스트: `FileserverCompositionIntegrationTest.anUploadByATierWithoutTheUploadPermissionIsRefusedBeforeAnythingIsStaged`(실제 PG, `MethodSecurityConfig` 없이 FAIL 1건 → 포함 PASS; fileserver tier는 통과하지만 권한 매핑이 없는 역할 `ROLE_UNMAPPED_WRITER`), 같은 클래스 3건 PASS; `BlockingTransferExecutorSecurityContextTest.workOnTheTransferPoolSeesTheCallersAuthentication` FAIL(assertion) → PASS(전송 풀 작업에 요청 SecurityContext 전달 — 없으면 append·finalize·download stream이 권한 게이트에서 익명으로 거부됨). ArchUnit: fileserver access policy 패키지(`adapter.outbound.fileserver.platform.security`, IO 없음)를 D7 in-process driven outbound로 추가(`ApplicationBoundaryArchitectureTest.isInProcessDrivenOutbound`), `FileserverUseCaseContractDeviationTest` 동결 목록을 `DefaultCleanupService`·`DefaultFileReconciliationService`·`WriterLeaseCoordinator`로 축소(배경 작업은 caller identity가 없어 권한을 가질 수 없음). `:app-bootstrap:architectureTest` PASS. 수정 방향과 다른 점: 트랜잭션을 열지 않던 append·status·download read·incomplete-list는 `USE_CASE_CAPABILITY_MATCHES_TRANSACTION_PORT_BOUNDARY` 때문에 해당 경계(`inWrite`로 lease commit 감쌈 — coordinator 경계에 join, `inRead`로 조회)를 직접 연다; 여러 use case를 합성하는 single-request upload·operator cleanup은 `RepositoryAccess.NONE`(각 단계가 자기 경계를 연다) |
|
||||
| S1-#18b | 완료 | P28 W3 `b06b4166`: inbound `UploadApplicationService`·`DownloadApplicationService`·`FileLifecycleService`·`FileserverAdminService`·`SingleShotUploadService`·`FinalizeUploadService`와 `Default*` 구현을 `port.in/*UseCase` + `*ApplicationUseCase`로(notification의 `port.in` 규칙과 같음). 남긴 `*Service`는 transport가 부르지 않는 배경 작업 `CleanupService`·`FileReconciliationService`뿐 — 쓰기 use case는 `@RequiresPermission`이 필수인데 scheduler는 권한을 가질 caller가 없으므로 use case로 만들면 매 실행이 거부된다(`FileserverUseCaseContractDeviationTest` 주석) |
|
||||
| S4-lead-2 | 남음 | 한 것(P28 W3 `da49df6c`): fileserver의 descriptor 기반 primitive를 `adapter/outbound/support/.../support/filesystem/SecureDirectoryWalk.java`(이동, public)·`SecureFileAccess.java`(신규: createNew·openForRead/Write·deleteRegularFile·readAttributes·isRegularFile·createParentDirectories)로 올리고, 거부를 에러 코드 없는 타입 있는 `IOException`(`SymbolicComponentException`·`PathEscapeException`·`NotRegularFileException`)으로. fileserver `SafeFileChannelFactory`는 위임 + `LocalStorageFailures` 번역만(P24 메모대로 번역 분리). 테스트: `SecureFileAccessTest` 8건(symlink leaf·symlink 디렉터리 component·`..` 탈출·create-only 충돌·symlink delete 거부·열린 뒤 디렉터리를 link로 바꾸는 race `aDirectorySwappedForALinkAfterItWasOpenedDoesNotRedirectTheOperation`), `SecureDirectoryWalkTest` 2건(support로 이동), `LocalStorageFailuresTest` 2건 FAIL→PASS(P28-new-1). fileserver·support `check`, PG lane `postgresqlFileserver{Migration,Metadata,Reclamation}IntegrationTest` 6·15·15 PASS. 남은 것: objectstorage `LocalObjectPathGuard`를 이 primitive로 바꾸는 재작성(과 objectstorage→support registry edge). 이유: local-dev provider의 쓰기는 "없거나 완전한" 게시를 위해 임시 파일을 `Files.createLink`(link(2))로 create-only 연결하는데, `SecureDirectoryStream`에는 linkat이 없고 `move`는 기존 대상을 덮어쓴다(renameat2 NOREPLACE 미노출). descriptor 기반으로 바꾸면 create-only 원자 게시를 잃거나(대상 선점 후 덮어쓰기 — 읽는 쪽이 빈/부분 객체를 볼 수 있음) native 호출이 필요해 설계 결정이 먼저다. 읽기·retire 경로만 바꾸면 쓰기 경로의 race가 남아 "한 primitive"가 되지 않으므로 이번 묶음에서는 손대지 않음(대상은 local-dev 전용 provider) |
|
||||
| S6-#10a | 남음 | / P28 에이전트가 세션 재시작으로 중단(미커밋) — P30으로 |
|
||||
| S2-#8a | 남음 | 한 것(P28 W3 `537310f9`): persistence-fileserver의 `@ComponentScan` + store 9개 클래스별 `@Repository`·`@ConditionalOnProperty`를 없애고, 조건 한 곳(`FileserverJpaPersistenceConfig`, 이 leaf의 `AutoConfiguration.imports` root) + 명시적 `@Bean` 설정 둘(`FileserverJpaMetadataStoreConfig`·`FileserverJpaQueueStoreConfig`)을 `@Import` — notification(`NotificationJpaPersistenceFacade`)과 같은 방식. web-fileserver 컨트롤러 4개·예외 처리기가 조립 root가 이미 거는 `app.fileserver-platform.enabled`를 반복하던 것 삭제(tus·draft12·admin은 자기 스위치만). 검증: persistence-fileserver·web-fileserver·composition fileserver `check`, PG lane `postgresqlFileserver{Metadata,Reclamation}IntegrationTest` 15·15, `FileserverCompositionIntegrationTest` 3 PASS. 남은 것: persistence-jpa `JpaAdapterComponentsConfig`의 8개 패키지 stereotype 스캔. 이유: 스캔이 있는 까닭이 이 leaf의 패키지 경계 목록(`JpaModuleBoundaryTest.PACKAGE_CATALOG`)이 `config`/`autoconfigure` → `audit`·`failure`·`liveevent`·`lock`·`operation`·`outbox` edge를 허용하지 않기 때문이다 — 명시적 `@Bean`으로 바꾸려면 (a) `autoconfigure`에 6개 edge를 추가하거나 (b) 패키지마다 capability 스위치를 반복하는 auto-configuration을 두어야 해서 leaf 내부 모듈 지도 결정이 먼저다(`JpaAdapterComponentsConfigTest`·`PersistenceEntityScanCoverageTest`가 스캔 계약을 고정). Mongo는 이미 자기 `AutoConfiguration.imports` 둘 + `@Bean` 방식이라 변경 없음(남은 것은 `MongoPlatformAutoConfiguration`의 bean별 조건 반복 19개) |
|
||||
| S2-#13b | 완료 | P28 W3 `2619cb18`: 규칙 `<Tech><포트 이름에서 Port를 뺀 것>` 하나로 24개 개명(테스트 클래스 이름 포함). persistence-fileserver `JpaFileMetadata`·`JpaFileQuota`·`JpaQuotaCommit`·`JpaQuotaReclaim`·`JpaUploadSession`(이미 규칙대로인 `JpaCleanupQueue`·`JpaContentReferenceLedger`·`JpaRecoveryQueue`·`JpaStagingUploadLocator`는 유지); fileserver adapter `LocalCleanupContent`·`LocalCopyContent`·`LocalOrphanScan`·`LocalReconciliationContent`·`LocalStorageHealth`·`LocalStorageUsage`·`LocalUploadContent`·`LocalUploadStorage`·`StructuredAdminAudit`·`StructuredFileserverAudit`·`RandomUploadIdentifier`; persistence-jpa core `SpringTransaction`·`JpaOutboxStore`·`JpaDurableOperationStore`·`PostgreSqlIdempotencyStore`·`LockRegistryDistributedLock`·`MeteredDistributedLock`·`DomainContextAuditContext`·`JpaLiveEventReplay`. 행에 적힌 `CanonicalOutboxAppendAdapter`는 P18에서 이미 삭제됨. 유지(이유): `LocalBlockingContentStore`(포트 3개를 구현하는 store 자체), `VerificationCoordinator`(verifier 파이프라인 합성 — 기술 어댑터가 아님), `RoleBased`/`UnenforcedFileAccessPolicy`(이미 `<정책><Port>`). 문서·README·CLAUDE.md의 단순 이름과 PG 통합 테스트의 bean 이름 문자열도 갱신. API surface 재승인(`updateJpaApiSurface -PapproveJpaApiSurfaceChange`, `updatePersistenceFileserverApiSurface -PapprovePersistenceFileserverApiSurfaceChange`, 개수 증가 없음). persistence-jpa·persistence-fileserver·fileserver·composition fileserver·idempotency·application-core·notification·persistence-notification `check`, `:app-bootstrap:architectureTest`·`test` PASS |
|
||||
| P24-new-2 | 해당 없음(코드 삭제) | P28 D `a49342e2`: `PosterEventPublisher.publishImageAttached`, `domain/poster/PosterImageAttached`, `PosterImageAttachedPayload`, `PortfolioEventContracts.POSTER_IMAGE_ATTACHED`와 그 bean, `contracts/messaging/poster.image-attached/v1.schema.json` 삭제. `git grep "ImageAttached\b"` 0건. `:sample-portfolio:test` PASS |
|
||||
| P25-new-2 | 해당 없음(코드 삭제) | P24-new-2와 같음(`a49342e2`) |
|
||||
| P24-new-3 | 완료 | P28 W3 `12f0b183`: `FileVerifier`를 `application-fileserver/.../api/security`에서 `adapter/outbound/fileserver/.../platform/verification/FileVerifier.java`로 이동(사용처는 그 패키지의 verifier 5개·`VerificationCoordinator`·`FileserverVerificationConfiguration`뿐). application은 `FileVerificationPort`만 본다 |
|
||||
| P23-new-1 | 완료 | P28 W2 `b13cf08b`: `AppliedMigrationImmutabilityTest.MIGRATION_ROOTS`에 `../persistence-fileserver/src/main/resources/db/migration` 추가 → `everyVersionedMigrationIsPinned` FAIL(`AssertionError at AppliedMigrationImmutabilityTest.java:72`, `jpa/fileserver/V1..V5` 미고정) → `applied-migrations.sha256`에 5줄 추가 후 PASS. `persistence-jpa/build.gradle` test `inputs.dir(...fileserver migration)` 추가. 새 migration 버전은 추가하지 않음 |
|
||||
| P23-new-2 | 완료 | P28 W2 `b13cf08b`: `ProviderRuntimeRegistryTest.closingTheRegistryClosesTheAdapterOfEveryRegisteredGeneration` FAIL(컴파일 실패 `cannot find symbol registry.close()`) → PASS; `SesNotificationProviderAdapterTest.closingTheAdapterClosesItsSdkClient` PASS. `SesNotificationProviderAdapter implements AutoCloseable`(`close()`→`client.close()`), `ProviderRuntime.release()`, `ProviderRuntimeRegistry implements AutoCloseable`(현재·drain 세대 모두 release) — `providerRuntimeRegistry` `@Bean`의 추론 destroy method로 context 종료 때 호출. `:adapter:outbound:notification:check` PASS |
|
||||
|
||||
## 제거된 코드
|
||||
| 대상 | 경로 | 마지막으로 존재한 커밋 | 이유 |
|
||||
|---|---|---|---|
|
||||
| `poster.image-attached` v1 이벤트(`PosterEventPublisher.publishImageAttached`, `PosterImageAttached`, `PosterImageAttachedPayload`, `PortfolioEventContracts.POSTER_IMAGE_ATTACHED`, schema) | `src/sample-portfolio/src/main/java/dev/caskeleton/sample/portfolio/{domain/poster/PosterImageAttached.java,application/event/PosterImageAttachedPayload.java}`, `src/sample-portfolio/src/main/resources/contracts/messaging/poster.image-attached/` | `36ba0810` | legacy 업로드 삭제 뒤 호출자 0(P24-new-2·P25-new-2) |
|
||||
| fileserver inbound 서비스 인터페이스 6개(`UploadApplicationService`, `FinalizeUploadService`, `SingleShotUploadService`, `DownloadApplicationService`, `FileLifecycleService`, `FileserverAdminService`)와 구현 `DefaultUploadApplicationService`·`DefaultFinalizeUploadService`·`DefaultSingleShotUploadService`·`DefaultDownloadApplicationService`·`DefaultFileLifecycleService`·`DefaultFileserverAdminService`, `download/DownloadRequest` | `src/application-fileserver/src/main/java/dev/caskeleton/application/fileserver/{upload,download,lifecycle,admin}/` | `36ba0810` | 결정 32: 연산별 `port.in` use case로 대체(S1-#6b·S1-#18b) |
|
||||
| `FileserverDownloadLifecycleConfiguration`, `FileserverMaintenanceServiceConfiguration`의 admin 서비스 bean | `src/adapter/outbound/fileserver/src/main/java/dev/caskeleton/adapter/outbound/fileserver/platform/autoconfigure/` | `36ba0810` | application use case 조립을 composition root(`composition:fileserver-platform`)로 |
|
||||
| `FileserverUploadServiceConfiguration`(→ `FileserverUploadSupportConfiguration`로 개명, 서비스 bean은 use case 설정으로) | `src/composition/fileserver-platform/src/main/java/dev/caskeleton/composition/fileserver/` | `36ba0810` | 같음 |
|
||||
|
||||
## 새로 발견한 결함
|
||||
- `P28-new-1` (고침, `da49df6c`): `adapter/outbound/fileserver/.../platform/local/AtomicMoveContentPublisher.java`(`SecureDirectoryWalk.move`)와 `ContentPublishVerification.java`(`SecureDirectoryWalk.inDirectory`)는 walk를 직접 불러 거부를 `LocalStorageFailures.translate`로 번역했는데, 거기서는 `SymbolicComponentException`·경로 탈출이 일반 `IOException`으로 분류돼 `STORAGE_UNAVAILABLE`(재시도 가능 503)이 됐다 — 클라이언트가 이미 link로 바뀐 경로로 재시도한다. `SafeFileChannelFactory`만 symlink를 따로 잡고 있었다. `LocalStorageFailures.translate`가 walk의 타입 있는 거부를 모두 `PATH_OUTSIDE_NAMESPACE`(재시도 불가)로. `LocalStorageFailuresTest.aSymbolicComponentRefusedByTheWalkIsAPermanentPathRejection`·`aTargetOutsideTheRootIsAPermanentPathRejection` FAIL(분기 제거 시 2건 실패) → PASS. (커밋 라벨은 W3지만 이 결함 수정이 함께 들어 있다.)
|
||||
@@ -0,0 +1,18 @@
|
||||
# W3-P29 결과 (에이전트 중단 후 오케스트레이터가 통합 검증으로 확정)
|
||||
|
||||
worktree: `.claude/worktrees/agent-aa7d1d4704847ed1c` (브랜치 `worktree-agent-aa7d1d4704847ed1c`)
|
||||
커밋: `e3a0bd32` (jvm-test-suite), `3967c9ef` (redis-sdk api)
|
||||
|
||||
## 행 결과
|
||||
| ID | 결과 | 근거 |
|
||||
|---|---|---|
|
||||
| BUILD-O3-5 | 완료 | `e3a0bd32`. `ca.auxiliary-source-set` 삭제, 13 leaf → `testing.suites`. TDD: `StrictTestLaneConventionTest.aLaneNamedAfterItsJvmTestSuiteMakesTheSuiteTaskStrict` FAIL(이전 플러그인: "Cannot add task 'integrationTest' as a task with that name already exists.") → PASS / 통합 검증(2026-09-29): ci·mainCheck·build-logic test·optional-platforms ci·releaseCheck 통과, integrationCheck는 jar 리소스 목록 조회 1건 수정 후 재실행 |
|
||||
| BUILD-결론-1 | 완료 | build-logic Java 6,068 → 5,851줄(main 3,966 + test 1,885) / 수정 방향(O3-2·5·6) 전부 이행: 16,768 → 5,851줄(main 3,966 + test 1,885). main+test 합계는 목표 3.5–4k 초과 — 남은 것은 아키텍처 코어·컨벤션·레인 하나와 그 테스트 |
|
||||
| P22-new-3 | 완료 | `3967c9ef`. redis-sdk만 `java-library` + `api project(':adapter:outbound:redis-runtime')` / 통합 검증 통과(redis-sdk java-library + api redis-runtime) |
|
||||
|
||||
## 제거된 코드
|
||||
| 대상 | 경로 | 마지막으로 존재한 커밋 | 이유 |
|
||||
|---|---|---|---|
|
||||
| `ca.auxiliary-source-set` 플러그인(`AuxiliarySourceSetPlugin`·`Extension`·`Spec`)과 `AuxiliarySourceSetConventionTest` | `src/build-logic/src/{main,test}/java/dev/caskeleton/buildlogic/auxiliary/` | `4f4bd1fd` | Gradle `jvm-test-suite`로 대체(BUILD-O3-5) |
|
||||
|
||||
## 새로 발견한 결함
|
||||
@@ -583,7 +583,7 @@ Wave 3 라운드 1 결과로 받은 4건(2026-09-28, desktop):
|
||||
|
||||
| ID | 심각도 | 요약 | 상태 | 근거 | Wave | 수정 방향 |
|
||||
|---|---|---|---|---|---|---|
|
||||
| BUILD-결론-1 | 권고 | 빌드 코드가 목적에 비해 너무 큼(16,768줄 중 아키텍처 검사 13%) | 남음 | 현재 Java(main+test) build-logic 6,184 + build-tools 4,320 = 10,504줄. O3 목표는 3.5–4k줄<br>Wave 3 W3-P16: 미완 — build-logic+build-tools Java 10,504줄 → build-logic 6,185줄(main 4,184 + test 2,001; build-tools 0). 목표 3.5–4k에는 BUILD-O3-5 나머지(auxiliary → jvm-test-suite, release-provenance 제거)가 필요<br>Wave 3 W3-P27: 미완 — O3-5 나머지 뒤 build-logic Java 줄 수로 판정 | W3 | BUILD-O3-2·5·6 진행으로 줄인다 |
|
||||
| BUILD-결론-1 | 권고 | 빌드 코드가 목적에 비해 너무 큼(16,768줄 중 아키텍처 검사 13%) | 완료 | Wave 3 W3-P29 (Wave 3 라운드 3 커밋): build-logic Java 6,068 → 5,851줄(main 3,966 + test 1,885) / 수정 방향(O3-2·5·6) 전부 이행: 16,768 → 5,851줄(main 3,966 + test 1,885). main+test 합계는 목표 3.5–4k 초과 — 남은 것은 아키텍처 코어·컨벤션·레인 하나와 그 테스트 | - | BUILD-O3-2·5·6 진행으로 줄인다 |
|
||||
| BUILD-결론-2 | 권고 | 기능별 증거 검사(E)가 46%로 가장 큰 덩어리 | 완료 | Wave 3 W3-P16 (Wave 3 라운드 1 커밋): 기능별 evidence 검사 중 JPA(`jpa/` 2,701+706줄, `junit/` 138+76줄) 삭제. 남은 E는 redis topology(소유자 결정 4로 유지) | - | JPA evidence 폐기(BUILD-O3-2) |
|
||||
| BUILD-결론-3 | 권고 | 아키텍처 게이트(방향 task·ArchUnit)는 크기가 적정하니 유지 | 완료 | `src/build-logic/src/main/java/dev/caskeleton/buildlogic/architecture/ArchitecturePlugin.java:58-223` 방향·순수성·ignored-source 유지, `src/app-bootstrap/build.gradle:45-52` architectureTest 레인 유지 | - | - |
|
||||
| BUILD-결론-4 | 권고 | 09-16 단계 분리 계획이 절반만 이행됨(2단계 게이트가 PR에서 돎) | 완료 | Wave 3 W3-P16 (Wave 3 라운드 1 커밋): 하위 행으로 추적: B2·B4-17·B4-27·B4-28·B4-30·중복-6 완료, B3의 "변경 모듈만 실행"과 C는 보류(각 행) | - | 해당 행 참고 |
|
||||
@@ -613,7 +613,7 @@ Wave 3 라운드 1 결과로 받은 4건(2026-09-28, desktop):
|
||||
| BUILD-O3-2 | 권고 | O3: JPA evidence manifest(`ca.jpa-evidence`, `ca.jpa-qualification`) 폐기, leaf 테스트로 | 완료 | Wave 3 W3-P16 (Wave 3 라운드 1 커밋): build-tools `jpa/`·`junit/`, `ca.jpa-evidence`·`ca.jpa-qualification` 삭제. readiness 카드 검사 → `JpaReadinessRegistryTest`(persistence-jpa `test`, 입력 `readiness-cards.yaml`·`src/postgresqlIntegrationTest/java` 선언). `everyImplementedCardNamesTasksThisLeafDeclares` FAIL(삭제된 `verifyJpaPrimaryFoundationEvidence`를 가리키던 카드, AssertionError at :106) → 카드를 `integrationTestLaneCheck`로 고쳐 PASS. 카드가 인용한 scenario는 readiness 레인의 `requires` + `rejectSkipped`로(manifest가 JUnit XML로 확인하던 것). `jpaReleaseQualification`은 leaf 집계 태스크(registry의 blocking gate를 dependsOn). workflow: `jpa-r2-evidence.yml`, integration-main `jpa-candidate-evidence` 삭제 | - | 두 플러그인과 `junit` 패키지를 삭제하고, readiness/release registry 검사만 persistence-jpa 테스트(inputs 선언)로 옮김. workflow의 evidence task 호출도 정리 |
|
||||
| BUILD-O3-3 | 권고 | O3: verifyEnvKeys 위치 | 완료 | 소유자 결정은 bootstrap에 유지. 현재 `src/app-bootstrap/build.gradle:5`(`ca.config-contract`), `src/build.gradle:75-79`→mainCheck | - | - |
|
||||
| BUILD-O3-4 | 권고 | O3: redis topology lane을 strict lane으로 흡수 | 완료 | 소유자 결정은 유지. `src/build-logic/src/main/java/dev/caskeleton/buildlogic/redis/` 유지, `.github/workflows/redis-sdk-topology.yml` 경로 필터 PR | - | - |
|
||||
| BUILD-O3-5 | 권고 | O3: build-logic에는 코어·컨벤션·레인 하나만 남김(인벤토리 #11·#18·#19·#20·#31) | 남음 | 남은 비핵심 플러그인(main+test 줄 수): publicpath 288+37, archive 216+46, release 138+71, bootstrap(developer-bootstrap·bootrun-dotenv) 328+203, auxiliary 151+145. leaf 버전은 아직 SHA 버전(`src/build-logic/src/main/java/dev/caskeleton/buildlogic/java/JavaConventionsPlugin.java:36-39`)<br>Wave 3 W3-P16: 미완 — 완료: public-path → app-bootstrap `PublicPathSnapshotTest`(main 단계 레인 `publicPathSnapshotTest`, 루트 별칭 `verifyPublicPathSnapshot`, 승인 `-PapprovePublicPathChange`; 기준선은 헤더의 명령만 바뀜), developer-bootstrap → `scripts/bootstrap-local.sh`, leaf version에서 revision 제거 후 archive-hygiene 삭제, app-bootstrap `springBoot.buildInfo`(`build.revision`, `time` 제외). 남음: (1) `ca.release-provenance` 플러그인 제거 — `src/optional-platforms/build.gradle`이 적용하고 있어 이번 Wave에서 건드리지 않기로 한 gRPC build 파일 수정이 필요, (2) auxiliary → `jvm-test-suite` — grpc·messaging 포함 14개 leaf build 파일을 바꾸는 작업이라 동시 묶음과 충돌. 둘 다 다음 순차 작업으로<br>Wave 3 W3-P27: 미완 — 완료분: `302ba915` `ca.release-provenance` 제거(leaf version·sourceRevision은 `ca.java-conventions`의 `JavaConventionsPlugin.sourceRevision`, 루트 `verifyReleaseProvenance`는 같은 함수를 부르는 build.gradle 태스크, TestKit 테스트는 `PlatformModuleConventionTest`로). 남은 것: auxiliary 레인 → `jvm-test-suite`(중단된 WIP 패치) | W3 | public-path는 app-bootstrap approval test로, release-provenance는 `springBoot { buildInfo() }`로 바꾸고, leaf 버전 고정 후 archive-hygiene 삭제. developer-bootstrap은 `scripts/`로, auxiliary는 `jvm-test-suite`로 |
|
||||
| BUILD-O3-5 | 권고 | O3: build-logic에는 코어·컨벤션·레인 하나만 남김(인벤토리 #11·#18·#19·#20·#31) | 완료 | Wave 3 W3-P29 (Wave 3 라운드 3 커밋): `e3a0bd32`. `ca.auxiliary-source-set` 삭제, 13 leaf → `testing.suites`. TDD: `StrictTestLaneConventionTest.aLaneNamedAfterItsJvmTestSuiteMakesTheSuiteTaskStrict` FAIL(이전 플러그인: "Cannot add task 'integrationTest' as a task with that name already exists.") → PASS / 통합 검증(2026-09-29): ci·mainCheck·build-logic test·optional-platforms ci·releaseCheck 통과, integrationCheck는 jar 리소스 목록 조회 1건 수정 후 재실행 | - | public-path는 app-bootstrap approval test로, release-provenance는 `springBoot { buildInfo() }`로 바꾸고, leaf 버전 고정 후 archive-hygiene 삭제. developer-bootstrap은 `scripts/`로, auxiliary는 `jvm-test-suite`로 |
|
||||
| BUILD-O3-6 | 권고 | O3: build-tools를 비움 | 완료 | Wave 3 W3-P16 (Wave 3 라운드 1 커밋): `config` 패키지를 `dev.caskeleton.buildlogic.config`로 이동(테스트 2개 포함), `includeBuild('build-tools')`·Dockerfile `COPY build-tools/`·build-logic.yml step 삭제, `src/build-tools` 삭제. 태스크는 `:app-bootstrap:verifyEnvKeys` 그대로(PASS) | - | JPA 폐기 후 `ConfigContractPlugin`을 build-logic으로 옮기고 `includeBuild('build-tools')` 삭제. task는 계속 `:app-bootstrap:verifyEnvKeys` |
|
||||
| BUILD-바로할것-1b | Nit | runtime-membership 삭제 후 남은 주석 문구 | 남음 | `src/sample-portfolio/build.gradle:175`, `.github/workflows/ci-quality-gates.yml:55` "runtime-membership policy" | W5 | 두 주석에서 해당 문구 삭제 |
|
||||
| BUILD-바로할것-4 | 권고 | `ca.strict-qualification`을 `strictTestLanes` requires + rejectSkipped로 (= O-8) | 완료 | `strictQualification` grep 0건, id 없음. 예: `src/app-bootstrap/build.gradle:61-68` 레인 `requires`+`rejectSkipped` | - | - |
|
||||
@@ -783,7 +783,7 @@ Wave 3 라운드 1 결과로 받은 4건(2026-09-28, desktop):
|
||||
| S1-#4 | Required | `NotificationDispatchService` 생성자 15개, record 필드별 재조립·실패 분류가 한 클래스에 (B-5 구조 원인) | 완료 | Wave 3 W3-P23 (Wave 3 라운드 3 커밋): 구조 변경(결함 아님, 기존 동작 테스트로 회귀 확인). record 재조립 4곳을 전이 메서드로: `application-notification/.../dispatch/DeliveryAttemptRecord.java:97`(`completed`)·`:135`(`closedBeforeSubmission`), `RecipientDeliveryRecord.java:73`(`advancedRoute`)·`:113`(`failedBeforeAttempt`)·`:156`(`afterAttempt`)·`:194`(`terminalStateFor`, 종료 상태 계산 1곳). catch 3분기는 `ProviderOutcomeClassifier.java:31`(`fromException`), 호출은 `NotificationDispatchService.java:332`. `DispatchOutcomeRecorder`는 `attempt.completed`·`current.afterAttempt` 두 줄. 새 테스트 `ProviderOutcomeClassifierTest`(3건) PASS, `NotificationDispatchServiceTest`·`DispatchOutcomeRecorderTest` 그대로 PASS. 남은 점: 생성자 인자는 여전히 15개(`NotificationDispatchService.java:82`, registry→renderer로 바뀐 것뿐). 인자는 모두 실제 포트·정책이라 수정 방향에 없는 묶음 record를 새로 만들지 않았다 | - | `DeliveryAttemptRecord.completed(result, at)`·`RecipientDeliveryRecord.advancedRoute(now)` 전이 메서드 추가, catch 분기는 `ProviderOutcomeClassifier` 정적 메서드로 분리 |
|
||||
| S1-#5 | Required | fileserver retire 절차 3곳 복사, admin `forceDelete`는 content 없는 레코드를 DELETING에 남김 (C-4 관련) | 완료 | Wave 1–2 P4 (fcddab7e·Wave 2 커밋): `FileserverAdminServiceTest.forceDeletingAFileThatWasNeverPublishedRetiresItCompletely` FAIL(`expected: DELETED but was: DELETING`)→PASS. 세 호출부가 `src/application-fileserver/.../cleanup/FileRetirement.java:40` 하나를 쓴다: `DefaultFileLifecycleService.java:84`, `DefaultFileserverAdminService.java:167`, `DefaultUploadApplicationService.java:265`. `cleanup` 패키지에 둔 이유: 세 호출 패키지가 이미 cleanup을 의존하고 cleanup은 그들을 의존하지 않아 새 패키지 순환이 생기지 않는다 | - | `retire(FileRecord)` 하나로 합치고 content 없으면 DELETING→DELETED 전이를 세 호출부 모두에 적용 |
|
||||
| S1-#6a | Required | fileserver 단일 구현 인터페이스 6개(fake 없음) | 완료 | Wave 3 W3-P24 (Wave 3 라운드 2 커밋): `1ec8f087`·`8e731b9f`. 구현 1개·대역 0인 `WriterLeaseCoordinator`·`TransferAdmissionController` 인터페이스를 지우고 `Default*`가 그 이름을 가짐, `FileStateMachine`은 S1-#13으로 삭제. 수정 방향과 다르게 남긴 3개와 이유: `FileLifecycleService`는 web-fileserver `FileLifecycleController`가 부르는 inbound 포트라 `INBOUND_ADAPTERS_DEPEND_ON_PORTS_NOT_APPLICATION_SERVICES`(architectureTest)가 구체 클래스 의존을 금지(없앴다가 architectureTest FAIL로 복원), `CleanupService`·`FileReconciliationService`는 composition `FileserverCleanupWorkerTest`·`FileserverStructuredLoggingTest`가 람다/익명 대역으로 구현(두 번째 구현 존재 — 현황표 근거 "fake 없음"이 틀림). `FileserverUseCaseContractDeviationTest.KNOWN_DEVIATIONS` 갱신 | - | 인터페이스 6개 삭제, `Default*`를 인터페이스 이름으로 개명 |
|
||||
| S1-#6b | Required | fileserver 인바운드가 use-case 계약 밖(capability gate 미적용) | 남음 | Wave 3 W3-P24 (Wave 3 라운드 2 커밋): 사유: 결정 필요 — transport 연산 약 30개를 `CommandUseCase`/`QueryUseCase` + `@UseCaseCapability`로 바꾸면 `MUTATING_USE_CASES_DECLARE_REQUIRED_PERMISSION`(architectureTest) 때문에 쓰기 연산마다 `@RequiresPermission("file:…")`이 필요하고, 그 annotation은 web `RequiresPermissionAuthorizationManager`가 `AuthorizationPort`로 런타임에 강제한다. 즉 기존 `FileAccessPolicyPort`(역할·소유자 검사, C-8a) 위에 권한 게이트가 하나 더 생기고, 배포는 새 권한 이름을 부여해야 기존 업로드·다운로드가 계속 된다. (1) fileserver 연산에 method-security 권한을 추가할지(추가하면 권한 이름 체계), 아니면 (2) `RepositoryAccess`/권한 규칙에서 fileserver를 예외로 둘지를 정해야 한다(`docs/fileserver/design-deviations.md` §5가 ADR로 열어 둔 질문). 승인자: 저장소 소유자 결정 필요<br>결정 32(2026-09-28): 권한 추가로 결정 → 남음, P28 | W3 | transport가 부르는 연산을 `*UseCase` + `@UseCaseCapability`로 선언 |
|
||||
| S1-#6b | Required | fileserver 인바운드가 use-case 계약 밖(capability gate 미적용) | 완료 | Wave 3 W3-P28 (Wave 3 라운드 3 커밋): P28 W3 `b06b4166`(결정 32). transport가 부르는 21개 연산을 `application-fileserver/.../port/in/*UseCase`(연산 하나씩, `CommandUseCase`/`QueryUseCase`) + `*Command`/`*Query`로 선언하고 구현 `*ApplicationUseCase`(upload·download·lifecycle·admin 패키지)에 `@UseCaseCapability`를 단다. 권한: `file:read`(describe·prepare·open·transfer·upload status), `file:upload`(create·append·finalize·cancel·single-request upload), `file:delete`, `file:copy`, `file:move`, `file:admin`(관리 plane 8개). `FileAccessPolicyPort`(tier·소유자·tenant)는 각 use case 안에서 그대로(결정 32 "둘 다"). `security.yml` `"[ROLE_FILE_READ]": file:read`, `"[ROLE_FILE_WRITE]": file:upload,file:delete,file:copy,file:move`, `"[ROLE_FILE_ADMIN]": file:admin`(fileserver 기본 tier 역할 이름을 key로 — 한 역할이 권한과 tier를 함께 준다), dev Keycloak realm에 같은 client role 3개(`ROLE_FILE_ADMIN`은 서비스 계정에 미부여), `docs/fileserver/design-deviations.md` §5·`configuration.md`·`infra/keycloak/README.md`. 조립은 `composition:fileserver-platform`의 `FileserverUploadUseCaseConfiguration`·`FileserverFileUseCaseConfiguration`·`FileserverAdminReadUseCaseConfiguration`·`FileserverAdminActionUseCaseConfiguration`(BOOT-007 8-bean 한도), adapter의 download/lifecycle/admin 서비스 조립 삭제. 테스트: `FileserverCompositionIntegrationTest.anUploadByATierWithoutTheUploadPermissionIsRefusedBeforeAnythingIsStaged`(실제 PG, `MethodSecurityConfig` 없이 FAIL 1건 → 포함 PASS; fileserver tier는 통과하지만 권한 매핑이 없는 역할 `ROLE_UNMAPPED_WRITER`), 같은 클래스 3건 PASS; `BlockingTransferExecutorSecurityContextTest.workOnTheTransferPoolSeesTheCallersAuthentication` FAIL(assertion) → PASS(전송 풀 작업에 요청 SecurityContext 전달 — 없으면 append·finalize·download stream이 권한 게이트에서 익명으로 거부됨). ArchUnit: fileserver access policy 패키지(`adapter.outbound.fileserver.platform.security`, IO 없음)를 D7 in-process driven outbound로 추가(`ApplicationBoundaryArchitectureTest.isInProcessDrivenOutbound`), `FileserverUseCaseContractDeviationTest` 동결 목록을 `DefaultCleanupService`·`DefaultFileReconciliationService`·`WriterLeaseCoordinator`로 축소(배경 작업은 caller identity가 없어 권한을 가질 수 없음). `:app-bootstrap:architectureTest` PASS. 수정 방향과 다른 점: 트랜잭션을 열지 않던 append·status·download read·incomplete-list는 `USE_CASE_CAPABILITY_MATCHES_TRANSACTION_PORT_BOUNDARY` 때문에 해당 경계(`inWrite`로 lease commit 감쌈 — coordinator 경계에 join, `inRead`로 조회)를 직접 연다; 여러 use case를 합성하는 single-request upload·operator cleanup은 `RepositoryAccess.NONE`(각 단계가 자기 경계를 연다) | - | transport가 부르는 연산을 `*UseCase` + `@UseCaseCapability`로 선언 |
|
||||
| S1-#7 | Consider | 에러 코드마다 예외 서브클래스, 타입 분기는 몇 개뿐 | 완료 | Wave 3 W3-P24 (Wave 3 라운드 2 커밋): `6d6c69fe`. `FileserverException`을 구체 클래스로(`api/error/FileserverException.java:37` `of(code, message)`, `notReady(fileId, state)`). catch/instanceof로 타입 분기하는 5개(`FileNotFoundException`·`FileAlreadyExistsException`·`InvalidPathException`·`UploadOffsetMismatchException`·`AmbiguousCompletionException`)만 남기고 17개 삭제, 생성 지점 약 110곳을 `new FileserverException(message, context)`/`FileserverException.of(CODE, …)`로. 테스트의 타입 분기(`MvcUploadExecutorSaturationTest`, PG `aReleasedReservationCanNeverBeCommittedOrExtended`)는 `code()` 비교로. fileserver 5개 leaf `check`·PG lane 3개 PASS | - | base를 구체 클래스 + `of(code, …)`, 서브클래스는 catch로 타입 분기하는 5개만 남김 |
|
||||
| S1-#8 | Consider | `PolicyTransactionPort` 계열이 호출 1곳용 | 해당 없음(코드 삭제) | 「제거된 코드」 `PolicyTransactionPort` 계열·`SpringPolicyTransactionPort`·`FileserverCompensationTransaction` 행. grep 0건 | - | - |
|
||||
| S1-#9 | Consider | 같은 전략만 담은 레지스트리 2개 | 완료 | Wave 3 W3-P23 (Wave 3 라운드 3 커밋): `TemplateRendererRegistry`·`MapTemplateRendererRegistry`·`ThymeleafNotificationRenderer`, `ProviderEventProjectorRegistry`·`MapProviderEventProjectorRegistry`·`SesDeliveryProjector` 삭제(`bff135d6`). renderer 하나(`CanonicalNotificationRenderer`, channel은 `RenderCommand`에서; `NotificationPlatformProviderConfig.java:53`)와 projector 하나(`StandardDeliveryProjector`; `NotificationPlatformRegistriesConfig.java:38`)를 직접 주입. `ProviderEventProjector.providerId()`·`NotificationTemplateRenderer.channel()`, `AssembledProvider`/`AssembledPlatform`의 projector 슬롯, `ProviderCallbackAssembler.projector()`, `NO_PROJECTOR` 분기 삭제. 테스트 `NotificationProviderAssemblyTest.anSesHardBounceIsProjectedByTheSharedProjector` PASS. PG 테스트 `PostgreSqlNotificationBackgroundPassIntegrationTest.replayMarksAnEventWithNoProjectorFailed`는 그 분기가 없어져 삭제 | - | 레지스트리·`Map*Registry` 삭제, 구현체 직접 주입 |
|
||||
@@ -801,7 +801,7 @@ Wave 3 라운드 1 결과로 받은 4건(2026-09-28, desktop):
|
||||
| S1-#17a | Consider | objectstorage 식별자 클래스 6개·가드 2개 복사 | 완료 | Wave 3 W3-P24 (Wave 3 라운드 2 커밋): `7a21c6e7`. `ObjectId`·`ObjectReference`·`ObjectStageHandle`·`ObjectVersionToken`을 compact constructor + `toString`(redacted) record로(`identity/ObjectId.java:4`). `DirectTransferSessionId`·`PartReceiptToken`은 D-7a에서 이미 삭제. 가드는 `ObjectModelSupport.requireBoundedToken`(`model/ObjectModelSupport.java:9`) 하나, `ObjectRequestSupport.boundedToken` 삭제. `:application-objectstorage:check`, control record 골든 digest(`ObjectControlRecordCodecTest`) PASS | - | 식별자를 record + `toString` 재정의로, 가드는 하나로 |
|
||||
| S1-#17b | Consider | legacy `application.storage` 네임스페이스 공존(Javadoc 모순) | 완료 | Wave 3 W3-P24 (Wave 3 라운드 2 커밋): `e8b6bae0`. sample에는 이미 canonical 포트 위의 `PublishPosterImageUseCase`(mode=publication)가 있어 legacy mode(`UploadPosterImageUseCase`·`LegacyPosterImageController`)를 지우고 local/test profile은 `mode: disabled`. `application.storage.ObjectStoragePort`·`StoredObject`와 legacy 어댑터 2개 삭제. `:sample-portfolio:check`·`systemTest` PASS | - | 「한 기능에 한 세대」: sample `UploadPosterImageUseCase`를 `application.objectstorage` 포트로 옮기고 legacy 포트·어댑터 2개 삭제 |
|
||||
| S1-#18a | Consider | `V2` 접미사 타입 | 완료 | `6d27356e`: 멱등성 V2 → 무접미사, outbox V2 삭제. main의 `*V2*.java`는 sample 이벤트 스키마 버전 `PosterImageAttachmentReadyV2` 하나뿐 | - | - |
|
||||
| S1-#18b | Consider | 포트·서비스 이름 규칙이 leaf마다 다름 | 남음 | Wave 3 W3-P24 (Wave 3 라운드 2 커밋): outbound 부분은 완료(`18ed5e7d`): `FileQuotaService`→`FileQuotaPort`, `FileMetadataStore`→`FileMetadataPort`, `UploadSessionStore`→`UploadSessionPort`, `*Gateway` 8개→`*Port`, 그 밖의 outbound 포트 9개에 `Port` 접미사(어댑터 구현 이름은 유지). 남은 inbound `*Service`→`*UseCase` 개명은 S1-#6b와 같은 결정에 묶인다 — 이름이 `UseCase`로 끝나고 `TransactionPort`를 쥔 클래스는 `ORCHESTRATION_ENTRYPOINTS_DECLARE_A_CAPABILITY`로 `@UseCaseCapability`가, 쓰기면 `@RequiresPermission`이 필요하다. 승인자: 저장소 소유자 결정 필요(S1-#6b와 함께)<br>결정 32(2026-09-28): 권한 추가로 결정 → 남음, P28 | W3 | 소유자 규칙대로 outbound `*Port`, inbound `*UseCase`로 기계적 개명 |
|
||||
| S1-#18b | Consider | 포트·서비스 이름 규칙이 leaf마다 다름 | 완료 | Wave 3 W3-P28 (Wave 3 라운드 3 커밋): P28 W3 `b06b4166`: inbound `UploadApplicationService`·`DownloadApplicationService`·`FileLifecycleService`·`FileserverAdminService`·`SingleShotUploadService`·`FinalizeUploadService`와 `Default*` 구현을 `port.in/*UseCase` + `*ApplicationUseCase`로(notification의 `port.in` 규칙과 같음). 남긴 `*Service`는 transport가 부르지 않는 배경 작업 `CleanupService`·`FileReconciliationService`뿐 — 쓰기 use case는 `@RequiresPermission`이 필수인데 scheduler는 권한을 가질 caller가 없으므로 use case로 만들면 매 실행이 거부된다(`FileserverUseCaseContractDeviationTest` 주석) | - | 소유자 규칙대로 outbound `*Port`, inbound `*UseCase`로 기계적 개명 |
|
||||
| S1-#19 | Nit | 이력 주석·inline FQN | 남음 | 재측정: 이력 문구("used to" 등) application-core 14·notification 23·fileserver 9·objectstorage 1줄, notification inline FQN 74줄 | W5 | 불변 조건 1~2줄만 남기고 이력은 git/ADR로, FQN은 import로 |
|
||||
| S1-#20 | Nit | notification `dispatch/` 패키지에 여러 기능 | 남음 | `application-notification/.../platform/dispatch/` 46파일 3,855줄(제출·템플릿 게시·`ContactPoint*`·reconciliation 포함) | W5 | `submission/`, `dispatch/`, `reconciliation/`로 이동, `ContactPoint*`는 `contact/`로 |
|
||||
| S1-lead-1 | 권고 | messaging 자체 outbox/inbox와 app-core outbox/inbox가 같은 패턴 3~4벌 | 완료 | app-core inbox 삭제(「제거된 코드」 same-store inbox 행), outbox V2 삭제. 남은 2벌(app outbox + vendored `messaging_outbox`)은 D2 결정(`docs/superpowers/specs/2026-09-25-capability-module-packaging-design.md:104` "messaging platform outbox는 vendored라 유지") | - | - |
|
||||
@@ -821,14 +821,14 @@ Wave 3 라운드 1 결과로 받은 4건(2026-09-28, desktop):
|
||||
| S2-#6a | Required | owner-lease claim 절차·`digestFields` 복사(inbox·polling) | 해당 없음(코드 삭제) | `PostgreSqlSameStoreInboxAdapter`·`PostgreSqlPollingDeliveryAdapter`·`PostgreSqlImmutableOutboxAppendAdapter` 삭제(「제거된 코드」 same-store inbox, JPA outbox V2 adapter 행). claim 절차는 멱등성 store에만 남음 | - | - |
|
||||
| S2-#6c | Required | `capability_schema_registry` 확인 SQL 복사 | 완료 | Wave 3 W3-P23 (Wave 3 라운드 3 커밋): 추출 뒤 persistence-jpa 안의 `capability_schema_registry` 확인 SQL은 `PostgreSqlOwnerSafeIdempotencyStore.java:66` 하나뿐. notification 사본(`persistence-notification/.../NotificationSchemaActivation.java:29`)은 fileserver와 같은 처지(jpa edge 없는 capability leaf)가 되어 행의 "fileserver는 자기 사본 유지" 규칙을 그대로 따름. 두 capability의 공용화(support로)는 P18(idempotency 이동)·P24(fileserver)와 겹쳐 이번에 하지 않음 | - | persistence-jpa 안 2곳은 `CapabilitySchemaRequirement` record 하나로, fileserver는 jpa edge가 없어 자기 사본 유지(또는 support로) |
|
||||
| S2-#7 | Required | JPA 플랫폼 라이브러리가 지원 표면 밖 | 완료 | 단일 구현 인터페이스 8개 grep 0(「제거된 코드」 work-claim·upsert 실행기, 단일 구현 인터페이스 행), 남은 라이브러리는 소유자 결정(Wave 3)대로 `adapter/outbound/persistence-jpa/README.md:61` 라이브러리 API 표에 명시. main 26.3k→20.0k줄 | - | - |
|
||||
| S2-#8a | Consider | 조립 방식 3가지, 게이트 반복 | 남음 | `persistence-jpa/.../config/JpaAdapterComponentsConfig.java`(스캔 stereotype 16개), `notification/configuration/NotificationJpaPersistenceFacade.java`, `persistence-fileserver/.../FileserverJpaPersistenceConfig.java` + fileserver main `@ConditionalOnProperty` 10개, Mongo 6개<br>Wave 3 W3-P23: 미완 — 이유: 알림은 이미 feature config의 명시적 `@Bean` 한 방식(`NotificationJpaPersistenceFacade`, 이번에 이 leaf의 auto-configuration root로). 남은 대상 — `JpaAdapterComponentsConfig`의 stereotype 스캔(outbox·idempotency·lock 등), `persistence-fileserver`의 `@ComponentScan`+클래스별 `@ConditionalOnProperty`, Mongo — 은 동시에 도는 P18(outbox·멱등성 패키지 이동)·P24(fileserver)가 같은 파일을 옮기고 있어 충돌을 피해 손대지 않음. 통합 뒤 한 묶음으로 | W3 | feature config별 명시적 `@Bean` 한 방식으로, 클래스별 stereotype·조건 제거 |
|
||||
| S2-#8a | Consider | 조립 방식 3가지, 게이트 반복 | 남음 | `persistence-jpa/.../config/JpaAdapterComponentsConfig.java`(스캔 stereotype 16개), `notification/configuration/NotificationJpaPersistenceFacade.java`, `persistence-fileserver/.../FileserverJpaPersistenceConfig.java` + fileserver main `@ConditionalOnProperty` 10개, Mongo 6개<br>Wave 3 W3-P23: 미완 — 이유: 알림은 이미 feature config의 명시적 `@Bean` 한 방식(`NotificationJpaPersistenceFacade`, 이번에 이 leaf의 auto-configuration root로). 남은 대상 — `JpaAdapterComponentsConfig`의 stereotype 스캔(outbox·idempotency·lock 등), `persistence-fileserver`의 `@ComponentScan`+클래스별 `@ConditionalOnProperty`, Mongo — 은 동시에 도는 P18(outbox·멱등성 패키지 이동)·P24(fileserver)가 같은 파일을 옮기고 있어 충돌을 피해 손대지 않음. 통합 뒤 한 묶음으로<br>Wave 3 W3-P28: 미완 — 한 것(P28 W3 `537310f9`): persistence-fileserver의 `@ComponentScan` + store 9개 클래스별 `@Repository`·`@ConditionalOnProperty`를 없애고, 조건 한 곳(`FileserverJpaPersistenceConfig`, 이 leaf의 `AutoConfiguration.imports` root) + 명시적 `@Bean` 설정 둘(`FileserverJpaMetadataStoreConfig`·`FileserverJpaQueueStoreConfig`)을 `@Import` — notification(`NotificationJpaPersistenceFacade`)과 같은 방식. web-fileserver 컨트롤러 4개·예외 처리기가 조립 root가 이미 거는 `app.fileserver-platform.enabled`를 반복하던 것 삭제(tus·draft12·admin은 자기 스위치만). 검증: persistence-fileserver·web-fileserver·composition fileserver `check`, PG lane `postgresqlFileserver{Metadata,Reclamation}IntegrationTest` 15·15, `FileserverCompositionIntegrationTest` 3 PASS. 남은 것: persistence-jpa `JpaAdapterComponentsConfig`의 8개 패키지 stereotype 스캔. 이유: 스캔이 있는 까닭이 이 leaf의 패키지 경계 목록(`JpaModuleBoundaryTest.PACKAGE_CATALOG`)이 `config`/`autoconfigure` → `audit`·`failure`·`liveevent`·`lock`·`operation`·`outbox` edge를 허용하지 않기 때문이다 — 명시적 `@Bean`으로 바꾸려면 (a) `autoconfigure`에 6개 edge를 추가하거나 (b) 패키지마다 capability 스위치를 반복하는 auto-configuration을 두어야 해서 leaf 내부 모듈 지도 결정이 먼저다(`JpaAdapterComponentsConfigTest`·`PersistenceEntityScanCoverageTest`가 스캔 계약을 고정). Mongo는 이미 자기 `AutoConfiguration.imports` 둘 + `@Bean` 방식이라 변경 없음(남은 것은 `MongoPlatformAutoConfiguration`의 bean별 조건 반복 19개) | W3 | feature config별 명시적 `@Bean` 한 방식으로, 클래스별 stereotype·조건 제거 |
|
||||
| S2-#8b | Consider | "두 조립 루트가 `dev.caskeleton.adapter`를 스캔한다" 서술이 사실과 다름 | 남음 | `persistence-jpa/.../postgresql/idempotency/PostgreSqlOwnerSafeIdempotencyStore.java:53`, `src/test/.../CandidateAdapterCompositionTest.java:10-18`(현재 `CaSkeletonApplication`은 scan 제외식 없음, sample은 `SamplePortfolioApplication.java:31-40`처럼 좁게 스캔) | W5 | 잘못된 단락 삭제, 전제가 사라진 `CandidateAdapterCompositionTest` 삭제 또는 현재 조립 기준으로 재작성 |
|
||||
| S2-#9a | Consider | 무관한 `inbox` 패키지 2개 | 해당 없음(코드 삭제) | `postgresql/inbox` 삭제(「제거된 코드」 same-store inbox 행) | - | - |
|
||||
| S2-#9b | Consider | feature가 vendor별로 흩어짐 | 완료 | Wave 3 W3-P18 (Wave 3 라운드 2 커밋): 이동만 했다(`910ab7ab`). 새 패키지는 `persistence/outbox/{jpa(+entity),postgresql,h2}`, `persistence/idempotency/{jpa(+entity),postgresql}`다. JPA API surface는 `updateJpaApiSurface -PapproveJpaApiSurfaceChange`로 다시 승인했다. `JpaModuleBoundaryTest`에 autoconfigure→idempotency edge를 기록했다. `verifyJpaApiSurface`·`verifyJpaReadinessRegistry` PASS. | - | feature 기준 패키지(`outbox/{jpa,postgresql,h2}`, `idempotency/{jpa,postgresql}`)로 이동만 |
|
||||
| S2-#10 | Consider | promotion/benchmark gate가 production classpath에 | 해당 없음(코드 삭제) | 「제거된 코드」 `experimental/next/*`, `MongoAdvancedPromotionGate`·`Evidence`, search·vector(benchmark·readiness gate 포함) 행. grep 0 | - | - |
|
||||
| S2-#12 | Consider | Javadoc이 이력을 서술 | 남음 | 재측정: "used to/until now/never was/no longer" 포함 파일 jpa 25·mongo 36·fileserver 6 | W5 | 불변 조건 1~2줄만 남기고 이력은 git/ADR로 |
|
||||
| S2-#13a | Nit | `JpaTransactionAutoConfiguration` 팩토리 2회 생성, `new JpaTransactionSettings(null ×9)` | 해당 없음(코드 삭제) | 「제거된 코드」 두 번째 엔진(`JpaTransactionAutoConfiguration`)·`JpaTransactionSettings` 행 | - | - |
|
||||
| S2-#13b | Nit | port 구현 이름 규칙 7가지 | 남음 | `OutboxStoreAdapter`, `CanonicalOutboxAppendAdapter`, `Jpa*Store`(notification), `JdbcReconciliationJobStore`, `PostgreSqlOwnerSafeIdempotencyStore`, `SpringTransactionPort`, `LockRegistryDistributedLockAdapter`, `persistence-fileserver/.../JpaFileQuotaService`<br>Wave 3 W3-P23: 미완 — 알림 부분만 완료: `JpaNotificationSideEffectStore` → `JpaNotificationSideEffect`(`NotificationSideEffectPort`), 나머지 알림 구현은 이미 `<Tech><Port>`(`JdbcReconciliationJobStore` 포함). 이유: 행에 열거된 나머지(`OutboxStoreAdapter`, `CanonicalOutboxAppendAdapter`, `PostgreSqlOwnerSafeIdempotencyStore` — P18, `JpaFileQuotaService` — P24, `SpringTransactionPort`·`LockRegistryDistributedLockAdapter` — core)는 다른 묶음 소유이고 S1-#18b와 함께 기계적 개명으로 해야 함 | W3 | `<Tech><Port>` 규칙 하나로 개명(S1-#18b와 함께) |
|
||||
| S2-#13b | Nit | port 구현 이름 규칙 7가지 | 완료 | Wave 3 W3-P28 (Wave 3 라운드 3 커밋): P28 W3 `2619cb18`: 규칙 `<Tech><포트 이름에서 Port를 뺀 것>` 하나로 24개 개명(테스트 클래스 이름 포함). persistence-fileserver `JpaFileMetadata`·`JpaFileQuota`·`JpaQuotaCommit`·`JpaQuotaReclaim`·`JpaUploadSession`(이미 규칙대로인 `JpaCleanupQueue`·`JpaContentReferenceLedger`·`JpaRecoveryQueue`·`JpaStagingUploadLocator`는 유지); fileserver adapter `LocalCleanupContent`·`LocalCopyContent`·`LocalOrphanScan`·`LocalReconciliationContent`·`LocalStorageHealth`·`LocalStorageUsage`·`LocalUploadContent`·`LocalUploadStorage`·`StructuredAdminAudit`·`StructuredFileserverAudit`·`RandomUploadIdentifier`; persistence-jpa core `SpringTransaction`·`JpaOutboxStore`·`JpaDurableOperationStore`·`PostgreSqlIdempotencyStore`·`LockRegistryDistributedLock`·`MeteredDistributedLock`·`DomainContextAuditContext`·`JpaLiveEventReplay`. 행에 적힌 `CanonicalOutboxAppendAdapter`는 P18에서 이미 삭제됨. 유지(이유): `LocalBlockingContentStore`(포트 3개를 구현하는 store 자체), `VerificationCoordinator`(verifier 파이프라인 합성 — 기술 어댑터가 아님), `RoleBased`/`UnenforcedFileAccessPolicy`(이미 `<정책><Port>`). 문서·README·CLAUDE.md의 단순 이름과 PG 통합 테스트의 bean 이름 문자열도 갱신. API surface 재승인(`updateJpaApiSurface -PapproveJpaApiSurfaceChange`, `updatePersistenceFileserverApiSurface -PapprovePersistenceFileserverApiSurfaceChange`, 개수 증가 없음). persistence-jpa·persistence-fileserver·fileserver·composition fileserver·idempotency·application-core·notification·persistence-notification `check`, `:app-bootstrap:architectureTest`·`test` PASS | - | `<Tech><Port>` 규칙 하나로 개명(S1-#18b와 함께) |
|
||||
| S2-#14a | Nit | jpa CLAUDE.md의 "NoSQL은 미래 모듈"·MapStruct 절이 현실과 다름 | 남음 | `adapter/outbound/persistence-jpa/CLAUDE.md:17-19,202-206`(Mongo leaf 이미 존재), `:309-330` MapStruct 절(의존성 없음) | W5 | NoSQL 문장을 현재 leaf 기준으로 고치고 MapStruct 절 삭제 |
|
||||
| S2-#14b | Nit | jpa API surface 파일에 옮겨간 타입 | 남음 | `docs/architecture/jpa-adopter-api-surface.txt:11` `...persistence.fileserver.FileserverSchemaActivation`(지금은 persistence-fileserver leaf) | W5 | 해당 줄 삭제(필요하면 fileserver 쪽 surface로) |
|
||||
| S2-#14c | Nit | Mongo CLAUDE.md `MongoAdvancedProperties` 오기 | 완료 | `6d27356e`: 해당 이름 없음, `adapter/outbound/persistence-mongo/CLAUDE.md:146`이 "flags have no configuration property"로 갱신(`MongoAdvancedSettings`도 삭제) | - | - |
|
||||
@@ -907,7 +907,7 @@ Wave 3 라운드 1 결과로 받은 4건(2026-09-28, desktop):
|
||||
| S4-#17a | Nit | fileserver `*Config`/`*Configuration` 혼재, 클래스 이름의 버전 라벨 | 해당 없음(코드 삭제) | 루트 `*Config`(`FileserverR2Config` 등)와 `R2PublishedReferenceCodec` 삭제. 남은 fileserver 설정 8개는 모두 `*Configuration` | - | - |
|
||||
| S4-#17b | Nit | notification `*ProviderProperties`는 `@ConfigurationProperties`가 아닌 파생 값 | 남음 | `Apns`/`Fcm`/`Ses`/`Smtp`/`Twilio`/`WebPushProviderProperties` 6개. 어느 것도 `@ConfigurationProperties`가 아님 | W5 | #3a 이후 남는 `Ses`·`SmtpProviderProperties`를 `*ProviderProfile`로 이름 변경 |
|
||||
| S4-lead-1 | 권고 | 손으로 만든 canonical JSON codec이 3개 leaf에 있음 (= X1-8) | 해당 없음(코드 삭제) | fileserver 2벌·messaging `DeterministicEnvelopeWriter` 삭제. 남은 건 objectstorage `control/CanonicalJson{Reader,Writer}.java` 하나라 중복 아님 | - | - |
|
||||
| S4-lead-2 | 권고 | 로컬 보안 파일시스템 primitive가 fileserver·objectstorage에 따로 있음 | 남음 | fileserver `platform/local/SafeFileChannelFactory.java:250`(`SecureDirectoryStream`)·`SecureDirectoryWalk.java`. objectstorage `filesystem/LocalObjectPathGuard.java:62-117`은 경로 검사 후 사용 방식(`rejectExistingLinks` → 생성). 방식과 검사가 다름. objectstorage는 `adapter-outbound-support` edge가 없음<br>Wave 3 W3-P24: 미완 — 이유: fileserver primitive 중 `SecureDirectoryWalk`는 JDK만 쓰지만 `SafeFileChannelFactory`는 `IOException`을 Fileserver 에러 코드로 바꾸는 번역을 품고 있어, support로 올리려면 에러 어휘를 떼어 내야 한다. 그리고 objectstorage `LocalObjectPathGuard`는 Path를 돌려주고 호출자(`LocalDevObjectDataStore`·`LocalDevObjectControlStore`·`LocalObjectStreamTransfer`, 약 520줄)가 `Files.*`로 여는 구조라, primitive를 쓰려면 이 I/O를 fd 기준(`SecureDirectoryStream`) 연산으로 다시 써야 한다. registry edge 추가만으로는 끝나지 않는 보안 민감 재작성이라 별도 묶음(권고 행)으로 남김 | W3 | fileserver 쪽 primitive를 `adapter:outbound:support`로 올리고, objectstorage에 support edge를 추가해서 `LocalObjectPathGuard`가 그것을 쓴다(registry 수정 포함) |
|
||||
| S4-lead-2 | 권고 | 로컬 보안 파일시스템 primitive가 fileserver·objectstorage에 따로 있음 | 남음 | fileserver `platform/local/SafeFileChannelFactory.java:250`(`SecureDirectoryStream`)·`SecureDirectoryWalk.java`. objectstorage `filesystem/LocalObjectPathGuard.java:62-117`은 경로 검사 후 사용 방식(`rejectExistingLinks` → 생성). 방식과 검사가 다름. objectstorage는 `adapter-outbound-support` edge가 없음<br>Wave 3 W3-P24: 미완 — 이유: fileserver primitive 중 `SecureDirectoryWalk`는 JDK만 쓰지만 `SafeFileChannelFactory`는 `IOException`을 Fileserver 에러 코드로 바꾸는 번역을 품고 있어, support로 올리려면 에러 어휘를 떼어 내야 한다. 그리고 objectstorage `LocalObjectPathGuard`는 Path를 돌려주고 호출자(`LocalDevObjectDataStore`·`LocalDevObjectControlStore`·`LocalObjectStreamTransfer`, 약 520줄)가 `Files.*`로 여는 구조라, primitive를 쓰려면 이 I/O를 fd 기준(`SecureDirectoryStream`) 연산으로 다시 써야 한다. registry edge 추가만으로는 끝나지 않는 보안 민감 재작성이라 별도 묶음(권고 행)으로 남김<br>Wave 3 W3-P28: 미완 — 한 것(P28 W3 `da49df6c`): fileserver의 descriptor 기반 primitive를 `adapter/outbound/support/.../support/filesystem/SecureDirectoryWalk.java`(이동, public)·`SecureFileAccess.java`(신규: createNew·openForRead/Write·deleteRegularFile·readAttributes·isRegularFile·createParentDirectories)로 올리고, 거부를 에러 코드 없는 타입 있는 `IOException`(`SymbolicComponentException`·`PathEscapeException`·`NotRegularFileException`)으로. fileserver `SafeFileChannelFactory`는 위임 + `LocalStorageFailures` 번역만(P24 메모대로 번역 분리). 테스트: `SecureFileAccessTest` 8건(symlink leaf·symlink 디렉터리 component·`..` 탈출·create-only 충돌·symlink delete 거부·열린 뒤 디렉터리를 link로 바꾸는 race `aDirectorySwappedForALinkAfterItWasOpenedDoesNotRedirectTheOperation`), `SecureDirectoryWalkTest` 2건(support로 이동), `LocalStorageFailuresTest` 2건 FAIL→PASS(P28-new-1). fileserver·support `check`, PG lane `postgresqlFileserver{Migration,Metadata,Reclamation}IntegrationTest` 6·15·15 PASS. 남은 것: objectstorage `LocalObjectPathGuard`를 이 primitive로 바꾸는 재작성(과 objectstorage→support registry edge). 이유: local-dev provider의 쓰기는 "없거나 완전한" 게시를 위해 임시 파일을 `Files.createLink`(link(2))로 create-only 연결하는데, `SecureDirectoryStream`에는 linkat이 없고 `move`는 기존 대상을 덮어쓴다(renameat2 NOREPLACE 미노출). descriptor 기반으로 바꾸면 create-only 원자 게시를 잃거나(대상 선점 후 덮어쓰기 — 읽는 쪽이 빈/부분 객체를 볼 수 있음) native 호출이 필요해 설계 결정이 먼저다. 읽기·retire 경로만 바꾸면 쓰기 경로의 race가 남아 "한 primitive"가 되지 않으므로 이번 묶음에서는 손대지 않음(대상은 local-dev 전용 provider) | W3 | fileserver 쪽 primitive를 `adapter:outbound:support`로 올리고, objectstorage에 support edge를 추가해서 `LocalObjectPathGuard`가 그것을 쓴다(registry 수정 포함) |
|
||||
| S4-lead-3 | 권고 | notification 자체 JDK HTTP gateway·SigV4 서명기 vs httpclient leaf·AWS SDK | 완료 | Wave 3 W3-P23 (Wave 3 라운드 3 커밋): 소유자 결정 17. `SesNotificationProviderAdapter.java:113` `client.sendEmail`(AWS SDK v2 `sesv2` 2.30.0, 카탈로그 `awsSdk`·SDK BOM, objectstorage와 같은 버전). client는 `SesClients.java`: SDK 재시도 끔(`:54` `AwsRetryStrategy.doNotRetry()`), 기본 자격 증명 체인 대신 던지는 provider, 설정 endpoint(라우팅 가드 통과)를 `endpointOverride`, Apache client(redirect 안 따라감). 자격 증명은 기존 계약 유지(설정 `access-key-id` + `ProviderCredentialManager`의 프로필·세대별 secret)로 요청마다 `AwsRequestOverrideConfiguration`에 실음. `JdkNotificationHttpGateway`·`NotificationHttpGateway/Request/Response/TransportException`·`AwsSignatureV4Signer`·`notificationHttpGateway` bean 삭제. SNS 인증서 fetch는 callback 설정 안의 redirect 없음·64KiB 상한 JDK 요청. 검증: SDK client를 로컬 HTTP 가짜(`ProviderFaultHarness`)에 `endpointOverride`로 붙인 계약 테스트 `SesNotificationProviderAdapterTest` 17건(수락·거절·응답 유실=AMBIGUOUS·throttle·첨부 raw MIME·프로필별 서명·경로 `/v2/email/outbound-emails`) + 새 `theSdkRetriesNothingSoAServerErrorIsOneRequest`·`aMessageRejectedAnswerIsAPermanentRejection` PASS, `CrossProviderContractSuiteTest` 5건 PASS. env 키·설정 키 변경 없음 | - | 결정(2026-09-25): AWS SDK(sesv2)로 교체, 자체 JDK gateway·SigV4 서명기 삭제 |
|
||||
| S4-lead-4a | 권고 | adapter `LocalJsonSchemaRegistry` vs vendored `messaging-schema-json` | 해당 없음(코드 삭제) | `LocalJsonSchemaRegistry` grep 0건. 「제거된 코드」 표 123행 | - | - |
|
||||
| S4-lead-4b | 권고 | `adapter:outbound:messaging-kafka`(R0 seam) vs vendored `messaging/messaging-kafka` | 완료 | Wave 3 W3-P18 (Wave 3 라운드 2 커밋): **삭제:** `core/MessageBroker` 계열(MessageBroker, MessagePublisher, OutboundMessage, OutboundMessagePublisher, DisabledMessagePublisher)과 `OutboxEnvelopeJson`, `adapter:outbound:messaging-kafka`의 Java 코드 전부.<br>**relay 경로:** relay는 claim한 row의 `ValidatedIntegrationEvent`를 bridge로만 보낸다(`OutboxMessagePublishAdapter(IntegrationEventPublishPort)`, `src/adapter/outbound/messaging/src/main/java/dev/caskeleton/adapter/outbound/messaging/outbox/OutboxMessagePublishAdapter.java:23`).<br>**leaf를 남긴 이유:** 계획은 leaf 삭제였다. 대신 bridge+starter-kafka를 싣는 코드 없는 capability 묶음으로 남겼다. 한 줄 선택이 유지되고, bridge leaf는 broker 중립으로 남는다.<br>**테스트:** `KafkaCapabilityActivationTest` PASS. | - | legacy `OutboxEvent`에 canonical metadata를 채우는 migration 후 relay를 bridge로 바꾸고 `adapter:outbound:messaging-kafka`와 `core/MessageBroker` 계열 삭제 |
|
||||
@@ -982,7 +982,7 @@ Wave 3 라운드 1 결과로 받은 4건(2026-09-28, desktop):
|
||||
| S6-#7 | Required | sample이 bootstrap 인프라를 복사, 이미 갈라짐 | 완료 | Wave 3 W3-P18 (Wave 3 라운드 2 커밋): **새 leaf `composition:service-runtime`**(`dev.caskeleton.composition.runtime`, edge application-core, shared-contract, adapter-outbound-support, adapter-outbound-identifier):<br>- 원본을 app-bootstrap에서 옮겼다: `tracing`(TracingConfig 외 5), `metrics`(MetricsContractConfig+filter 2), `context`(DomainContextConfig/Settings), `logging`(PseudonymizationConfig, PrivacySettings), `management/security`(ManagementSecurityConfig).<br>- 모두 이 모듈의 `AutoConfiguration.imports`로, sampling bridge는 `spring.factories`로 등록한다.<br>- app-bootstrap과 sample이 `runtimeOnly project(':composition:service-runtime')`를 쓴다.<br>**sample:** 복사본 10개와 `spring.factories`를 삭제했다. 원본을 쓰므로 `staging=0.10` 분기도 사라졌다.<br>**sample actuator chain:** 복사본이 아니라 공개 데모라는 샘플만의 결정이라 남겼다. bean 이름을 `actuatorSecurityFilterChain`으로 바꿔 공용 chain이 물러나게 했다(`ConditionalOnMissingBean(name)`).<br>**테스트:** `ServiceRuntimeRegistrationTest` 4개(신규), 옮긴 테스트 9 클래스 — `:composition:service-runtime:test` 86 PASS. `ActuatorSecurityHttpTest`, `DefaultCompositionBootTest`, `StartupOrderContractTest`, `ConfigurationNamespaceContractTest` 갱신 후 PASS. | - | 소유자 결정대로 멱등성 executor·outbox relay 조립을 `composition:*` 모듈로 옮겨 두 root가 함께 쓰고, tracing·logging·metrics·context·management는 공용 library leaf로(registry edge 추가), staging 분기 삭제 |
|
||||
| S6-#8 | Required | sample root가 다른 leaf 패키지를 넓게 scan | 완료 | Wave 3 W3-P25 (Wave 3 라운드 2 커밋): `SamplePortfolioApplication`: `@ComponentScan("dev.caskeleton.sample")`·`@ConfigurationPropertiesScan("dev.caskeleton.sample")`, 제외는 `WebSecurityAutoConfiguration` 하나(`SamplePortfolioApplication.java:31-32`). web·objectstorage는 각 auto-config로. `SamplePublicAccessSecurityConfigTest.sampleCompositionRootExcludesOnlyTheWebSecurityRoot`·`sampleCompositionRootScansOnlyTheSamplePackage`(옛 exclude-filter 단언 대체). sample `test`·`integrationTest` 51·`systemTest` 3·`webSystemTest` 5 PASS | - | scan을 `dev.caskeleton.sample`로 좁히고 web·identifier·objectstorage는 각 leaf auto-config로 받기(보안 설정 2개는 exclude/property로 끔) |
|
||||
| S6-#9 | Required | sample `application.yml` 중 읽는 코드 없는 블록 | 남음 | 326줄 중 약 101줄: `src/sample-portfolio/src/main/resources/application.yml:150-177`(capabilities.cache), `:180-181`(bootstrap), `:210-226`(logging), `:255-279`(app.cache.redis), `:280-283`(messaging), `:284-288`(notification), `:289-308`(outbound.http). sample classpath에 해당 binder 없음(`src/sample-portfolio/build.gradle:48-83`) | W5 | 해당 블록 삭제 |
|
||||
| S6-#10a | Consider | sample 대표 예제가 poster-image에 묻힘, 패키지 종류별·기능별 혼재 | 남음 | poster 관련 main 약 5.9k줄 vs WorkLog 약 2.2k줄. `SP/application/`에 `command/query/event/port/exception`과 `poster/posterimage/worklog` 공존<br>Wave 3 W3-P25: 미완 — 이유: 기능별 패키지 재배치와 poster-image 별도 sample 모듈 분리는 sample 전체 파일 이동(+`modules.json` leaf 등록)이라, 동시에 도는 P18(sample outbox·멱등성·`PosterEventPublisher`)·P24(object storage)와 같은 파일을 대량으로 겹친다. 통합 뒤 단독 작업으로 넘김. 이번 묶음에서 legacy 모드 삭제(S6-#10b)로 poster 표면은 줄었다 | W3 | 기능별 패키지로 정리, poster-image는 objectstorage 검증용 별도 sample 모듈로 이동 |
|
||||
| S6-#10a | Consider | sample 대표 예제가 poster-image에 묻힘, 패키지 종류별·기능별 혼재 | 남음 | poster 관련 main 약 5.9k줄 vs WorkLog 약 2.2k줄. `SP/application/`에 `command/query/event/port/exception`과 `poster/posterimage/worklog` 공존<br>Wave 3 W3-P25: 미완 — 이유: 기능별 패키지 재배치와 poster-image 별도 sample 모듈 분리는 sample 전체 파일 이동(+`modules.json` leaf 등록)이라, 동시에 도는 P18(sample outbox·멱등성·`PosterEventPublisher`)·P24(object storage)와 같은 파일을 대량으로 겹친다. 통합 뒤 단독 작업으로 넘김. 이번 묶음에서 legacy 모드 삭제(S6-#10b)로 poster 표면은 줄었다<br>Wave 3 W3-P28: 미완 — / P28 에이전트가 세션 재시작으로 중단(미커밋) — P30으로 | W3 | 기능별 패키지로 정리, poster-image는 objectstorage 검증용 별도 sample 모듈로 이동 |
|
||||
| S6-#10b | Consider | poster-image legacy API 모드 | 해당 없음(코드 삭제) | Wave 3 W3-P25 (Wave 3 라운드 2 커밋): `d54909c4`: `LegacyPosterImageController`·`UploadPosterImageUseCase`·`UploadPosterImageCommand`·`LegacyPosterImageAttachment`·`PosterImageApiConfig`·`PosterImageApiSettings`(LEGACY 모드)·`Poster.attachImage`·`Poster.imageKey()`·dual-read `rehydrate` 삭제. `PosterEntity`는 `image_key`를 매핑하지 않고, CAS attach가 `image_key = NULL`로 pre-V8 행을 정규 경로로 받는다(`PosterImageAttachmentCasRepository.java:32`). `PosterRepositoryAdapterIntegrationTest.aPreV8RawKeyRowReadsBackWithoutAnImage`·`canonicalAttachClearsAPreV8RawKeyOnTheSameRow` PASS(삭제에 따른 새 동작이라 FAIL 재현 없음). `PosterResponse.imageKey` wire 이름은 유지하고 published reference를 싣는다. sample `local` 프로필·systemTest yml의 `mode: legacy`·`object-storage.legacy` 블록 삭제 | - | legacy 모드와 전용 타입 삭제 |
|
||||
| S6-#10c | Consider | 상태 머신이 application 계층, use case 생성자 14개 | 완료(부분 수정 방향 변경) | Wave 3 W3-P25 (Wave 3 라운드 2 커밋): `PublishPosterImageUseCase` 설정값 인자(destination·epoch·intentTtl·handoffLease)를 `PosterImagePublicationParameters` record 하나로(생성자 14→11, 양수 검증). 상태 머신(`PosterImageUploadIntent`)의 domain 이동은 하지 않음: 필드가 `application-objectstorage`·`application-core` 값 타입(`ObjectOperationKey`, `ObjectStageHandle`, `ObjectVersionToken`, `ObjectContentIdentity`, `ObjectMediaType`, `RequestFingerprint`)이라 domain으로 옮기면 domain→application 의존이 생긴다(HARD-STOP 1과 같은 방향 위반). sample `test` PASS | - | 상태 머신을 domain으로, 설정값 인자(TTL·lease·epoch·destination)를 record 하나로 |
|
||||
| S6-#10d | Consider | `WorkLogSortField`(domain)가 HTTP 이름과 persistence 이름을 같이 앎 | 완료 | Wave 3 W3-P25 (Wave 3 라운드 2 커밋): `WorkLogSortField`·`PosterSortField`는 논리 필드만. 요청 이름은 web mapper `SORT_FIELDS`(`WorkLogWebMapper.java:24`, `PosterWebMapper.java:19`), persistence 속성은 `sortProperty`(`WorkLogPersistenceMapper.java:57`, `PosterPersistenceMapper.java:38`). 계약 테스트·integration 51 PASS | - | 요청 이름 매핑은 web mapper로, persistence 이름은 persistence mapper로; domain enum은 논리 필드만 |
|
||||
@@ -1199,16 +1199,16 @@ Wave 1–2 구현 묶음(`P1`–`P13`)이 작업 중 찾은 결함과 통합 검
|
||||
| P16-new-6 | 발견 | persistence-fileserver 공개 타입의 adopter import를 보는 검사가 없어짐(예전 정규식 테스트가 접두어 전체를 봤음). | 완료 | Wave 3 W3-P27 (Wave 3 라운드 3 커밋): `976c175f`: persistence-fileserver에 `ca.api-surface`, 공개 타입 24개 기준선과 adopter 목록(`FileserverSchemaActivation`) 승인 — 목록에서 빼면 composition import로 `verifyPersistenceFileserverApiSurface` 실패 | - | persistence-fileserver에 `ca.api-surface` 적용 — 빌드 잔여 묶음 |
|
||||
| P16-new-7 | 발견 | `docs/study/postgresql-jpa-walkthrough.ko.md` §15.6 등이 삭제된 JPA evidence manifest를 설명. | 남음 | Wave 3 P16 결과 파일 | W5 | 결정 6: 현재 코드 기준으로 갱신 |
|
||||
| P24-new-1 | 발견 | S3 응답 bridge가 source 무효화 전에 결과를 게시하고, 실패 원인 기록 전에 취소해 테스트가 간헐 실패(P14-new-2·P16-new-4의 원인). | 완료 | Wave 3 P24: 순서 수정, bridge 테스트 40회 반복 통과 | - | - |
|
||||
| P24-new-2 | 발견 | legacy upload 삭제 뒤 `PosterEventPublisher.publishImageAttached`·`PosterImageAttached` 호출자 0. | 남음 | Wave 3 P24 결과 파일 | W3 | P18 통합 뒤 삭제(같은 파일) |
|
||||
| P24-new-3 | 발견 | `FileVerifier`가 application-fileserver에 있지만 fileserver adapter만 쓴다. | 남음 | Wave 3 P24 결과 파일 | W3 | adapter로 이동 |
|
||||
| P24-new-2 | 발견 | legacy upload 삭제 뒤 `PosterEventPublisher.publishImageAttached`·`PosterImageAttached` 호출자 0. | 해당 없음(코드 삭제) | Wave 3 W3-P28 (Wave 3 라운드 3 커밋): P28 D `a49342e2`: `PosterEventPublisher.publishImageAttached`, `domain/poster/PosterImageAttached`, `PosterImageAttachedPayload`, `PortfolioEventContracts.POSTER_IMAGE_ATTACHED`와 그 bean, `contracts/messaging/poster.image-attached/v1.schema.json` 삭제. `git grep "ImageAttached\b"` 0건. `:sample-portfolio:test` PASS | - | P18 통합 뒤 삭제(같은 파일) |
|
||||
| P24-new-3 | 발견 | `FileVerifier`가 application-fileserver에 있지만 fileserver adapter만 쓴다. | 완료 | Wave 3 W3-P28 (Wave 3 라운드 3 커밋): P28 W3 `12f0b183`: `FileVerifier`를 `application-fileserver/.../api/security`에서 `adapter/outbound/fileserver/.../platform/verification/FileVerifier.java`로 이동(사용처는 그 패키지의 verifier 5개·`VerificationCoordinator`·`FileserverVerificationConfiguration`뿐). application은 `FileVerificationPort`만 본다 | - | adapter로 이동 |
|
||||
| P25-new-1 | 발견 | `TomcatWebSocketAbuseIT` shutdown 테스트가 부하 중 `20.0006s < 20s`로 한 번 실패, 재실행 4회 통과(타이밍 의존). | 남음 | Wave 3 P25 결과 파일 | W4 | 시간 경계 단언을 결정적 신호로 |
|
||||
| P25-new-2 | 발견 | legacy upload 삭제 뒤 `PosterEventPublisher.publishImageAttached`·`PosterImageAttached` 호출자 0(= P24-new-2). | 남음 | Wave 3 P25 결과 파일 | W3 | P24-new-2와 함께(P28) |
|
||||
| P25-new-2 | 발견 | legacy upload 삭제 뒤 `PosterEventPublisher.publishImageAttached`·`PosterImageAttached` 호출자 0(= P24-new-2). | 해당 없음(코드 삭제) | Wave 3 W3-P28 (Wave 3 라운드 3 커밋): P24-new-2와 같음(`a49342e2`) | - | P24-new-2와 함께(P28) |
|
||||
| P25-new-3 | 발견 | sample `local` 프로필이 기본값과 같은 `object-storage.enabled=false`만 남김. | 남음 | Wave 3 P25 결과 파일 | W5 | 불필요한 설정 삭제 또는 이유 주석 |
|
||||
| P18-new-1 | 발견 | messaging outbox의 손으로 쓴 header JSON reader가 `\\`로 끝나는 값에서 다음 header를 삼켰다. | 완료 | Wave 3 P18: PostgreSQL `jsonb_object`/`jsonb_each_text`, `OutboxPostgresIT.aHeaderValueEndingInABackslashRoundTripsWithoutSwallowingTheNextHeader` FAIL→PASS | - | - |
|
||||
| P18-new-2 | 발견 | root `CLAUDE.md`가 legacy outbox/realtime seam이 `src/messaging/CLAUDE.md`에 기록돼 있다고 적음(cutover 끝남). | 완료 | Wave 3 라운드 2 통합: `CLAUDE.md` Module families 문장 수정 | - | - |
|
||||
| P18-new-3 | 발견 | actuator security chain이 auto-configuration이 되어, web security를 직접 켜지 않은 조립은 Boot 기본 actuator chain을 받는다(설계 노트). | 남음 | Wave 3 P18 결과 파일, `composition/service-runtime/.../ManagementSecurityConfig.java` | W5 | service-runtime README에 켜짐 조건 명시 |
|
||||
| P23-new-1 | 발견 | fileserver migration V1–V5가 `applied-migrations.sha256`에 고정돼 있지 않다. | 남음 | Wave 3 P23 결과 파일 | W3 | `AppliedMigrationImmutabilityTest`에 fileserver 경로 추가 + 5줄. P28 |
|
||||
| P23-new-2 | 발견 | profile마다 만드는 SES SDK client를 닫지 않는다(기동 때 한 번이라 유한). | 남음 | Wave 3 P23 결과 파일 | W3 | provider 종료 시 close. P28 |
|
||||
| P23-new-1 | 발견 | fileserver migration V1–V5가 `applied-migrations.sha256`에 고정돼 있지 않다. | 완료 | Wave 3 W3-P28 (Wave 3 라운드 3 커밋): P28 W2 `b13cf08b`: `AppliedMigrationImmutabilityTest.MIGRATION_ROOTS`에 `../persistence-fileserver/src/main/resources/db/migration` 추가 → `everyVersionedMigrationIsPinned` FAIL(`AssertionError at AppliedMigrationImmutabilityTest.java:72`, `jpa/fileserver/V1..V5` 미고정) → `applied-migrations.sha256`에 5줄 추가 후 PASS. `persistence-jpa/build.gradle` test `inputs.dir(...fileserver migration)` 추가. 새 migration 버전은 추가하지 않음 | - | `AppliedMigrationImmutabilityTest`에 fileserver 경로 추가 + 5줄. P28 |
|
||||
| P23-new-2 | 발견 | profile마다 만드는 SES SDK client를 닫지 않는다(기동 때 한 번이라 유한). | 완료 | Wave 3 W3-P28 (Wave 3 라운드 3 커밋): P28 W2 `b13cf08b`: `ProviderRuntimeRegistryTest.closingTheRegistryClosesTheAdapterOfEveryRegisteredGeneration` FAIL(컴파일 실패 `cannot find symbol registry.close()`) → PASS; `SesNotificationProviderAdapterTest.closingTheAdapterClosesItsSdkClient` PASS. `SesNotificationProviderAdapter implements AutoCloseable`(`close()`→`client.close()`), `ProviderRuntime.release()`, `ProviderRuntimeRegistry implements AutoCloseable`(현재·drain 세대 모두 release) — `providerRuntimeRegistry` `@Bean`의 추론 destroy method로 context 종료 때 호출. `:adapter:outbound:notification:check` PASS | - | provider 종료 시 close. P28 |
|
||||
| P23-new-3 | 발견 | `app-bootstrap/build.gradle` 알림 선택 줄 주석이 persistence-jpa 줄을 함께 풀라고 함(composition이 직접 가져옴). | 완료 | Wave 3 라운드 3 통합: 주석 수정 | - | - |
|
||||
| ORCH-new-2 | 발견 | `NotificationPayloadAtRestContractTest`가 저장소 소스·migration을 읽지만 test inputs를 선언하지 않아(`notification/build.gradle:98`이 필요 없다고 주장) 파일이 옮겨져도 up-to-date로 건너뜀. P23 worktree에서 통과, main 통합에서 실패(옛 `persistence-jpa` 경로·`build/` 경합 walk). | 남음 | 경로와 walk 범위는 통합 때 수정(`src/main/java`만) | W4 | 읽는 파일을 test `inputs`로 선언(CLAUDE.md build-logic 규칙) |
|
||||
| ORCH-new-3 | 발견 | `web-advanced` `WebStreamingSoakIT.concurrent arrivals never exceed the node's ceiling`가 부하 중 `expected: 1000 but was: 1001`로 실패, 단독 3회 통과 — 상한을 1 넘는 실제 경합일 수 있다. | 완료 | Wave 3 W3-P19 (Wave 3 라운드 3 커밋): 커밋 `c3380270`. 원인: `WebStreamRegistry.register`가 `compute()` 안에서 `sessions.size()`를 읽음 — compute는 한 bin만 잠그고 크기 카운터는 잠금 해제 뒤 갱신되므로 다른 bin의 두 도착이 모두 999를 보고 삽입(실제 경합, 테스트 타이밍 문제 아님: 먼저 단언하는 `activeStreams()`가 1001). 수정: AtomicInteger CAS로 슬롯 선예약 + `putIfAbsent`, 중복·deregister는 슬롯 반환. 테스트 `stream/WebStreamRegistryAdmissionTest`(경쟁 도착 200라운드, 슬롯 반환 2건). FAIL 근거: P27 통합 ci의 `expected: 1000 but was: 1001` — 로컬에서는 수정 전 soak 형태 6회 + 200라운드로도 재현되지 않았다(창이 `addCount` 한 구간뿐). 수정 후 `WebStreamingSoakIT`+새 테스트 3회 반복 통과 | - | 재현(반복·부하)으로 경합 여부 판정, 경합이면 admission 카운터 수정. P19 |
|
||||
@@ -1217,8 +1217,10 @@ Wave 1–2 구현 묶음(`P1`–`P13`)이 작업 중 찾은 결함과 통합 검
|
||||
| P21-new-3 | 발견 | `src/messaging/CLAUDE.md`가 `MessagingPublicSurfaceContractTest`를 인용 — 테스트는 app-bootstrap에 있다(P21은 없다고 보고). 통합 때 이 테스트가 P21 변경(reactive facade 삭제, leaf 병합, starter-kafka 공개 consumer seam)을 반영하지 못해 실패 → 기대값 수정, starter-kafka에 `api kafka-clients` 선언. | 남음 | Wave 3 라운드 3 통합 | W5 | messaging CLAUDE.md의 테스트 위치 문구를 app-bootstrap 경로로 |
|
||||
| P22-new-1 | 발견 | bootstrap `SecretSourceValidator`가 persistence-jpa의 모듈 스위치를 읽어 `APP_DATASOURCE_PASSWORD` 필요 여부를 판정(모듈 지식이 bootstrap에). | 남음 | Wave 3 P22 결과 파일 | W3 | Redis처럼 persistence-jpa가 secret 요구를 기여. P20 |
|
||||
| P22-new-2 | 발견 | `infra/redis-sdk/acl/application.acl`·`all-accounts.acl`이 pub/sub 삭제 뒤에도 `+@pubsub`·`&prod:*`를 준다(최소 권한 위반, fixture). | 남음 | Wave 3 P22 결과 파일 | W3 | ACL fixture에서 제거 후 topology lane 재실행. P20 |
|
||||
| P22-new-3 | 발견 | redis-sdk 공개 API가 runtime 타입을 노출하면서 runtime을 `implementation`으로만 의존. `ca.spring-library`에 `api` 구성이 없어 한 줄로 못 고침. | 남음 | Wave 3 P22 결과 파일, 통합 때 시도 | W3 | 컨벤션에 `java-library` 적용 또는 공개 표면에서 runtime 타입 제거. P29 |
|
||||
| P22-new-3 | 발견 | redis-sdk 공개 API가 runtime 타입을 노출하면서 runtime을 `implementation`으로만 의존. `ca.spring-library`에 `api` 구성이 없어 한 줄로 못 고침. | 완료 | Wave 3 W3-P29 (Wave 3 라운드 3 커밋): `3967c9ef`. redis-sdk만 `java-library` + `api project(':adapter:outbound:redis-runtime')` / 통합 검증 통과(redis-sdk java-library + api redis-runtime) | - | 컨벤션에 `java-library` 적용 또는 공개 표면에서 runtime 타입 제거. P29 |
|
||||
| ORCH-new-4 | 발견 | redis-sdk `RedisSdkModuleBoundaryTest`·`RedisSupportMatrixTest`가 옛 split package(`redis-runtime/.../redis/sdk`)를 훑음 — P22 worktree에서 통과, main 통합에서 `NoSuchFileException`(ORCH-new-2와 같은 유형: 저장소 파일을 읽지만 test inputs 미선언). | 남음 | 경로는 통합 때 수정(`redis-sdk` 하나) | W4 | 읽는 파일을 test `inputs`로 선언 |
|
||||
| P19-new-1 | 발견 | notification `platform.api.TenantId`가 비어 있지 않음·100자 이하만 검사 — web·GraphQL이 거부하는 tenant(공백·줄바꿈·경로 문자)를 받는다. 강화하면 이미 저장된 행을 못 읽을 수 있다. | 남음 | Wave 3 P19 결과 파일 | W3 | 읽기는 관대하게, 새 쓰기만 공용 `TenantId` 문법으로. P30 |
|
||||
| P19-new-2 | 발견 | redis-session 인증 경로(`PrimitiveSessionSecurityContextRepository.java:116`)가 세션에 tenant를 저장하지 않아 JWT 경로와 달리 principal에 tenant가 없다. | 남음 | Wave 3 P19 결과 파일 | W3 | 세션 저장·복원에 tenant 포함. P30 |
|
||||
| P19-new-3 | 발견 | `docs/study/postgresql-jpa-walkthrough.ko.md:818`이 삭제된 `JpaStreamScope`를 설명. | 남음 | Wave 3 P19 결과 파일 | W5 | 결정 6: 현재 코드 기준으로 |
|
||||
| P28-new-1 | 발견 | fileserver `AtomicMoveContentPublisher`·`ContentPublishVerification`이 보안 walk를 직접 불러 거부를 번역하지 않고 내보냈다. | 완료 | Wave 3 P28 `da49df6c` | - | - |
|
||||
| ORCH-new-5 | 발견 | P18의 V19가 persistence-jpa `postgresqlMigrationIntegrationTest` 기대값(버전 목록·제약 목록, legacy 미발행 행 삽입)에 반영되지 않았다 — P18 게이트에 이 lane이 없었다. messaging `OutboxPostgresIT`는 P29의 jvm-test-suite 전환 뒤 main 리소스가 jar로 와서 migration 목록을 `File`로 못 읽었다. | 완료 | Wave 3 라운드 3 통합: V19·제약 추가, legacy 행은 PUBLISHED로(V19가 미발행 legacy 행을 거부하는 것이 의도), jar/디렉터리 모두 읽는 목록 조회 — `integrationCheck` 통과 | - | - |
|
||||
|
||||
@@ -318,12 +318,12 @@ application-core:
|
||||
+ inTransaction(TransactionRequest, Supplier) : TransactionResult<T>
|
||||
|
||||
adapter:
|
||||
SpringTransactionPort implements PolicyTransactionPort
|
||||
SpringTransaction implements PolicyTransactionPort
|
||||
├─ 레거시 4모드 → 미리 만들어 둔 TransactionTemplate 3개
|
||||
└─ inTransaction → SpringPolicyTransactionPort (package-private 위임체)
|
||||
```
|
||||
|
||||
### 3.1 `SpringTransactionPort` — 레거시 4-mode
|
||||
### 3.1 `SpringTransaction` — 레거시 4-mode
|
||||
|
||||
모드별로 `TransactionTemplate`을 **생성 시점에 하나씩 미리 만들어 둔다.**
|
||||
|
||||
@@ -1627,7 +1627,7 @@ provision하므로 DDL 체크를 건너뛴다.
|
||||
`JdbcLockRegistry(lockRepository, settings.leaseTtl())` — SI 7.0 이후 기본 TTL은 repository
|
||||
setter가 아니라 **registry 생성자**에서 설정한다.
|
||||
|
||||
`LockRegistryDistributedLockAdapter`의 계약:
|
||||
`LockRegistryDistributedLock`의 계약:
|
||||
|
||||
- **D4 — transaction-commit ordering invariant.** 이 어댑터는 트랜잭션 경계를 관리하지 않는다.
|
||||
호출자는 보호된 트랜잭션이 **커밋된 뒤에만** 핸들을 release해야 한다. 커밋 전에 release하면
|
||||
@@ -1670,7 +1670,7 @@ setter가 아니라 **registry 생성자**에서 설정한다.
|
||||
6. **Spring stereotype 없음** — 두 composition root가 `dev.caskeleton.adapter`를
|
||||
component-scan하므로 `@Repository`를 붙이면 선택하지 않은 배포에서도 빈이 된다.
|
||||
|
||||
### 10.1 `PostgreSqlOwnerSafeIdempotencyStore`
|
||||
### 10.1 `PostgreSqlIdempotencyStore`
|
||||
|
||||
`IdempotencyStorePort` 구현. 상태:
|
||||
`CLAIMED → EXECUTING → COMPLETED | FAILED_RETRYABLE | ABANDONED`.
|
||||
@@ -2442,7 +2442,7 @@ audited 엔티티에 대한 `update`가 audit 컬럼을 set하는지 확인한
|
||||
> 통과와 실패 케이스가 한 번도 실행된 적 없는 아키텍처 규칙은 **모양을 알 수 없는 규칙**이고,
|
||||
> production 그래프에는 오늘 audited bulk update가 없어서 그래프만으로는 통과만 보여줄 수 있다.
|
||||
|
||||
`DomainContextAuditContextPort`는 actor를 `DomainContextPropagator`에서 읽고, 빈/blank면
|
||||
`DomainContextAuditContext`는 actor를 `DomainContextPropagator`에서 읽고, 빈/blank면
|
||||
`"system"`으로 떨어뜨린다 — scheduler / Flyway / anonymous 경로에서도 NOT NULL
|
||||
`created_by`/`updated_by`를 항상 만족시키려고. `ACTOR_KEY`를 상수로 격리해서 canonical actor
|
||||
key가 바뀌어도 **정확히 한 클래스**만 손대면 된다.
|
||||
@@ -2690,8 +2690,8 @@ app.fileserver-platform.enabled && transaction-provider != none
|
||||
> 정규식으로 제외하고, 그 제외는 **옳다**: 그게 optional capability를 optional하게 만든다.
|
||||
>
|
||||
> 빠진 건 나머지 절반이다. 이 leaf의 여덟 클래스가 scanned component로 쓰여 있는데 —
|
||||
> `SpringTransactionPort`, `PersistenceExceptionTranslator`, `StandardSqlStateErrorMapping`,
|
||||
> `DomainContextAuditContextPort`, idempotency store와 reaper, outbox store와 reaper —
|
||||
> `SpringTransaction`, `PersistenceExceptionTranslator`, `StandardSqlStateErrorMapping`,
|
||||
> `DomainContextAuditContext`, idempotency store와 reaper, outbox store와 reaper —
|
||||
> 넓은 scan이 그들에게 도달하기를 멈추자 **아무것도 도달하지 않았다.** `@Component`와
|
||||
> `@Repository`가 붙어 있고 **돌고 있는 어떤 애플리케이션에서도 빈이 아니었다**:
|
||||
> 특히 `TransactionPort`는 구현이 전혀 없어서, **트랜잭션을 여는 모든 유스케이스가 열
|
||||
@@ -3296,12 +3296,12 @@ grep -rnE "[0-9]+ ?(개 ?)?-?(leaf|leaves)" docs | grep -v "^docs/superpowers/\|
|
||||
|---|---|
|
||||
| `PostgreSqlIdempotencyStoreConfig` | `@ConditionalOnProperty(ca-skeleton.capabilities.idempotency.provider = postgresql)` |
|
||||
| `IdempotencyReaper` | 동일 |
|
||||
| `OutboxStoreAdapter` | **없음** (`@Repository`만) |
|
||||
| `JpaOutboxStore` | **없음** (`@Repository`만) |
|
||||
| `OutboxReaper` | **없음** (`@Component` + `@Scheduled`) |
|
||||
|
||||
`JpaAdapterComponentsConfig`가 `...persistence.outbox` 패키지를 component scan한다. 따라서
|
||||
`ca-skeleton.persistence-jpa.enabled=true`이면 `ca-skeleton.outbox.enabled=false`여도
|
||||
`OutboxStoreAdapter`와 `OutboxReaper`가 빈이 되고, reaper의 `@Scheduled`가 10분마다
|
||||
`JpaOutboxStore`와 `OutboxReaper`가 빈이 되고, reaper의 `@Scheduled`가 10분마다
|
||||
`delete from outbox_event where status='PUBLISHED' and occurred_at < ?`를 돈다.
|
||||
|
||||
**확인**
|
||||
@@ -3330,7 +3330,7 @@ V1 `OutboxReaper`의 bulk delete가 매 주기 실패한다.** 지금은 V2가 c
|
||||
않았지만, cutover 런북에 "V1 reaper/relay 먼저 끄기"가 명시돼야 한다.
|
||||
|
||||
**제안**
|
||||
- `OutboxStoreAdapter` / `OutboxReaper`에 `@ConditionalOnProperty(prefix="ca-skeleton.outbox",
|
||||
- `JpaOutboxStore` / `OutboxReaper`에 `@ConditionalOnProperty(prefix="ca-skeleton.outbox",
|
||||
name="enabled", havingValue="true")` 추가.
|
||||
- cutover 절차에 V1 writer 비활성화 단계를 명시.
|
||||
|
||||
@@ -3495,7 +3495,7 @@ import하지 않는다** (§11.0 측정).
|
||||
- **`SafeSortMapper.MAX_SORT_TERMS = 4`**: registry에 더 많이 등록할 수 있지만 요청은 4개까지.
|
||||
의도로 보인다.
|
||||
- **`PgRangeCodec.parse("empty")` 거부**: 의도이고 근거가 적혀 있다.
|
||||
- **`SpringTransactionPort`의 non-`@Autowired` 생성자들**: 테스트 전용
|
||||
- **`SpringTransaction`의 non-`@Autowired` 생성자들**: 테스트 전용
|
||||
(`withoutAcquisitionEnvelope`). package-private이라 표면이 넓어지지 않는다.
|
||||
|
||||
---
|
||||
|
||||
BIN
Binary file not shown.
@@ -78,7 +78,7 @@ The design gives `web-idempotency` its own `IdempotencyStore`, `IdempotencyRecor
|
||||
`IdempotencyState`, `IdempotencyScope` and `RequestFingerprint`. This repository already has the
|
||||
equivalents in `application-core/idempotency` — `IdempotencyStorePort`, `IdempotencyState`,
|
||||
`IdempotencyScopeDigest` and `RequestFingerprint` — with two provider stores behind the port:
|
||||
PostgreSQL (`PostgreSqlOwnerSafeIdempotencyStore` in `persistence-jpa`) and Redis
|
||||
PostgreSQL (`PostgreSqlIdempotencyStore` in `persistence-jpa`) and Redis
|
||||
(`RedisIdempotencyStoreAdapter` in `cache-redis`), selected by
|
||||
`ca-skeleton.capabilities.idempotency.provider`. That is what the design's Tasks 39 and 40 ask for,
|
||||
built in the direction the registry permits.
|
||||
@@ -118,7 +118,7 @@ holding a JPA store for long-running operations, with the port
|
||||
|
||||
This is the same shape as §6 and takes the same resolution — the one the repository already used
|
||||
for idempotency, where `IdempotencyStorePort` lives in `application-core` and
|
||||
`PostgreSqlOwnerSafeIdempotencyStore` in `persistence-jpa`:
|
||||
`PostgreSqlIdempotencyStore` in `persistence-jpa`:
|
||||
|
||||
| Design type | Here |
|
||||
| --- | --- |
|
||||
|
||||
@@ -23,6 +23,12 @@ why this rationale lives in Markdown next to the artifact instead of inside it.
|
||||
|
||||
- realm role `user` — the baseline role the application authorizes ordinary calls on
|
||||
- client role `ca-skeleton-api:graphql-query` — permission to execute a GraphQL query
|
||||
- client roles `notification-submit`, `notification-template-publish`, `operation-submit` — the
|
||||
platform permissions `security.yml` maps them to
|
||||
- client roles `ROLE_FILE_READ` and `ROLE_FILE_WRITE` — the fileserver's read and write tiers, which
|
||||
`security.yml` also maps to `file:read` and to `file:upload`, `file:delete`, `file:copy`,
|
||||
`file:move`; `ROLE_FILE_ADMIN` (`file:admin`) is defined but not granted to the service account,
|
||||
since the management plane is off by default
|
||||
- a service account for the client-credentials grant the qualification lane uses
|
||||
- audience and realm/client role mappers, so the issued token carries what the resource server
|
||||
validates
|
||||
|
||||
@@ -32,6 +32,24 @@
|
||||
"description": "Submit a durable operation and cancel one's own.",
|
||||
"composite": false,
|
||||
"clientRole": true
|
||||
},
|
||||
{
|
||||
"name": "ROLE_FILE_READ",
|
||||
"description": "Fileserver data-plane reads (file:read): metadata, download, upload status, on one's own files. The name is the fileserver's default read tier.",
|
||||
"composite": false,
|
||||
"clientRole": true
|
||||
},
|
||||
{
|
||||
"name": "ROLE_FILE_WRITE",
|
||||
"description": "Fileserver data-plane writes (file:upload, file:delete, file:copy, file:move) on one's own files. The name is the fileserver's default write tier, so one role satisfies both the permission and the tier check.",
|
||||
"composite": false,
|
||||
"clientRole": true
|
||||
},
|
||||
{
|
||||
"name": "ROLE_FILE_ADMIN",
|
||||
"description": "Fileserver management plane (file:admin): storage health, orphan reconcile, re-verify, force delete. Not granted to the service account.",
|
||||
"composite": false,
|
||||
"clientRole": true
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -103,7 +121,9 @@
|
||||
"graphql-query",
|
||||
"notification-submit",
|
||||
"notification-template-publish",
|
||||
"operation-submit"
|
||||
"operation-submit",
|
||||
"ROLE_FILE_READ",
|
||||
"ROLE_FILE_WRITE"
|
||||
]
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,7 +2,6 @@ plugins {
|
||||
id 'ca.spring-library'
|
||||
id 'ca.spring-config'
|
||||
id 'java-test-fixtures'
|
||||
id 'ca.auxiliary-source-set'
|
||||
id 'ca.api-surface'
|
||||
}
|
||||
|
||||
@@ -18,8 +17,18 @@ plugins {
|
||||
// coordinates the BOM does not manage).
|
||||
description = 'Inbound adapter: GraphQL API (Spring for GraphQL, GraphQL execution platform)'
|
||||
|
||||
auxiliarySourceSets {
|
||||
sourceSet('systemTest') { compilesAgainst 'main' }
|
||||
testing {
|
||||
suites {
|
||||
systemTest(JvmTestSuite) {
|
||||
dependencies {
|
||||
implementation project()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
configurations {
|
||||
systemTestImplementation.extendsFrom testImplementation
|
||||
systemTestRuntimeOnly.extendsFrom testRuntimeOnly
|
||||
}
|
||||
|
||||
|
||||
|
||||
+60
-20
@@ -3,16 +3,30 @@ package dev.caskeleton.adapter.inbound.web.fileserver.admin;
|
||||
import dev.caskeleton.adapter.inbound.web.core.OwnsAbsoluteWebRoute;
|
||||
import dev.caskeleton.adapter.inbound.web.fileserver.dto.UploadedFileResponse;
|
||||
import dev.caskeleton.adapter.inbound.web.fileserver.security.FileserverRequestContextFactory;
|
||||
import dev.caskeleton.application.fileserver.admin.FileserverAdminService;
|
||||
import dev.caskeleton.application.fileserver.admin.ForceDeleteCommand;
|
||||
import dev.caskeleton.application.fileserver.admin.IncompleteUploadView;
|
||||
import dev.caskeleton.application.fileserver.admin.OrphanObject;
|
||||
import dev.caskeleton.application.fileserver.admin.OrphanReconcileCommand;
|
||||
import dev.caskeleton.application.fileserver.admin.OrphanReconcileReport;
|
||||
import dev.caskeleton.application.fileserver.admin.RuntimeCapabilityReport;
|
||||
import dev.caskeleton.application.fileserver.admin.StorageHealthReport;
|
||||
import dev.caskeleton.application.fileserver.api.FileId;
|
||||
import dev.caskeleton.application.fileserver.api.security.RequestContext;
|
||||
import dev.caskeleton.application.fileserver.cleanup.CleanupBatchResult;
|
||||
import dev.caskeleton.application.fileserver.port.in.CleanupUploadsCommand;
|
||||
import dev.caskeleton.application.fileserver.port.in.CleanupUploadsUseCase;
|
||||
import dev.caskeleton.application.fileserver.port.in.ForceDeleteCommand;
|
||||
import dev.caskeleton.application.fileserver.port.in.ForceDeleteFileUseCase;
|
||||
import dev.caskeleton.application.fileserver.port.in.GetRuntimeCapabilitiesQuery;
|
||||
import dev.caskeleton.application.fileserver.port.in.GetRuntimeCapabilitiesUseCase;
|
||||
import dev.caskeleton.application.fileserver.port.in.GetStorageHealthQuery;
|
||||
import dev.caskeleton.application.fileserver.port.in.GetStorageHealthUseCase;
|
||||
import dev.caskeleton.application.fileserver.port.in.ListIncompleteUploadsQuery;
|
||||
import dev.caskeleton.application.fileserver.port.in.ListIncompleteUploadsUseCase;
|
||||
import dev.caskeleton.application.fileserver.port.in.ListOrphansQuery;
|
||||
import dev.caskeleton.application.fileserver.port.in.ListOrphansUseCase;
|
||||
import dev.caskeleton.application.fileserver.port.in.OrphanReconcileCommand;
|
||||
import dev.caskeleton.application.fileserver.port.in.ReconcileOrphansUseCase;
|
||||
import dev.caskeleton.application.fileserver.port.in.ReverifyFileCommand;
|
||||
import dev.caskeleton.application.fileserver.port.in.ReverifyFileUseCase;
|
||||
import jakarta.validation.Valid;
|
||||
import java.util.List;
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
|
||||
@@ -39,18 +53,40 @@ import org.springframework.web.bind.annotation.RestController;
|
||||
@RestController
|
||||
@ConditionalOnProperty(
|
||||
prefix = "app.fileserver-platform",
|
||||
name = {"enabled", "admin.enabled"},
|
||||
name = "admin.enabled",
|
||||
havingValue = "true")
|
||||
public class FileserverAdminController {
|
||||
|
||||
private static final int DEFAULT_PAGE = 100;
|
||||
|
||||
private final FileserverAdminService adminService;
|
||||
private final GetStorageHealthUseCase storageHealth;
|
||||
private final GetRuntimeCapabilitiesUseCase capabilities;
|
||||
private final ListOrphansUseCase orphans;
|
||||
private final ReconcileOrphansUseCase reconcileOrphans;
|
||||
private final ReverifyFileUseCase reverify;
|
||||
private final ForceDeleteFileUseCase forceDelete;
|
||||
private final ListIncompleteUploadsUseCase incompleteUploads;
|
||||
private final CleanupUploadsUseCase cleanupUploads;
|
||||
private final FileserverRequestContextFactory contextFactory;
|
||||
|
||||
public FileserverAdminController(
|
||||
FileserverAdminService adminService, FileserverRequestContextFactory contextFactory) {
|
||||
this.adminService = adminService;
|
||||
GetStorageHealthUseCase storageHealth,
|
||||
GetRuntimeCapabilitiesUseCase capabilities,
|
||||
ListOrphansUseCase orphans,
|
||||
ReconcileOrphansUseCase reconcileOrphans,
|
||||
ReverifyFileUseCase reverify,
|
||||
ForceDeleteFileUseCase forceDelete,
|
||||
ListIncompleteUploadsUseCase incompleteUploads,
|
||||
CleanupUploadsUseCase cleanupUploads,
|
||||
FileserverRequestContextFactory contextFactory) {
|
||||
this.storageHealth = storageHealth;
|
||||
this.capabilities = capabilities;
|
||||
this.orphans = orphans;
|
||||
this.reconcileOrphans = reconcileOrphans;
|
||||
this.reverify = reverify;
|
||||
this.forceDelete = forceDelete;
|
||||
this.incompleteUploads = incompleteUploads;
|
||||
this.cleanupUploads = cleanupUploads;
|
||||
this.contextFactory = contextFactory;
|
||||
}
|
||||
|
||||
@@ -58,19 +94,19 @@ public class FileserverAdminController {
|
||||
path = "/internal/fileserver/storage-health",
|
||||
produces = MediaType.APPLICATION_JSON_VALUE)
|
||||
public StorageHealthReport storageHealth() {
|
||||
return adminService.storageHealth(contextFactory.current());
|
||||
return storageHealth.handle(new GetStorageHealthQuery(contextFactory.current()));
|
||||
}
|
||||
|
||||
@GetMapping(
|
||||
path = "/internal/fileserver/capabilities",
|
||||
produces = MediaType.APPLICATION_JSON_VALUE)
|
||||
public RuntimeCapabilityReport capabilities() {
|
||||
return adminService.capabilities(contextFactory.current());
|
||||
return capabilities.handle(new GetRuntimeCapabilitiesQuery(contextFactory.current()));
|
||||
}
|
||||
|
||||
@GetMapping(path = "/internal/fileserver/orphans", produces = MediaType.APPLICATION_JSON_VALUE)
|
||||
public List<OrphanObject> orphans(@RequestParam(name = "limit", defaultValue = "100") int limit) {
|
||||
return adminService.orphans(limit, contextFactory.current());
|
||||
return orphans.handle(new ListOrphansQuery(limit, contextFactory.current()));
|
||||
}
|
||||
|
||||
@PostMapping(
|
||||
@@ -78,7 +114,7 @@ public class FileserverAdminController {
|
||||
consumes = MediaType.APPLICATION_JSON_VALUE,
|
||||
produces = MediaType.APPLICATION_JSON_VALUE)
|
||||
public OrphanReconcileReport reconcileOrphans(@RequestBody OrphanReconcileHttpRequest request) {
|
||||
return adminService.reconcileOrphans(toCommand(request), contextFactory.current());
|
||||
return reconcileOrphans.handle(toCommand(request, contextFactory.current()));
|
||||
}
|
||||
|
||||
@PostMapping(
|
||||
@@ -86,7 +122,7 @@ public class FileserverAdminController {
|
||||
produces = MediaType.APPLICATION_JSON_VALUE)
|
||||
public UploadedFileResponse reverify(@PathVariable("fileId") String fileId) {
|
||||
return UploadedFileResponse.from(
|
||||
adminService.reverify(FileId.parse(fileId), contextFactory.current()));
|
||||
reverify.handle(new ReverifyFileCommand(FileId.parse(fileId), contextFactory.current())));
|
||||
}
|
||||
|
||||
@PostMapping(
|
||||
@@ -94,9 +130,9 @@ public class FileserverAdminController {
|
||||
consumes = MediaType.APPLICATION_JSON_VALUE)
|
||||
public ResponseEntity<Void> forceDelete(
|
||||
@PathVariable("fileId") String fileId, @Valid @RequestBody ForceDeleteHttpRequest request) {
|
||||
adminService.forceDelete(
|
||||
new ForceDeleteCommand(FileId.parse(fileId), request.reasonCode()),
|
||||
contextFactory.current());
|
||||
forceDelete.handle(
|
||||
new ForceDeleteCommand(
|
||||
FileId.parse(fileId), request.reasonCode(), contextFactory.current()));
|
||||
return ResponseEntity.accepted().build();
|
||||
}
|
||||
|
||||
@@ -105,7 +141,8 @@ public class FileserverAdminController {
|
||||
produces = MediaType.APPLICATION_JSON_VALUE)
|
||||
public List<IncompleteUploadView> incompleteUploads(
|
||||
@RequestParam(name = "limit", defaultValue = "100") int limit) {
|
||||
return adminService.incompleteUploads(limit, contextFactory.current());
|
||||
return incompleteUploads.handle(
|
||||
new ListIncompleteUploadsQuery(limit, contextFactory.current()));
|
||||
}
|
||||
|
||||
@PostMapping(
|
||||
@@ -114,7 +151,8 @@ public class FileserverAdminController {
|
||||
public CleanupBatchResult cleanupUploads(
|
||||
@RequestParam(name = "maxItems", defaultValue = "100") int maxItems,
|
||||
@RequestParam(name = "maxBytes", defaultValue = "1073741824") long maxBytes) {
|
||||
return adminService.cleanupUploads(maxItems, maxBytes, contextFactory.current());
|
||||
return cleanupUploads.handle(
|
||||
new CleanupUploadsCommand(maxItems, maxBytes, contextFactory.current()));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -123,17 +161,19 @@ public class FileserverAdminController {
|
||||
* <p>Every absent field resolves to the safe value: a dry run, the default page, and no
|
||||
* fingerprints. Nothing here can be omitted into a destructive default.
|
||||
*/
|
||||
private static OrphanReconcileCommand toCommand(OrphanReconcileHttpRequest request) {
|
||||
private static OrphanReconcileCommand toCommand(
|
||||
OrphanReconcileHttpRequest request, RequestContext context) {
|
||||
boolean dryRun = request.dryRun() == null || request.dryRun();
|
||||
int limit = request.limit() == null ? DEFAULT_PAGE : request.limit();
|
||||
if (dryRun) {
|
||||
return OrphanReconcileCommand.dryRun(limit);
|
||||
return OrphanReconcileCommand.dryRun(limit, context);
|
||||
}
|
||||
return new OrphanReconcileCommand(
|
||||
false,
|
||||
limit,
|
||||
request.maxBytes() == null ? 1L << 30 : request.maxBytes(),
|
||||
request.expectedFingerprints() == null ? List.of() : request.expectedFingerprints(),
|
||||
request.reasonCode() == null ? "ORPHAN_APPLY" : request.reasonCode());
|
||||
request.reasonCode() == null ? "ORPHAN_APPLY" : request.reasonCode(),
|
||||
context);
|
||||
}
|
||||
}
|
||||
|
||||
+11
-1
@@ -10,6 +10,8 @@ import java.util.concurrent.TimeoutException;
|
||||
import java.util.function.Supplier;
|
||||
import org.springframework.core.task.TaskRejectedException;
|
||||
import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;
|
||||
import org.springframework.security.concurrent.DelegatingSecurityContextCallable;
|
||||
import org.springframework.security.core.context.SecurityContextHolder;
|
||||
|
||||
/**
|
||||
* Admission control for blocking transfers.
|
||||
@@ -43,7 +45,15 @@ public final class BlockingTransferExecutor {
|
||||
public <T> T call(Supplier<T> work) {
|
||||
Future<T> future;
|
||||
try {
|
||||
future = executor.submit(work::get);
|
||||
// The worker runs as the caller. Method security checks a use case's @RequiresPermission
|
||||
// against the security context of the thread that calls it, and a pool thread has none of
|
||||
// its own: without this an authenticated upload's append and finalize were refused as
|
||||
// anonymous. The delegate restores the worker's previous context afterwards, so nothing of
|
||||
// this request stays on the pooled thread for the next one.
|
||||
future =
|
||||
executor.submit(
|
||||
new DelegatingSecurityContextCallable<>(
|
||||
work::get, SecurityContextHolder.getContext()));
|
||||
} catch (TaskRejectedException rejected) {
|
||||
throw new FileserverException(
|
||||
"transfer pool is saturated",
|
||||
|
||||
+27
-16
@@ -14,17 +14,22 @@ import dev.caskeleton.adapter.inbound.web.fileserver.security.FileserverRequestC
|
||||
import dev.caskeleton.application.fileserver.api.ByteRange;
|
||||
import dev.caskeleton.application.fileserver.api.FileId;
|
||||
import dev.caskeleton.application.fileserver.api.security.RequestContext;
|
||||
import dev.caskeleton.application.fileserver.download.DownloadApplicationService;
|
||||
import dev.caskeleton.application.fileserver.download.DownloadDescriptor;
|
||||
import dev.caskeleton.application.fileserver.download.DownloadRequest;
|
||||
import dev.caskeleton.application.fileserver.download.ZeroCopyTransferResult;
|
||||
import dev.caskeleton.application.fileserver.port.in.DescribeFileQuery;
|
||||
import dev.caskeleton.application.fileserver.port.in.DescribeFileUseCase;
|
||||
import dev.caskeleton.application.fileserver.port.in.OpenDownloadContentQuery;
|
||||
import dev.caskeleton.application.fileserver.port.in.OpenDownloadContentUseCase;
|
||||
import dev.caskeleton.application.fileserver.port.in.PrepareDownloadQuery;
|
||||
import dev.caskeleton.application.fileserver.port.in.PrepareDownloadUseCase;
|
||||
import dev.caskeleton.application.fileserver.port.in.TransferDownloadContentQuery;
|
||||
import dev.caskeleton.application.fileserver.port.in.TransferDownloadContentUseCase;
|
||||
import jakarta.servlet.http.HttpServletRequest;
|
||||
import jakarta.servlet.http.HttpServletResponse;
|
||||
import java.io.IOException;
|
||||
import java.io.UncheckedIOException;
|
||||
import java.nio.channels.Channels;
|
||||
import java.nio.channels.ReadableByteChannel;
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
|
||||
import org.springframework.http.MediaType;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
@@ -42,14 +47,12 @@ import org.springframework.web.bind.annotation.RestController;
|
||||
*/
|
||||
@OwnsAbsoluteWebRoute
|
||||
@RestController
|
||||
@ConditionalOnProperty(
|
||||
prefix = "app.fileserver-platform",
|
||||
name = "enabled",
|
||||
havingValue = "true",
|
||||
matchIfMissing = true)
|
||||
public class FileDownloadController {
|
||||
|
||||
private final DownloadApplicationService downloadService;
|
||||
private final DescribeFileUseCase describeFile;
|
||||
private final PrepareDownloadUseCase prepareDownload;
|
||||
private final OpenDownloadContentUseCase openContent;
|
||||
private final TransferDownloadContentUseCase transferContent;
|
||||
private final MvcConditionalRequestFactory conditionalFactory;
|
||||
private final HttpDownloadPlanner downloadPlanner;
|
||||
private final MvcDownloadResponseWriter responseWriter;
|
||||
@@ -67,7 +70,10 @@ public class FileDownloadController {
|
||||
* without saying so. Every construction site names its zero-copy policy.
|
||||
*/
|
||||
public FileDownloadController(
|
||||
DownloadApplicationService downloadService,
|
||||
DescribeFileUseCase describeFile,
|
||||
PrepareDownloadUseCase prepareDownload,
|
||||
OpenDownloadContentUseCase openContent,
|
||||
TransferDownloadContentUseCase transferContent,
|
||||
MvcConditionalRequestFactory conditionalFactory,
|
||||
HttpDownloadPlanner downloadPlanner,
|
||||
MvcDownloadResponseWriter responseWriter,
|
||||
@@ -75,7 +81,10 @@ public class FileDownloadController {
|
||||
BlockingTransferExecutor transferExecutor,
|
||||
NginxDownloadStrategy delegationStrategy,
|
||||
ZeroCopyEligibility zeroCopy) {
|
||||
this.downloadService = downloadService;
|
||||
this.describeFile = describeFile;
|
||||
this.prepareDownload = prepareDownload;
|
||||
this.openContent = openContent;
|
||||
this.transferContent = transferContent;
|
||||
this.conditionalFactory = conditionalFactory;
|
||||
this.downloadPlanner = downloadPlanner;
|
||||
this.responseWriter = responseWriter;
|
||||
@@ -88,7 +97,7 @@ public class FileDownloadController {
|
||||
@GetMapping(path = "/v1/files/{fileId}", produces = MediaType.APPLICATION_JSON_VALUE)
|
||||
public UploadedFileResponse describe(@PathVariable("fileId") String fileId) {
|
||||
return UploadedFileResponse.from(
|
||||
downloadService.describeFile(FileId.parse(fileId), contextFactory.current()));
|
||||
describeFile.handle(new DescribeFileQuery(FileId.parse(fileId), contextFactory.current())));
|
||||
}
|
||||
|
||||
@RequestMapping(
|
||||
@@ -104,7 +113,7 @@ public class FileDownloadController {
|
||||
RequestContext context = contextFactory.current();
|
||||
|
||||
DownloadDescriptor descriptor =
|
||||
downloadService.describe(new DownloadRequest(FileId.parse(fileId)), context);
|
||||
prepareDownload.handle(new PrepareDownloadQuery(FileId.parse(fileId), context));
|
||||
HttpDownloadDecision decision = downloadPlanner.plan(descriptor, conditional, inline);
|
||||
responseWriter.writeHeaders(decision, response);
|
||||
if (!decision.bodyExpected()) {
|
||||
@@ -150,8 +159,9 @@ public class FileDownloadController {
|
||||
try {
|
||||
if (zeroCopy.isEligible(true, range.length(), secure)) {
|
||||
ZeroCopyTransferResult transfer =
|
||||
downloadService.transferContent(
|
||||
descriptor, range, Channels.newChannel(response.getOutputStream()));
|
||||
transferContent.handle(
|
||||
new TransferDownloadContentQuery(
|
||||
descriptor, range, Channels.newChannel(response.getOutputStream())));
|
||||
if (transfer.isComplete()) {
|
||||
return null;
|
||||
}
|
||||
@@ -163,7 +173,8 @@ public class FileDownloadController {
|
||||
+ " bytes; the response is already committed and must not be re-sent"));
|
||||
}
|
||||
}
|
||||
try (ReadableByteChannel content = downloadService.openContent(descriptor, range)) {
|
||||
try (ReadableByteChannel content =
|
||||
openContent.handle(new OpenDownloadContentQuery(descriptor, range))) {
|
||||
responseWriter.writeBody(content, response);
|
||||
}
|
||||
} catch (IOException exception) {
|
||||
|
||||
+12
-16
@@ -16,10 +16,11 @@ import dev.caskeleton.application.fileserver.api.error.FileserverException;
|
||||
import dev.caskeleton.application.fileserver.api.error.FileserverFailureContext;
|
||||
import dev.caskeleton.application.fileserver.api.security.RequestContext;
|
||||
import dev.caskeleton.application.fileserver.api.transfer.UploadMode;
|
||||
import dev.caskeleton.application.fileserver.port.in.UploadFileCommand;
|
||||
import dev.caskeleton.application.fileserver.port.in.UploadFileUseCase;
|
||||
import dev.caskeleton.application.fileserver.upload.CreateUploadRequest;
|
||||
import dev.caskeleton.application.fileserver.upload.FileView;
|
||||
import dev.caskeleton.application.fileserver.upload.FinalizeUploadRequest;
|
||||
import dev.caskeleton.application.fileserver.upload.SingleShotUploadService;
|
||||
import jakarta.servlet.http.HttpServletRequest;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
@@ -28,7 +29,6 @@ import java.nio.channels.Channels;
|
||||
import java.nio.channels.ReadableByteChannel;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.MediaType;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
@@ -47,14 +47,9 @@ import org.springframework.web.multipart.MultipartFile;
|
||||
*/
|
||||
@OwnsAbsoluteWebRoute
|
||||
@RestController
|
||||
@ConditionalOnProperty(
|
||||
prefix = "app.fileserver-platform",
|
||||
name = "enabled",
|
||||
havingValue = "true",
|
||||
matchIfMissing = true)
|
||||
public class FileUploadController {
|
||||
|
||||
private final SingleShotUploadService uploadService;
|
||||
private final UploadFileUseCase uploadFile;
|
||||
private final RawUploadRequestMapper rawMapper;
|
||||
private final MultipartUploadRequestMapper multipartMapper;
|
||||
private final FileserverRequestContextFactory contextFactory;
|
||||
@@ -62,13 +57,13 @@ public class FileUploadController {
|
||||
private final FileserverWebProperties properties;
|
||||
|
||||
public FileUploadController(
|
||||
SingleShotUploadService uploadService,
|
||||
UploadFileUseCase uploadFile,
|
||||
RawUploadRequestMapper rawMapper,
|
||||
MultipartUploadRequestMapper multipartMapper,
|
||||
FileserverRequestContextFactory contextFactory,
|
||||
BlockingTransferExecutor transferExecutor,
|
||||
FileserverWebProperties properties) {
|
||||
this.uploadService = uploadService;
|
||||
this.uploadFile = uploadFile;
|
||||
this.rawMapper = rawMapper;
|
||||
this.multipartMapper = multipartMapper;
|
||||
this.contextFactory = contextFactory;
|
||||
@@ -182,12 +177,13 @@ public class FileUploadController {
|
||||
intent.declaredLength(),
|
||||
intent.expectedSha256(),
|
||||
mode);
|
||||
return uploadService.upload(
|
||||
request,
|
||||
content,
|
||||
contentLength,
|
||||
new FinalizeUploadRequest(intent.expectedSha256(), false),
|
||||
context);
|
||||
return uploadFile.handle(
|
||||
new UploadFileCommand(
|
||||
request,
|
||||
content,
|
||||
contentLength,
|
||||
new FinalizeUploadRequest(intent.expectedSha256(), false),
|
||||
context));
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
+49
-25
@@ -9,11 +9,15 @@ import dev.caskeleton.application.fileserver.api.error.FileserverException;
|
||||
import dev.caskeleton.application.fileserver.api.error.UploadOffsetMismatchException;
|
||||
import dev.caskeleton.application.fileserver.api.security.RequestContext;
|
||||
import dev.caskeleton.application.fileserver.api.transfer.UploadMode;
|
||||
import dev.caskeleton.application.fileserver.port.in.AppendUploadCommand;
|
||||
import dev.caskeleton.application.fileserver.port.in.AppendUploadUseCase;
|
||||
import dev.caskeleton.application.fileserver.port.in.CreateUploadCommand;
|
||||
import dev.caskeleton.application.fileserver.port.in.CreateUploadUseCase;
|
||||
import dev.caskeleton.application.fileserver.port.in.FinalizeUploadCommand;
|
||||
import dev.caskeleton.application.fileserver.port.in.FinalizeUploadUseCase;
|
||||
import dev.caskeleton.application.fileserver.upload.AppendUploadResult;
|
||||
import dev.caskeleton.application.fileserver.upload.CreateUploadRequest;
|
||||
import dev.caskeleton.application.fileserver.upload.FinalizeUploadRequest;
|
||||
import dev.caskeleton.application.fileserver.upload.FinalizeUploadService;
|
||||
import dev.caskeleton.application.fileserver.upload.UploadApplicationService;
|
||||
import dev.caskeleton.application.fileserver.upload.UploadSessionView;
|
||||
import jakarta.servlet.http.HttpServletRequest;
|
||||
import java.io.IOException;
|
||||
@@ -47,26 +51,29 @@ import org.springframework.web.bind.annotation.RestController;
|
||||
@ExperimentalApi(specification = "draft-ietf-httpbis-resumable-upload-12")
|
||||
@ConditionalOnProperty(
|
||||
prefix = "app.fileserver-platform",
|
||||
name = {"enabled", "httpbis-draft12.enabled"},
|
||||
name = "httpbis-draft12.enabled",
|
||||
havingValue = "true")
|
||||
public class Draft12UploadController {
|
||||
|
||||
private static final String DRAFT_PATH = "/v1/experimental/draft12/uploads";
|
||||
|
||||
private final UploadApplicationService uploadService;
|
||||
private final FinalizeUploadService finalizeService;
|
||||
private final CreateUploadUseCase create;
|
||||
private final AppendUploadUseCase append;
|
||||
private final FinalizeUploadUseCase finalizer;
|
||||
private final FileserverRequestContextFactory contextFactory;
|
||||
private final BlockingTransferExecutor transferExecutor;
|
||||
private final Draft12Properties draftProperties;
|
||||
|
||||
public Draft12UploadController(
|
||||
UploadApplicationService uploadService,
|
||||
FinalizeUploadService finalizeService,
|
||||
CreateUploadUseCase create,
|
||||
AppendUploadUseCase append,
|
||||
FinalizeUploadUseCase finalizer,
|
||||
FileserverRequestContextFactory contextFactory,
|
||||
BlockingTransferExecutor transferExecutor,
|
||||
Draft12Properties draftProperties) {
|
||||
this.uploadService = uploadService;
|
||||
this.finalizeService = finalizeService;
|
||||
this.create = create;
|
||||
this.append = append;
|
||||
this.finalizer = finalizer;
|
||||
this.contextFactory = contextFactory;
|
||||
this.transferExecutor = transferExecutor;
|
||||
this.draftProperties = draftProperties;
|
||||
@@ -86,14 +93,15 @@ public class Draft12UploadController {
|
||||
public ResponseEntity<Void> create(HttpServletRequest request) throws IOException {
|
||||
RequestContext context = contextFactory.current();
|
||||
UploadSessionView created =
|
||||
uploadService.create(
|
||||
new CreateUploadRequest(
|
||||
filename(request),
|
||||
Optional.empty(),
|
||||
declaredLength(request),
|
||||
Optional.empty(),
|
||||
UploadMode.EXPERIMENTAL_RESUMABLE),
|
||||
context);
|
||||
create.handle(
|
||||
new CreateUploadCommand(
|
||||
new CreateUploadRequest(
|
||||
filename(request),
|
||||
Optional.empty(),
|
||||
declaredLength(request),
|
||||
Optional.empty(),
|
||||
UploadMode.EXPERIMENTAL_RESUMABLE),
|
||||
context));
|
||||
|
||||
long offset = 0;
|
||||
long bodyLength = request.getContentLengthLong();
|
||||
@@ -103,15 +111,24 @@ public class Draft12UploadController {
|
||||
transferExecutor
|
||||
.call(
|
||||
() ->
|
||||
uploadService.append(
|
||||
created.uploadId(), 0, Channels.newChannel(body), bodyLength, context))
|
||||
append.handle(
|
||||
new AppendUploadCommand(
|
||||
created.uploadId(),
|
||||
0,
|
||||
Channels.newChannel(body),
|
||||
bodyLength,
|
||||
Optional.empty(),
|
||||
context)))
|
||||
.committedOffset();
|
||||
}
|
||||
if (isComplete(request)) {
|
||||
transferExecutor.call(
|
||||
() ->
|
||||
finalizeService.finalizeUpload(
|
||||
created.uploadId(), FinalizeUploadRequest.synchronousWithoutDigest(), context));
|
||||
finalizer.handle(
|
||||
new FinalizeUploadCommand(
|
||||
created.uploadId(),
|
||||
FinalizeUploadRequest.synchronousWithoutDigest(),
|
||||
context)));
|
||||
}
|
||||
return ResponseEntity.created(URI.create(DRAFT_PATH + "/" + created.uploadId().canonicalText()))
|
||||
.header(Draft12Headers.UPLOAD_OFFSET, String.valueOf(offset))
|
||||
@@ -136,13 +153,20 @@ public class Draft12UploadController {
|
||||
AppendUploadResult appended =
|
||||
transferExecutor.call(
|
||||
() ->
|
||||
uploadService.append(
|
||||
id, expectedOffset, Channels.newChannel(body), declared, context));
|
||||
append.handle(
|
||||
new AppendUploadCommand(
|
||||
id,
|
||||
expectedOffset,
|
||||
Channels.newChannel(body),
|
||||
declared,
|
||||
Optional.empty(),
|
||||
context)));
|
||||
if (complete) {
|
||||
transferExecutor.call(
|
||||
() ->
|
||||
finalizeService.finalizeUpload(
|
||||
id, FinalizeUploadRequest.synchronousWithoutDigest(), context));
|
||||
finalizer.handle(
|
||||
new FinalizeUploadCommand(
|
||||
id, FinalizeUploadRequest.synchronousWithoutDigest(), context)));
|
||||
}
|
||||
return ResponseEntity.noContent()
|
||||
.header(Draft12Headers.UPLOAD_OFFSET, String.valueOf(appended.committedOffset()))
|
||||
|
||||
+28
-21
@@ -6,14 +6,17 @@ import dev.caskeleton.adapter.inbound.web.fileserver.dto.UploadedFileResponse;
|
||||
import dev.caskeleton.adapter.inbound.web.fileserver.security.FileserverRequestContextFactory;
|
||||
import dev.caskeleton.application.fileserver.api.FileId;
|
||||
import dev.caskeleton.application.fileserver.api.StorageNamespace;
|
||||
import dev.caskeleton.application.fileserver.lifecycle.CopyFileCommand;
|
||||
import dev.caskeleton.application.fileserver.lifecycle.DeleteOutcome;
|
||||
import dev.caskeleton.application.fileserver.lifecycle.FileLifecycleService;
|
||||
import dev.caskeleton.application.fileserver.port.in.CopyFileCommand;
|
||||
import dev.caskeleton.application.fileserver.port.in.CopyFileUseCase;
|
||||
import dev.caskeleton.application.fileserver.port.in.DeleteFileCommand;
|
||||
import dev.caskeleton.application.fileserver.port.in.DeleteFileUseCase;
|
||||
import dev.caskeleton.application.fileserver.port.in.MoveFileCommand;
|
||||
import dev.caskeleton.application.fileserver.port.in.MoveFileUseCase;
|
||||
import dev.caskeleton.application.fileserver.upload.FileView;
|
||||
import jakarta.validation.Valid;
|
||||
import java.net.URI;
|
||||
import java.util.Optional;
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
|
||||
import org.springframework.http.HttpHeaders;
|
||||
import org.springframework.http.MediaType;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
@@ -39,19 +42,21 @@ import org.springframework.web.bind.annotation.RestController;
|
||||
*/
|
||||
@OwnsAbsoluteWebRoute
|
||||
@RestController
|
||||
@ConditionalOnProperty(
|
||||
prefix = "app.fileserver-platform",
|
||||
name = "enabled",
|
||||
havingValue = "true",
|
||||
matchIfMissing = true)
|
||||
public class FileLifecycleController {
|
||||
|
||||
private final FileLifecycleService lifecycleService;
|
||||
private final DeleteFileUseCase delete;
|
||||
private final CopyFileUseCase copy;
|
||||
private final MoveFileUseCase move;
|
||||
private final FileserverRequestContextFactory contextFactory;
|
||||
|
||||
public FileLifecycleController(
|
||||
FileLifecycleService lifecycleService, FileserverRequestContextFactory contextFactory) {
|
||||
this.lifecycleService = lifecycleService;
|
||||
DeleteFileUseCase delete,
|
||||
CopyFileUseCase copy,
|
||||
MoveFileUseCase move,
|
||||
FileserverRequestContextFactory contextFactory) {
|
||||
this.delete = delete;
|
||||
this.copy = copy;
|
||||
this.move = move;
|
||||
this.contextFactory = contextFactory;
|
||||
}
|
||||
|
||||
@@ -60,8 +65,9 @@ public class FileLifecycleController {
|
||||
@PathVariable("fileId") String fileId,
|
||||
@RequestHeader(name = HttpHeaders.IF_MATCH, required = false) String ifMatch) {
|
||||
DeleteOutcome outcome =
|
||||
lifecycleService.delete(
|
||||
FileId.parse(fileId), expectedSha256(ifMatch), contextFactory.current());
|
||||
delete.handle(
|
||||
new DeleteFileCommand(
|
||||
FileId.parse(fileId), expectedSha256(ifMatch), contextFactory.current()));
|
||||
return outcome.physicalCleanupScheduled()
|
||||
? ResponseEntity.accepted().build()
|
||||
: ResponseEntity.noContent().build();
|
||||
@@ -76,13 +82,13 @@ public class FileLifecycleController {
|
||||
@RequestHeader(name = HttpHeaders.IF_MATCH, required = false) String ifMatch,
|
||||
@Valid @RequestBody RelocateFileRequest request) {
|
||||
FileView copied =
|
||||
lifecycleService.copy(
|
||||
copy.handle(
|
||||
new CopyFileCommand(
|
||||
FileId.parse(fileId),
|
||||
StorageNamespace.of(request.namespace()),
|
||||
Optional.ofNullable(request.filename()),
|
||||
expectedSha256(ifMatch)),
|
||||
contextFactory.current());
|
||||
expectedSha256(ifMatch),
|
||||
contextFactory.current()));
|
||||
return ResponseEntity.accepted()
|
||||
.location(URI.create("/v1/files/" + copied.fileId().canonicalText()))
|
||||
.body(UploadedFileResponse.from(copied));
|
||||
@@ -97,11 +103,12 @@ public class FileLifecycleController {
|
||||
@RequestHeader(name = HttpHeaders.IF_MATCH, required = false) String ifMatch,
|
||||
@Valid @RequestBody RelocateFileRequest request) {
|
||||
return UploadedFileResponse.from(
|
||||
lifecycleService.move(
|
||||
FileId.parse(fileId),
|
||||
StorageNamespace.of(request.namespace()),
|
||||
expectedSha256(ifMatch),
|
||||
contextFactory.current()));
|
||||
move.handle(
|
||||
new MoveFileCommand(
|
||||
FileId.parse(fileId),
|
||||
StorageNamespace.of(request.namespace()),
|
||||
expectedSha256(ifMatch),
|
||||
contextFactory.current())));
|
||||
}
|
||||
|
||||
private static Optional<String> expectedSha256(String ifMatch) {
|
||||
|
||||
-6
@@ -6,7 +6,6 @@ import dev.caskeleton.application.fileserver.api.error.FileserverFailureContext;
|
||||
import dev.caskeleton.shared.response.Envelope;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.Map;
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
|
||||
import org.springframework.core.Ordered;
|
||||
import org.springframework.core.annotation.Order;
|
||||
import org.springframework.http.MediaType;
|
||||
@@ -35,11 +34,6 @@ import org.springframework.web.bind.annotation.RestControllerAdvice;
|
||||
* explicit exception (owner decision 12).
|
||||
*/
|
||||
@RestControllerAdvice
|
||||
@ConditionalOnProperty(
|
||||
prefix = "app.fileserver-platform",
|
||||
name = "enabled",
|
||||
havingValue = "true",
|
||||
matchIfMissing = true)
|
||||
@Order(Ordered.HIGHEST_PRECEDENCE)
|
||||
public class FileserverExceptionHandler {
|
||||
|
||||
|
||||
+49
-29
@@ -6,11 +6,19 @@ import dev.caskeleton.adapter.inbound.web.fileserver.security.FileserverRequestC
|
||||
import dev.caskeleton.application.fileserver.api.UploadId;
|
||||
import dev.caskeleton.application.fileserver.api.security.RequestContext;
|
||||
import dev.caskeleton.application.fileserver.api.transfer.UploadMode;
|
||||
import dev.caskeleton.application.fileserver.port.in.AppendUploadCommand;
|
||||
import dev.caskeleton.application.fileserver.port.in.AppendUploadUseCase;
|
||||
import dev.caskeleton.application.fileserver.port.in.CancelUploadCommand;
|
||||
import dev.caskeleton.application.fileserver.port.in.CancelUploadUseCase;
|
||||
import dev.caskeleton.application.fileserver.port.in.CreateUploadCommand;
|
||||
import dev.caskeleton.application.fileserver.port.in.CreateUploadUseCase;
|
||||
import dev.caskeleton.application.fileserver.port.in.FinalizeUploadCommand;
|
||||
import dev.caskeleton.application.fileserver.port.in.FinalizeUploadUseCase;
|
||||
import dev.caskeleton.application.fileserver.port.in.GetUploadStatusQuery;
|
||||
import dev.caskeleton.application.fileserver.port.in.GetUploadStatusUseCase;
|
||||
import dev.caskeleton.application.fileserver.upload.AppendUploadResult;
|
||||
import dev.caskeleton.application.fileserver.upload.CreateUploadRequest;
|
||||
import dev.caskeleton.application.fileserver.upload.FinalizeUploadRequest;
|
||||
import dev.caskeleton.application.fileserver.upload.FinalizeUploadService;
|
||||
import dev.caskeleton.application.fileserver.upload.UploadApplicationService;
|
||||
import dev.caskeleton.application.fileserver.upload.UploadSessionView;
|
||||
import jakarta.servlet.http.HttpServletRequest;
|
||||
import java.io.IOException;
|
||||
@@ -47,29 +55,38 @@ import org.springframework.web.bind.annotation.RestController;
|
||||
@RestController
|
||||
@ConditionalOnProperty(
|
||||
prefix = "app.fileserver-platform",
|
||||
name = {"enabled", "tus.enabled"},
|
||||
name = "tus.enabled",
|
||||
havingValue = "true")
|
||||
public class TusController {
|
||||
|
||||
private static final DateTimeFormatter HTTP_DATE =
|
||||
DateTimeFormatter.RFC_1123_DATE_TIME.withZone(ZoneOffset.UTC);
|
||||
|
||||
private final UploadApplicationService uploadService;
|
||||
private final FinalizeUploadService finalizeService;
|
||||
private final CreateUploadUseCase create;
|
||||
private final GetUploadStatusUseCase status;
|
||||
private final AppendUploadUseCase append;
|
||||
private final FinalizeUploadUseCase finalizer;
|
||||
private final CancelUploadUseCase cancel;
|
||||
private final TusRequestParser parser;
|
||||
private final FileserverRequestContextFactory contextFactory;
|
||||
private final BlockingTransferExecutor transferExecutor;
|
||||
private final TusProperties tusProperties;
|
||||
|
||||
public TusController(
|
||||
UploadApplicationService uploadService,
|
||||
FinalizeUploadService finalizeService,
|
||||
CreateUploadUseCase create,
|
||||
GetUploadStatusUseCase status,
|
||||
AppendUploadUseCase append,
|
||||
FinalizeUploadUseCase finalizer,
|
||||
CancelUploadUseCase cancel,
|
||||
TusRequestParser parser,
|
||||
FileserverRequestContextFactory contextFactory,
|
||||
BlockingTransferExecutor transferExecutor,
|
||||
TusProperties tusProperties) {
|
||||
this.uploadService = uploadService;
|
||||
this.finalizeService = finalizeService;
|
||||
this.create = create;
|
||||
this.status = status;
|
||||
this.append = append;
|
||||
this.finalizer = finalizer;
|
||||
this.cancel = cancel;
|
||||
this.parser = parser;
|
||||
this.contextFactory = contextFactory;
|
||||
this.transferExecutor = transferExecutor;
|
||||
@@ -92,14 +109,15 @@ public class TusController {
|
||||
parser.requireProtocolVersion(request);
|
||||
RequestContext context = contextFactory.current();
|
||||
UploadSessionView created =
|
||||
uploadService.create(
|
||||
new CreateUploadRequest(
|
||||
parser.filename(request).orElse("upload.bin"),
|
||||
Optional.ofNullable(parser.metadata(request).get("filetype")),
|
||||
parser.declaredLength(request),
|
||||
Optional.empty(),
|
||||
UploadMode.RESUMABLE),
|
||||
context);
|
||||
create.handle(
|
||||
new CreateUploadCommand(
|
||||
new CreateUploadRequest(
|
||||
parser.filename(request).orElse("upload.bin"),
|
||||
Optional.ofNullable(parser.metadata(request).get("filetype")),
|
||||
parser.declaredLength(request),
|
||||
Optional.empty(),
|
||||
UploadMode.RESUMABLE),
|
||||
context));
|
||||
|
||||
return ResponseEntity.created(URI.create("/v1/uploads/" + created.uploadId().canonicalText()))
|
||||
.header(TusHeaders.RESUMABLE, tusProperties.version())
|
||||
@@ -113,7 +131,7 @@ public class TusController {
|
||||
@PathVariable("uploadId") String uploadId, HttpServletRequest request) {
|
||||
parser.requireProtocolVersion(request);
|
||||
UploadSessionView session =
|
||||
uploadService.status(UploadId.parse(uploadId), contextFactory.current());
|
||||
status.handle(new GetUploadStatusQuery(UploadId.parse(uploadId), contextFactory.current()));
|
||||
|
||||
ResponseEntity.HeadersBuilder<?> response =
|
||||
ResponseEntity.noContent()
|
||||
@@ -153,22 +171,24 @@ public class TusController {
|
||||
AppendUploadResult appended =
|
||||
transferExecutor.call(
|
||||
() ->
|
||||
uploadService.append(
|
||||
id,
|
||||
expectedOffset,
|
||||
Channels.newChannel(body),
|
||||
declared,
|
||||
expectedChunkSha256,
|
||||
context));
|
||||
append.handle(
|
||||
new AppendUploadCommand(
|
||||
id,
|
||||
expectedOffset,
|
||||
Channels.newChannel(body),
|
||||
declared,
|
||||
expectedChunkSha256,
|
||||
context)));
|
||||
|
||||
UploadSessionView session = uploadService.status(id, context);
|
||||
UploadSessionView session = status.handle(new GetUploadStatusQuery(id, context));
|
||||
if (isComplete(session, appended)) {
|
||||
// Finalize reads the whole object back and moves it: transfer work, bounded by the same
|
||||
// executor as the append rather than holding a servlet thread for it.
|
||||
transferExecutor.call(
|
||||
() ->
|
||||
finalizeService.finalizeUpload(
|
||||
id, FinalizeUploadRequest.synchronousWithoutDigest(), context));
|
||||
finalizer.handle(
|
||||
new FinalizeUploadCommand(
|
||||
id, FinalizeUploadRequest.synchronousWithoutDigest(), context)));
|
||||
}
|
||||
return ResponseEntity.noContent()
|
||||
.header(TusHeaders.RESUMABLE, tusProperties.version())
|
||||
@@ -181,7 +201,7 @@ public class TusController {
|
||||
public ResponseEntity<Void> terminate(
|
||||
@PathVariable("uploadId") String uploadId, HttpServletRequest request) {
|
||||
parser.requireProtocolVersion(request);
|
||||
uploadService.cancel(UploadId.parse(uploadId), contextFactory.current());
|
||||
cancel.handle(new CancelUploadCommand(UploadId.parse(uploadId), contextFactory.current()));
|
||||
return ResponseEntity.noContent().header(TusHeaders.RESUMABLE, tusProperties.version()).build();
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -24,7 +24,7 @@ class FileserverAdminControllerTest {
|
||||
void setUp() {
|
||||
mvc =
|
||||
MockMvcBuilders.standaloneSetup(
|
||||
new FileserverAdminController(adminService, FileserverWebFixtures.contextFactory()))
|
||||
adminService.controller(FileserverWebFixtures.contextFactory()))
|
||||
.build();
|
||||
}
|
||||
|
||||
|
||||
+79
@@ -0,0 +1,79 @@
|
||||
package dev.caskeleton.adapter.inbound.web.fileserver.config;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
import java.util.List;
|
||||
import org.junit.jupiter.api.AfterEach;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.DisplayName;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;
|
||||
import org.springframework.security.authentication.UsernamePasswordAuthenticationToken;
|
||||
import org.springframework.security.core.Authentication;
|
||||
import org.springframework.security.core.authority.SimpleGrantedAuthority;
|
||||
import org.springframework.security.core.context.SecurityContextHolder;
|
||||
|
||||
/**
|
||||
* A transfer runs as the caller that asked for it.
|
||||
*
|
||||
* <p>The upload use cases carry {@code @RequiresPermission}, which method security checks against
|
||||
* the security context of the thread that calls them. Append and finalize are called on the
|
||||
* transfer pool, so a worker that did not carry the request's context would be refused as an
|
||||
* anonymous caller, whoever had actually authenticated.
|
||||
*/
|
||||
class BlockingTransferExecutorSecurityContextTest {
|
||||
|
||||
private ThreadPoolTaskExecutor pool;
|
||||
|
||||
@BeforeEach
|
||||
void startPool() {
|
||||
pool = new ThreadPoolTaskExecutor();
|
||||
pool.setCorePoolSize(1);
|
||||
pool.setMaxPoolSize(1);
|
||||
pool.setQueueCapacity(1);
|
||||
pool.initialize();
|
||||
}
|
||||
|
||||
@AfterEach
|
||||
void stopPool() {
|
||||
pool.shutdown();
|
||||
SecurityContextHolder.clearContext();
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisplayName("전송 풀의 작업은 요청 스레드의 인증 정보로 실행된다")
|
||||
void workOnTheTransferPoolSeesTheCallersAuthentication() {
|
||||
// given
|
||||
Authentication caller =
|
||||
UsernamePasswordAuthenticationToken.authenticated(
|
||||
"uploader", "n/a", List.of(new SimpleGrantedAuthority("ROLE_FILE_WRITE")));
|
||||
SecurityContextHolder.getContext().setAuthentication(caller);
|
||||
BlockingTransferExecutor executor = new BlockingTransferExecutor(pool, 5);
|
||||
|
||||
// when
|
||||
Authentication seen =
|
||||
executor.call(() -> SecurityContextHolder.getContext().getAuthentication());
|
||||
|
||||
// then
|
||||
assertThat(seen).isSameAs(caller);
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisplayName("작업이 끝난 전송 스레드에는 요청의 인증 정보가 남지 않는다")
|
||||
void theWorkerDoesNotKeepTheCallersAuthenticationAfterward() {
|
||||
// given
|
||||
SecurityContextHolder.getContext()
|
||||
.setAuthentication(
|
||||
UsernamePasswordAuthenticationToken.authenticated("uploader", "n/a", List.of()));
|
||||
BlockingTransferExecutor executor = new BlockingTransferExecutor(pool, 5);
|
||||
executor.call(() -> null);
|
||||
SecurityContextHolder.clearContext();
|
||||
|
||||
// when
|
||||
Authentication leftOver =
|
||||
executor.call(() -> SecurityContextHolder.getContext().getAuthentication());
|
||||
|
||||
// then
|
||||
assertThat(leftOver).isNull();
|
||||
}
|
||||
}
|
||||
+4
-1
@@ -31,7 +31,10 @@ class FileDownloadControllerContractTest {
|
||||
mvc =
|
||||
MockMvcBuilders.standaloneSetup(
|
||||
new FileDownloadController(
|
||||
downloadService,
|
||||
downloadService.describePort(),
|
||||
downloadService.preparePort(),
|
||||
downloadService.openPort(),
|
||||
downloadService.transferPort(),
|
||||
new MvcConditionalRequestFactory(),
|
||||
downloadService.httpPlanner(),
|
||||
new MvcDownloadResponseWriter(),
|
||||
|
||||
+1
-1
@@ -35,7 +35,7 @@ class FileUploadControllerTest {
|
||||
mvc =
|
||||
MockMvcBuilders.standaloneSetup(
|
||||
new FileUploadController(
|
||||
uploadService,
|
||||
uploadService.port(),
|
||||
new RawUploadRequestMapper(false),
|
||||
new MultipartUploadRequestMapper(),
|
||||
FileserverWebFixtures.contextFactory(),
|
||||
|
||||
+3
-2
@@ -32,8 +32,9 @@ class Draft12ProtocolTest {
|
||||
mvc =
|
||||
MockMvcBuilders.standaloneSetup(
|
||||
new Draft12UploadController(
|
||||
uploads,
|
||||
finalizeService,
|
||||
uploads.createPort(),
|
||||
uploads.appendPort(),
|
||||
finalizeService.port(),
|
||||
FileserverWebFixtures.contextFactory(),
|
||||
FileserverWebFixtures.transferExecutor(),
|
||||
DRAFT))
|
||||
|
||||
+4
-1
@@ -98,7 +98,10 @@ class NginxDownloadDelegationTest {
|
||||
private MockMvc mvc(NginxDelegationProperties properties) {
|
||||
return MockMvcBuilders.standaloneSetup(
|
||||
new FileDownloadController(
|
||||
downloadService,
|
||||
downloadService.describePort(),
|
||||
downloadService.preparePort(),
|
||||
downloadService.openPort(),
|
||||
downloadService.transferPort(),
|
||||
new MvcConditionalRequestFactory(),
|
||||
downloadService.httpPlanner(),
|
||||
new MvcDownloadResponseWriter(),
|
||||
|
||||
+5
-2
@@ -34,7 +34,7 @@ class FileserverHardeningContractTest {
|
||||
private final MockMvc uploadMvc =
|
||||
MockMvcBuilders.standaloneSetup(
|
||||
new FileUploadController(
|
||||
uploads,
|
||||
uploads.port(),
|
||||
new RawUploadRequestMapper(false),
|
||||
new MultipartUploadRequestMapper(),
|
||||
FileserverWebFixtures.contextFactory(),
|
||||
@@ -46,7 +46,10 @@ class FileserverHardeningContractTest {
|
||||
private final MockMvc downloadMvc =
|
||||
MockMvcBuilders.standaloneSetup(
|
||||
new FileDownloadController(
|
||||
downloads,
|
||||
downloads.describePort(),
|
||||
downloads.preparePort(),
|
||||
downloads.openPort(),
|
||||
downloads.transferPort(),
|
||||
new MvcConditionalRequestFactory(),
|
||||
downloads.httpPlanner(),
|
||||
new MvcDownloadResponseWriter(),
|
||||
|
||||
+35
-6
@@ -8,9 +8,12 @@ import dev.caskeleton.application.fileserver.api.error.FileserverException;
|
||||
import dev.caskeleton.application.fileserver.api.error.FileserverFailureContext;
|
||||
import dev.caskeleton.application.fileserver.api.error.UploadOffsetMismatchException;
|
||||
import dev.caskeleton.application.fileserver.api.security.RequestContext;
|
||||
import dev.caskeleton.application.fileserver.port.in.AppendUploadUseCase;
|
||||
import dev.caskeleton.application.fileserver.port.in.CancelUploadUseCase;
|
||||
import dev.caskeleton.application.fileserver.port.in.CreateUploadUseCase;
|
||||
import dev.caskeleton.application.fileserver.port.in.GetUploadStatusUseCase;
|
||||
import dev.caskeleton.application.fileserver.upload.AppendUploadResult;
|
||||
import dev.caskeleton.application.fileserver.upload.CreateUploadRequest;
|
||||
import dev.caskeleton.application.fileserver.upload.UploadApplicationService;
|
||||
import dev.caskeleton.application.fileserver.upload.UploadSessionView;
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.IOException;
|
||||
@@ -35,7 +38,7 @@ import java.util.UUID;
|
||||
* production service does. A chunk checksum is likewise compared with the digest of that chunk
|
||||
* alone, and a mismatch is rejected before the bytes are kept.
|
||||
*/
|
||||
public final class InMemoryUploadApplicationService implements UploadApplicationService {
|
||||
public final class InMemoryUploadApplicationService {
|
||||
|
||||
private final Map<UploadId, Session> sessions = new LinkedHashMap<>();
|
||||
private boolean expired;
|
||||
@@ -56,7 +59,6 @@ public final class InMemoryUploadApplicationService implements UploadApplication
|
||||
return require(uploadId).cancelled;
|
||||
}
|
||||
|
||||
@Override
|
||||
public UploadSessionView create(CreateUploadRequest request, RequestContext context) {
|
||||
UploadId uploadId = UploadId.of(UUID.randomUUID());
|
||||
Session session = new Session(FileId.of(UUID.randomUUID()), request);
|
||||
@@ -64,7 +66,6 @@ public final class InMemoryUploadApplicationService implements UploadApplication
|
||||
return view(uploadId, session);
|
||||
}
|
||||
|
||||
@Override
|
||||
public AppendUploadResult append(
|
||||
UploadId uploadId,
|
||||
long expectedOffset,
|
||||
@@ -91,12 +92,10 @@ public final class InMemoryUploadApplicationService implements UploadApplication
|
||||
session.buffer.size(), appended, sha256Hex(session.buffer.toByteArray()));
|
||||
}
|
||||
|
||||
@Override
|
||||
public UploadSessionView status(UploadId uploadId, RequestContext context) {
|
||||
return view(uploadId, require(uploadId));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void cancel(UploadId uploadId, RequestContext context) {
|
||||
require(uploadId).cancelled = true;
|
||||
}
|
||||
@@ -170,4 +169,34 @@ public final class InMemoryUploadApplicationService implements UploadApplication
|
||||
this.request = request;
|
||||
}
|
||||
}
|
||||
|
||||
/** This fake as the create port. */
|
||||
public CreateUploadUseCase createPort() {
|
||||
return command -> create(command.request(), command.context());
|
||||
}
|
||||
|
||||
/** This fake as the append port. */
|
||||
public AppendUploadUseCase appendPort() {
|
||||
return command ->
|
||||
append(
|
||||
command.uploadId(),
|
||||
command.expectedOffset(),
|
||||
command.content(),
|
||||
command.contentLength(),
|
||||
command.expectedChunkSha256(),
|
||||
command.context());
|
||||
}
|
||||
|
||||
/** This fake as the status port. */
|
||||
public GetUploadStatusUseCase statusPort() {
|
||||
return query -> status(query.uploadId(), query.context());
|
||||
}
|
||||
|
||||
/** This fake as the cancel port. */
|
||||
public CancelUploadUseCase cancelPort() {
|
||||
return command -> {
|
||||
cancel(command.uploadId(), command.context());
|
||||
return null;
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
+48
-15
@@ -1,10 +1,9 @@
|
||||
package dev.caskeleton.adapter.inbound.web.fileserver.testkit;
|
||||
|
||||
import dev.caskeleton.application.fileserver.admin.FileserverAdminService;
|
||||
import dev.caskeleton.application.fileserver.admin.ForceDeleteCommand;
|
||||
import dev.caskeleton.adapter.inbound.web.fileserver.admin.FileserverAdminController;
|
||||
import dev.caskeleton.adapter.inbound.web.fileserver.security.FileserverRequestContextFactory;
|
||||
import dev.caskeleton.application.fileserver.admin.IncompleteUploadView;
|
||||
import dev.caskeleton.application.fileserver.admin.OrphanObject;
|
||||
import dev.caskeleton.application.fileserver.admin.OrphanReconcileCommand;
|
||||
import dev.caskeleton.application.fileserver.admin.OrphanReconcileReport;
|
||||
import dev.caskeleton.application.fileserver.admin.RuntimeCapabilityReport;
|
||||
import dev.caskeleton.application.fileserver.admin.StorageHealthReport;
|
||||
@@ -17,6 +16,16 @@ import dev.caskeleton.application.fileserver.api.content.PublishMode;
|
||||
import dev.caskeleton.application.fileserver.api.metadata.FileDescriptor;
|
||||
import dev.caskeleton.application.fileserver.api.security.RequestContext;
|
||||
import dev.caskeleton.application.fileserver.cleanup.CleanupBatchResult;
|
||||
import dev.caskeleton.application.fileserver.port.in.CleanupUploadsUseCase;
|
||||
import dev.caskeleton.application.fileserver.port.in.ForceDeleteCommand;
|
||||
import dev.caskeleton.application.fileserver.port.in.ForceDeleteFileUseCase;
|
||||
import dev.caskeleton.application.fileserver.port.in.GetRuntimeCapabilitiesUseCase;
|
||||
import dev.caskeleton.application.fileserver.port.in.GetStorageHealthUseCase;
|
||||
import dev.caskeleton.application.fileserver.port.in.ListIncompleteUploadsUseCase;
|
||||
import dev.caskeleton.application.fileserver.port.in.ListOrphansUseCase;
|
||||
import dev.caskeleton.application.fileserver.port.in.OrphanReconcileCommand;
|
||||
import dev.caskeleton.application.fileserver.port.in.ReconcileOrphansUseCase;
|
||||
import dev.caskeleton.application.fileserver.port.in.ReverifyFileUseCase;
|
||||
import dev.caskeleton.application.fileserver.upload.FileView;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
@@ -24,7 +33,7 @@ import java.util.Optional;
|
||||
import java.util.UUID;
|
||||
|
||||
/** Admin service that records what the controller forwarded, without touching storage. */
|
||||
public final class RecordingAdminService implements FileserverAdminService {
|
||||
public final class RecordingAdminService {
|
||||
|
||||
private final List<ForceDeleteCommand> forceDeletes = new ArrayList<>();
|
||||
private OrphanReconcileCommand lastReconcile;
|
||||
@@ -42,12 +51,10 @@ public final class RecordingAdminService implements FileserverAdminService {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public StorageHealthReport storageHealth(RequestContext context) {
|
||||
return new StorageHealthReport(1000, 400, 0.6, true, true, "linux-ext4", List.of());
|
||||
}
|
||||
|
||||
@Override
|
||||
public RuntimeCapabilityReport capabilities(RequestContext context) {
|
||||
return new RuntimeCapabilityReport(
|
||||
"LOCAL",
|
||||
@@ -56,19 +63,15 @@ public final class RecordingAdminService implements FileserverAdminService {
|
||||
"linux-ext4");
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<OrphanObject> orphans(int limit, RequestContext context) {
|
||||
return List.of();
|
||||
}
|
||||
|
||||
@Override
|
||||
public OrphanReconcileReport reconcileOrphans(
|
||||
OrphanReconcileCommand command, RequestContext context) {
|
||||
public OrphanReconcileReport reconcileOrphans(OrphanReconcileCommand command) {
|
||||
this.lastReconcile = command;
|
||||
return new OrphanReconcileReport(command.dryRun(), List.of(), 0, 0, 0);
|
||||
}
|
||||
|
||||
@Override
|
||||
public FileView reverify(FileId fileId, RequestContext context) {
|
||||
return FileView.of(
|
||||
new FileDescriptor(
|
||||
@@ -84,12 +87,10 @@ public final class RecordingAdminService implements FileserverAdminService {
|
||||
1));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void forceDelete(ForceDeleteCommand command, RequestContext context) {
|
||||
public void forceDelete(ForceDeleteCommand command) {
|
||||
forceDeletes.add(command);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<IncompleteUploadView> incompleteUploads(int limit, RequestContext context) {
|
||||
return List.of(
|
||||
new IncompleteUploadView(
|
||||
@@ -101,8 +102,40 @@ public final class RecordingAdminService implements FileserverAdminService {
|
||||
Optional.of(FileserverWebFixtures.NOW)));
|
||||
}
|
||||
|
||||
@Override
|
||||
public CleanupBatchResult cleanupUploads(int maxItems, long maxBytes, RequestContext context) {
|
||||
return CleanupBatchResult.empty();
|
||||
}
|
||||
|
||||
/**
|
||||
* The admin controller over this fake, one port per operation.
|
||||
*
|
||||
* @param contextFactory the request context source
|
||||
* @return the controller
|
||||
*/
|
||||
public FileserverAdminController controller(FileserverRequestContextFactory contextFactory) {
|
||||
GetStorageHealthUseCase health = query -> storageHealth(query.context());
|
||||
GetRuntimeCapabilitiesUseCase runtime = query -> capabilities(query.context());
|
||||
ListOrphansUseCase orphanList = query -> orphans(query.limit(), query.context());
|
||||
ReconcileOrphansUseCase reconcile = this::reconcileOrphans;
|
||||
ReverifyFileUseCase reverifying = command -> reverify(command.fileId(), command.context());
|
||||
ForceDeleteFileUseCase forcing =
|
||||
command -> {
|
||||
forceDelete(command);
|
||||
return null;
|
||||
};
|
||||
ListIncompleteUploadsUseCase incomplete =
|
||||
query -> incompleteUploads(query.limit(), query.context());
|
||||
CleanupUploadsUseCase cleanup =
|
||||
command -> cleanupUploads(command.maxItems(), command.maxBytes(), command.context());
|
||||
return new FileserverAdminController(
|
||||
health,
|
||||
runtime,
|
||||
orphanList,
|
||||
reconcile,
|
||||
reverifying,
|
||||
forcing,
|
||||
incomplete,
|
||||
cleanup,
|
||||
contextFactory);
|
||||
}
|
||||
}
|
||||
|
||||
+7
-10
@@ -5,18 +5,17 @@ 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.metadata.FileDescriptor;
|
||||
import dev.caskeleton.application.fileserver.api.metadata.UploadSession;
|
||||
import dev.caskeleton.application.fileserver.api.security.RequestContext;
|
||||
import dev.caskeleton.application.fileserver.port.in.FinalizeUploadUseCase;
|
||||
import dev.caskeleton.application.fileserver.upload.FileView;
|
||||
import dev.caskeleton.application.fileserver.upload.FinalizeUploadRequest;
|
||||
import dev.caskeleton.application.fileserver.upload.FinalizeUploadService;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
import java.util.UUID;
|
||||
import java.util.concurrent.CopyOnWriteArrayList;
|
||||
|
||||
/** Records which uploads a protocol adapter decided to finalize. */
|
||||
public final class RecordingFinalizeService implements FinalizeUploadService {
|
||||
public final class RecordingFinalizeService {
|
||||
|
||||
private final List<UploadId> finalized = new CopyOnWriteArrayList<>();
|
||||
private final List<String> threads = new CopyOnWriteArrayList<>();
|
||||
@@ -30,13 +29,6 @@ public final class RecordingFinalizeService implements FinalizeUploadService {
|
||||
return List.copyOf(threads);
|
||||
}
|
||||
|
||||
@Override
|
||||
public FileView finalizeUpload(
|
||||
UploadSession session, FinalizeUploadRequest request, RequestContext context) {
|
||||
return finalizeUpload(session.uploadId(), request, context);
|
||||
}
|
||||
|
||||
@Override
|
||||
public FileView finalizeUpload(
|
||||
UploadId uploadId, FinalizeUploadRequest request, RequestContext context) {
|
||||
finalized.add(uploadId);
|
||||
@@ -54,4 +46,9 @@ public final class RecordingFinalizeService implements FinalizeUploadService {
|
||||
Optional.empty(),
|
||||
1));
|
||||
}
|
||||
|
||||
/** This fake as the finalize port. */
|
||||
public FinalizeUploadUseCase port() {
|
||||
return command -> finalizeUpload(command.uploadId(), command.request(), command.context());
|
||||
}
|
||||
}
|
||||
|
||||
+13
-3
@@ -6,10 +6,10 @@ import dev.caskeleton.application.fileserver.api.StorageNamespace;
|
||||
import dev.caskeleton.application.fileserver.api.error.FileserverException;
|
||||
import dev.caskeleton.application.fileserver.api.metadata.FileDescriptor;
|
||||
import dev.caskeleton.application.fileserver.api.security.RequestContext;
|
||||
import dev.caskeleton.application.fileserver.port.in.UploadFileUseCase;
|
||||
import dev.caskeleton.application.fileserver.upload.CreateUploadRequest;
|
||||
import dev.caskeleton.application.fileserver.upload.FileView;
|
||||
import dev.caskeleton.application.fileserver.upload.FinalizeUploadRequest;
|
||||
import dev.caskeleton.application.fileserver.upload.SingleShotUploadService;
|
||||
import java.io.IOException;
|
||||
import java.io.UncheckedIOException;
|
||||
import java.nio.ByteBuffer;
|
||||
@@ -29,7 +29,7 @@ import java.util.function.Function;
|
||||
* pass a fake that ignored the channel, so this one proves the bytes actually arrived through the
|
||||
* channel the controller handed over.
|
||||
*/
|
||||
public final class RecordingUploadService implements SingleShotUploadService {
|
||||
public final class RecordingUploadService {
|
||||
|
||||
private final List<String> receivedBodies = new ArrayList<>();
|
||||
private final List<CreateUploadRequest> requests = new ArrayList<>();
|
||||
@@ -59,7 +59,6 @@ public final class RecordingUploadService implements SingleShotUploadService {
|
||||
return List.copyOf(declaredContentLengths);
|
||||
}
|
||||
|
||||
@Override
|
||||
public FileView upload(
|
||||
CreateUploadRequest request,
|
||||
ReadableByteChannel content,
|
||||
@@ -111,4 +110,15 @@ public final class RecordingUploadService implements SingleShotUploadService {
|
||||
1);
|
||||
return FileView.of(descriptor);
|
||||
}
|
||||
|
||||
/** This fake as the single-request upload port. */
|
||||
public UploadFileUseCase port() {
|
||||
return command ->
|
||||
upload(
|
||||
command.request(),
|
||||
command.content(),
|
||||
command.contentLength(),
|
||||
command.finalizeRequest(),
|
||||
command.context());
|
||||
}
|
||||
}
|
||||
|
||||
+28
-10
@@ -17,10 +17,12 @@ import dev.caskeleton.application.fileserver.api.metadata.FileDescriptor;
|
||||
import dev.caskeleton.application.fileserver.api.security.RequestContext;
|
||||
import dev.caskeleton.application.fileserver.api.security.SanitizedFilename;
|
||||
import dev.caskeleton.application.fileserver.api.transfer.FileRepresentation;
|
||||
import dev.caskeleton.application.fileserver.download.DownloadApplicationService;
|
||||
import dev.caskeleton.application.fileserver.download.DownloadDescriptor;
|
||||
import dev.caskeleton.application.fileserver.download.DownloadRequest;
|
||||
import dev.caskeleton.application.fileserver.download.ZeroCopyTransferResult;
|
||||
import dev.caskeleton.application.fileserver.port.in.DescribeFileUseCase;
|
||||
import dev.caskeleton.application.fileserver.port.in.OpenDownloadContentUseCase;
|
||||
import dev.caskeleton.application.fileserver.port.in.PrepareDownloadUseCase;
|
||||
import dev.caskeleton.application.fileserver.port.in.TransferDownloadContentUseCase;
|
||||
import dev.caskeleton.application.fileserver.upload.FileView;
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.nio.channels.Channels;
|
||||
@@ -34,7 +36,7 @@ import java.util.Optional;
|
||||
import java.util.UUID;
|
||||
|
||||
/** Download service backed by an in-memory immutable representation. */
|
||||
public final class StubDownloadService implements DownloadApplicationService {
|
||||
public final class StubDownloadService {
|
||||
|
||||
public static final String DIGEST = "d".repeat(64);
|
||||
public static final Instant PUBLISHED_AT = Instant.parse("2026-08-07T10:00:00Z");
|
||||
@@ -78,27 +80,24 @@ public final class StubDownloadService implements DownloadApplicationService {
|
||||
new HttpDownloadPolicy(HttpRangePolicy.unbounded(), "private, no-store", false));
|
||||
}
|
||||
|
||||
@Override
|
||||
public FileView describeFile(FileId fileId, RequestContext context) {
|
||||
return FileView.of(descriptor(fileId));
|
||||
}
|
||||
|
||||
@Override
|
||||
public DownloadDescriptor describe(DownloadRequest request, RequestContext context) {
|
||||
public DownloadDescriptor describe(FileId fileId, RequestContext context) {
|
||||
if (!state.isPubliclyReadable()) {
|
||||
throw new FileserverException(
|
||||
"file is not in a publicly readable state",
|
||||
FileserverFailureContext.forFileState(
|
||||
FileserverErrorCode.FILE_NOT_READY, request.fileId(), state, true));
|
||||
FileserverErrorCode.FILE_NOT_READY, fileId, state, true));
|
||||
}
|
||||
return new DownloadDescriptor(
|
||||
request.fileId(),
|
||||
fileId,
|
||||
new FileRepresentation(DIGEST, PUBLISHED_AT, content.length, mediaType),
|
||||
ContentKey.of("ab/cd/stub-object-000001"),
|
||||
new SanitizedFilename(filename));
|
||||
}
|
||||
|
||||
@Override
|
||||
public ReadableByteChannel openContent(DownloadDescriptor descriptor, ByteRange range) {
|
||||
opened.add(range);
|
||||
int from = Math.toIntExact(range.startInclusive());
|
||||
@@ -106,7 +105,6 @@ public final class StubDownloadService implements DownloadApplicationService {
|
||||
return Channels.newChannel(new ByteArrayInputStream(Arrays.copyOfRange(content, from, to)));
|
||||
}
|
||||
|
||||
@Override
|
||||
public ZeroCopyTransferResult transferContent(
|
||||
DownloadDescriptor descriptor, ByteRange range, WritableByteChannel sink) {
|
||||
return ZeroCopyTransferResult.notStarted();
|
||||
@@ -130,4 +128,24 @@ public final class StubDownloadService implements DownloadApplicationService {
|
||||
return FileId.of(
|
||||
UUID.nameUUIDFromBytes("stub-download".getBytes(java.nio.charset.StandardCharsets.UTF_8)));
|
||||
}
|
||||
|
||||
/** This fake as the describe port. */
|
||||
public DescribeFileUseCase describePort() {
|
||||
return query -> describeFile(query.fileId(), query.context());
|
||||
}
|
||||
|
||||
/** This fake as the prepare-download port. */
|
||||
public PrepareDownloadUseCase preparePort() {
|
||||
return query -> describe(query.fileId(), query.context());
|
||||
}
|
||||
|
||||
/** This fake as the open-content port. */
|
||||
public OpenDownloadContentUseCase openPort() {
|
||||
return query -> openContent(query.descriptor(), query.byteRange());
|
||||
}
|
||||
|
||||
/** This fake as the zero-copy transfer port. */
|
||||
public TransferDownloadContentUseCase transferPort() {
|
||||
return query -> transferContent(query.descriptor(), query.byteRange(), query.sink());
|
||||
}
|
||||
}
|
||||
|
||||
+5
-2
@@ -39,8 +39,11 @@ class TusProtocolContractTest {
|
||||
mvc =
|
||||
MockMvcBuilders.standaloneSetup(
|
||||
new TusController(
|
||||
uploads,
|
||||
finalizeService,
|
||||
uploads.createPort(),
|
||||
uploads.statusPort(),
|
||||
uploads.appendPort(),
|
||||
finalizeService.port(),
|
||||
uploads.cancelPort(),
|
||||
new TusRequestParser(TUS),
|
||||
FileserverWebFixtures.contextFactory(),
|
||||
FileserverWebFixtures.transferExecutor(),
|
||||
|
||||
@@ -2,7 +2,6 @@ plugins {
|
||||
id 'ca.spring-library'
|
||||
id 'ca.spring-config'
|
||||
id 'java-test-fixtures'
|
||||
id 'ca.auxiliary-source-set'
|
||||
}
|
||||
|
||||
// Shared test code as a Gradle test-fixtures variant — ADR-BUILD-001.
|
||||
@@ -50,22 +49,39 @@ tasks.named('test') {
|
||||
// The web platform's reusable ArchUnit rules ship in their own source set, consumed by this leaf's
|
||||
// tests and by the composition root. A rule pack that only its own fixture tests import is verified
|
||||
// as library code and applied to nothing — the shape the JPA testkit had to be corrected out of.
|
||||
auxiliarySourceSets {
|
||||
sourceSet('systemTest') {
|
||||
compilesAgainst 'main', 'testFixtures'
|
||||
}
|
||||
sourceSet('performanceTest') {
|
||||
compilesAgainst 'main', 'testFixtures'
|
||||
}
|
||||
// The Jetty compatibility lane is its own source set because it needs a different embedded
|
||||
// server on the classpath. Two servers in one source set means Spring Boot picks one and the
|
||||
// "Jetty" lane silently runs on Tomcat — a compatibility matrix that certifies the same
|
||||
// container twice.
|
||||
sourceSet('jettyCompatTest') {
|
||||
compilesAgainst 'main', 'testFixtures'
|
||||
inherits 'implementation'
|
||||
testing {
|
||||
suites {
|
||||
systemTest(JvmTestSuite) {
|
||||
dependencies {
|
||||
implementation project()
|
||||
implementation testFixtures(project())
|
||||
}
|
||||
}
|
||||
performanceTest(JvmTestSuite) {
|
||||
dependencies {
|
||||
implementation project()
|
||||
implementation testFixtures(project())
|
||||
}
|
||||
}
|
||||
// The Jetty compatibility lane is its own source set because it needs a different embedded
|
||||
// server on the classpath. Two servers in one source set means Spring Boot picks one and the
|
||||
// "Jetty" lane silently runs on Tomcat — a compatibility matrix that certifies the same
|
||||
// container twice.
|
||||
jettyCompatTest(JvmTestSuite) {
|
||||
dependencies {
|
||||
implementation project()
|
||||
implementation testFixtures(project())
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
configurations {
|
||||
systemTestImplementation.extendsFrom testImplementation
|
||||
systemTestRuntimeOnly.extendsFrom testRuntimeOnly
|
||||
performanceTestImplementation.extendsFrom testImplementation
|
||||
performanceTestRuntimeOnly.extendsFrom testRuntimeOnly
|
||||
jettyCompatTestImplementation.extendsFrom testImplementation
|
||||
}
|
||||
|
||||
// ArchUnit is declared after the testkit source set exists, because `testFixturesImplementation` is
|
||||
// created by that declaration.
|
||||
|
||||
@@ -2,7 +2,6 @@ plugins {
|
||||
id 'ca.spring-library'
|
||||
id 'ca.spring-config'
|
||||
id 'java-test-fixtures'
|
||||
id 'ca.auxiliary-source-set'
|
||||
}
|
||||
|
||||
// Shared test code as a Gradle test-fixtures variant — ADR-BUILD-001.
|
||||
@@ -29,25 +28,41 @@ dependencies {
|
||||
implementation 'org.springframework.boot:spring-boot-starter-validation'
|
||||
}
|
||||
|
||||
auxiliarySourceSets {
|
||||
sourceSet('systemTest') {
|
||||
compilesAgainst 'main', 'testFixtures'
|
||||
}
|
||||
// Jetty replaces Tomcat for this lane only. With both on one classpath Boot starts Tomcat and
|
||||
// the lane certifies the same container twice — which for a WebSocket matters more than for
|
||||
// HTTP, because upgrade handling, close-frame timing and idle handling are all container code.
|
||||
// The proxy lane runs the platform behind a real Nginx. Its own source set because it is the
|
||||
// only lane that needs Docker; folded into `test`, every developer's `check` would depend on a
|
||||
// container runtime and the usual end of that is a disabled test nobody notices.
|
||||
sourceSet('nginxWebSocketTest') {
|
||||
compilesAgainst 'main', 'testFixtures'
|
||||
inherits 'implementation'
|
||||
}
|
||||
sourceSet('jettyWebSocketTest') {
|
||||
compilesAgainst 'main', 'testFixtures'
|
||||
inherits 'implementation'
|
||||
testing {
|
||||
suites {
|
||||
systemTest(JvmTestSuite) {
|
||||
dependencies {
|
||||
implementation project()
|
||||
implementation testFixtures(project())
|
||||
}
|
||||
}
|
||||
// Jetty replaces Tomcat for the jetty lane only. With both on one classpath Boot starts
|
||||
// Tomcat and the lane certifies the same container twice — which for a WebSocket matters
|
||||
// more than for HTTP, because upgrade handling, close-frame timing and idle handling are
|
||||
// all container code. The proxy lane runs the platform behind a real Nginx. Its own source
|
||||
// set because it is the only lane that needs Docker; folded into `test`, every developer's
|
||||
// `check` would depend on a container runtime and the usual end of that is a disabled test
|
||||
// nobody notices.
|
||||
nginxWebSocketTest(JvmTestSuite) {
|
||||
dependencies {
|
||||
implementation project()
|
||||
implementation testFixtures(project())
|
||||
}
|
||||
}
|
||||
jettyWebSocketTest(JvmTestSuite) {
|
||||
dependencies {
|
||||
implementation project()
|
||||
implementation testFixtures(project())
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
configurations {
|
||||
systemTestImplementation.extendsFrom testImplementation
|
||||
systemTestRuntimeOnly.extendsFrom testRuntimeOnly
|
||||
nginxWebSocketTestImplementation.extendsFrom testImplementation
|
||||
jettyWebSocketTestImplementation.extendsFrom testImplementation
|
||||
}
|
||||
|
||||
dependencies {
|
||||
// Declared rather than inherited: the `testkit` source set extended testImplementation, so the
|
||||
|
||||
+1
-1
@@ -16,7 +16,7 @@ import org.slf4j.LoggerFactory;
|
||||
* logged at the same level as a successful one: a refused force-delete is the entry a reviewer most
|
||||
* needs to find.
|
||||
*/
|
||||
public final class StructuredAdminAuditAdapter implements AdminAuditPort {
|
||||
public final class StructuredAdminAudit implements AdminAuditPort {
|
||||
|
||||
private static final Logger AUDIT = LoggerFactory.getLogger("dev.caskeleton.fileserver.audit");
|
||||
|
||||
+1
-1
@@ -12,7 +12,7 @@ import org.slf4j.LoggerFactory;
|
||||
* file needs the operator action and the user action interleaved in one ordered stream, not
|
||||
* correlated across two sinks after the fact.
|
||||
*/
|
||||
public final class StructuredFileserverAuditAdapter implements FileserverAuditPort {
|
||||
public final class StructuredFileserverAudit implements FileserverAuditPort {
|
||||
|
||||
private static final Logger AUDIT = LoggerFactory.getLogger("dev.caskeleton.fileserver.audit");
|
||||
|
||||
-1
@@ -43,7 +43,6 @@ import org.springframework.core.env.Environment;
|
||||
FileserverStorageOperationsConfiguration.class,
|
||||
FileserverVerificationConfiguration.class,
|
||||
FileserverSecurityConfiguration.class,
|
||||
FileserverDownloadLifecycleConfiguration.class,
|
||||
FileserverMaintenanceServiceConfiguration.class
|
||||
})
|
||||
public class FileserverCapabilityAutoConfiguration {
|
||||
|
||||
-70
@@ -1,70 +0,0 @@
|
||||
package dev.caskeleton.adapter.outbound.fileserver.platform.autoconfigure;
|
||||
|
||||
import dev.caskeleton.application.fileserver.api.metadata.FileMetadataPort;
|
||||
import dev.caskeleton.application.fileserver.api.metadata.UploadSessionPort;
|
||||
import dev.caskeleton.application.fileserver.api.security.FileAccessPolicyPort;
|
||||
import dev.caskeleton.application.fileserver.api.security.OriginalFilenamePolicy;
|
||||
import dev.caskeleton.application.fileserver.cleanup.CleanupQueuePort;
|
||||
import dev.caskeleton.application.fileserver.download.DefaultDownloadApplicationService;
|
||||
import dev.caskeleton.application.fileserver.download.DownloadApplicationService;
|
||||
import dev.caskeleton.application.fileserver.download.DownloadContentPort;
|
||||
import dev.caskeleton.application.fileserver.download.ZeroCopyDownloadPort;
|
||||
import dev.caskeleton.application.fileserver.lifecycle.CopyContentPort;
|
||||
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.StagingUploadLocatorPort;
|
||||
import dev.caskeleton.application.fileserver.upload.UploadIdentifierPort;
|
||||
import dev.caskeleton.application.transaction.TransactionPort;
|
||||
import java.time.Clock;
|
||||
import java.util.Optional;
|
||||
import org.springframework.beans.factory.ObjectProvider;
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
|
||||
@Configuration(proxyBeanMethods = false)
|
||||
class FileserverDownloadLifecycleConfiguration {
|
||||
|
||||
@Bean
|
||||
@ConditionalOnMissingBean
|
||||
DownloadApplicationService fileserverDownloadService(
|
||||
FileMetadataPort metadataStore,
|
||||
DownloadContentPort contentGateway,
|
||||
FileAccessPolicyPort accessPolicy,
|
||||
ZeroCopyDownloadPort zeroCopyGateway,
|
||||
ObjectProvider<FileserverMetricsPort> metrics) {
|
||||
return new DefaultDownloadApplicationService(
|
||||
metadataStore,
|
||||
contentGateway,
|
||||
accessPolicy,
|
||||
Optional.of(zeroCopyGateway),
|
||||
FileserverMetricsSupport.metricsOrNoop(metrics));
|
||||
}
|
||||
|
||||
@Bean
|
||||
@ConditionalOnMissingBean
|
||||
FileLifecycleService fileserverLifecycleService(
|
||||
FileMetadataPort metadataStore,
|
||||
CopyContentPort copyGateway,
|
||||
FileAccessPolicyPort accessPolicy,
|
||||
OriginalFilenamePolicy filenamePolicy,
|
||||
CleanupQueuePort cleanupQueue,
|
||||
UploadSessionPort sessionStore,
|
||||
StagingUploadLocatorPort stagingLocator,
|
||||
UploadIdentifierPort identifierFactory,
|
||||
TransactionPort transactions,
|
||||
Clock clock) {
|
||||
return new DefaultFileLifecycleService(
|
||||
metadataStore,
|
||||
copyGateway,
|
||||
accessPolicy,
|
||||
filenamePolicy,
|
||||
cleanupQueue,
|
||||
sessionStore,
|
||||
stagingLocator,
|
||||
identifierFactory,
|
||||
transactions,
|
||||
clock);
|
||||
}
|
||||
}
|
||||
-48
@@ -1,20 +1,13 @@
|
||||
package dev.caskeleton.adapter.outbound.fileserver.platform.autoconfigure;
|
||||
|
||||
import dev.caskeleton.application.fileserver.admin.AdminAuditPort;
|
||||
import dev.caskeleton.application.fileserver.admin.DefaultFileserverAdminService;
|
||||
import dev.caskeleton.application.fileserver.admin.FileserverAdminService;
|
||||
import dev.caskeleton.application.fileserver.admin.OrphanScanPort;
|
||||
import dev.caskeleton.application.fileserver.admin.StorageHealthPort;
|
||||
import dev.caskeleton.application.fileserver.api.metadata.FileMetadataPort;
|
||||
import dev.caskeleton.application.fileserver.api.metadata.UploadSessionPort;
|
||||
import dev.caskeleton.application.fileserver.api.security.FileAccessPolicyPort;
|
||||
import dev.caskeleton.application.fileserver.cleanup.CleanupContentPort;
|
||||
import dev.caskeleton.application.fileserver.cleanup.CleanupQueuePort;
|
||||
import dev.caskeleton.application.fileserver.cleanup.CleanupService;
|
||||
import dev.caskeleton.application.fileserver.cleanup.DefaultCleanupService;
|
||||
import dev.caskeleton.application.fileserver.cleanup.QuotaReclaimPort;
|
||||
import dev.caskeleton.application.fileserver.observability.FileserverMetricsPort;
|
||||
import dev.caskeleton.application.fileserver.observability.SafeFileFingerprint;
|
||||
import dev.caskeleton.application.fileserver.recovery.DefaultFileReconciliationService;
|
||||
import dev.caskeleton.application.fileserver.recovery.FileReconciliationService;
|
||||
import dev.caskeleton.application.fileserver.recovery.ReconciliationContentPort;
|
||||
@@ -25,7 +18,6 @@ import dev.caskeleton.application.transaction.TransactionPort;
|
||||
import java.time.Clock;
|
||||
import org.springframework.beans.factory.ObjectProvider;
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
|
||||
@@ -77,44 +69,4 @@ class FileserverMaintenanceServiceConfiguration {
|
||||
transactions,
|
||||
clock);
|
||||
}
|
||||
|
||||
/**
|
||||
* The management plane, gated on its own switch.
|
||||
*
|
||||
* <p>Admin is a separate decision from the data plane: a deployment that serves files does not
|
||||
* automatically want an endpoint that can force-delete them.
|
||||
*/
|
||||
@Bean
|
||||
@ConditionalOnMissingBean
|
||||
@ConditionalOnProperty(
|
||||
prefix = "app.fileserver-platform.admin",
|
||||
name = "enabled",
|
||||
havingValue = "true")
|
||||
FileserverAdminService fileserverAdminService(
|
||||
StorageHealthPort healthPort,
|
||||
OrphanScanPort orphanScanPort,
|
||||
FileMetadataPort metadataStore,
|
||||
UploadSessionPort sessionStore,
|
||||
StagingUploadLocatorPort stagingLocator,
|
||||
CleanupQueuePort cleanupQueue,
|
||||
CleanupService cleanupService,
|
||||
FileAccessPolicyPort accessPolicy,
|
||||
AdminAuditPort auditPort,
|
||||
SafeFileFingerprint fingerprint,
|
||||
TransactionPort transactions,
|
||||
Clock clock) {
|
||||
return new DefaultFileserverAdminService(
|
||||
healthPort,
|
||||
orphanScanPort,
|
||||
metadataStore,
|
||||
sessionStore,
|
||||
stagingLocator,
|
||||
cleanupQueue,
|
||||
cleanupService,
|
||||
accessPolicy,
|
||||
auditPort,
|
||||
fingerprint,
|
||||
transactions,
|
||||
clock);
|
||||
}
|
||||
}
|
||||
|
||||
+4
-4
@@ -1,7 +1,7 @@
|
||||
package dev.caskeleton.adapter.outbound.fileserver.platform.autoconfigure;
|
||||
|
||||
import dev.caskeleton.adapter.outbound.fileserver.platform.audit.StructuredAdminAuditAdapter;
|
||||
import dev.caskeleton.adapter.outbound.fileserver.platform.audit.StructuredFileserverAuditAdapter;
|
||||
import dev.caskeleton.adapter.outbound.fileserver.platform.audit.StructuredAdminAudit;
|
||||
import dev.caskeleton.adapter.outbound.fileserver.platform.audit.StructuredFileserverAudit;
|
||||
import dev.caskeleton.adapter.outbound.fileserver.platform.security.RoleBasedFileAccessPolicy;
|
||||
import dev.caskeleton.adapter.outbound.fileserver.platform.security.UnenforcedFileAccessPolicy;
|
||||
import dev.caskeleton.adapter.outbound.support.CapabilityStartupValidationException;
|
||||
@@ -69,13 +69,13 @@ public class FileserverSecurityConfiguration {
|
||||
@Bean
|
||||
@ConditionalOnMissingBean
|
||||
AdminAuditPort fileserverAdminAudit() {
|
||||
return new StructuredAdminAuditAdapter();
|
||||
return new StructuredAdminAudit();
|
||||
}
|
||||
|
||||
@Bean
|
||||
@ConditionalOnMissingBean
|
||||
FileserverAuditPort fileserverAccessAudit() {
|
||||
return new StructuredFileserverAuditAdapter();
|
||||
return new StructuredFileserverAudit();
|
||||
}
|
||||
|
||||
private static FileAccessPolicyPort unenforcedOrFail(Environment environment) {
|
||||
|
||||
+8
-8
@@ -1,10 +1,10 @@
|
||||
package dev.caskeleton.adapter.outbound.fileserver.platform.autoconfigure;
|
||||
|
||||
import dev.caskeleton.adapter.outbound.fileserver.platform.local.LocalBlockingContentStore;
|
||||
import dev.caskeleton.adapter.outbound.fileserver.platform.local.LocalCleanupContentGateway;
|
||||
import dev.caskeleton.adapter.outbound.fileserver.platform.local.LocalCopyContentGateway;
|
||||
import dev.caskeleton.adapter.outbound.fileserver.platform.local.LocalUploadContentGateway;
|
||||
import dev.caskeleton.adapter.outbound.fileserver.platform.local.LocalUploadStorageGateway;
|
||||
import dev.caskeleton.adapter.outbound.fileserver.platform.local.LocalCleanupContent;
|
||||
import dev.caskeleton.adapter.outbound.fileserver.platform.local.LocalCopyContent;
|
||||
import dev.caskeleton.adapter.outbound.fileserver.platform.local.LocalUploadContent;
|
||||
import dev.caskeleton.adapter.outbound.fileserver.platform.local.LocalUploadStorage;
|
||||
import dev.caskeleton.application.fileserver.admin.OrphanScanPort;
|
||||
import dev.caskeleton.application.fileserver.api.metadata.FileMetadataPort;
|
||||
import dev.caskeleton.application.fileserver.api.metadata.UploadSessionPort;
|
||||
@@ -22,7 +22,7 @@ class FileserverStorageGatewayConfiguration {
|
||||
@Bean
|
||||
@ConditionalOnMissingBean
|
||||
UploadStoragePort fileserverUploadStorageGateway(LocalBlockingContentStore store) {
|
||||
return new LocalUploadStorageGateway(store);
|
||||
return new LocalUploadStorage(store);
|
||||
}
|
||||
|
||||
@Bean
|
||||
@@ -32,7 +32,7 @@ class FileserverStorageGatewayConfiguration {
|
||||
FileMetadataPort metadataStore,
|
||||
UploadSessionPort sessionStore,
|
||||
FileserverPlatformSettings settings) {
|
||||
return new LocalUploadContentGateway(
|
||||
return new LocalUploadContent(
|
||||
store, metadataStore, sessionStore, settings.upload().maxFileSize().toBytes());
|
||||
}
|
||||
|
||||
@@ -40,13 +40,13 @@ class FileserverStorageGatewayConfiguration {
|
||||
@ConditionalOnMissingBean
|
||||
CopyContentPort fileserverCopyContentGateway(
|
||||
LocalBlockingContentStore store, FileserverPlatformSettings settings) {
|
||||
return new LocalCopyContentGateway(store, settings.upload().maxFileSize().toBytes());
|
||||
return new LocalCopyContent(store, settings.upload().maxFileSize().toBytes());
|
||||
}
|
||||
|
||||
@Bean
|
||||
@ConditionalOnMissingBean
|
||||
CleanupContentPort fileserverCleanupContentGateway(
|
||||
LocalBlockingContentStore store, OrphanScanPort orphans) {
|
||||
return new LocalCleanupContentGateway(store, orphans);
|
||||
return new LocalCleanupContent(store, orphans);
|
||||
}
|
||||
}
|
||||
|
||||
+8
-9
@@ -1,12 +1,12 @@
|
||||
package dev.caskeleton.adapter.outbound.fileserver.platform.autoconfigure;
|
||||
|
||||
import dev.caskeleton.adapter.outbound.fileserver.platform.local.LocalBlockingContentStore;
|
||||
import dev.caskeleton.adapter.outbound.fileserver.platform.local.LocalOrphanScanAdapter;
|
||||
import dev.caskeleton.adapter.outbound.fileserver.platform.local.LocalReconciliationContentProbe;
|
||||
import dev.caskeleton.adapter.outbound.fileserver.platform.local.LocalStorageHealthAdapter;
|
||||
import dev.caskeleton.adapter.outbound.fileserver.platform.local.LocalOrphanScan;
|
||||
import dev.caskeleton.adapter.outbound.fileserver.platform.local.LocalReconciliationContent;
|
||||
import dev.caskeleton.adapter.outbound.fileserver.platform.local.LocalStorageHealth;
|
||||
import dev.caskeleton.adapter.outbound.fileserver.platform.local.LocalStorageProbeResult;
|
||||
import dev.caskeleton.adapter.outbound.fileserver.platform.local.LocalStorageProperties;
|
||||
import dev.caskeleton.adapter.outbound.fileserver.platform.local.LocalStorageUsageProbe;
|
||||
import dev.caskeleton.adapter.outbound.fileserver.platform.local.LocalStorageUsage;
|
||||
import dev.caskeleton.application.fileserver.admin.ContentReferenceLedgerPort;
|
||||
import dev.caskeleton.application.fileserver.admin.OrphanScanPort;
|
||||
import dev.caskeleton.application.fileserver.admin.StorageHealthPort;
|
||||
@@ -27,7 +27,7 @@ class FileserverStorageOperationsConfiguration {
|
||||
LocalStorageProperties properties,
|
||||
LocalStorageProbeResult probeResult,
|
||||
LocalBlockingContentStore store) {
|
||||
return new LocalStorageHealthAdapter(properties, probeResult, store);
|
||||
return new LocalStorageHealth(properties, probeResult, store);
|
||||
}
|
||||
|
||||
@Bean
|
||||
@@ -37,20 +37,19 @@ class FileserverStorageOperationsConfiguration {
|
||||
LocalStorageProperties properties,
|
||||
FileserverPlatformSettings settings,
|
||||
Clock clock) {
|
||||
return new LocalOrphanScanAdapter(
|
||||
ledger, properties, settings.admin().orphanMinimumAge(), clock);
|
||||
return new LocalOrphanScan(ledger, properties, settings.admin().orphanMinimumAge(), clock);
|
||||
}
|
||||
|
||||
@Bean
|
||||
@ConditionalOnMissingBean
|
||||
StorageUsagePort fileserverStorageUsageProbe(LocalStorageProperties properties) {
|
||||
return new LocalStorageUsageProbe(properties.root());
|
||||
return new LocalStorageUsage(properties.root());
|
||||
}
|
||||
|
||||
@Bean
|
||||
@ConditionalOnMissingBean
|
||||
ReconciliationContentPort fileserverReconciliationProbe(
|
||||
LocalBlockingContentStore store, StagingUploadLocatorPort stagingLocator) {
|
||||
return new LocalReconciliationContentProbe(store, stagingLocator);
|
||||
return new LocalReconciliationContent(store, stagingLocator);
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
@@ -1,6 +1,7 @@
|
||||
package dev.caskeleton.adapter.outbound.fileserver.platform.autoconfigure;
|
||||
|
||||
import dev.caskeleton.adapter.outbound.fileserver.platform.local.LocalBlockingContentStore;
|
||||
import dev.caskeleton.adapter.outbound.fileserver.platform.verification.FileVerifier;
|
||||
import dev.caskeleton.adapter.outbound.fileserver.platform.verification.FilenamePolicyVerifier;
|
||||
import dev.caskeleton.adapter.outbound.fileserver.platform.verification.LengthVerifier;
|
||||
import dev.caskeleton.adapter.outbound.fileserver.platform.verification.LocalVerificationContentReader;
|
||||
@@ -9,7 +10,6 @@ import dev.caskeleton.adapter.outbound.fileserver.platform.verification.Scriptab
|
||||
import dev.caskeleton.adapter.outbound.fileserver.platform.verification.Sha256Verifier;
|
||||
import dev.caskeleton.adapter.outbound.fileserver.platform.verification.VerificationContentReader;
|
||||
import dev.caskeleton.adapter.outbound.fileserver.platform.verification.VerificationCoordinator;
|
||||
import dev.caskeleton.application.fileserver.api.security.FileVerifier;
|
||||
import dev.caskeleton.application.fileserver.api.security.OriginalFilenamePolicy;
|
||||
import dev.caskeleton.application.fileserver.upload.FileVerificationPort;
|
||||
import java.util.List;
|
||||
|
||||
+1
-1
@@ -17,7 +17,7 @@ import java.util.UUID;
|
||||
* <p>{@link UUID#randomUUID()} is backed by a seeded {@code SecureRandom} and is safe to share
|
||||
* across threads.
|
||||
*/
|
||||
public final class RandomUploadIdentifierFactory implements UploadIdentifierPort {
|
||||
public final class RandomUploadIdentifier implements UploadIdentifierPort {
|
||||
|
||||
@Override
|
||||
public FileId newFileId() {
|
||||
+1
@@ -1,5 +1,6 @@
|
||||
package dev.caskeleton.adapter.outbound.fileserver.platform.local;
|
||||
|
||||
import dev.caskeleton.adapter.outbound.support.filesystem.SecureDirectoryWalk;
|
||||
import dev.caskeleton.application.fileserver.api.ContentKey;
|
||||
import dev.caskeleton.application.fileserver.api.content.FinalizeContentCommand;
|
||||
import dev.caskeleton.application.fileserver.api.error.AmbiguousCompletionException;
|
||||
|
||||
+1
@@ -1,5 +1,6 @@
|
||||
package dev.caskeleton.adapter.outbound.fileserver.platform.local;
|
||||
|
||||
import dev.caskeleton.adapter.outbound.support.filesystem.SecureDirectoryWalk;
|
||||
import dev.caskeleton.application.fileserver.api.content.FinalizeContentCommand;
|
||||
import dev.caskeleton.application.fileserver.api.error.FileserverErrorCode;
|
||||
import dev.caskeleton.application.fileserver.api.error.FileserverException;
|
||||
|
||||
+2
-2
@@ -14,12 +14,12 @@ import dev.caskeleton.application.fileserver.cleanup.CleanupContentPort;
|
||||
* deleting, and the store refuses the delete when the object on disk disagrees. Dropping the
|
||||
* precondition here would turn every stale queue entry into a live-data delete.
|
||||
*/
|
||||
public final class LocalCleanupContentGateway implements CleanupContentPort {
|
||||
public final class LocalCleanupContent implements CleanupContentPort {
|
||||
|
||||
private final LocalBlockingContentStore store;
|
||||
private final OrphanScanPort orphans;
|
||||
|
||||
public LocalCleanupContentGateway(LocalBlockingContentStore store, OrphanScanPort orphans) {
|
||||
public LocalCleanupContent(LocalBlockingContentStore store, OrphanScanPort orphans) {
|
||||
this.store = store;
|
||||
this.orphans = orphans;
|
||||
}
|
||||
+3
-4
@@ -28,18 +28,17 @@ import java.util.UUID;
|
||||
* <p>A failed copy takes its staging object with it, because an abandoned partial copy has no
|
||||
* record pointing at it and would otherwise only ever be found by an orphan scan.
|
||||
*/
|
||||
public final class LocalCopyContentGateway implements CopyContentPort {
|
||||
public final class LocalCopyContent implements CopyContentPort {
|
||||
|
||||
private final LocalBlockingContentStore store;
|
||||
private final long maximumFileSize;
|
||||
private final SecureRandom random;
|
||||
|
||||
public LocalCopyContentGateway(LocalBlockingContentStore store, long maximumFileSize) {
|
||||
public LocalCopyContent(LocalBlockingContentStore store, long maximumFileSize) {
|
||||
this(store, maximumFileSize, new SecureRandom());
|
||||
}
|
||||
|
||||
LocalCopyContentGateway(
|
||||
LocalBlockingContentStore store, long maximumFileSize, SecureRandom random) {
|
||||
LocalCopyContent(LocalBlockingContentStore store, long maximumFileSize, SecureRandom random) {
|
||||
if (maximumFileSize <= 0) {
|
||||
throw new IllegalArgumentException("maximumFileSize must be positive");
|
||||
}
|
||||
+2
-2
@@ -39,7 +39,7 @@ import java.util.stream.Stream;
|
||||
* <p>Third, the delete still carries a size precondition, so even a matching fingerprint cannot
|
||||
* remove an object whose length no longer agrees with what was observed.
|
||||
*/
|
||||
public final class LocalOrphanScanAdapter implements OrphanScanPort {
|
||||
public final class LocalOrphanScan implements OrphanScanPort {
|
||||
|
||||
private static final int MAXIMUM_WALK_DEPTH = 4;
|
||||
|
||||
@@ -48,7 +48,7 @@ public final class LocalOrphanScanAdapter implements OrphanScanPort {
|
||||
private final Duration minimumAge;
|
||||
private final Clock clock;
|
||||
|
||||
public LocalOrphanScanAdapter(
|
||||
public LocalOrphanScan(
|
||||
ContentReferenceLedgerPort ledger,
|
||||
LocalStorageProperties properties,
|
||||
Duration minimumAge,
|
||||
+2
-2
@@ -19,12 +19,12 @@ import java.util.Optional;
|
||||
* exists, and reporting either as absence would have reconciliation quarantine intact files or
|
||||
* declare a completed publish not-applied.
|
||||
*/
|
||||
public final class LocalReconciliationContentProbe implements ReconciliationContentPort {
|
||||
public final class LocalReconciliationContent implements ReconciliationContentPort {
|
||||
|
||||
private final LocalBlockingContentStore store;
|
||||
private final StagingUploadLocatorPort stagingLocator;
|
||||
|
||||
public LocalReconciliationContentProbe(
|
||||
public LocalReconciliationContent(
|
||||
LocalBlockingContentStore store, StagingUploadLocatorPort stagingLocator) {
|
||||
this.store = store;
|
||||
this.stagingLocator = stagingLocator;
|
||||
+1
@@ -1,5 +1,6 @@
|
||||
package dev.caskeleton.adapter.outbound.fileserver.platform.local;
|
||||
|
||||
import dev.caskeleton.adapter.outbound.support.filesystem.SecureDirectoryWalk;
|
||||
import java.io.IOException;
|
||||
import java.nio.ByteBuffer;
|
||||
import java.nio.channels.FileChannel;
|
||||
|
||||
+17
@@ -1,5 +1,7 @@
|
||||
package dev.caskeleton.adapter.outbound.fileserver.platform.local;
|
||||
|
||||
import dev.caskeleton.adapter.outbound.support.filesystem.SecureDirectoryWalk;
|
||||
import dev.caskeleton.adapter.outbound.support.filesystem.SecureFileAccess;
|
||||
import dev.caskeleton.application.fileserver.api.error.FileAlreadyExistsException;
|
||||
import dev.caskeleton.application.fileserver.api.error.FileNotFoundException;
|
||||
import dev.caskeleton.application.fileserver.api.error.FileserverErrorCode;
|
||||
@@ -17,6 +19,16 @@ final class LocalStorageFailures {
|
||||
private LocalStorageFailures() {}
|
||||
|
||||
static FileserverException translate(IOException exception) {
|
||||
// The descriptor walk's own refusals first. They are permanent path rejections, and the
|
||||
// classifier below would read the platform's generic exception as an unavailable volume — a
|
||||
// retryable 503 that a client would retry into a link that now points somewhere else.
|
||||
if (exception instanceof SecureDirectoryWalk.SymbolicComponentException) {
|
||||
return pathRejected("a storage path component is a symbolic link");
|
||||
}
|
||||
if (exception instanceof SecureFileAccess.NotRegularFileException
|
||||
|| exception instanceof SecureDirectoryWalk.PathEscapeException) {
|
||||
return pathRejected("storage target is not a regular file below the storage root");
|
||||
}
|
||||
FileserverErrorCode code = FilesystemFailureClassifier.classify(exception);
|
||||
return switch (code) {
|
||||
case FILE_ALREADY_EXISTS ->
|
||||
@@ -42,4 +54,9 @@ final class LocalStorageFailures {
|
||||
FileserverFailureContext.of(FileserverErrorCode.STORAGE_UNAVAILABLE, true));
|
||||
};
|
||||
}
|
||||
|
||||
private static FileserverException pathRejected(String message) {
|
||||
return new FileserverException(
|
||||
message, FileserverFailureContext.of(FileserverErrorCode.PATH_OUTSIDE_NAMESPACE, false));
|
||||
}
|
||||
}
|
||||
|
||||
+2
-2
@@ -21,13 +21,13 @@ import java.util.List;
|
||||
* configured. Configuration states an intent; the probe states a fact, and only the fact is safe to
|
||||
* publish as a capability.
|
||||
*/
|
||||
public final class LocalStorageHealthAdapter implements StorageHealthPort {
|
||||
public final class LocalStorageHealth implements StorageHealthPort {
|
||||
|
||||
private final LocalStorageProperties properties;
|
||||
private final LocalStorageProbeResult probeResult;
|
||||
private final LocalBlockingContentStore store;
|
||||
|
||||
public LocalStorageHealthAdapter(
|
||||
public LocalStorageHealth(
|
||||
LocalStorageProperties properties,
|
||||
LocalStorageProbeResult probeResult,
|
||||
LocalBlockingContentStore store) {
|
||||
+2
-2
@@ -18,11 +18,11 @@ import java.util.OptionalDouble;
|
||||
* synthetic 0% would silently disable the high-water guard, and a synthetic 100% would take the
|
||||
* capability down over a failed syscall.
|
||||
*/
|
||||
public final class LocalStorageUsageProbe implements StorageUsagePort {
|
||||
public final class LocalStorageUsage implements StorageUsagePort {
|
||||
|
||||
private final Path root;
|
||||
|
||||
public LocalStorageUsageProbe(Path root) {
|
||||
public LocalStorageUsage(Path root) {
|
||||
if (!root.isAbsolute()) {
|
||||
throw new IllegalArgumentException("storage root must be absolute");
|
||||
}
|
||||
+2
-2
@@ -25,14 +25,14 @@ import java.util.OptionalLong;
|
||||
* the authoritative record rather than guessed from configuration: a file created under one
|
||||
* namespace must finalize under that same namespace even if the default has since changed.
|
||||
*/
|
||||
public final class LocalUploadContentGateway implements UploadContentPort {
|
||||
public final class LocalUploadContent implements UploadContentPort {
|
||||
|
||||
private final LocalBlockingContentStore store;
|
||||
private final FileMetadataPort metadataStore;
|
||||
private final UploadSessionPort sessionStore;
|
||||
private final long maximumFileSize;
|
||||
|
||||
public LocalUploadContentGateway(
|
||||
public LocalUploadContent(
|
||||
LocalBlockingContentStore store,
|
||||
FileMetadataPort metadataStore,
|
||||
UploadSessionPort sessionStore,
|
||||
+2
-2
@@ -19,11 +19,11 @@ import java.util.OptionalLong;
|
||||
* belongs to the store; repeating any of it here would give the capability two answers to the same
|
||||
* question.
|
||||
*/
|
||||
public final class LocalUploadStorageGateway implements UploadStoragePort {
|
||||
public final class LocalUploadStorage implements UploadStoragePort {
|
||||
|
||||
private final LocalBlockingContentStore store;
|
||||
|
||||
public LocalUploadStorageGateway(LocalBlockingContentStore store) {
|
||||
public LocalUploadStorage(LocalBlockingContentStore store) {
|
||||
this.store = store;
|
||||
}
|
||||
|
||||
+32
-194
@@ -1,53 +1,32 @@
|
||||
package dev.caskeleton.adapter.outbound.fileserver.platform.local;
|
||||
|
||||
import dev.caskeleton.adapter.outbound.support.filesystem.SecureFileAccess;
|
||||
import dev.caskeleton.application.fileserver.api.error.FileserverErrorCode;
|
||||
import dev.caskeleton.application.fileserver.api.error.FileserverException;
|
||||
import dev.caskeleton.application.fileserver.api.error.FileserverFailureContext;
|
||||
import java.io.IOException;
|
||||
import java.nio.channels.FileChannel;
|
||||
import java.nio.channels.SeekableByteChannel;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.LinkOption;
|
||||
import java.nio.file.NoSuchFileException;
|
||||
import java.nio.file.OpenOption;
|
||||
import java.nio.file.Path;
|
||||
import java.nio.file.SecureDirectoryStream;
|
||||
import java.nio.file.StandardOpenOption;
|
||||
import java.nio.file.attribute.BasicFileAttributes;
|
||||
import java.nio.file.attribute.PosixFileAttributeView;
|
||||
import java.nio.file.attribute.PosixFilePermission;
|
||||
import java.nio.file.attribute.PosixFilePermissions;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* Opens local files through directory descriptors, never through a re-resolved pathname.
|
||||
* The Fileserver's face of the shared descriptor-relative file primitive.
|
||||
*
|
||||
* <p>The previous shape proved that no component below the root was a symbolic link and then called
|
||||
* {@code FileChannel.open} on the full path. Those are two independent lookups: a directory
|
||||
* replaced between them is followed by the second one, and no amount of additional checking closes
|
||||
* that window — it only moves it. Every open, delete and stat here instead descends one directory
|
||||
* at a time with {@code NOFOLLOW_LINKS}, and performs the final operation relative to the innermost
|
||||
* descriptor, so what was verified and what is used are the same object.
|
||||
* <p>The primitive itself — descend one directory at a time with {@code NOFOLLOW_LINKS} and act
|
||||
* relative to the innermost descriptor, so what was verified and what is used are the same object —
|
||||
* is {@link SecureFileAccess} in {@code adapter:outbound:support}, where object storage's local
|
||||
* provider can use the same one. What stays here is the translation into the Fileserver's failure
|
||||
* vocabulary: a symbolic component or a non-regular leaf is a permanent {@code
|
||||
* PATH_OUTSIDE_NAMESPACE}, never a retryable storage outage, and every other filesystem failure
|
||||
* goes through {@link LocalStorageFailures}.
|
||||
*
|
||||
* <p>{@code failOnSymlink} remains as a constructor argument for the probe and for tests that
|
||||
* deliberately exercise a permissive profile. In the production profile it is pinned on, and with
|
||||
* descriptor-relative access the refusal is structural rather than advisory: a symlinked component
|
||||
* cannot be descended into at all.
|
||||
* <p>{@code failOnSymlink} remains for the capability probe, which still reasons about pathnames,
|
||||
* and for tests that exercise a permissive profile. Descriptor-relative access refuses a symlinked
|
||||
* component by construction whatever it says.
|
||||
*/
|
||||
final class SafeFileChannelFactory {
|
||||
|
||||
private static final Set<PosixFilePermission> OWNER_ONLY_FILE =
|
||||
PosixFilePermissions.fromString("rw-------");
|
||||
private static final Set<PosixFilePermission> OWNER_ONLY_DIRECTORY =
|
||||
PosixFilePermissions.fromString("rwx------");
|
||||
|
||||
private static final Set<OpenOption> CREATE_NEW_OPTIONS =
|
||||
Set.of(StandardOpenOption.CREATE_NEW, StandardOpenOption.WRITE, LinkOption.NOFOLLOW_LINKS);
|
||||
private static final Set<OpenOption> WRITE_OPTIONS =
|
||||
Set.of(StandardOpenOption.WRITE, LinkOption.NOFOLLOW_LINKS);
|
||||
private static final Set<OpenOption> READ_OPTIONS =
|
||||
Set.of(StandardOpenOption.READ, LinkOption.NOFOLLOW_LINKS);
|
||||
|
||||
private final boolean failOnSymlink;
|
||||
|
||||
SafeFileChannelFactory(boolean failOnSymlink) {
|
||||
@@ -56,99 +35,40 @@ final class SafeFileChannelFactory {
|
||||
|
||||
/** Creates a brand-new zero-length file; an existing target is a conflict, never an overwrite. */
|
||||
FileChannel createNew(Path root, Path target) {
|
||||
createParentDirectories(root, target);
|
||||
return inParent(
|
||||
root,
|
||||
target,
|
||||
(directory, leaf) -> {
|
||||
FileChannel channel =
|
||||
requireFileChannel(
|
||||
directory.newByteChannel(
|
||||
leaf,
|
||||
CREATE_NEW_OPTIONS,
|
||||
PosixFilePermissions.asFileAttribute(OWNER_ONLY_FILE)));
|
||||
// Anything that fails after the file exists must not also leak its descriptor. The
|
||||
// previous version applied permissions and re-checked the type after opening, and threw
|
||||
// both without closing.
|
||||
try {
|
||||
applyOwnerOnlyPermissions(directory, leaf);
|
||||
requireRegularFile(directory, leaf);
|
||||
return channel;
|
||||
} catch (IOException | RuntimeException failure) {
|
||||
closeQuietly(channel);
|
||||
throw failure;
|
||||
}
|
||||
});
|
||||
return translated(() -> SecureFileAccess.createNew(root, target));
|
||||
}
|
||||
|
||||
/** Opens an existing file for append; the file must already be a regular non-link file. */
|
||||
FileChannel openForWrite(Path root, Path target) {
|
||||
return inParent(
|
||||
root,
|
||||
target,
|
||||
(directory, leaf) -> {
|
||||
requireRegularFile(directory, leaf);
|
||||
return requireFileChannel(directory.newByteChannel(leaf, WRITE_OPTIONS));
|
||||
});
|
||||
return translated(() -> SecureFileAccess.openForWrite(root, target));
|
||||
}
|
||||
|
||||
/** Opens an existing file for reading, refusing anything that is not a regular file. */
|
||||
FileChannel openForRead(Path root, Path target) {
|
||||
return inParent(
|
||||
root,
|
||||
target,
|
||||
(directory, leaf) -> {
|
||||
requireRegularFile(directory, leaf);
|
||||
return requireFileChannel(directory.newByteChannel(leaf, READ_OPTIONS));
|
||||
});
|
||||
return translated(() -> SecureFileAccess.openForRead(root, target));
|
||||
}
|
||||
|
||||
/** Deletes a regular file relative to its verified parent; absence is not an error. */
|
||||
boolean deleteRegularFile(Path root, Path target) {
|
||||
return inParent(
|
||||
root,
|
||||
target,
|
||||
(directory, leaf) -> {
|
||||
try {
|
||||
requireRegularFile(directory, leaf);
|
||||
directory.deleteFile(leaf);
|
||||
return true;
|
||||
} catch (NoSuchFileException alreadyGone) {
|
||||
return false;
|
||||
}
|
||||
});
|
||||
return translated(() -> SecureFileAccess.deleteRegularFile(root, target));
|
||||
}
|
||||
|
||||
/** Reads attributes without following a link, or empty when the object is not there. */
|
||||
/** Reads attributes without following a link. */
|
||||
BasicFileAttributes readAttributes(Path root, Path target) {
|
||||
return inParent(root, target, (directory, leaf) -> attributesOf(directory, leaf));
|
||||
return translated(() -> SecureFileAccess.readAttributes(root, target));
|
||||
}
|
||||
|
||||
/** True when a regular, non-symbolic file exists at {@code target}. */
|
||||
boolean isRegularFile(Path root, Path target) {
|
||||
return inParent(
|
||||
root,
|
||||
target,
|
||||
(directory, leaf) -> {
|
||||
try {
|
||||
return attributesOf(directory, leaf).isRegularFile();
|
||||
} catch (NoSuchFileException absent) {
|
||||
return false;
|
||||
}
|
||||
});
|
||||
return translated(() -> SecureFileAccess.isRegularFile(root, target));
|
||||
}
|
||||
|
||||
void createParentDirectories(Path root, Path target) {
|
||||
Path parent = target.getParent();
|
||||
if (parent == null || Files.isDirectory(parent, LinkOption.NOFOLLOW_LINKS)) {
|
||||
return;
|
||||
}
|
||||
try {
|
||||
Files.createDirectories(parent);
|
||||
applyOwnerOnlyDirectoryPermissions(root, parent);
|
||||
} catch (IOException exception) {
|
||||
throw translate(exception);
|
||||
}
|
||||
translated(
|
||||
() -> {
|
||||
SecureFileAccess.createParentDirectories(root, target);
|
||||
return null;
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -175,102 +95,20 @@ final class SafeFileChannelFactory {
|
||||
}
|
||||
}
|
||||
|
||||
/** Type check performed through the parent descriptor, so it names the object that was opened. */
|
||||
private void requireRegularFile(SecureDirectoryStream<Path> directory, Path leaf)
|
||||
throws IOException {
|
||||
BasicFileAttributes attributes;
|
||||
/** One filesystem step whose failure is translated into the Fileserver vocabulary. */
|
||||
@FunctionalInterface
|
||||
private interface FileStep<T> {
|
||||
T run() throws IOException;
|
||||
}
|
||||
|
||||
private static <T> T translated(FileStep<T> step) {
|
||||
try {
|
||||
attributes = attributesOf(directory, leaf);
|
||||
} catch (NoSuchFileException absent) {
|
||||
return;
|
||||
}
|
||||
if (attributes.isSymbolicLink()) {
|
||||
throw symlinkRejected();
|
||||
}
|
||||
if (!attributes.isRegularFile()) {
|
||||
throw new FileserverException(
|
||||
"storage target is not a regular file",
|
||||
FileserverFailureContext.of(FileserverErrorCode.PATH_OUTSIDE_NAMESPACE, false));
|
||||
}
|
||||
}
|
||||
|
||||
private static BasicFileAttributes attributesOf(SecureDirectoryStream<Path> directory, Path leaf)
|
||||
throws IOException {
|
||||
return directory
|
||||
.getFileAttributeView(leaf, PosixFileAttributeView.class, LinkOption.NOFOLLOW_LINKS)
|
||||
.readAttributes();
|
||||
}
|
||||
|
||||
private void applyOwnerOnlyPermissions(SecureDirectoryStream<Path> directory, Path leaf)
|
||||
throws IOException {
|
||||
PosixFileAttributeView view =
|
||||
directory.getFileAttributeView(
|
||||
leaf, PosixFileAttributeView.class, LinkOption.NOFOLLOW_LINKS);
|
||||
if (view == null) {
|
||||
return;
|
||||
}
|
||||
view.setPermissions(OWNER_ONLY_FILE);
|
||||
}
|
||||
|
||||
private void applyOwnerOnlyDirectoryPermissions(Path root, Path leaf) {
|
||||
if (!supportsPosix(leaf)) {
|
||||
return;
|
||||
}
|
||||
Path relative = root.relativize(leaf);
|
||||
Path current = root;
|
||||
for (Path segment : relative) {
|
||||
current = current.resolve(segment);
|
||||
try {
|
||||
Files.setPosixFilePermissions(current, OWNER_ONLY_DIRECTORY);
|
||||
} catch (IOException exception) {
|
||||
throw translate(exception);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* The storage engine needs a {@link FileChannel}, not any seekable channel.
|
||||
*
|
||||
* <p>Positional reads, {@code truncate} for the append rollback, {@code force} for durability and
|
||||
* {@code transferTo} for zero copy are all {@code FileChannel} operations. Every platform that
|
||||
* offers {@link SecureDirectoryStream} returns one here; a platform that did not would have to be
|
||||
* refused rather than silently degraded, since the alternative is losing the rollback.
|
||||
*/
|
||||
private static FileChannel requireFileChannel(SeekableByteChannel channel) throws IOException {
|
||||
if (channel instanceof FileChannel fileChannel) {
|
||||
return fileChannel;
|
||||
}
|
||||
closeQuietly(channel);
|
||||
throw new IOException(
|
||||
"secure directory stream did not yield a FileChannel; positional write, truncate and "
|
||||
+ "force are required and cannot be emulated");
|
||||
}
|
||||
|
||||
/** Bridges the checked-exception walk into the Fileserver failure vocabulary. */
|
||||
private <T> T inParent(Path root, Path target, SecureDirectoryWalk.LeafOperation<T> operation) {
|
||||
try {
|
||||
return SecureDirectoryWalk.inParentOf(root, target, operation);
|
||||
} catch (SecureDirectoryWalk.SymbolicComponentException symlinked) {
|
||||
// A permanent path rejection, not a storage outage: it must not be answered as a retryable
|
||||
// 503, and it must never be retried into a link that now points somewhere else.
|
||||
throw symlinkRejected();
|
||||
return step.run();
|
||||
} catch (IOException exception) {
|
||||
throw translate(exception);
|
||||
}
|
||||
}
|
||||
|
||||
private static boolean supportsPosix(Path target) {
|
||||
return target.getFileSystem().supportedFileAttributeViews().contains("posix");
|
||||
}
|
||||
|
||||
private static void closeQuietly(AutoCloseable channel) {
|
||||
try {
|
||||
channel.close();
|
||||
} catch (Exception ignored) {
|
||||
// The caller is already failing; a close failure must not mask the original cause.
|
||||
}
|
||||
}
|
||||
|
||||
private static FileserverException symlinkRejected() {
|
||||
return new FileserverException(
|
||||
"a storage path component is a symbolic link",
|
||||
|
||||
+23
@@ -0,0 +1,23 @@
|
||||
package dev.caskeleton.adapter.outbound.fileserver.platform.verification;
|
||||
|
||||
import dev.caskeleton.application.fileserver.api.security.VerificationRequest;
|
||||
import dev.caskeleton.application.fileserver.api.security.VerificationResult;
|
||||
import dev.caskeleton.application.fileserver.api.security.VerificationVerdict;
|
||||
import java.util.concurrent.CompletionStage;
|
||||
|
||||
/**
|
||||
* One step of the verification pipeline {@link VerificationCoordinator} runs.
|
||||
*
|
||||
* <p>The application sees only {@code FileVerificationPort}; which steps make up the pipeline is
|
||||
* this adapter's own business, so the step type lives here rather than in the application API.
|
||||
*
|
||||
* <p>A verifier returns only a stable code and bounded safe metadata. It never logs a content
|
||||
* sample, and a failure to reach an external scanner is {@link VerificationVerdict#RETRY}, never
|
||||
* {@link VerificationVerdict#ACCEPT}.
|
||||
*/
|
||||
public interface FileVerifier {
|
||||
|
||||
String verifierId();
|
||||
|
||||
CompletionStage<VerificationResult> verify(VerificationRequest request);
|
||||
}
|
||||
-1
@@ -1,6 +1,5 @@
|
||||
package dev.caskeleton.adapter.outbound.fileserver.platform.verification;
|
||||
|
||||
import dev.caskeleton.application.fileserver.api.security.FileVerifier;
|
||||
import dev.caskeleton.application.fileserver.api.security.OriginalFilenamePolicy;
|
||||
import dev.caskeleton.application.fileserver.api.security.VerificationRequest;
|
||||
import dev.caskeleton.application.fileserver.api.security.VerificationResult;
|
||||
|
||||
-1
@@ -1,6 +1,5 @@
|
||||
package dev.caskeleton.adapter.outbound.fileserver.platform.verification;
|
||||
|
||||
import dev.caskeleton.application.fileserver.api.security.FileVerifier;
|
||||
import dev.caskeleton.application.fileserver.api.security.VerificationRequest;
|
||||
import dev.caskeleton.application.fileserver.api.security.VerificationResult;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
|
||||
-1
@@ -1,6 +1,5 @@
|
||||
package dev.caskeleton.adapter.outbound.fileserver.platform.verification;
|
||||
|
||||
import dev.caskeleton.application.fileserver.api.security.FileVerifier;
|
||||
import dev.caskeleton.application.fileserver.api.security.VerificationRequest;
|
||||
import dev.caskeleton.application.fileserver.api.security.VerificationResult;
|
||||
import java.util.List;
|
||||
|
||||
-1
@@ -1,6 +1,5 @@
|
||||
package dev.caskeleton.adapter.outbound.fileserver.platform.verification;
|
||||
|
||||
import dev.caskeleton.application.fileserver.api.security.FileVerifier;
|
||||
import dev.caskeleton.application.fileserver.api.security.VerificationRequest;
|
||||
import dev.caskeleton.application.fileserver.api.security.VerificationResult;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
|
||||
-1
@@ -1,6 +1,5 @@
|
||||
package dev.caskeleton.adapter.outbound.fileserver.platform.verification;
|
||||
|
||||
import dev.caskeleton.application.fileserver.api.security.FileVerifier;
|
||||
import dev.caskeleton.application.fileserver.api.security.VerificationRequest;
|
||||
import dev.caskeleton.application.fileserver.api.security.VerificationResult;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
|
||||
-1
@@ -1,6 +1,5 @@
|
||||
package dev.caskeleton.adapter.outbound.fileserver.platform.verification;
|
||||
|
||||
import dev.caskeleton.application.fileserver.api.security.FileVerifier;
|
||||
import dev.caskeleton.application.fileserver.api.security.VerificationRequest;
|
||||
import dev.caskeleton.application.fileserver.api.security.VerificationResult;
|
||||
import dev.caskeleton.application.fileserver.upload.FileVerificationPort;
|
||||
|
||||
+8
-8
@@ -32,7 +32,7 @@ import org.junit.jupiter.api.io.TempDir;
|
||||
* failure mode that matters: a scan that misses an orphan wastes disk, a scan that names a live
|
||||
* object loses a file.
|
||||
*/
|
||||
class LocalOrphanScanAdapterTest {
|
||||
class LocalOrphanScanTest {
|
||||
|
||||
private static final Instant NOW = Instant.parse("2026-08-08T12:00:00Z");
|
||||
private static final Duration GRACE = Duration.ofHours(1);
|
||||
@@ -87,7 +87,7 @@ class LocalOrphanScanAdapterTest {
|
||||
@Test
|
||||
void retiringWithTheObservedFingerprintTakesTheObjectOutOfService() {
|
||||
StoredContent published = publish("reclaim me");
|
||||
LocalOrphanScanAdapter scanner = scanner(NOW.plus(Duration.ofDays(1)));
|
||||
LocalOrphanScan scanner = scanner(NOW.plus(Duration.ofDays(1)));
|
||||
OrphanObject orphan = scanner.scan(10).get(0);
|
||||
|
||||
assertThat(scanner.deleteIfFingerprintMatches(orphan.contentKey(), orphan.fingerprint()))
|
||||
@@ -104,7 +104,7 @@ class LocalOrphanScanAdapterTest {
|
||||
@Test
|
||||
void anObjectClaimedWhileItIsBeingRetiredIsPutBack() {
|
||||
StoredContent published = publish("adopted mid-flight");
|
||||
LocalOrphanScanAdapter scanner = scanner(NOW.plus(Duration.ofDays(1)));
|
||||
LocalOrphanScan scanner = scanner(NOW.plus(Duration.ofDays(1)));
|
||||
OrphanObject orphan = scanner.scan(10).get(0);
|
||||
// The ledger starts unreferenced and becomes referenced on its second consultation, which is
|
||||
// exactly the interleaving a check-then-unlink cannot survive.
|
||||
@@ -119,7 +119,7 @@ class LocalOrphanScanAdapterTest {
|
||||
@Test
|
||||
void aQuarantinedObjectIsPurgedOnlyWhileNothingReferencesIt() {
|
||||
StoredContent published = publish("purge me");
|
||||
LocalOrphanScanAdapter scanner = scanner(NOW.plus(Duration.ofDays(1)));
|
||||
LocalOrphanScan scanner = scanner(NOW.plus(Duration.ofDays(1)));
|
||||
OrphanObject orphan = scanner.scan(10).get(0);
|
||||
scanner.deleteIfFingerprintMatches(orphan.contentKey(), orphan.fingerprint());
|
||||
|
||||
@@ -133,7 +133,7 @@ class LocalOrphanScanAdapterTest {
|
||||
@Test
|
||||
void deletingWithAStaleFingerprintIsRefused() {
|
||||
StoredContent published = publish("protected");
|
||||
LocalOrphanScanAdapter scanner = scanner(NOW.plus(Duration.ofDays(1)));
|
||||
LocalOrphanScan scanner = scanner(NOW.plus(Duration.ofDays(1)));
|
||||
|
||||
assertThat(scanner.deleteIfFingerprintMatches(published.contentKey(), "not-what-was-seen"))
|
||||
.isFalse();
|
||||
@@ -143,7 +143,7 @@ class LocalOrphanScanAdapterTest {
|
||||
@Test
|
||||
void anObjectThatGainedARecordBetweenScanAndApplyIsNoLongerDeletable() {
|
||||
StoredContent published = publish("adopted");
|
||||
LocalOrphanScanAdapter scanner = scanner(NOW.plus(Duration.ofDays(1)));
|
||||
LocalOrphanScan scanner = scanner(NOW.plus(Duration.ofDays(1)));
|
||||
OrphanObject orphan = scanner.scan(10).get(0);
|
||||
|
||||
referenced.add(published.contentKey().value());
|
||||
@@ -168,7 +168,7 @@ class LocalOrphanScanAdapterTest {
|
||||
|
||||
private String claimAfterFirstLookup;
|
||||
|
||||
private LocalOrphanScanAdapter scanner(Instant now) {
|
||||
private LocalOrphanScan scanner(Instant now) {
|
||||
ContentReferenceLedgerPort ledger =
|
||||
key -> {
|
||||
if (key.value().equals(claimAfterFirstLookup)) {
|
||||
@@ -179,7 +179,7 @@ class LocalOrphanScanAdapterTest {
|
||||
}
|
||||
return referenced.contains(key.value()) || claimedKeys.contains(key.value());
|
||||
};
|
||||
return new LocalOrphanScanAdapter(
|
||||
return new LocalOrphanScan(
|
||||
ledger,
|
||||
LocalContentStoreFixture.properties(root, PublishMode.ATOMIC_MOVE_PREFERRED),
|
||||
GRACE,
|
||||
+74
@@ -0,0 +1,74 @@
|
||||
package dev.caskeleton.adapter.outbound.fileserver.platform.local;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.assertj.core.api.Assertions.catchThrowableOfType;
|
||||
|
||||
import dev.caskeleton.adapter.outbound.support.filesystem.SecureDirectoryWalk;
|
||||
import dev.caskeleton.application.fileserver.api.error.FileserverErrorCode;
|
||||
import dev.caskeleton.application.fileserver.api.error.FileserverException;
|
||||
import java.io.IOException;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
import java.util.List;
|
||||
import org.junit.jupiter.api.Assumptions;
|
||||
import org.junit.jupiter.api.DisplayName;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.api.io.TempDir;
|
||||
|
||||
/**
|
||||
* A path the descriptor walk refuses is a permanent rejection wherever the refusal surfaces.
|
||||
*
|
||||
* <p>The publish move and the directory fsync call the walk directly rather than through the file
|
||||
* channel factory, and their failures went through the generic classifier, which reads the refusal
|
||||
* as an unavailable volume: a retryable 503 that a client would retry into a link that now points
|
||||
* somewhere else.
|
||||
*/
|
||||
class LocalStorageFailuresTest {
|
||||
|
||||
@TempDir Path root;
|
||||
|
||||
@Test
|
||||
@DisplayName("게시 이동 중 심볼릭 링크 경로 거부는 재시도 불가 PATH_OUTSIDE_NAMESPACE로 번역된다")
|
||||
void aSymbolicComponentRefusedByTheWalkIsAPermanentPathRejection() throws IOException {
|
||||
// given
|
||||
Assumptions.assumeTrue(SecureDirectoryWalk.isSupported(root));
|
||||
Path source = root.resolve("staging/aa/source.part");
|
||||
Path outside = root.resolve("outside");
|
||||
Files.createDirectories(source.getParent());
|
||||
Files.createDirectories(root.resolve("content"));
|
||||
Files.createDirectories(outside);
|
||||
Files.writeString(source, "payload");
|
||||
Files.createSymbolicLink(root.resolve("content/redirect"), outside);
|
||||
IOException refusal =
|
||||
catchThrowableOfType(
|
||||
IOException.class,
|
||||
() -> SecureDirectoryWalk.move(root, source, root.resolve("content/redirect/object")));
|
||||
|
||||
// when
|
||||
FileserverException translated = LocalStorageFailures.translate(refusal);
|
||||
|
||||
// then
|
||||
assertThat(List.of(translated.code(), translated.context().retryable()))
|
||||
.containsExactly(FileserverErrorCode.PATH_OUTSIDE_NAMESPACE, false);
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisplayName("루트 밖을 가리키는 대상은 재시도 불가 PATH_OUTSIDE_NAMESPACE로 번역된다")
|
||||
void aTargetOutsideTheRootIsAPermanentPathRejection() {
|
||||
// given
|
||||
Assumptions.assumeTrue(SecureDirectoryWalk.isSupported(root));
|
||||
IOException refusal =
|
||||
catchThrowableOfType(
|
||||
IOException.class,
|
||||
() ->
|
||||
SecureDirectoryWalk.inParentOf(
|
||||
root, root.resolve("../elsewhere/object"), (directory, leaf) -> null));
|
||||
|
||||
// when
|
||||
FileserverException translated = LocalStorageFailures.translate(refusal);
|
||||
|
||||
// then
|
||||
assertThat(List.of(translated.code(), translated.context().retryable()))
|
||||
.containsExactly(FileserverErrorCode.PATH_OUTSIDE_NAMESPACE, false);
|
||||
}
|
||||
}
|
||||
+7
-7
@@ -45,23 +45,23 @@ class LocalStorageGatewayContractTest {
|
||||
@TempDir Path root;
|
||||
|
||||
private LocalBlockingContentStore store;
|
||||
private LocalUploadStorageGateway uploads;
|
||||
private LocalCleanupContentGateway cleanup;
|
||||
private LocalCopyContentGateway copies;
|
||||
private LocalUploadStorage uploads;
|
||||
private LocalCleanupContent cleanup;
|
||||
private LocalCopyContent copies;
|
||||
|
||||
@BeforeEach
|
||||
void setUp() {
|
||||
store = LocalContentStoreFixture.store(root, PublishMode.ATOMIC_MOVE_PREFERRED);
|
||||
uploads = new LocalUploadStorageGateway(store);
|
||||
uploads = new LocalUploadStorage(store);
|
||||
cleanup =
|
||||
new LocalCleanupContentGateway(
|
||||
new LocalCleanupContent(
|
||||
store,
|
||||
new LocalOrphanScanAdapter(
|
||||
new LocalOrphanScan(
|
||||
key -> false,
|
||||
LocalContentStoreFixture.properties(root, PublishMode.ATOMIC_MOVE_PREFERRED),
|
||||
Duration.ZERO,
|
||||
Clock.systemUTC()));
|
||||
copies = new LocalCopyContentGateway(store, LocalContentStoreFixture.MAX_FILE);
|
||||
copies = new LocalCopyContent(store, LocalContentStoreFixture.MAX_FILE);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
-1
@@ -4,7 +4,6 @@ import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
import dev.caskeleton.application.fileserver.api.FileId;
|
||||
import dev.caskeleton.application.fileserver.api.UploadId;
|
||||
import dev.caskeleton.application.fileserver.api.security.FileVerifier;
|
||||
import dev.caskeleton.application.fileserver.api.security.OriginalFilenamePolicy;
|
||||
import dev.caskeleton.application.fileserver.api.security.SanitizedFilename;
|
||||
import dev.caskeleton.application.fileserver.api.security.VerificationRequest;
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
plugins {
|
||||
id 'ca.spring-library'
|
||||
id 'java-test-fixtures'
|
||||
id 'ca.auxiliary-source-set'
|
||||
id 'ca.platform-module'
|
||||
id 'me.champeau.jmh'
|
||||
}
|
||||
@@ -82,10 +81,27 @@ dependencies {
|
||||
// Performance certification and JMH benchmarks are separate source sets for their own reason: they
|
||||
// are slow, they assert on resource bounds rather than behaviour, and they must never be part of
|
||||
// the default unit lane.
|
||||
auxiliarySourceSets {
|
||||
// The testkit compiles against exactly what a test does: `implementation` inheritance runs
|
||||
sourceSet('integrationTest') { compilesAgainst 'main', 'testFixtures' }
|
||||
sourceSet('httpClientPerformanceTest') { compilesAgainst 'main', 'testFixtures' }
|
||||
testing {
|
||||
suites {
|
||||
integrationTest(JvmTestSuite) {
|
||||
dependencies {
|
||||
implementation project()
|
||||
implementation testFixtures(project())
|
||||
}
|
||||
}
|
||||
httpClientPerformanceTest(JvmTestSuite) {
|
||||
dependencies {
|
||||
implementation project()
|
||||
implementation testFixtures(project())
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
configurations {
|
||||
integrationTestImplementation.extendsFrom testImplementation
|
||||
integrationTestRuntimeOnly.extendsFrom testRuntimeOnly
|
||||
httpClientPerformanceTestImplementation.extendsFrom testImplementation
|
||||
httpClientPerformanceTestRuntimeOnly.extendsFrom testRuntimeOnly
|
||||
}
|
||||
|
||||
dependencies {
|
||||
|
||||
+21
@@ -103,6 +103,27 @@ public final class ProviderRuntime {
|
||||
return health.get().reason();
|
||||
}
|
||||
|
||||
/**
|
||||
* Releases what the adapter holds, when it holds anything.
|
||||
*
|
||||
* <p>An SDK-backed adapter owns a client with a connection pool. The runtime is the only thing
|
||||
* that keeps the adapter, so it is also what lets it go: nothing else could reach the client to
|
||||
* close it once the process begins shutting down.
|
||||
*
|
||||
* @throws IllegalStateException if the adapter fails to release its resource
|
||||
*/
|
||||
public void release() {
|
||||
if (adapter instanceof AutoCloseable closeable) {
|
||||
try {
|
||||
closeable.close();
|
||||
} catch (Exception failure) {
|
||||
throw new IllegalStateException(
|
||||
"provider adapter for profile " + profile.profileId().value() + " failed to close",
|
||||
failure);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/** Attempts currently in flight on this generation. */
|
||||
public int activeAttempts() {
|
||||
return limiter.activeAttempts();
|
||||
|
||||
+29
-1
@@ -11,7 +11,7 @@ import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.concurrent.atomic.AtomicReference;
|
||||
|
||||
/** Holds the current generation of every provider profile plus the generations still draining. */
|
||||
public final class ProviderRuntimeRegistry {
|
||||
public final class ProviderRuntimeRegistry implements AutoCloseable {
|
||||
|
||||
private final Map<ProviderProfileId, ProviderRuntime> current = new ConcurrentHashMap<>();
|
||||
|
||||
@@ -137,4 +137,32 @@ public final class ProviderRuntimeRegistry {
|
||||
generations.removeIf(runtime -> runtime.activeAttempts() == 0);
|
||||
return generations.isEmpty() ? null : List.copyOf(generations);
|
||||
}
|
||||
|
||||
/**
|
||||
* Releases every generation's adapter at shutdown: the current ones and those still draining.
|
||||
*
|
||||
* <p>Each profile's adapter was built once at startup and never released, so an SDK client and
|
||||
* its connection pool outlived the context that created it. Every generation is attempted even
|
||||
* when one fails, and the first failure is reported with the rest attached.
|
||||
*/
|
||||
@Override
|
||||
public void close() {
|
||||
List<ProviderRuntime> generations = new ArrayList<>(current.values());
|
||||
draining.values().forEach(generations::addAll);
|
||||
IllegalStateException failure = null;
|
||||
for (ProviderRuntime generation : generations) {
|
||||
try {
|
||||
generation.release();
|
||||
} catch (IllegalStateException released) {
|
||||
if (failure == null) {
|
||||
failure = released;
|
||||
} else {
|
||||
failure.addSuppressed(released);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (failure != null) {
|
||||
throw failure;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+8
-1
@@ -40,7 +40,8 @@ import software.amazon.awssdk.services.sesv2.model.SendEmailResponse;
|
||||
* retries turned off, because a resend after a lost response is exactly the decision the evidence
|
||||
* model must make.
|
||||
*/
|
||||
public final class SesNotificationProviderAdapter implements NotificationProviderAdapter {
|
||||
public final class SesNotificationProviderAdapter
|
||||
implements NotificationProviderAdapter, AutoCloseable {
|
||||
|
||||
private static final ProviderId PROVIDER_ID = new ProviderId("ses");
|
||||
|
||||
@@ -69,6 +70,12 @@ public final class SesNotificationProviderAdapter implements NotificationProvide
|
||||
this.accessKeyId = Objects.requireNonNull(accessKeyId, "accessKeyId");
|
||||
}
|
||||
|
||||
/** Closes the SDK client and its connection pool; the runtime that owns this adapter calls it. */
|
||||
@Override
|
||||
public void close() {
|
||||
client.close();
|
||||
}
|
||||
|
||||
@Override
|
||||
public ProviderId providerId() {
|
||||
return PROVIDER_ID;
|
||||
|
||||
+39
-2
@@ -17,10 +17,12 @@ import java.time.Clock;
|
||||
import java.time.Duration;
|
||||
import java.time.Instant;
|
||||
import java.time.ZoneOffset;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
import java.util.concurrent.CompletionStage;
|
||||
import org.junit.jupiter.api.DisplayName;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
class ProviderRuntimeRegistryTest {
|
||||
@@ -82,7 +84,31 @@ class ProviderRuntimeRegistryTest {
|
||||
runtime.acquireAttempt().close();
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisplayName("레지스트리를 닫으면 현재 세대와 drain 중인 세대의 어댑터 자원을 모두 닫는다")
|
||||
void closingTheRegistryClosesTheAdapterOfEveryRegisteredGeneration() {
|
||||
// given
|
||||
var registry = new ProviderRuntimeRegistry();
|
||||
var firstAdapter = new ClosingAdapter();
|
||||
var secondAdapter = new ClosingAdapter();
|
||||
var first = runtime(1, firstAdapter);
|
||||
registry.register(first);
|
||||
var inFlight = first.acquireAttempt();
|
||||
registry.replace(runtime(2, secondAdapter));
|
||||
|
||||
// when
|
||||
registry.close();
|
||||
|
||||
// then
|
||||
assertThat(List.of(firstAdapter.closed, secondAdapter.closed)).containsExactly(true, true);
|
||||
inFlight.close();
|
||||
}
|
||||
|
||||
private static ProviderRuntime runtime(long generation) {
|
||||
return runtime(generation, new StubAdapter());
|
||||
}
|
||||
|
||||
private static ProviderRuntime runtime(long generation, NotificationProviderAdapter adapter) {
|
||||
return new ProviderRuntime(
|
||||
new ProviderProfileSnapshot(
|
||||
PROFILE,
|
||||
@@ -103,12 +129,23 @@ class ProviderRuntimeRegistryTest {
|
||||
4096L,
|
||||
Duration.ofHours(1)),
|
||||
Map.of("topic", "com.example.app")),
|
||||
new StubAdapter(),
|
||||
adapter,
|
||||
new ProviderAttemptLimiter(1, 100, CLOCK));
|
||||
}
|
||||
|
||||
/** Adapter holding a resource, as an SDK-client-backed provider does. */
|
||||
private static final class ClosingAdapter extends StubAdapter implements AutoCloseable {
|
||||
|
||||
private boolean closed;
|
||||
|
||||
@Override
|
||||
public void close() {
|
||||
closed = true;
|
||||
}
|
||||
}
|
||||
|
||||
/** Adapter that is never actually invoked by these runtime tests. */
|
||||
private static final class StubAdapter implements NotificationProviderAdapter {
|
||||
private static class StubAdapter implements NotificationProviderAdapter {
|
||||
|
||||
@Override
|
||||
public ProviderId providerId() {
|
||||
|
||||
+46
@@ -47,6 +47,7 @@ import java.util.Properties;
|
||||
import org.junit.jupiter.api.AfterEach;
|
||||
import org.junit.jupiter.api.DisplayName;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import software.amazon.awssdk.services.sesv2.SesV2Client;
|
||||
|
||||
class SesNotificationProviderAdapterTest extends ProviderAdapterContract {
|
||||
|
||||
@@ -284,6 +285,51 @@ class SesNotificationProviderAdapterTest extends ProviderAdapterContract {
|
||||
assertThat(harness.received()).isEmpty();
|
||||
}
|
||||
|
||||
@Test
|
||||
void closingTheAdapterClosesItsSdkClient() {
|
||||
// given
|
||||
var properties =
|
||||
new SesProviderProperties(
|
||||
harness.baseUri(),
|
||||
"ap-northeast-2",
|
||||
"transactional@example.com",
|
||||
Optional.empty(),
|
||||
Duration.ofSeconds(3));
|
||||
var client = new CloseRecordingSesClient();
|
||||
var adapter =
|
||||
new SesNotificationProviderAdapter(
|
||||
client,
|
||||
new SesRequestMapper(
|
||||
properties, new SmtpMimeMessageFactory(Session.getInstance(new Properties()))),
|
||||
new AttachmentIntegrityGuard(new UnconfiguredAttachmentResolver()),
|
||||
new SesFailureClassifier(),
|
||||
protector,
|
||||
SecurityFixtures.credentials("ses-primary"),
|
||||
"AKIAEXAMPLE");
|
||||
|
||||
// when
|
||||
adapter.close();
|
||||
|
||||
// then
|
||||
assertThat(client.closed).isTrue();
|
||||
}
|
||||
|
||||
/** An SDK client that does nothing but remember being closed. */
|
||||
private static final class CloseRecordingSesClient implements SesV2Client {
|
||||
|
||||
private boolean closed;
|
||||
|
||||
@Override
|
||||
public String serviceName() {
|
||||
return SERVICE_NAME;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void close() {
|
||||
closed = true;
|
||||
}
|
||||
}
|
||||
|
||||
private SesNotificationProviderAdapter adapter(
|
||||
ProviderCredentialManager credentials, AttachmentResolver attachments) {
|
||||
var properties =
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
plugins {
|
||||
id 'ca.spring-library'
|
||||
id 'ca.spring-config'
|
||||
id 'ca.auxiliary-source-set'
|
||||
}
|
||||
|
||||
// Driven adapter: provider-neutral semantic object-storage ports plus a bounded local-development
|
||||
@@ -22,9 +21,25 @@ description = 'Outbound adapter: object storage (S3/MinIO + local filesystem)'
|
||||
// MinIO/Testcontainers exercises are one physical INTEGRATION runtime. Contract/fault are
|
||||
// qualification meanings over that source set, not separate test kinds. The AWS sandbox keeps its
|
||||
// own source set because credentials/network authority make it a materially different environment.
|
||||
auxiliarySourceSets {
|
||||
sourceSet('integrationTest') { compilesAgainst 'main' }
|
||||
sourceSet('objectStorageAwsQualificationTest') { compilesAgainst 'main' }
|
||||
testing {
|
||||
suites {
|
||||
integrationTest(JvmTestSuite) {
|
||||
dependencies {
|
||||
implementation project()
|
||||
}
|
||||
}
|
||||
objectStorageAwsQualificationTest(JvmTestSuite) {
|
||||
dependencies {
|
||||
implementation project()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
configurations {
|
||||
integrationTestImplementation.extendsFrom testImplementation
|
||||
integrationTestRuntimeOnly.extendsFrom testRuntimeOnly
|
||||
objectStorageAwsQualificationTestImplementation.extendsFrom testImplementation
|
||||
objectStorageAwsQualificationTestRuntimeOnly.extendsFrom testRuntimeOnly
|
||||
}
|
||||
|
||||
dependencyManagement {
|
||||
|
||||
+44
@@ -0,0 +1,44 @@
|
||||
package dev.caskeleton.adapter.outbound.persistence.fileserver;
|
||||
|
||||
import dev.caskeleton.adapter.outbound.persistence.fileserver.repository.FileTransitionRepository;
|
||||
import dev.caskeleton.adapter.outbound.persistence.fileserver.repository.JpaFileRepository;
|
||||
import dev.caskeleton.adapter.outbound.persistence.fileserver.repository.JpaUploadSessionRepository;
|
||||
import dev.caskeleton.adapter.outbound.persistence.fileserver.repository.UploadLeaseRepository;
|
||||
import java.time.Clock;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
|
||||
/**
|
||||
* The file records and upload sessions, and the two read-side views over them.
|
||||
*
|
||||
* <p>Plain {@code @Bean} methods, like every other capability's persistence. These classes used to
|
||||
* be {@code @Repository} stereotypes, each repeating the capability condition, reached by a
|
||||
* component scan this leaf ran over its own package — a third way of assembling a module beside the
|
||||
* JPA leaf's scan and the notification leaf's explicit beans. The condition now lives once, on
|
||||
* {@link FileserverJpaPersistenceConfig}, which imports this.
|
||||
*/
|
||||
@Configuration(proxyBeanMethods = false)
|
||||
class FileserverJpaMetadataStoreConfig {
|
||||
|
||||
@Bean
|
||||
JpaFileMetadata fileserverFileMetadata(
|
||||
JpaFileRepository files, FileTransitionRepository transitions, Clock clock) {
|
||||
return new JpaFileMetadata(files, transitions, clock);
|
||||
}
|
||||
|
||||
@Bean
|
||||
JpaUploadSession fileserverUploadSessions(
|
||||
JpaUploadSessionRepository sessions, UploadLeaseRepository leases, Clock clock) {
|
||||
return new JpaUploadSession(sessions, leases, clock);
|
||||
}
|
||||
|
||||
@Bean
|
||||
JpaStagingUploadLocator fileserverStagingUploadLocator(JpaUploadSessionRepository sessions) {
|
||||
return new JpaStagingUploadLocator(sessions);
|
||||
}
|
||||
|
||||
@Bean
|
||||
JpaContentReferenceLedger fileserverContentReferenceLedger(JpaFileRepository files) {
|
||||
return new JpaContentReferenceLedger(files);
|
||||
}
|
||||
}
|
||||
+7
-8
@@ -3,7 +3,7 @@ package dev.caskeleton.adapter.outbound.persistence.fileserver;
|
||||
import org.springframework.boot.autoconfigure.AutoConfiguration;
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
|
||||
import org.springframework.boot.persistence.autoconfigure.EntityScan;
|
||||
import org.springframework.context.annotation.ComponentScan;
|
||||
import org.springframework.context.annotation.Import;
|
||||
import org.springframework.data.jpa.repository.config.EnableJpaRepositories;
|
||||
|
||||
/**
|
||||
@@ -31,12 +31,11 @@ import org.springframework.data.jpa.repository.config.EnableJpaRepositories;
|
||||
* the persistence unit, and a contribution that arrives after the {@code EntityManagerFactory} is
|
||||
* built arrives too late to be in it.
|
||||
*
|
||||
* <p>{@code @ComponentScan} is here for the reason the JPA leaf's {@code
|
||||
* JpaAdapterComponentsConfig} exists: the nine {@code @Repository} adapters in this package carry
|
||||
* the condition quoted above but were reached by no scan at all once the composition root stopped
|
||||
* scanning the persistence tree, so the condition had nothing to decide about.
|
||||
* {@code @EnableJpaRepositories} does not cover them — it registers Spring Data interfaces, and
|
||||
* these are classes that consume those interfaces.
|
||||
* <p>The stores are {@code @Bean}s of the two configurations imported here, under this one
|
||||
* condition. They used to be {@code @Repository} stereotypes, each repeating the condition, reached
|
||||
* by an {@code @ComponentScan} of this package — the module was assembled differently from its
|
||||
* neighbours and the condition was stated nine times. {@code @EnableJpaRepositories} still covers
|
||||
* the Spring Data interfaces, which is what it is for.
|
||||
*/
|
||||
@AutoConfiguration(
|
||||
beforeName =
|
||||
@@ -48,5 +47,5 @@ import org.springframework.data.jpa.repository.config.EnableJpaRepositories;
|
||||
matchIfMissing = true)
|
||||
@EntityScan(basePackages = "dev.caskeleton.adapter.outbound.persistence.fileserver")
|
||||
@EnableJpaRepositories(basePackages = "dev.caskeleton.adapter.outbound.persistence.fileserver")
|
||||
@ComponentScan(basePackages = "dev.caskeleton.adapter.outbound.persistence.fileserver")
|
||||
@Import({FileserverJpaMetadataStoreConfig.class, FileserverJpaQueueStoreConfig.class})
|
||||
public class FileserverJpaPersistenceConfig {}
|
||||
|
||||
+46
@@ -0,0 +1,46 @@
|
||||
package dev.caskeleton.adapter.outbound.persistence.fileserver;
|
||||
|
||||
import dev.caskeleton.adapter.outbound.persistence.fileserver.repository.FileserverCleanupRepository;
|
||||
import dev.caskeleton.adapter.outbound.persistence.fileserver.repository.FileserverQuotaRepository;
|
||||
import dev.caskeleton.adapter.outbound.persistence.fileserver.repository.FileserverRecoveryRepository;
|
||||
import dev.caskeleton.application.fileserver.api.metadata.FileMetadataPort;
|
||||
import java.time.Clock;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
|
||||
/**
|
||||
* Quota reservations and the two work queues — cleanup and recovery.
|
||||
*
|
||||
* <p>Imported by {@link FileserverJpaPersistenceConfig}, which carries the capability condition;
|
||||
* see {@link FileserverJpaMetadataStoreConfig} for why these are beans rather than scanned
|
||||
* stereotypes.
|
||||
*/
|
||||
@Configuration(proxyBeanMethods = false)
|
||||
class FileserverJpaQueueStoreConfig {
|
||||
|
||||
@Bean
|
||||
JpaFileQuota fileserverFileQuota(FileserverQuotaRepository reservations, Clock clock) {
|
||||
return new JpaFileQuota(reservations, clock);
|
||||
}
|
||||
|
||||
@Bean
|
||||
JpaQuotaCommit fileserverQuotaCommit(
|
||||
FileserverQuotaRepository reservations, FileMetadataPort metadataStore, Clock clock) {
|
||||
return new JpaQuotaCommit(reservations, metadataStore, clock);
|
||||
}
|
||||
|
||||
@Bean
|
||||
JpaQuotaReclaim fileserverQuotaReclaim(FileserverQuotaRepository reservations, Clock clock) {
|
||||
return new JpaQuotaReclaim(reservations, clock);
|
||||
}
|
||||
|
||||
@Bean
|
||||
JpaCleanupQueue fileserverCleanupQueue(FileserverCleanupRepository items, Clock clock) {
|
||||
return new JpaCleanupQueue(items, clock);
|
||||
}
|
||||
|
||||
@Bean
|
||||
JpaRecoveryQueue fileserverRecoveryQueue(FileserverRecoveryRepository items, Clock clock) {
|
||||
return new JpaRecoveryQueue(items, clock);
|
||||
}
|
||||
}
|
||||
-8
@@ -15,9 +15,7 @@ import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
import java.util.UUID;
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
|
||||
import org.springframework.data.domain.Limit;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
/**
|
||||
* Durable, at-most-one-worker cleanup queue over {@code fs_cleanup_item}.
|
||||
@@ -32,12 +30,6 @@ import org.springframework.stereotype.Repository;
|
||||
* <p>Staging cleanups carry an upload id and published cleanups carry a content key. The row keeps
|
||||
* both columns nullable for that reason; which one is set is what tells the worker where to look.
|
||||
*/
|
||||
@Repository
|
||||
@ConditionalOnProperty(
|
||||
prefix = "app.fileserver-platform",
|
||||
name = "enabled",
|
||||
havingValue = "true",
|
||||
matchIfMissing = true)
|
||||
public class JpaCleanupQueue implements CleanupQueuePort {
|
||||
|
||||
/** After this many failed attempts an item stops being rescheduled. */
|
||||
|
||||
-8
@@ -3,8 +3,6 @@ package dev.caskeleton.adapter.outbound.persistence.fileserver;
|
||||
import dev.caskeleton.adapter.outbound.persistence.fileserver.repository.JpaFileRepository;
|
||||
import dev.caskeleton.application.fileserver.admin.ContentReferenceLedgerPort;
|
||||
import dev.caskeleton.application.fileserver.api.ContentKey;
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
/**
|
||||
* Answers the orphan scan's one question against {@code fs_file}.
|
||||
@@ -14,12 +12,6 @@ import org.springframework.stereotype.Repository;
|
||||
* cleanup worker's precondition check, and a DELETED row still proves the key is not free to be
|
||||
* reclaimed by a second, unrelated deletion path.
|
||||
*/
|
||||
@Repository
|
||||
@ConditionalOnProperty(
|
||||
prefix = "app.fileserver-platform",
|
||||
name = "enabled",
|
||||
havingValue = "true",
|
||||
matchIfMissing = true)
|
||||
public class JpaContentReferenceLedger implements ContentReferenceLedgerPort {
|
||||
|
||||
private final JpaFileRepository files;
|
||||
|
||||
+2
-10
@@ -21,9 +21,7 @@ import java.time.Instant;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
|
||||
import org.springframework.data.domain.Limit;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
/**
|
||||
* JPA-backed {@link FileMetadataPort}.
|
||||
@@ -38,13 +36,7 @@ import org.springframework.stereotype.Repository;
|
||||
* answer — the modifying statement refuses to run outside a transaction, which is the failure mode
|
||||
* worth having.
|
||||
*/
|
||||
@Repository
|
||||
@ConditionalOnProperty(
|
||||
prefix = "app.fileserver-platform",
|
||||
name = "enabled",
|
||||
havingValue = "true",
|
||||
matchIfMissing = true)
|
||||
public class JpaFileMetadataStore implements FileMetadataPort {
|
||||
public class JpaFileMetadata implements FileMetadataPort {
|
||||
|
||||
private final JpaFileRepository files;
|
||||
private final FileTransitionRepository transitions;
|
||||
@@ -53,7 +45,7 @@ public class JpaFileMetadataStore implements FileMetadataPort {
|
||||
/** The states the transition table lets into DELETING, read from the table itself. */
|
||||
private final List<String> deletableStates;
|
||||
|
||||
public JpaFileMetadataStore(
|
||||
public JpaFileMetadata(
|
||||
JpaFileRepository files, FileTransitionRepository transitions, Clock clock) {
|
||||
this.files = files;
|
||||
this.transitions = transitions;
|
||||
+2
-10
@@ -13,8 +13,6 @@ import java.time.Clock;
|
||||
import java.time.Duration;
|
||||
import java.time.Instant;
|
||||
import java.util.UUID;
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
/**
|
||||
* JPA-backed {@link FileQuotaPort}.
|
||||
@@ -22,18 +20,12 @@ import org.springframework.stereotype.Repository;
|
||||
* <p>Reservation, extension, commit, and release are conditional statements, so a reservation that
|
||||
* already expired or was released can never be extended or committed.
|
||||
*/
|
||||
@Repository
|
||||
@ConditionalOnProperty(
|
||||
prefix = "app.fileserver-platform",
|
||||
name = "enabled",
|
||||
havingValue = "true",
|
||||
matchIfMissing = true)
|
||||
public class JpaFileQuotaService implements FileQuotaPort {
|
||||
public class JpaFileQuota implements FileQuotaPort {
|
||||
|
||||
private final FileserverQuotaRepository reservations;
|
||||
private final Clock clock;
|
||||
|
||||
public JpaFileQuotaService(FileserverQuotaRepository reservations, Clock clock) {
|
||||
public JpaFileQuota(FileserverQuotaRepository reservations, Clock clock) {
|
||||
this.reservations = reservations;
|
||||
this.clock = clock;
|
||||
}
|
||||
+2
-10
@@ -12,9 +12,7 @@ import java.time.Instant;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
import java.util.UUID;
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
|
||||
import org.springframework.data.domain.Limit;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
/**
|
||||
* Settles an upload's share of its scope's quota ledger.
|
||||
@@ -34,13 +32,7 @@ import org.springframework.stereotype.Repository;
|
||||
* recorded. Durable usage that goes unrecorded because a reservation expired is how a quota ledger
|
||||
* silently drifts below the truth.
|
||||
*/
|
||||
@Repository
|
||||
@ConditionalOnProperty(
|
||||
prefix = "app.fileserver-platform",
|
||||
name = "enabled",
|
||||
havingValue = "true",
|
||||
matchIfMissing = true)
|
||||
public class JpaQuotaCommitGateway implements QuotaCommitPort {
|
||||
public class JpaQuotaCommit implements QuotaCommitPort {
|
||||
|
||||
private static final Limit OLDEST = Limit.of(1);
|
||||
|
||||
@@ -48,7 +40,7 @@ public class JpaQuotaCommitGateway implements QuotaCommitPort {
|
||||
private final FileMetadataPort metadataStore;
|
||||
private final Clock clock;
|
||||
|
||||
public JpaQuotaCommitGateway(
|
||||
public JpaQuotaCommit(
|
||||
FileserverQuotaRepository reservations, FileMetadataPort metadataStore, Clock clock) {
|
||||
this.reservations = reservations;
|
||||
this.metadataStore = metadataStore;
|
||||
+2
-10
@@ -6,9 +6,7 @@ import dev.caskeleton.application.fileserver.api.metadata.QuotaScope;
|
||||
import dev.caskeleton.application.fileserver.cleanup.QuotaReclaimPort;
|
||||
import java.time.Clock;
|
||||
import java.time.Instant;
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
|
||||
import org.springframework.data.domain.Limit;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
/**
|
||||
* Returns reclaimed bytes to a scope's committed total.
|
||||
@@ -26,20 +24,14 @@ import org.springframework.stereotype.Repository;
|
||||
* a scope cannot owe negative bytes, and a reclaim that outruns the recorded total means the total
|
||||
* was already understated, which a negative balance would not fix.
|
||||
*/
|
||||
@Repository
|
||||
@ConditionalOnProperty(
|
||||
prefix = "app.fileserver-platform",
|
||||
name = "enabled",
|
||||
havingValue = "true",
|
||||
matchIfMissing = true)
|
||||
public class JpaQuotaReclaimGateway implements QuotaReclaimPort {
|
||||
public class JpaQuotaReclaim implements QuotaReclaimPort {
|
||||
|
||||
private static final Limit RECLAIM_PAGE = Limit.of(64);
|
||||
|
||||
private final FileserverQuotaRepository reservations;
|
||||
private final Clock clock;
|
||||
|
||||
public JpaQuotaReclaimGateway(FileserverQuotaRepository reservations, Clock clock) {
|
||||
public JpaQuotaReclaim(FileserverQuotaRepository reservations, Clock clock) {
|
||||
this.reservations = reservations;
|
||||
this.clock = clock;
|
||||
}
|
||||
-8
@@ -9,9 +9,7 @@ import java.time.Clock;
|
||||
import java.time.Instant;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
|
||||
import org.springframework.data.domain.Limit;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
/**
|
||||
* Durable recovery queue over {@code fs_recovery_item}.
|
||||
@@ -25,12 +23,6 @@ import org.springframework.stereotype.Repository;
|
||||
* QUARANTINE_REQUIRED} are the two answers a human has to act on, and both are worthless if the
|
||||
* record of what the system concluded disappears with the item.
|
||||
*/
|
||||
@Repository
|
||||
@ConditionalOnProperty(
|
||||
prefix = "app.fileserver-platform",
|
||||
name = "enabled",
|
||||
havingValue = "true",
|
||||
matchIfMissing = true)
|
||||
public class JpaRecoveryQueue implements RecoveryQueuePort {
|
||||
|
||||
private static final String STATUS_PENDING = "PENDING";
|
||||
|
||||
-8
@@ -7,9 +7,7 @@ import dev.caskeleton.application.fileserver.api.UploadId;
|
||||
import dev.caskeleton.application.fileserver.recovery.StagingUploadLocatorPort;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
|
||||
import org.springframework.data.domain.Limit;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
/**
|
||||
* Maps a file back to the upload that last staged it.
|
||||
@@ -18,12 +16,6 @@ import org.springframework.stereotype.Repository;
|
||||
* one session row, and an older one names a staging object that has since been reclaimed — treating
|
||||
* that as live evidence would tell reconciliation the upload is resumable when it is not.
|
||||
*/
|
||||
@Repository
|
||||
@ConditionalOnProperty(
|
||||
prefix = "app.fileserver-platform",
|
||||
name = "enabled",
|
||||
havingValue = "true",
|
||||
matchIfMissing = true)
|
||||
public class JpaStagingUploadLocator implements StagingUploadLocatorPort {
|
||||
|
||||
private static final Limit NEWEST = Limit.of(1);
|
||||
|
||||
+2
-10
@@ -17,9 +17,7 @@ import java.time.Instant;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
import java.util.UUID;
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
|
||||
import org.springframework.data.domain.Limit;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
/**
|
||||
* JPA-backed {@link UploadSessionPort} with database writer leases.
|
||||
@@ -32,19 +30,13 @@ import org.springframework.stereotype.Repository;
|
||||
* says nothing about whether the upload is still one anybody may write to, so cleanup could delete
|
||||
* the staged bytes of an upload a writer was about to take a lease on.
|
||||
*/
|
||||
@Repository
|
||||
@ConditionalOnProperty(
|
||||
prefix = "app.fileserver-platform",
|
||||
name = "enabled",
|
||||
havingValue = "true",
|
||||
matchIfMissing = true)
|
||||
public class JpaUploadSessionStore implements UploadSessionPort {
|
||||
public class JpaUploadSession implements UploadSessionPort {
|
||||
|
||||
private final JpaUploadSessionRepository sessions;
|
||||
private final UploadLeaseRepository leases;
|
||||
private final Clock clock;
|
||||
|
||||
public JpaUploadSessionStore(
|
||||
public JpaUploadSession(
|
||||
JpaUploadSessionRepository sessions, UploadLeaseRepository leases, Clock clock) {
|
||||
this.sessions = sessions;
|
||||
this.leases = leases;
|
||||
@@ -30,7 +30,7 @@ packages.
|
||||
|---|---|
|
||||
| `autoconfigure` | package-private Boot composition root/runtime: vendor and optional-store imports and provider runtime beans. It is intentionally not exported as public API |
|
||||
| `api` (+ `.capability`, `.error`, `.query`, `.transaction`) | framework-free contracts: operation and query names, the stable error hierarchy, commit-completion evidence, keyset cursors |
|
||||
| `transaction` | `SpringTransactionPort`, the one transaction engine (`TransactionPort` over Spring's `PlatformTransactionManager`) |
|
||||
| `transaction` | `SpringTransaction`, the one transaction engine (`TransactionPort` over Spring's `PlatformTransactionManager`) |
|
||||
| `springdata` | repository fragments, safe sort, fetch plans, keyset execution, stream guard |
|
||||
| `hibernate` (+ `.batch`, `.bulk`, `.stateless`) | statement inspector, statistics, batch, bulk DML, stateless session |
|
||||
| `postgresql` (+ `.error`, `.lock`, `.constraint`, `.json`, `.array`, `.range`, `.copy`) | SQLSTATE classification, lock options, JSONB, arrays and ranges, COPY |
|
||||
@@ -55,7 +55,7 @@ Because Boot loads those candidates independently, **both** require
|
||||
`ca-skeleton.persistence-jpa.enabled=true`. The first owns vendor/entity/repository and
|
||||
capability-store imports. The second contributes only the provider runtime beans
|
||||
(`HibernateProviderPolicy`, `PostgreSqlRuntimeRoleVerifier`). The
|
||||
transaction engine is `SpringTransactionPort` alone; the second engine
|
||||
transaction engine is `SpringTransaction` alone; the second engine
|
||||
(`SpringJpaTransactionExecutor`/`FullTransactionRetryCoordinator`) was removed on 2026-09-25 — see
|
||||
`docs/capability-status.md`. Never rely on the first candidate's condition to gate the sibling
|
||||
import candidate.
|
||||
@@ -89,7 +89,7 @@ not grow by wiring accident.
|
||||
|
||||
- No `GenericRepository<T, ID>` and no platform base repository. Domains own their repositories.
|
||||
- `TransactionCompletionUnknownException` is never retried. `JpaFailureContext` refuses to
|
||||
represent a retryable completion-unknown failure, and `SpringTransactionPort` retries nothing.
|
||||
represent a retryable completion-unknown failure, and `SpringTransaction` retries nothing.
|
||||
- A caller that retries re-runs the whole use case in a new transaction and a new Persistence
|
||||
Context.
|
||||
- OSIV is false in every runtime profile; Flyway owns schema change and Hibernate only validates.
|
||||
@@ -126,7 +126,7 @@ nobody tested.
|
||||
- Spring Data repositories.
|
||||
- Persistence mappers.
|
||||
- Repository adapter implementations.
|
||||
- Outbox append: one model. `OutboxStoreAdapter` implements `OutboxAppendPort` and persists a
|
||||
- Outbox append: one model. `JpaOutboxStore` implements `OutboxAppendPort` and persists a
|
||||
`ValidatedIntegrationEvent`'s exact envelope bytes and hashes; a claim restores the same event
|
||||
from them. A row without complete canonical metadata is unreadable and goes to DEAD, never
|
||||
published by guess. `V19` refuses unpublished pre-canonical rows.
|
||||
@@ -135,10 +135,10 @@ nobody tested.
|
||||
conditional UPDATE on `event_id` + `IN_FLIGHT` + owner + token and return `APPLIED`/`STALE`. A
|
||||
completion never loads and overwrites a row. The V2 outbox generation was deleted on 2026-09-25
|
||||
(`docs/capability-status.md`).
|
||||
- `TransactionPort` implementation (`SpringTransactionPort`) — the bridge between
|
||||
- `TransactionPort` implementation (`SpringTransaction`) — the bridge between
|
||||
application transactional intent and Spring's `PlatformTransactionManager`.
|
||||
- Audit-metadata base + actor seam (`audit/AuditableEntity`, `audit/AuditContextPort`,
|
||||
`audit/DomainContextAuditContextPort`) — see "Persistence auditing contract" below.
|
||||
`audit/DomainContextAuditContext`) — see "Persistence auditing contract" below.
|
||||
- Vendor SPI extension points shared by all RDBMS vendors:
|
||||
- `outbox/jpa/OutboxClaimRepository` — vendor module implements claim strategy (e.g. FOR UPDATE SKIP LOCKED); the implementations sit beside it in `outbox/postgresql` and `outbox/h2`.
|
||||
- `failure/SqlStateErrorMapping` — vendor module contributes vendor-specific SQLState rows.
|
||||
@@ -216,7 +216,7 @@ should not exist.
|
||||
|
||||
## TransactionPort implementation contract
|
||||
|
||||
`SpringTransactionPort` pre-builds one `TransactionTemplate` per mode:
|
||||
`SpringTransaction` pre-builds one `TransactionTemplate` per mode:
|
||||
|
||||
| Mode | Propagation | Isolation | Read-only |
|
||||
|---|---|---|---|
|
||||
|
||||
@@ -24,8 +24,8 @@ bean과 함께 Boot의 JDBC·Hibernate·Spring Data JPA·Flyway 자동 설정도
|
||||
추가되므로 DataSource·풀·EntityManagerFactory·Flyway가 만들어지지 않고 DB 없이 기동한다. 그래서 DB가
|
||||
필요한 다른 capability(notification·fileserver 저장소, messaging JDBC outbox/inbox 등)와 함께 끌 수는 없다)
|
||||
|
||||
- 포트 구현: `TransactionPort`(`SpringTransactionPort`), `DistributedLockPort`(단일 인스턴스는
|
||||
in-process, `APP_MULTI_INSTANCE_ENABLED=true`면 JDBC `INT_LOCK` + `MeteredDistributedLockPort`
|
||||
- 포트 구현: `TransactionPort`(`SpringTransaction`), `DistributedLockPort`(단일 인스턴스는
|
||||
in-process, `APP_MULTI_INSTANCE_ENABLED=true`면 JDBC `INT_LOCK` + `MeteredDistributedLock`
|
||||
데코레이터 = `distributedLockProvider`), outbox store(`OutboxStorePort`, `APP_OUTBOX_ENABLED=true`),
|
||||
PostgreSQL 멱등성 store(`APP_IDEMPOTENCY_PROVIDER=postgresql`), audit·operation·live-event store.
|
||||
- 엔티티/리포지토리 스캔, vendor 조립(PostgreSQL 기본, H2는 개발용), Flyway 위치.
|
||||
@@ -101,7 +101,7 @@ metric은 기본으로 하나도 나오지 않는다. `jpa.query.*`는 서비스
|
||||
promotion gate, 생성하는 곳 없는 `JpaTransactionObservation` 등)은 `docs/capability-status.md`
|
||||
"제거된 코드"에 있다.
|
||||
|
||||
## transaction — `SpringTransactionPort`
|
||||
## transaction — `SpringTransaction`
|
||||
|
||||
### 왜 모드별 템플릿을 미리 만들어 두나
|
||||
`TransactionTemplate` 은 문서상 thread-safe 지만 **mutable** 하다. 매 호출마다 propagation /
|
||||
@@ -123,7 +123,7 @@ write template을 재사용한다. 차이는 실행 전 precondition이다.
|
||||
예외로 전파된다. 이 보장은 action이 외부 객체를 직접 변경하는 것을 되돌리는 보상이 아니라,
|
||||
경계의 반환값을 성공으로 노출하지 않는 계약이다.
|
||||
|
||||
## audit — `AuditableEntity` / `AuditContextPort` / `DomainContextAuditContextPort`
|
||||
## audit — `AuditableEntity` / `AuditContextPort` / `DomainContextAuditContext`
|
||||
|
||||
### 캡처 메커니즘 — Manual explicit-set (D1 현재 스켈레톤 기본값)
|
||||
`AuditableEntity` 의 네 필드(`created_at` / `updated_at` / `created_by` / `updated_by`)는 평범한
|
||||
@@ -156,7 +156,7 @@ actor 의 **값 의미론**(user id vs email vs subject claim)은 application/we
|
||||
포트가 보장하는 건 오직 "non-null actor"(프레임워크의 blank-on-absent 가 아니라) 하나 —
|
||||
principal 이 없으면 `"system"`.
|
||||
|
||||
`DomainContextAuditContextPort` 는 actor id 를 runtime-context-propagation seam
|
||||
`DomainContextAuditContext` 는 actor id 를 runtime-context-propagation seam
|
||||
(`DomainContextPropagator`)에서 읽는다. 그 브랜치가 canonical actor key 를 소유하지만 API 가
|
||||
확정되기 전까지 이 어댑터가 `ACTOR_KEY` 뒤로 격리해, 키가 바뀌어도 정확히 한 클래스만 손대게
|
||||
한다(D5 Open Risk). 빈/blank context 값은 null/blank actor 가 아니라 `"system"` 으로 떨어뜨려
|
||||
@@ -205,7 +205,7 @@ failure translation contract 다. 여기서는 SPI 구조와 fallback 근거만
|
||||
|
||||
`ca-skeleton.capabilities.idempotency.provider=postgresql` 일 때만 켜진다
|
||||
(`autoconfigure/PostgreSqlIdempotencyStoreConfig`). 이 leaf 는 `IdempotencyStorePort` 구현
|
||||
(`PostgreSqlOwnerSafeIdempotencyStore`) 하나만 내놓고, executor 는 app-bootstrap
|
||||
(`PostgreSqlIdempotencyStore`) 하나만 내놓고, executor 는 app-bootstrap
|
||||
`IdempotencyProviderSelectionConfig` 가 만든다. V1 JDBC store 와 `jdbc` provider 값은 없다.
|
||||
|
||||
- **스키마**: 기본 테이블은 primary Flyway(`db/migration/postgresql/V1__idempotency_record.sql`)가,
|
||||
@@ -221,11 +221,11 @@ failure translation contract 다. 여기서는 SPI 구조와 fallback 근거만
|
||||
(`IdempotencyRecordJpaRepository` 사용, 기본 10분 간격 `reaper-interval`)가 지난 행을 지운다.
|
||||
reaper 는 provider 가 `postgresql` 일 때만 돈다.
|
||||
|
||||
## outbox — `OutboxStoreAdapter` 외
|
||||
## outbox — `JpaOutboxStore` 외
|
||||
|
||||
스키마는 Flyway(`V3__outbox_event.sql`)가 소유하고, `V13__outbox_canonical_transport_compatibility.sql`이
|
||||
canonical metadata와 exact `BYTEA envelope_bytes`를 더했다. append 모델은 canonical 하나다(2026-09-28,
|
||||
소유자 결정 7): `OutboxStoreAdapter`가 `OutboxAppendPort`(`ValidatedIntegrationEvent`)와
|
||||
소유자 결정 7): `JpaOutboxStore`가 `OutboxAppendPort`(`ValidatedIntegrationEvent`)와
|
||||
`OutboxStorePort`를 함께 구현하고, `ca-skeleton.outbox.enabled=true`일 때만 존재한다. row는 validated
|
||||
event의 exact envelope bytes와 hash를 저장하고, claim은 그 bytes로 같은 event를 복원한다
|
||||
(`ClaimedOutboxEvent`). `event_type`·`aggregate_id`·`correlation_id`는 claim gate와 metrics query를
|
||||
@@ -323,7 +323,7 @@ A가 FAILED로 바꾸면 다시 발행되고(중복 전달), A의 늦은 PUBLISH
|
||||
2-요소 배열 리스트를 돌려준다(각각 outbox.pending.size, outbox.publisher.lag gauge 용).
|
||||
두 쿼리 모두 PUBLISHED row 는 세지 않는다 — retention 기간 동안 테이블 대부분이 PUBLISHED 라,
|
||||
매 poll 마다 테이블 전체를 세게 된다.
|
||||
`OutboxStoreAdapter.oldestUnpublishedAgeSecondsByEventType` 가 `HashMap` 을 쓰는 건 키가
|
||||
`JpaOutboxStore.oldestUnpublishedAgeSecondsByEventType` 가 `HashMap` 을 쓰는 건 키가
|
||||
enum 이 아니라 String(event-type 이름)이기 때문이다 — `countByStatus()` 는 키가
|
||||
`OutboxEventStatus` enum 이라 `EnumMap` 을 쓴다(두 반환 타입이 의도적으로 다름).
|
||||
|
||||
@@ -362,7 +362,7 @@ machine-readable SSOT다(개수는 registry가 소유한다). `selected` base ca
|
||||
|
||||
### owner-safe idempotency
|
||||
|
||||
`PostgreSqlOwnerSafeIdempotencyStore`는 row lock을 얻은 뒤 `clock_timestamp()`를 평가한다.
|
||||
`PostgreSqlIdempotencyStore`는 row lock을 얻은 뒤 `clock_timestamp()`를 평가한다.
|
||||
claim takeover와 start/renew/complete/fail/release는 scope/state/owner/attempt/claim operation/
|
||||
state revision을 SQL predicate로 다시 검증한다. expired `CLAIMED`만 takeover하며 expired
|
||||
`EXECUTING`은 `ABANDONED`로 닫고 reconciliation을 요구한다. raw client key는 저장하지 않고
|
||||
@@ -415,7 +415,7 @@ stream migration이 중단되면 history/registry/object 상태를 먼저 확인
|
||||
provider 선택표(flag → bean → registry)의 SSOT 는 CLAUDE.md(또는 app-bootstrap 와이어링)다.
|
||||
여기서는 어댑터/설정 결정 근거만 적는다.
|
||||
|
||||
### `LockRegistryDistributedLockAdapter` 계약
|
||||
### `LockRegistryDistributedLock` 계약
|
||||
- **D4 — transaction-commit ordering invariant.** 이 어댑터는 트랜잭션 경계를 관리하지 않는다.
|
||||
호출자는 보호된 트랜잭션이 **커밋된 뒤에만** 핸들(`DistributedLock.close()`)을 release 해야
|
||||
한다. 커밋 전(트랜잭션 안)에 release 하면 lost-update race 가 생긴다.
|
||||
@@ -447,7 +447,7 @@ provider 선택표(flag → bean → registry)의 SSOT 는 CLAUDE.md(또는 app-
|
||||
|
||||
### `DistributedLockPersistenceConfig` 와이어링 결정
|
||||
- `jdbcDistributedLock` 빈은 일부러 `@Primary` 가 아니다. 같은 설정이 이를 metrics
|
||||
데코레이터(`MeteredDistributedLockPort`, package-private)로 감싸 `@Primary`
|
||||
데코레이터(`MeteredDistributedLock`, package-private)로 감싸 `@Primary`
|
||||
`distributedLockProvider` 빈으로 노출한다. 예전에는 app-bootstrap의 `DistributedLockConfig`가
|
||||
감쌌지만, JDBC 락이 있을 때만 의미가 있는 코드라 이 모듈로 옮겼다. SI 타입은 여전히 이 모듈
|
||||
밖으로 보이지 않는다(SI 는 `implementation` 의존).
|
||||
@@ -468,7 +468,7 @@ provider 선택표(flag → bean → registry)의 SSOT 는 CLAUDE.md(또는 app-
|
||||
이어야 한다 — TTL 이 waitTime 보다 먼저 만료되면 첫 holder 의 보호작업이 끝나기 전에 두 번째
|
||||
holder 가 락을 잡을 수 있다.
|
||||
|
||||
### `MeteredDistributedLockPort` (app-bootstrap에서 이동)
|
||||
### `MeteredDistributedLock` (app-bootstrap에서 이동)
|
||||
- **`DistributedLockPort`를 감싸는 얇은 Micrometer 데코레이터다.** `tryAcquire` 호출마다
|
||||
`lock.acquisition` 카운터를 `outcome` 태그와 함께 1 증가시킨다. 태그 값은 세 가지: `acquired`(락
|
||||
획득 성공, 위임 핸들 반환), `timeout`(`LockAcquisitionTimeoutException` 발생), `error`(그 외 모든
|
||||
|
||||
@@ -2,7 +2,6 @@ plugins {
|
||||
id 'ca.spring-library'
|
||||
id 'ca.spring-config'
|
||||
id 'java-test-fixtures'
|
||||
id 'ca.auxiliary-source-set'
|
||||
id 'ca.api-surface'
|
||||
}
|
||||
|
||||
@@ -21,15 +20,31 @@ plugins {
|
||||
// The testkit is its own source set rather than part of `test` because more than one lane consumes
|
||||
// it and because a source set whose dependencies are declared only on the test configurations gives
|
||||
// the design's "no production module depends on the testkit" guarantee without a new Gradle project.
|
||||
auxiliarySourceSets {
|
||||
sourceSet('postgresqlIntegrationTest') {
|
||||
// 'testFixtures' as well as 'main': the integration lane consumed the testkit through the
|
||||
// convention's `consumedBy 'test', 'postgresqlIntegrationTest'`, and java-test-fixtures only
|
||||
// wires `test` on its own. The lane has to say so (ADR-BUILD-001).
|
||||
compilesAgainst 'main', 'testFixtures'
|
||||
inherits 'implementation', 'compileOnly', 'runtimeOnly', 'annotationProcessor'
|
||||
testing {
|
||||
suites {
|
||||
postgresqlIntegrationTest(JvmTestSuite) {
|
||||
// testFixtures as well as the project: java-test-fixtures wires only `test` on its own,
|
||||
// so the integration lane has to say so (ADR-BUILD-001).
|
||||
dependencies {
|
||||
implementation project()
|
||||
implementation testFixtures(project())
|
||||
}
|
||||
}
|
||||
jpaPlatformPerformanceTest(JvmTestSuite) {
|
||||
dependencies {
|
||||
implementation project()
|
||||
implementation testFixtures(project())
|
||||
}
|
||||
}
|
||||
}
|
||||
sourceSet('jpaPlatformPerformanceTest') { compilesAgainst 'main', 'testFixtures' }
|
||||
}
|
||||
configurations {
|
||||
postgresqlIntegrationTestImplementation.extendsFrom testImplementation
|
||||
postgresqlIntegrationTestCompileOnly.extendsFrom testCompileOnly
|
||||
postgresqlIntegrationTestRuntimeOnly.extendsFrom testRuntimeOnly
|
||||
postgresqlIntegrationTestAnnotationProcessor.extendsFrom testAnnotationProcessor
|
||||
jpaPlatformPerformanceTestImplementation.extendsFrom testImplementation
|
||||
jpaPlatformPerformanceTestRuntimeOnly.extendsFrom testRuntimeOnly
|
||||
}
|
||||
|
||||
dependencies {
|
||||
@@ -249,9 +264,11 @@ tasks.named('test') {
|
||||
inputs.dir(new File(rootProject.projectDir.parentFile, '.github/workflows'))
|
||||
inputs.file(file('build.gradle'))
|
||||
inputs.dir(file('src/jpaPlatformPerformanceTest/java'))
|
||||
// AppliedMigrationImmutabilityTest pins the notification stream where it now lives.
|
||||
// AppliedMigrationImmutabilityTest pins the notification and fileserver streams where they live.
|
||||
inputs.dir(file('../persistence-notification/src/main/resources/db/migration'))
|
||||
.withPropertyName('notificationMigrations')
|
||||
inputs.dir(file('../persistence-fileserver/src/main/resources/db/migration'))
|
||||
.withPropertyName('fileserverMigrations')
|
||||
}
|
||||
|
||||
// verifyJpaApiSurface — every public type this leaf exposes is a committed decision.
|
||||
|
||||
+2
-2
@@ -10,7 +10,7 @@ import org.springframework.stereotype.Component;
|
||||
* isolated behind {@link #ACTOR_KEY} so a future key change touches one class (see README "audit").
|
||||
*/
|
||||
@Component
|
||||
public class DomainContextAuditContextPort implements AuditContextPort {
|
||||
public class DomainContextAuditContext implements AuditContextPort {
|
||||
|
||||
static final String SYSTEM_ACTOR = "system";
|
||||
|
||||
@@ -18,7 +18,7 @@ public class DomainContextAuditContextPort implements AuditContextPort {
|
||||
|
||||
private final DomainContextPropagator propagator;
|
||||
|
||||
public DomainContextAuditContextPort(DomainContextPropagator propagator) {
|
||||
public DomainContextAuditContext(DomainContextPropagator propagator) {
|
||||
this.propagator = propagator;
|
||||
}
|
||||
|
||||
+2
-2
@@ -1,7 +1,7 @@
|
||||
package dev.caskeleton.adapter.outbound.persistence.autoconfigure;
|
||||
|
||||
import dev.caskeleton.adapter.outbound.persistence.idempotency.postgresql.IdempotencySchemaStream;
|
||||
import dev.caskeleton.adapter.outbound.persistence.idempotency.postgresql.PostgreSqlOwnerSafeIdempotencyStore;
|
||||
import dev.caskeleton.adapter.outbound.persistence.idempotency.postgresql.PostgreSqlIdempotencyStore;
|
||||
import dev.caskeleton.application.idempotency.IdempotencyStorePort;
|
||||
import javax.sql.DataSource;
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
|
||||
@@ -24,7 +24,7 @@ class PostgreSqlIdempotencyStoreConfig {
|
||||
|
||||
@Bean
|
||||
IdempotencyStorePort postgreSqlOwnerSafeIdempotencyStore(JdbcOperations jdbc) {
|
||||
return new PostgreSqlOwnerSafeIdempotencyStore(jdbc);
|
||||
return new PostgreSqlIdempotencyStore(jdbc);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
+3
-3
@@ -14,9 +14,9 @@ import org.springframework.context.annotation.FilterType;
|
||||
* beans rather than assembling them and hoping each one remembered to carry the switch.
|
||||
*
|
||||
* <p>What was missing is the other half. Eight classes in this leaf are written as scanned
|
||||
* components — {@code SpringTransactionPort}, {@code PersistenceExceptionTranslator}, {@code
|
||||
* StandardSqlStateErrorMapping}, {@code DomainContextAuditContextPort}, the idempotency store and
|
||||
* its reaper, and the outbox store and its reaper — and once the broad scan stopped reaching them,
|
||||
* components — {@code SpringTransaction}, {@code PersistenceExceptionTranslator}, {@code
|
||||
* StandardSqlStateErrorMapping}, {@code DomainContextAuditContext}, the idempotency store and its
|
||||
* reaper, and the outbox store and its reaper — and once the broad scan stopped reaching them,
|
||||
* nothing else did. They are annotated {@code @Component} and {@code @Repository} and were beans in
|
||||
* no running application: {@code TransactionPort} in particular had no implementation at all, so
|
||||
* every use case that opens a transaction had no port to open it with.
|
||||
|
||||
+3
-3
@@ -55,7 +55,7 @@ import org.springframework.jdbc.core.JdbcOperations;
|
||||
* second store beside its own, which the composition root refuses. The persistence leaf builds it
|
||||
* for {@code provider=postgresql} and only while the JPA capability is enabled.
|
||||
*/
|
||||
public class PostgreSqlOwnerSafeIdempotencyStore implements IdempotencyStorePort {
|
||||
public class PostgreSqlIdempotencyStore implements IdempotencyStorePort {
|
||||
|
||||
static final int INLINE_RESPONSE_MAX_BYTES = 8 * 1024;
|
||||
|
||||
@@ -78,11 +78,11 @@ public class PostgreSqlOwnerSafeIdempotencyStore implements IdempotencyStorePort
|
||||
private final IdempotencyClaimGateway claims;
|
||||
private final IdempotencyTransitionGateway transitions;
|
||||
|
||||
public PostgreSqlOwnerSafeIdempotencyStore(JdbcOperations jdbc) {
|
||||
public PostgreSqlIdempotencyStore(JdbcOperations jdbc) {
|
||||
this(jdbc, new SecureRandom());
|
||||
}
|
||||
|
||||
PostgreSqlOwnerSafeIdempotencyStore(JdbcOperations jdbc, SecureRandom secureRandom) {
|
||||
PostgreSqlIdempotencyStore(JdbcOperations jdbc, SecureRandom secureRandom) {
|
||||
Objects.requireNonNull(jdbc, "jdbc");
|
||||
this.secureRandom = Objects.requireNonNull(secureRandom, "secureRandom");
|
||||
this.guard = new IdempotencyCapabilityGuard(jdbc, dataSourceOf(jdbc), ACTIVE_CAPABILITY_SQL);
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user