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>
125 lines
5.3 KiB
Markdown
125 lines
5.3 KiB
Markdown
---
|
|
kind: CONCEPT
|
|
slug: capability-schema-registry
|
|
title: capability_schema_registry — 스키마 적용과 사용 승인의 분리
|
|
topic: owner-safe-state-machines
|
|
project: clean-architecture-backend-template
|
|
status: 게시 전
|
|
sourceRevision: 21234e38cdb9a926cbc92bb97a2aee2e4a7d2916
|
|
rootTreeNode: concept:capability-schema-registry
|
|
evidenceCapturedOn: 2026-09-01
|
|
assets:
|
|
- key: capability-schema-registry
|
|
file: ../../../final/evidence/rendered/capability-schema-registry.svg
|
|
- key: capability-schema-registry-diagram
|
|
file: ../../../final/assets/diagrams/capability-schema-registry.svg
|
|
evidence:
|
|
- ../../../final/evidence/raw/capability-schema-registry.txt
|
|
source:
|
|
- 원본 분석 절은 final/document.md#4-1 · analysis/05 §8.4, §11.3 이다.
|
|
---
|
|
|
|
# capability_schema_registry — 스키마 적용과 사용 승인의 분리
|
|
|
|
테이블이 만들어졌다는 것과 그 능력을 써도 된다는 것을 별개의 사실로 기록한다. 레지스트리 테이블이 능력별 스키마 스트림과 설치 출처와 에포크를 담는다.
|
|
|
|
## 관계
|
|
|
|
- **capability는 스키마 적용과 사용 승인을 분리한다**
|
|
이 구조를 채택한 결정이다.
|
|
- **지원 등급은 추론이 아니라 선언이고 증거 없이는 올라가지 않는다**
|
|
같은 원칙의 능력 등급 판이다.
|
|
|
|
## 본문
|
|
|
|
<!-- body:start -->
|
|
|
|
독립 Flyway 스트림 설계의 접착제다. 각 capability 스트림의 V1이 세 단계를 밟는다 — (1) 선행조건 검사(`DO $$ ... RAISE EXCEPTION`으로 core epoch가 ACTIVE인지), (2) 테이블 생성, (3) **자기를 `INSTALLED_INACTIVE`로 등록**.
|
|
|
|
## 적용과 사용 승인이 갈리는 자리
|
|
|
|
:::evidence key="capability-schema-registry-diagram" alt="선행조건 검사에서 테이블 생성으로 core epoch 확인이 건너가고 테이블 생성에서 레지스트리 등록으로 INSTALLED_INACTIVE 가 건너간다" caption="적용과 사용 승인이 갈리는 자리" zoom="false"
|
|
:::
|
|
|
|
## 어댑터가 런타임에 다시 묻는다
|
|
|
|
어댑터가 `capability_id` + `core_epoch` + `feature_revision` + `lifecycle_state='ACTIVE'`를 조회해 확인한다. 그래서 "스키마가 적용됐다"와 "capability를 써도 된다"가 분리된다.
|
|
|
|
## 각 스트림 V1 이 밟는 세 단계
|
|
|
|
:::evidence key="capability-schema-registry" alt="분석 문서 final/document.md 에서 이 기록의 근거 절을 그대로 잘라낸 18줄. 코드베이스를 측정한 것이 아니라 원본 판정이 무엇을 적었는지를 보여 준다." caption="final/document.md 발췌 — 18줄" zoom="true"
|
|
:::
|
|
|
|
## 호출마다 묻지 않는 이유
|
|
|
|
확인은 startup에서만 하고 호출마다 하지 않는다 — "승격되지 않은 스트림은 배포 상태이고, 매 호출마다 묻는 것은 프로세스가 도는 동안 바뀔 수 없는 질문에 round trip을 넣는 것"이다.
|
|
|
|
:::note
|
|
|
|
없음
|
|
|
|
:::
|
|
|
|
## 왜 두 사실을 나누는가
|
|
|
|
스키마가 설치되었다는 것은 마이그레이션이 돌았다는 뜻이다. 그 능력을 써도 된다는 것은 운영자가 그렇게 정했다는 뜻이다.
|
|
|
|
둘을 하나로 보면 마이그레이션을 돌리는 행위가 곧 승인이 된다. 그러면 롤백이나 단계적 활성화 같은 운영 판단이 스키마 배포와 묶인다.
|
|
|
|
## 다리 마이그레이션
|
|
|
|
```sql
|
|
-- Bridge migration: preserve the immutable V1/V3/V4/V5 legacy history and record its
|
|
-- installation origin before independent JPA capability streams are adopted.
|
|
```
|
|
|
|
이 마이그레이션의 역할은 두 가지다. 이전의 불변 이력을 보존하는 것과 그 설치 출처를 기록하는 것이다.
|
|
|
|
## 전제를 먼저 검사한다
|
|
|
|
```sql
|
|
DO $$
|
|
BEGIN
|
|
IF to_regclass('public.idempotency_record') IS NULL THEN
|
|
RAISE EXCEPTION 'legacy adoption requires idempotency_record';
|
|
END IF;
|
|
IF to_regclass('public.outbox_event') IS NULL THEN
|
|
RAISE EXCEPTION 'legacy adoption requires outbox_event';
|
|
END IF;
|
|
IF to_regclass('public.int_lock') IS NULL THEN
|
|
RAISE EXCEPTION 'legacy adoption requires INT_LOCK';
|
|
END IF;
|
|
END
|
|
$$;
|
|
```
|
|
|
|
레거시 채택은 그 레거시가 실제로 있을 때만 의미가 있다. 없는데 진행하면 빈 레지스트리가 만들어지고, 그 뒤의 판단이 전부 그 빈 값 위에 선다.
|
|
|
|
:::note
|
|
|
|
마이그레이션이 자기 전제를 검사하고 실패하는 것은, 잘못된 상태를 만들어 놓고 나중에 발견되는 것보다 낫다. 여기서는 세 테이블의 존재를 각각 이름으로 확인한다.
|
|
|
|
:::
|
|
|
|
## 레지스트리가 담는 것
|
|
|
|
```sql
|
|
CREATE TABLE capability_schema_registry (
|
|
capability_id varchar(128) NOT NULL,
|
|
schema_stream varchar(32) NOT NULL,
|
|
installation_origin varchar(32) NOT NULL,
|
|
core_epoch integer NOT NULL,
|
|
```
|
|
|
|
능력 식별자와 스키마 스트림과 설치 출처와 코어 에포크다.
|
|
|
|
설치 출처가 있다는 것이 이 설계의 요점이다. 같은 스키마라도 레거시 채택으로 들어온 것과 새 스트림으로 설치된 것이 구별된다.
|
|
|
|
## 능력 스트림
|
|
|
|
각 능력이 자기 V1 마이그레이션을 갖는다. 능력별로 스키마 이력이 독립적이므로, 한 능력의 스키마 변경이 다른 능력의 마이그레이션 번호를 밀지 않는다.
|
|
|
|
승인 쪽은 별도 코드가 판정한다. 알림 능력의 스키마 활성화가 그 예다.
|
|
|
|
<!-- body:end -->
|