Files
document-haness/docs/clean-architecture-backend-template/tech-log-studio/delivery-and-settlement-models/concept/concept-messaging-schema-protobuf-c03.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

3.9 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-schema-protobuf-c03 어긋난 짝을 표현할 수 없게 만든 값 하나 delivery-and-settlement-models clean-architecture-backend-template 게시 전 21234e38cdb9a926cbc92bb97a2aee2e4a7d2916 concept:messaging-schema-protobuf-c03 2026-09-01
key file
messaging-schema-protobuf-c03 ../../../final/evidence/rendered/messaging-schema-protobuf-c03.svg
key file
messaging-schema-protobuf-c03-diagram ../../../final/assets/diagrams/messaging-schema-protobuf-c03.svg
../../../final/evidence/raw/messaging-schema-protobuf-c03.txt
원본 분석 절은 analysis/messaging/messaging-schema-protobuf.md#L112 이다.
messaging-schema-protobuf

어긋난 짝을 표현할 수 없게 만든 값 하나

이 leaf에서 가장 밀도 높은 결정이다. 증명 방법이 영리하다.

관계

  • 검증되지 않는 스키마 파일은 문서임을 파일 안에 적는다 같은 분석 리프에서 끌어낸 규칙이다.
  • 신뢰할 수 없는 입력 쪽 경계를 먼저 테스트한다 같은 분석 리프에서 끌어낸 규칙이다.

본문

이 leaf에서 가장 밀도 높은 결정이다. 예전에는 클래스와 parser가 두 개의 평행한 맵에 살았고 둘이 일치하는지 아무도 확인하지 않아, OrderCreated.classOrderCancelled의 parser를 짝지은 registry가 생성 시점에 받아들여진 뒤 디코딩 시점에 브로커 스레드에서 ClassCastException을 냈다. 둘을 한 값에 묶으면 어긋남을 표현할 수 없다.

짝을 생성 시점에 증명하는 방법

:::evidence key="messaging-schema-protobuf-c03-diagram" alt="빈 바이트 파싱에서 default instance 로 proto3 유효가 건너가고 default instance 에서 선언 클래스 대조로 산출 타입이 건너간다" caption="짝을 생성 시점에 증명하는 방법" zoom="false" :::

증명 방법이 영리하다. proto3에서 모든 필드가 wire상 optional이므로 빈 바이트는 항상 유효한 메시지다. 그것을 파싱하면 default instance가 나오고 그 클래스가 곧 parser의 산출 타입이다. 별도 리플렉션 없이 짝을 확인한다.

에러 메시지가 실패 지점을 명시한다

"a mismatched pairing fails at decode time on a broker thread, not here" — 즉 여기서 실패하는 것이 목적임을 메시지가 스스로 말한다. 두 코드가 다르다 — PROTOBUF_CONTRACT_UNUSABLE(파싱 자체 실패)과 PROTOBUF_CONTRACT_MISMATCH(파싱은 되는데 타입이 다름). 카테고리는 둘 다 CONFIGURATION이다. 테스트가 이 성질을 붙든다 — aParserThatDoesNotProduceTheDeclaredClassIsRejectedAtConstruction, as("the mismatch used to surface as a ClassCastException on a broker thread").

BoundedByteSink 참조 위치

:::evidence key="messaging-schema-protobuf-c03" alt="코드베이스에서 BoundedByteSink 를 검색한 출력 15줄. 이 기록이 세는 참조가 그 출력에 그대로 보인다." caption="BoundedByteSink 코드베이스 검색 — 15줄 · exit 0" zoom="true" :::

세 codec 중 유일하게 사전 거절이 가능하다

BoundedByteSink.requireFits가 이 leaf를 위해 존재하고, schema-api의 javadoc이 그것을 명시한다 — "Protobuf knows its serialized size exactly, so the whole encode can be refused before the first byte is written." 그리고 사전 검사가 사후 경계를 대체하지 않는다 — writeTo(sink)가 여전히 sink를 통과하므로 이중 방어다. schema-api javadoc: "this is a cheaper refusal, not a replacement for the bound."

두 검사를 함께 보는 이유

Message인지와 등록된 클래스의 인스턴스인지를 함께 본다. 후자만으로 충분해 보이지만 전자가 writeTo를 부를 수 있음을 보장한다. JSON codec과 같은 비대칭이다.