--- kind: CONCEPT slug: adapter-outbound-messaging-c02 title: 봉투를 쓰는 경로에 JSON 파서도 생성기도 없다 topic: schema-and-wire-models project: clean-architecture-backend-template status: 게시 전 sourceRevision: 21234e38cdb9a926cbc92bb97a2aee2e4a7d2916 rootTreeNode: concept:adapter-outbound-messaging-c02 evidenceCapturedOn: 2026-09-01 assets: - key: adapter-outbound-messaging-c02 file: ../../../final/evidence/rendered/adapter-outbound-messaging-c02.svg evidence: - ../../../final/evidence/raw/adapter-outbound-messaging-c02.txt source: - 원본 분석 절은 final/document.md#a12#L189 이다. module: adapter-outbound-messaging --- # 봉투를 쓰는 경로에 JSON 파서도 생성기도 없다 `DeterministicEnvelopeWriter`가 페이로드를 선언된 shape대로 스냅샷해 그 바이트를 리터럴로 이어 붙이므로, 같은 키로 다른 바이트가 나오는 경로가 구조적으로 없다. ## 본문 `DeterministicEnvelopeWriter`는 페이로드를 **선언된 shape을 따라 스냅샷**한 뒤 그 정확한 바이트를 봉투에 끼워 넣는다 — "those exact trusted bytes are then embedded in the envelope **without any raw JSON parser or generator API**." `embedExactPayload`가 `,"payload":` 리터럴로 이어 붙이는 방식이다. ## DeterministicEnvelopeWriter 참조 위치 :::evidence key="adapter-outbound-messaging-c02" alt="코드베이스에서 DeterministicEnvelopeWriter 를 검색한 출력 11줄. 이 기록이 세는 참조가 그 출력에 그대로 보인다." caption="DeterministicEnvelopeWriter 코드베이스 검색 — 11줄 · exit 0" zoom="true" ::: ## 입력이 통과해야 하는 것 draft의 페이로드가 **정확히 등록된 final record 클래스**여야 하고(`exactPayloadClassIsRequiredAndNoAssignableTypeSearchOccurs`), contractId와 payloadVersion이 컴파일된 계약과 같아야 하며, 레코드 성분 수·문자열 UTF-8 길이·배열/객체 크기·깊이가 모두 `EnvelopeAdmissionLimits`로 유계다. 그리고 **쓰는 도중에** 출력 크기를 본다(`boundsJsonOutputDuringWritesInsteadOfOnlyInspectingTheCompletedBuffer`). ## 접근자를 한 번만 부른다 가변 페이로드 처리도 명시적이다 — `snapshotsStatefulMutablePayloadAccessorsOnceAndEmbedsThoseExactBytes`. 접근자를 한 번만 부르고 그 바이트를 고정하므로, httpclient의 `ObjectBody` 문제(같은 키로 다른 바이트)가 여기서는 구조적으로 불가능하다.