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>
4.2 KiB
kind, slug, title, topic, project, status, sourceRevision, rootTreeNode, evidenceCapturedOn, assets, evidence, source, module
| kind | slug | title | topic | project | status | sourceRevision | rootTreeNode | evidenceCapturedOn | assets | evidence | source | module | ||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| CONCEPT | messaging-security-c03 | 한 경합에서 서로 다른 두 결함이 나왔다 | state-machines-and-ownership | clean-architecture-backend-template | 게시 전 | 21234e38cdb9a926cbc92bb97a2aee2e4a7d2916 | concept:messaging-security-c03 | 2026-09-01 |
|
|
|
messaging-security |
한 경합에서 서로 다른 두 결함이 나왔다
CredentialRuntimeRegistry.resolve의 key별 single-flight가 이 leaf에서 가장 조밀한 동시성 코드이고, 이전 결함이 주석에 통째로 남아 있다.
관계
- 배선된 게이트는 자기 leaf 레인에서 검증한다 같은 분석 리프에서 끌어낸 규칙이다.
- 같은 술어가 두 타입에 있으면 하나가 다른 하나를 부른다 같은 분석 리프에서 끌어낸 규칙이다.
- 가변 필드로 상태 전이를 표현하면 가시성을 함께 정한다 같은 분석 리프에서 끌어낸 규칙이다.
- 맵 갱신 함수 안에서 I/O를 하면 그 지연이 락 범위가 된다 같은 분석 리프에서 끌어낸 규칙이다.
본문
이 leaf에서 가장 조밀한 동시성 코드이고, 이전 결함이 주석에 통째로 남아 있다.
"get → fetch → put → clear had no synchronization at all. Two callers rotating the same credential both read the same old runtime and both fetched a replacement: one replacement was lost from the map without ever being cleared — a secret left in memory that nothing owns — and the caller that lost the race could clear material the winner was still using."
두 개의 서로 다른 결함이 한 경합에서 나왔다 — 소유자 없는 비밀이 힙에 남는 것과, 사용 중인 자격증명이 지워지는 것.
교체와 소거의 순서
:::evidence key="messaging-security-c03-diagram" alt="compute 진입과 provider resolve 와 replacement 설치와 이전 세대 소거가 왼쪽에서 오른쪽으로 이어지는 구조" caption="교체와 소거의 순서" zoom="false" :::
ConcurrentHashMap.compute가 해당 bin의 락을 잡으므로 fetch가 정확히 한 번 일어난다. 그리고 clear()가 replacement 생성 후에 온다 — 주석이 그 순서의 이유를 적는다: "no reader sees a window with no usable credential — and only by the thread that replaced it, so the material a concurrent reader holds is never wiped underneath it."
ConcurrentHashMap 참조 위치
:::evidence key="messaging-security-c03" alt="코드베이스에서 ConcurrentHashMap 를 검색한 출력 2줄. 이 기록이 세는 참조가 그 출력에 그대로 보인다." caption="ConcurrentHashMap 코드베이스 검색 — 2줄 · exit 0" zoom="true" :::
외부 I/O가 bin 락을 잡은 채로 일어난다
compute의 람다 안에서 provider.resolve(...)가 호출된다. 같은 credential id를 요청하는 다른 스레드는 그 동안 막히고, ConcurrentHashMap 문서는 compute 람다 안에서 같은 맵을 갱신하지 말라고 요구한다(여기서는 지켜진다). 다른 키는 다른 bin이면 막히지 않지만 해시 충돌 시 같은 bin이면 막힌다. §17.
별도 플래그 없이 같은 필드로 상태를 표현한다
소거 판정이 material.length == 0이다. 생성자가 빈 배열을 거절하므로("credential material must not be empty") 길이 0은 소거된 상태를 뜻한다.
volatile이 아닌 필드가 남긴 위험
material 필드가 volatile이 아니다. clear()가 다른 스레드에서 호출되면 material()이 옛 참조를 볼 수 있다. 실제 경로에서는 compute 안에서만 clear()가 불리고 그 전에 replacement가 맵에 들어가므로 위험이 낮지만, clearAll()은 락 없이 순회한다. §17.