Files
document-haness/docs/clean-architecture-backend-template/tech-log-studio/transaction-and-consistency-models/concept/concept-adapter-outbound-persistence-jpa-c37.md
T
DongHyeonkaandClaude Opus 5 b2963105a8 docs(keycloak-session-store): import the session-storage lab as a new project
The keycloak project ended with four open questions that design could not
settle. A two-VM lab was built to answer them by measurement, and this is
that material: 26 experiments, 125 raw command outputs, 22 browser captures.

Follows the import procedure in README.md.

  source/     the originating repository verbatim — 78 documents, 28 SVGs,
              8 manifests, plus .source-revision recording the commit
  final/      the SSOT
    document.md   729 lines written from the 29 experiment documents, not
                  concatenated: what was predicted, what was measured, and
                  where the measurement itself was wrong
    evidence/raw    125 outputs, flattened to <experiment>__<file> because
                    the originals collided (01-baseline.txt appeared three
                    times) and the audit only globs the top level
    evidence/meta   one per raw file; command and exitCode are null and the
                    README says why rather than inventing them
    evidence/browser  22 captures
    assets/       three diagrams through techviz
    .techviz/     their VizSpecs

A separate project rather than an addition to keycloak: the B-layer answers
that project's four questions, but the A, C and D layers are about cluster
failure, SSO and operations, and one document.md should hold one subject.
The four question records there can point here through 관계.

Recorded rather than papered over: only three of the 28 diagrams were
remade. The repository forbids hand-drawn SVG and forbids titles inside the
canvas; all 28 originals carry both, so converting them is redrawing, not
reformatting. They stay in source/ and the gap is written into the document.

verify-pipeline.py passes. audit-records.py reports no issues.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-09-04 22:51:59 +09:00

56 lines
3.3 KiB
Markdown

---
kind: CONCEPT
slug: adapter-outbound-persistence-jpa-c37
title: 중복 재생이 owner 검증보다 먼저 저장된 owner를 돌려준다
topic: transaction-and-consistency-models
project: clean-architecture-backend-template
status: 게시 전
sourceRevision: 21234e38cdb9a926cbc92bb97a2aee2e4a7d2916
rootTreeNode: concept:adapter-outbound-persistence-jpa-c37
evidenceCapturedOn: 2026-09-01
assets:
- key: adapter-outbound-persistence-jpa-c37
file: ../../../final/evidence/rendered/adapter-outbound-persistence-jpa-c37.svg
evidence:
- ../../../final/evidence/raw/adapter-outbound-persistence-jpa-c37.txt
source:
- 원본 분석 절은 analysis/05-adapter-outbound-persistence-jpa.md#L2734 이다.
module: adapter-outbound-persistence-jpa
---
# 중복 재생이 owner 검증보다 먼저 저장된 owner를 돌려준다
`PostgreSqlSameStoreInboxAdapter``PostgreSqlPollingDeliveryAdapter`는 owner-safe transition contract를 구현하지만 현재 production composition에서 bean construction이나 stereotype이 확인되지 않았다. 따라서 아래는 채택 시 활성화되는 latent defect다.
## 본문
<!-- body:start -->
`PostgreSqlSameStoreInboxAdapter``PostgreSqlPollingDeliveryAdapter``application-core`의 owner-safe transition contract를 구현하지만, 현재 production composition에서 bean construction이나 stereotype은 확인되지 않았다. 따라서 아래 finding은 **현재 배포 기본 경로의 즉시 장애가 아니라, 이 candidate adapter를 채택할 때 활성화되는 latent defect**로 분리한다.
## markProcessing이 검증보다 먼저 owner를 돌려준다
`markProcessing()`은 같은 `START + operationId`를 발견하면 `classifyMismatch()`보다 먼저 `owner(row)`를 반환한다. 이 때문에 scope/operation id만 맞춘 forged owner로 replay하면 DB에 저장된 실제 owner token을 돌려받을 수 있다. 실제 PostgreSQL probe는 이렇다.
```text
inboxForgedReplay.outcome=PROCESSING_STARTED
inboxForgedReplay.returnedActualToken=true
inboxForgedReplay.returnedForgedToken=false
inboxForgedReplay.completeWithReturnedOwner=COMPLETED
```
즉 duplicate handling이 owner capability recovery oracle처럼 동작한다. 채택 전에는 duplicate replay에서도 persisted owner tuple/revision과 supplied owner를 먼저 검증하도록 고쳐야 한다.
## PostgreSqlSameStoreInboxAdapter 참조 위치
:::evidence key="adapter-outbound-persistence-jpa-c37" alt="코드베이스에서 PostgreSqlSameStoreInboxAdapter 를 검색한 출력 8줄. 이 기록이 세는 참조가 그 출력에 그대로 보인다." caption="PostgreSqlSameStoreInboxAdapter 코드베이스 검색 — 8줄 · exit 0" zoom="true"
:::
## digest가 담지 않는 두 인자
`markRetryable`/`markDead``retention`은 실제 SQL update에는 들어가지만 transition digest에는 들어가지 않는다. 동일 operation id로 retention만 바꾼 replay가 same-operation으로 흡수된다. retention은 terminal row 보존 기간을 결정하는 semantic argument이므로 digest에 canonical millis를 포함해야 한다.
`markRetryable()``nextAttemptAt`을 DB에 기록하지만 transition digest는 kind + operation + owner + errorCode만 포함한다. 재시도 시각은 delivery scheduling 자체를 바꾸는 semantic argument다.
<!-- body:end -->