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>
58 lines
4.0 KiB
Markdown
58 lines
4.0 KiB
Markdown
---
|
||
kind: CONCEPT
|
||
slug: shared-contract-c01
|
||
title: factory는 검증하고 raw 생성자는 검증하지 않는다
|
||
topic: delivery-and-settlement-models
|
||
project: clean-architecture-backend-template
|
||
status: 게시 전
|
||
sourceRevision: 21234e38cdb9a926cbc92bb97a2aee2e4a7d2916
|
||
rootTreeNode: concept:shared-contract-c01
|
||
evidenceCapturedOn: 2026-09-01
|
||
assets:
|
||
- key: shared-contract-c01
|
||
file: ../../../final/evidence/rendered/shared-contract-c01.svg
|
||
- key: shared-contract-c01-diagram
|
||
file: ../../../final/assets/diagrams/shared-contract-c01.svg
|
||
evidence:
|
||
- ../../../final/evidence/raw/shared-contract-c01.txt
|
||
source:
|
||
- 원본 분석 절은 analysis/02-shared-contract.md#L51 이다.
|
||
module: shared-contract
|
||
---
|
||
|
||
# factory는 검증하고 raw 생성자는 검증하지 않는다
|
||
|
||
ApiErrorCode는 code/category/httpStatus/retryable의 최소 표면을 제공하고 OperationalError가 registry mirror 역할을 한다. Category는 VALIDATION, AUTH, AUTHZ, NOT_FOUND, CONFLICT, RATE_LIMIT, TRANSIENT_DEPENDENCY, PERMANENT_DEPENDENCY, DATA_INTEGRITY, INTERNAL의 10개 값으로 고정되어 있으며 테스트가 정확한 vocabulary를 pin 한다.
|
||
|
||
## 본문
|
||
|
||
<!-- body:start -->
|
||
|
||
`ApiErrorCode`는 code/category/httpStatus/retryable의 최소 표면을 제공하고 `OperationalError`가 registry mirror 역할을 한다. `Category`는 VALIDATION, AUTH, AUTHZ, NOT_FOUND, CONFLICT, RATE_LIMIT, TRANSIENT_DEPENDENCY, PERMANENT_DEPENDENCY, DATA_INTEGRITY, INTERNAL의 10개 값으로 고정되어 있으며 테스트가 정확한 vocabulary를 pin 한다.
|
||
|
||
## ApiErrorCode 참조 위치
|
||
|
||
:::evidence key="shared-contract-c01" alt="코드베이스에서 ApiErrorCode 를 검색한 출력 16줄. 이 기록이 세는 참조가 그 출력에 그대로 보인다." caption="ApiErrorCode 코드베이스 검색 — 16줄 · exit 0" zoom="true"
|
||
:::
|
||
|
||
## retryable 이 category 에서 자동으로 나오지 않는다
|
||
|
||
`OperationalErrorTest`는 단순 enum 존재보다 category × retryable 의미를 강하게 검증한다. deterministic VALIDATION/AUTHZ/NOT_FOUND는 retryable=false이고, transient INTERNAL은 기본적으로 retryable=true이되 deploy-time/configuration/terminal 상태인 일부 code는 명시적 예외로 false다. `AUTH_KID_UNKNOWN`은 key rotation 중 JWKS refresh 가능성을 이유로 AUTH 중 유일한 retryable case로 pin 되어 있다. upstream 4xx 전체를 permanent/non-retryable로 분류하면서 408/429의 의미 차이가 남는다는 점은 source comment와 README가 이미 known edge로 기록한다.
|
||
|
||
## 어떤 예외가 코드를 나르는가
|
||
|
||
`DependencyFailureException`과 `PersistenceFailureException`은 `ApiErrorCarrier`를 통해 transport adapter에 stable error code를 전달하면서 raw cause/diagnostic message를 server-side 정보로 남긴다. `AdapterDisabledException`은 carrier를 구현하지 않고 별도 mapping 대상이다.
|
||
|
||
## 검증이 걸리는 자리
|
||
|
||
:::evidence key="shared-contract-c01-diagram" alt="factory 경로에 배타성 검증과 문서의 정상 shape 가 놓이고 raw 생성자에 배타성 미검증과 invalid shape 가능이 빗금으로 놓인다" caption="검증이 걸리는 자리" zoom="false"
|
||
:::
|
||
|
||
`Envelope`, `BulkEnvelope`, `ResponseMeta`, `PageMeta`, `Operation`은 framework-neutral record/factory로 API shape를 전달한다. `Envelope.ok/failure`, `BulkEnvelope.allOk/partial`, `Operation.pending/succeeded/failed` factory는 문서의 정상 shape를 생성하고 테스트도 이 factory path를 검증한다. 그러나 canonical record constructor 자체는 success/data/error의 배타성, operation status와 result/error의 조합, pagination 범위 등을 검증하지 않는다.
|
||
|
||
## 그래서 이 규칙의 성격이 다르다
|
||
|
||
rate-limit value object처럼 intrinsic constructor invariant가 아니라 factory/adapter usage contract다. 현재 source와 test가 일치하므로 즉시 결함으로 분류하지 않지만, raw constructor가 외부 module에 public인 만큼 invalid shape 생성 가능성은 P1 hardening 후보로 남는다.
|
||
|
||
<!-- body:end -->
|