Files
document-haness/docs/clean-architecture-backend-template/tech-log-studio/identity-and-value-contracts/concept/concept-messaging-testkit-c04.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

66 lines
3.8 KiB
Markdown

---
kind: CONCEPT
slug: messaging-testkit-c04
title: 계약 테스트 일곱 개를 어댑터가 지울 수 없게 만든 방식
topic: identity-and-value-contracts
project: clean-architecture-backend-template
status: 게시 전
sourceRevision: 21234e38cdb9a926cbc92bb97a2aee2e4a7d2916
rootTreeNode: concept:messaging-testkit-c04
evidenceCapturedOn: 2026-09-01
assets:
- key: messaging-testkit-c04
file: ../../../final/evidence/rendered/messaging-testkit-c04.svg
- key: messaging-testkit-c04-diagram
file: ../../../final/assets/diagrams/messaging-testkit-c04.svg
evidence:
- ../../../final/evidence/raw/messaging-testkit-c04.txt
source:
- 원본 분석 절은 analysis/messaging/messaging-testkit.md#L169 이다.
module: messaging-testkit
---
# 계약 테스트 일곱 개를 어댑터가 지울 수 없게 만든 방식
계약을 `abstract class` + `@Test` 로 만들었기 때문에 어댑터가 `@Test` 를 삭제하는 방법이 없다. 그 위에 리플렉션으로 메서드 이름 집합을 상수와 대조하는 자물쇠가 하나 더 있어 계약의 크기 자체가 잠겨 있다.
## 본문
<!-- body:start -->
계약을 `abstract class` + `@Test` 로 만든 결정의 효과는 `InMemoryHarnessContractTest` 의 javadoc 에 있다.
> "Every broker adapter adds the same nested class over its own harness, so a guarantee can only be weakened by editing the contract, where the change is visible, rather than by an adapter quietly not implementing it."
즉 어댑터가 `@Test`**삭제하는 방법이 없다**. 상속받는 순간 7개가 전부 실행된다.
## 계약을 상속하면 일어나는 것
:::evidence key="messaging-testkit-c04-diagram" alt="계약 클래스에서 어댑터 중첩 클래스로 상속 화살표가 가고 거기서 계약 테스트 실행으로 이어지는 왼쪽에서 오른쪽 흐름" caption="계약을 상속하면 일어나는 것" zoom="false"
:::
어댑터 쪽에서 하나를 빼려면 이 파일을 고쳐야 하고, 그것은 리뷰에 보인다.
## 계약의 크기를 잠그는 두 번째 자물쇠
`CompatibilityMatrixTest` 가 리플렉션으로 `@Test` 가 붙은 메서드 이름 집합을 `REQUIRED_CONTRACT_TESTS` 상수와 정확히 대조한다. 계약에서 테스트 하나를 지우면 이 테스트가 깨진다. 추가해도 깨진다. 계약의 크기 자체가 잠겨 있다.
## InMemoryHarnessContractTest 참조 위치
:::evidence key="messaging-testkit-c04" alt="코드베이스에서 InMemoryHarnessContractTest 를 검색한 출력 1줄. 이 기록이 세는 참조가 그 출력에 그대로 보인다." caption="InMemoryHarnessContractTest 코드베이스 검색 — 1줄 · exit 0" zoom="true"
:::
## 시나리오가 기대 결과를 소유한다
5개 시나리오, 그리고 각각이 `rationale`**비어 있으면 생성 자체가 실패하도록** 강제한다. `REJECTED``BEFORE_TRANSMISSION` 하나뿐이라는 사실이 테스트로 잠겨 있다(`CrossBrokerContractSuite.aFailureBeforeTransmissionIsTheOnlyOneReportedAsRejected`). `byName` 은 알 수 없는 이름을 건너뛰지 않고 거절한다.
## 증거 파일을 커밋하고 손으로 못 쓰게 한다
두 javadoc 이 **자기가 고친 결함을 이름 붙여** 남겼고, 네 가지 결정이 한 문단에 압축되어 있다.
**(a) 커밋한다.** `src/main/resources/messaging/broker-certification-evidence.jsonl`. `build/` 를 읽으면 깨끗한 체크아웃에서 답이 달라진다는 이유가 명시되어 있다. 확인: `src``build/resources` 사본이 diff 로 동일(`EVD-300`).
**(b) 손으로 못 쓰게 하는 게이트.** `messaging-kafka/build.gradle:82``verifyMessagingCertificationEvidence`. `gitCommit``observedAt` 을 정규식으로 지우고 나머지 집합을 비교한다. 그 둘은 매 실행마다 달라지므로 비교 대상이 아니라는 주석이 붙어 있다.
<!-- body:end -->