review-followup Wave 3 라운드 2(P18): outbox canonical 통일, composition 모듈, legacy Kafka seam 삭제

- 결정 7: `LegacyOutboxAppendPort`·legacy 저장 모델·relay·Kafka R0 seam 삭제, 템플릿 JSON encoder(`JsonIntegrationEventEncoder`),
  durable operation·sample 이벤트가 `OutboxAppendPort` + encoder로, persistence-jpa V19(pre-canonical 미발행 row 거부)
- 결정 3: outbox relay·멱등성 executor 조립을 `composition:outbox-relay`·`composition:idempotency`로,
  sample이 복사한 bootstrap 인프라를 `composition:service-runtime`으로(sample `SampleIdempotencyConfig` 복사본 삭제)
- persistence-jpa outbox·멱등성 패키지 feature 기준 이동, messaging outbox·inbox leaf를 reliability / reliability-jdbc-postgresql로
- messaging outbox header를 jsonb로(P18-new-1 — `\`로 끝나는 값이 다음 header를 삼키던 결함)
- 통합(충돌 22건): P25 A-10c(전략 선택 설정 삭제)를 service-runtime `DomainContextConfig`에 적용, P25 startup 예외 통합을
  composition 설정 테스트에, P25 `CommandUseCase.handle` 이름을 PG 통합 테스트에, P15 `EventJson`은 호출자 0이 되어 삭제
- root CLAUDE.md의 legacy seam 문장 수정(P18-new-2)

검증: ./gradlew check architectureCheck verifyDependencyLocks verifyPublicPathSnapshot :app-bootstrap:verifyEnvKeys
configContractCheck :app-bootstrap:integrationTest :sample-portfolio:integrationTest :sample-portfolio:systemTest
persistence-jpa jpaPlatformContractTest·postgresql{Idempotency,OutboxAppendTransactional,OutboxConcurrentRelay,OutboxRowLifecycle}IntegrationTest
:messaging:messaging-reliability-jdbc-postgresql:integrationTest --continue 통과(700 task)

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
donghyeon-ka
2026-09-29 12:30:01 +09:00
co-authored by Claude Opus 5.5
parent b5e3c03777
commit 6397f52dc8
45 changed files with 298 additions and 532 deletions
@@ -22,38 +22,23 @@ public interface OutboxRepository {
void append(OutboxRecord record);
/**
* Leases a batch of publishable records.
* Claims a batch and returns the leases, each carrying its owner and fencing token, skipping rows
* that are waiting for their backoff or out of attempts.
*
* <p>Leasing rather than simply selecting is what makes multiple relay instances safe: a record
* claimed by one relay is invisible to the others until its lease expires, so the same message is
* not published concurrently by two processes.
*
* @param batchSize how many records to claim
* @param leaseDuration how long the claim holds
* @param now the current instant
* @return the leased records, oldest first
*/
List<OutboxRecord> leaseBatch(int batchSize, Duration leaseDuration, Instant now);
/**
* Claims a batch and returns the leases, each carrying its owner and fencing token.
*
* <p>The token is what a terminal write is checked against. {@link #leaseBatch} returns records
* without one, so its callers cannot prove a write belongs to their claim; it remains for
* inspection paths and is deprecated for the relay's use.
*
* @param owner this relay's stable identity
*/
List<OutboxLease> claimBatch(String owner, int batchSize, Duration leaseDuration, Instant now);
/**
* Claims a batch, skipping rows that are waiting for their backoff or out of attempts.
* <p>Claiming rather than simply selecting is what makes multiple relay instances safe: a record
* claimed by one relay is invisible to the others until its lease expires, and the token is what
* a terminal write is checked against, so a relay that stalled past its lease writes nothing.
*
* <p>Eligibility belongs in the row. A relay that decides in memory forgets on restart, and every
* replica decides for itself — so the same message is retried by as many workers as there are
* replicas, as often as they poll.
*
* @param owner this relay's stable identity
* @param batchSize how many records to claim
* @param leaseDuration how long the claim holds
* @param now the current instant
* @param maxAttempts the attempt budget; rows at or above it are not claimed
* @return the leases, oldest first
*/
List<OutboxLease> claimBatch(
String owner, int batchSize, Duration leaseDuration, Instant now, int maxAttempts);
@@ -65,10 +50,10 @@ public interface OutboxRepository {
*/
OutboxTransitionResult markPublished(OutboxLease lease, Instant now);
/** Records an ambiguous outcome, only if this lease still owns the row. */
OutboxTransitionResult markAmbiguous(OutboxLease lease, String failureCode, Instant now);
/** Records an ambiguous outcome and when this row may next be claimed. */
/**
* Records an ambiguous outcome and when this row may next be claimed, only if this lease still
* owns the row.
*/
OutboxTransitionResult markAmbiguous(
OutboxLease lease, String failureCode, Instant now, Instant nextAttemptAt);