fix!: 성숙도 리뷰의 High·P1 결함 19건을 고친다

문제: 2026-11-01 성숙도 리뷰에서 High 21건·P1 25건이 나왔다. 결과를
모르는 일을 "확실함"으로 기록했다(발송 중 죽은 알림 재발송, 커밋 중
끊긴 쓰기를 재시도 가능으로 응답, 재시도 가능한 거부를 DEAD로). 중복을
DB가 아니라 코드 순서로 막았다(정산 job, 포스터 제목). 짝 프론트와
wire 계약이 달랐고(처리 중 409, Envelope null), JWT audience 검증이
기본으로 꺼져 있었고, 트레이스가 나가지 않았고, CI가 strict lane 14개를
한 번도 돌리지 않았다.

방법: 발견마다 실패하는 테스트를 먼저 쓰고 고쳤다. 주요 선택:
- 알림 attempt는 처음부터 "시작 여부 모름"으로 쓴다(호출 직전 갱신은
  쓰기가 하나 늘어 버림).
- 정산 job claim은 lease·fence를 갱신하는 UPDATE 한 문장(처리 전체를
  트랜잭션으로 감싸는 안은 외부 호출 동안 잠금을 잡아 버림).
- 커밋 단계 연결 끊김은 DB_COMPLETION_UNKNOWN(재시도 불가).
- 처리 중 409는 retryable=true + Retry-After: 2, Envelope null 필드는
  web Jackson mixin으로 생략(shared-contract는 stdlib only).
- 트레이싱은 자체 Tracer를 지우고 Boot 4 tracing·OTLP로.
- strict lane을 단계에 연결하고 verifyStrictLaneStages가 고아를 막는다.
발견별 RED·GREEN·버린 대안은 리뷰 README 13절 표에 있다.

위험·한계: JWT 모드는 APP_SECURITY_JWT_AUDIENCE가 없으면 기동하지
않는다. 짝 프론트는 409 retryable과 Envelope 키 규칙을 맞춰야 한다.
이 커밋 시점에는 MinIO 공식 이미지가 사라져 MinIO 2 lane이 실패한다
(다음 커밋에서 대체 이미지로 해결).

검증: ci 통과. mainCheck·integrationCheck는 MinIO 2 lane만 실패(이미지
pull 거부). -p optional-platforms ci integrationCheck, performanceCheck,
releaseCheck(-PgitRevision) 통과.

Refs: docs/reviews/2026-11-01-maturity-review/README.md 2·13절
BREAKING CHANGE: JWT 모드에서 APP_SECURITY_JWT_AUDIENCE가 필수가 되고 role은
audience client와 realm 것만 읽는다. IDEMPOTENT_IN_FLIGHT가 retryable=true,
Retry-After: 2로 바뀌고 Envelope는 null 필드를 보내지 않는다.
This commit is contained in:
DongHyeonka
2026-11-03 19:52:06 +09:00
parent 01a8a2a70f
commit 34565130e0
253 changed files with 13849 additions and 1140 deletions
+14 -2
View File
@@ -116,8 +116,10 @@ Spring/Lettuce 타입을 노출하지 않는다.
**rate-limit / idempotency**
- `RATE_LIMIT_EXCEEDED` 는 `retryable=true` 이며 Retry-After 헤더와 짝을 이룬다.
- `IDEMPOTENT_IN_FLIGHT`/`IDEMPOTENT_REQUEST_MISMATCH` 는 결정적인 클라이언트 결과(다시
poll 하거나 본문을 고쳐야 함)라 `retryable=false`.
- `IDEMPOTENT_IN_FLIGHT` 는 `retryable=true`(Retry-After 2s): 결과 불명. 같은 `Idempotency-Key`로
`Retry-After` 뒤 재전송. 새 키 금지. 같은 키 재전송은 서버가 재생·처리 중·불일치로 판정하므로 안전하다.
- `IDEMPOTENT_REQUEST_MISMATCH` 는 본문을 고쳐야 하는 클라이언트 버그라 `retryable=false`.
두 코드의 클라이언트 행동은 `docs/web/http-contract.md` §2 가 정본이다.
**ADAPTER_DISABLED — 어댑터 런타임 fail-fast**
- 비활성(`app.<domain>.<adapter>.enabled=false`, 기본값) 상태인 선택적 어댑터(Kafka/Redis/Slack/
@@ -246,6 +248,9 @@ Spring/Lettuce 타입을 노출하지 않는다.
- **스켈레톤 공통 단일 아이템 응답 envelope.** 성공과 실패가 한 모양을 공유한다: 최상위 `success`
플래그, `data`(성공) 또는 `error`(실패) 필드, 그리고 request/trace/correlation id 를 담는 `meta`.
`data`/`error` 중 정확히 하나만 non-null 이다.
- **wire 에서는 null 필드를 키째 생략한다**(`Envelope`·`BulkEnvelope`·`ApiError`·`ResponseMeta`).
이 모듈은 Jackson 에 의존하지 않으므로 규칙은 web 어댑터의 `EnvelopeWireFormatConfig` mix-in 에 있다.
키 목록은 `docs/web/http-contract.md` §1 이 정본이다.
- **RFC 7807 ProblemDetail 을 대체한다**(boundary D5/D6). `meta` 객체는 예전의 평평한 `traceId`
필드를 대체하며, success/error 대칭은 유지하면서 요청 진단 정보를 더 풍부하게 담는다.
@@ -430,6 +435,13 @@ Spring/Lettuce 타입을 노출하지 않는다.
으로 전파하기 전에 제거한다 — W3C Baggage spec §4.1 의 trust-boundary 규칙과 OTel Baggage API 의
"untrusted process" 제거 의무(D2)에 따른 것.
### ActiveTrace
- **tracer 가 지금 스레드에서 열어 둔 span 의 trace context 를 W3C 값(`TraceParent`)으로 돌려주는 seam.**
adapter-web 의 `WebMvcRequestIdFilter` 가 `meta.traceId`·로그 `trace_id` 를 정할 때 tracer 가 있으면
그 span 의 id 를 쓰게 하려고 둔다. 이게 없으면 필터가 자기 id 를 따로 만들어, export 된 span 과
응답·로그의 trace id 가 서로 다른 값이 된다(리뷰 07-01).
- **`NONE` 기본값:** tracer 가 없는 조립. 구현은 `composition:service-runtime` 의 `MicrometerActiveTrace`.
### SpanErrorRecorder
- **tracer 라이브러리에 결합하지 않고 span error 를 기록하기 위한 D12 seam.** adapter-web
(`GlobalExceptionHandler`)·adapter-outbound 가 컴파일타임 tracer 의존 없이 span error 를 일관되게
@@ -44,7 +44,7 @@ public enum OperationalError implements ApiErrorCode {
ROUTE_NOT_FOUND(Category.NOT_FOUND, 404, false),
// rate-limit / idempotency
RATE_LIMIT_EXCEEDED(Category.RATE_LIMIT, 429, true),
IDEMPOTENT_IN_FLIGHT(Category.CONFLICT, 409, false),
IDEMPOTENT_IN_FLIGHT(Category.CONFLICT, 409, true),
IDEMPOTENT_REQUEST_MISMATCH(Category.VALIDATION, 422, false),
IDEMPOTENCY_UNAVAILABLE(Category.TRANSIENT_DEPENDENCY, 503, true),
IDEMPOTENCY_RECOVERY_REQUIRED(Category.DATA_INTEGRITY, 500, false),
@@ -4,7 +4,8 @@ package dev.caskeleton.shared.response;
* Skeleton-wide single-item response envelope. Success and failure share one shape: a top-level
* {@code success} flag, a {@code data} field (success) or an {@code error} field (failure), and a
* {@code meta} object carrying request / trace / correlation ids. Exactly one of {@code data} /
* {@code error} is non-null.
* {@code error} is non-null, and the HTTP adapter leaves the {@code null} one off the wire ({@code
* docs/web/http-contract.md}).
*
* <p>See the module README for why this replaces RFC 7807 ProblemDetail and how {@code meta}
* replaced the earlier flat {@code traceId} field.
@@ -0,0 +1,25 @@
package dev.caskeleton.shared.tracing;
import java.util.Optional;
/**
* The trace context of the span the tracer has active on the calling thread, as a W3C value.
*
* <p>Exists so an inbound adapter that names a request's trace id (the web filter that writes
* {@code meta.traceId} and the {@code trace_id} log field) uses the tracer's id when there is a
* tracer, rather than minting a second one the exported spans never carry. Java standard library
* only; {@link #NONE} is what a composition without a tracer gets.
*/
@FunctionalInterface
public interface ActiveTrace {
/**
* Returns the active span's trace context.
*
* @return the context, or empty when no tracer is wired or no span is active
*/
Optional<TraceParent> current();
/** No tracer: there is never an active span. */
ActiveTrace NONE = Optional::empty;
}
@@ -2,6 +2,7 @@ package dev.caskeleton.shared.error;
import static org.assertj.core.api.Assertions.assertThat;
import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Test;
class OperationalErrorTest {
@@ -228,13 +229,14 @@ class OperationalErrorTest {
}
@Test
void idempotentInFlightIs409ConflictNotRetryable() {
// D7 / error-codes.yaml#IDEMPOTENT_IN_FLIGHT — client polls for the in-flight result, not
// retries.
@DisplayName("처리 중 409는 같은 키로 다시 보내면 되므로 retryable이다")
void idempotentInFlightIs409ConflictRetryableWithTheSameKey() {
// docs/web/http-contract.md — the result is unknown and a resend with the same key is judged
// by the server (replay / in-flight / mismatch), so the resend is safe.
assertThat(OperationalError.IDEMPOTENT_IN_FLIGHT.code()).isEqualTo("IDEMPOTENT_IN_FLIGHT");
assertThat(OperationalError.IDEMPOTENT_IN_FLIGHT.httpStatus()).isEqualTo(409);
assertThat(OperationalError.IDEMPOTENT_IN_FLIGHT.category()).isEqualTo(Category.CONFLICT);
assertThat(OperationalError.IDEMPOTENT_IN_FLIGHT.retryable()).isFalse();
assertThat(OperationalError.IDEMPOTENT_IN_FLIGHT.retryable()).isTrue();
}
@Test