review-followup Wave 3 라운드 3(P19): 3-D 공통 유틸 — Sha256·HmacSha256·Backoff·MdcKeys·TenantId, caller 트랜잭션 guard 하나
- shared-contract `Sha256`(약 65벌 흡수, notification `MessageDigestPort` 삭제), `HmacSha256`(서명 헬퍼), `Backoff`("full jitter" 뜻 하나),
`MdcKeys`(gRPC·STOMP에도 상관관계), registry edge application-notification → shared-contract
- application-core `TenantId` 하나로 web·GraphQL tenant 문법 통일, web operation 경로에 tenant 해석(JWT `tenant_id`)
- persistence-jpa `CallerTransaction` 하나(복사본 4벌 + `JpaStreamScope` 흡수), 범위 없는 멱등성·outbox 리포지토리 메서드 제거(E-6b)
- 주입된 `Clock` 우회 제거(objectstorage·websocket·mongo·web stream), GraphQL 오류가 HTTP request id 사용, notification UUIDv7은 uuid-creator
- 호출처 없는 `WebRequestContext`·argument resolver 삭제
- 결함 수정: `WebStreamRegistry` 상한 경합(ORCH-new-3 — bin 하나만 잠그는 lock 안에서 크기 확인, 원자 카운터로 슬롯 예약)
- 현황표: 소유자 결정 33(persistence-notification·fileserver → persistence-jpa edge), 34(id 포트 domain 전환 보류), 35(X2-P2-6b 나머지 보류)
검증: ./gradlew check architectureCheck verifyDependencyLocks verifyPublicPathSnapshot :app-bootstrap:verifyEnvKeys configContractCheck
:app-bootstrap:integrationTest :sample-portfolio:integrationTest :sample-portfolio:systemTest graphql·websocket systemTest
persistence-jpa jpaPlatformContractTest·postgresql{Idempotency,Outbox*}IntegrationTest --continue 통과(695 task)
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
4f4bd1fd34
commit
09e2dd63d6
+2
-4
@@ -5,10 +5,10 @@ import dev.caskeleton.application.objectstorage.content.ObjectContentProducer;
|
||||
import dev.caskeleton.application.objectstorage.content.ObjectContentProductionContext;
|
||||
import dev.caskeleton.application.objectstorage.content.ObjectContentProductionException;
|
||||
import dev.caskeleton.application.objectstorage.model.ObjectContentIdentity;
|
||||
import dev.caskeleton.shared.digest.Sha256;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.security.MessageDigest;
|
||||
import java.security.NoSuchAlgorithmException;
|
||||
import java.util.concurrent.atomic.AtomicBoolean;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
@@ -34,7 +34,7 @@ public final class MultipartObjectContentProducer implements ObjectContentProduc
|
||||
throw new ObjectContentProductionException("multipart request content is already consumed");
|
||||
}
|
||||
try (InputStream input = file.getInputStream()) {
|
||||
MessageDigest digest = MessageDigest.getInstance("SHA-256");
|
||||
MessageDigest digest = Sha256.newMessageDigest();
|
||||
byte[] buffer = new byte[Math.min(context.maximumChunkBytes(), 64 * 1024)];
|
||||
long delivered = 0;
|
||||
int read;
|
||||
@@ -58,8 +58,6 @@ public final class MultipartObjectContentProducer implements ObjectContentProduc
|
||||
} catch (IOException exception) {
|
||||
throw new ObjectContentProductionException(
|
||||
"multipart request stream could not be read", exception);
|
||||
} catch (NoSuchAlgorithmException exception) {
|
||||
throw new IllegalStateException("SHA-256 must be available", exception);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+4
-12
@@ -2,18 +2,16 @@ package dev.caskeleton.sample.portfolio.adapter.outbound.identifier;
|
||||
|
||||
import dev.caskeleton.sample.portfolio.application.posterimage.PosterImageIdempotencyScopeDigest;
|
||||
import dev.caskeleton.sample.portfolio.application.posterimage.PosterImageIdempotencyScopeDigesterPort;
|
||||
import dev.caskeleton.shared.digest.HmacSha256;
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.nio.ByteBuffer;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.security.GeneralSecurityException;
|
||||
import java.util.Base64;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
import java.util.function.Supplier;
|
||||
import javax.crypto.Mac;
|
||||
import javax.crypto.spec.SecretKeySpec;
|
||||
|
||||
/** HMAC-SHA-256 length-prefixed scope digester with a versioned retained key ring. */
|
||||
public final class HmacPosterImageIdempotencyScopeDigester
|
||||
@@ -115,14 +113,8 @@ public final class HmacPosterImageIdempotencyScopeDigester
|
||||
throw new IllegalStateException(
|
||||
"DB-active idempotency HMAC key is not retained by this process");
|
||||
}
|
||||
try {
|
||||
Mac mac = Mac.getInstance("HmacSHA256");
|
||||
mac.init(new SecretKeySpec(key, "HmacSHA256"));
|
||||
String encoded =
|
||||
Base64.getUrlEncoder().withoutPadding().encodeToString(mac.doFinal(canonical));
|
||||
return new PosterImageIdempotencyScopeDigest(version, encoded);
|
||||
} catch (GeneralSecurityException exception) {
|
||||
throw new IllegalStateException("HmacSHA256 must be available", exception);
|
||||
}
|
||||
String encoded =
|
||||
Base64.getUrlEncoder().withoutPadding().encodeToString(HmacSha256.sign(key, canonical));
|
||||
return new PosterImageIdempotencyScopeDigest(version, encoded);
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
@@ -6,7 +6,7 @@ import dev.caskeleton.application.messaging.contract.IntegrationEventContractCon
|
||||
import dev.caskeleton.application.messaging.contract.IntegrationPayload;
|
||||
import dev.caskeleton.application.messaging.contract.LogicalDestinationId;
|
||||
import dev.caskeleton.application.messaging.contract.SchemaResourceId;
|
||||
import dev.caskeleton.application.messaging.contract.Sha256;
|
||||
import dev.caskeleton.shared.digest.Sha256;
|
||||
import java.lang.reflect.RecordComponent;
|
||||
import java.time.Duration;
|
||||
import java.util.Arrays;
|
||||
|
||||
+1
-1
@@ -5,7 +5,7 @@ import dev.caskeleton.application.messaging.contract.ContractId;
|
||||
import dev.caskeleton.application.messaging.contract.IntegrationEventContractContribution;
|
||||
import dev.caskeleton.application.messaging.contract.LogicalDestinationId;
|
||||
import dev.caskeleton.application.messaging.contract.SchemaResourceId;
|
||||
import dev.caskeleton.application.messaging.contract.Sha256;
|
||||
import dev.caskeleton.shared.digest.Sha256;
|
||||
import java.time.Duration;
|
||||
import java.util.HexFormat;
|
||||
import java.util.List;
|
||||
|
||||
+2
-11
@@ -37,13 +37,10 @@ import dev.caskeleton.sample.portfolio.application.posterimage.PosterImageSaniti
|
||||
import dev.caskeleton.sample.portfolio.application.posterimage.PosterImageUploadIntent;
|
||||
import dev.caskeleton.sample.portfolio.application.posterimage.PosterImageUploadIntentState;
|
||||
import dev.caskeleton.sample.portfolio.application.posterimage.PosterImageUploadIntentStorePort;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.security.MessageDigest;
|
||||
import java.security.NoSuchAlgorithmException;
|
||||
import dev.caskeleton.shared.digest.Sha256;
|
||||
import java.time.Clock;
|
||||
import java.time.Duration;
|
||||
import java.util.EnumSet;
|
||||
import java.util.HexFormat;
|
||||
|
||||
/** TX1 reservation followed by request-bound staging and a fenced TX2 PENDING handoff. */
|
||||
@RequiresPermission("poster:write")
|
||||
@@ -265,12 +262,6 @@ public class PublishPosterImageUseCase
|
||||
}
|
||||
|
||||
private static String sha256Hex(String value) {
|
||||
try {
|
||||
return HexFormat.of()
|
||||
.formatHex(
|
||||
MessageDigest.getInstance("SHA-256").digest(value.getBytes(StandardCharsets.UTF_8)));
|
||||
} catch (NoSuchAlgorithmException exception) {
|
||||
throw new IllegalStateException("SHA-256 must be available", exception);
|
||||
}
|
||||
return Sha256.ofUtf8(value).hex();
|
||||
}
|
||||
}
|
||||
|
||||
+2
-11
@@ -1,9 +1,6 @@
|
||||
package dev.caskeleton.sample.portfolio.domain.poster;
|
||||
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.security.MessageDigest;
|
||||
import java.security.NoSuchAlgorithmException;
|
||||
import java.util.HexFormat;
|
||||
import dev.caskeleton.shared.digest.Sha256;
|
||||
|
||||
/** Bounded opaque object-storage published reference with its canonical checksum. */
|
||||
public record PosterImageReference(String value) {
|
||||
@@ -31,13 +28,7 @@ public record PosterImageReference(String value) {
|
||||
}
|
||||
|
||||
private static String sha256Hex(String value) {
|
||||
try {
|
||||
return HexFormat.of()
|
||||
.formatHex(
|
||||
MessageDigest.getInstance("SHA-256").digest(value.getBytes(StandardCharsets.UTF_8)));
|
||||
} catch (NoSuchAlgorithmException exception) {
|
||||
throw new IllegalStateException("SHA-256 must be available", exception);
|
||||
}
|
||||
return Sha256.ofUtf8(value).hex();
|
||||
}
|
||||
|
||||
private static IllegalArgumentException invalid() {
|
||||
|
||||
+1
-1
@@ -3,7 +3,7 @@ package dev.caskeleton.sample.portfolio.application.event;
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
import dev.caskeleton.application.messaging.contract.IntegrationEventContractContribution;
|
||||
import dev.caskeleton.application.messaging.contract.Sha256;
|
||||
import dev.caskeleton.shared.digest.Sha256;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.UncheckedIOException;
|
||||
|
||||
+1
-1
@@ -13,7 +13,7 @@ import dev.caskeleton.application.messaging.contract.ContractId;
|
||||
import dev.caskeleton.application.messaging.contract.IntegrationPayload;
|
||||
import dev.caskeleton.application.messaging.contract.LogicalDestinationId;
|
||||
import dev.caskeleton.application.messaging.contract.SchemaResourceId;
|
||||
import dev.caskeleton.application.messaging.contract.Sha256;
|
||||
import dev.caskeleton.shared.digest.Sha256;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.net.URI;
|
||||
|
||||
Reference in New Issue
Block a user