Files
document-haness/docs/clean-architecture-backend-template/tech-log-studio/delivery-and-settlement-models/concept/concept-adapter-outbound-fileserver-c05.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

45 lines
2.5 KiB
Markdown

---
kind: CONCEPT
slug: adapter-outbound-fileserver-c05
title: 길이 프레이밍이 구분자를 없애고, 잘린 토큰의 충돌을 컴파일 시점에 잡는다
topic: delivery-and-settlement-models
project: clean-architecture-backend-template
status: 게시 전
sourceRevision: 21234e38cdb9a926cbc92bb97a2aee2e4a7d2916
rootTreeNode: concept:adapter-outbound-fileserver-c05
evidenceCapturedOn: 2026-09-01
assets:
- key: adapter-outbound-fileserver-c05
file: ../../../final/evidence/rendered/adapter-outbound-fileserver-c05.svg
evidence:
- ../../../final/evidence/raw/adapter-outbound-fileserver-c05.txt
source:
- 원본 분석 절은 analysis/08-adapter-outbound-fileserver.md#L300 이다.
module: adapter-outbound-fileserver
---
# 길이 프레이밍이 구분자를 없애고, 잘린 토큰의 충돌을 컴파일 시점에 잡는다
다이제스트는 값마다 길이를 앞세워 경계를 고정하고, 그 다이제스트를 잘라 만든 route token은 컴파일 시점에 충돌 검사를 받는다.
## 본문
<!-- body:start -->
`FilePublicationCanonicalDigests.digestOrderedValues`는 값 개수를 먼저 넣고, 값마다 **길이(4바이트) + 엄격 UTF-8 바이트**를 넣는다. 구분자를 쓰지 않으므로 값 안에 어떤 문자가 있어도 경계가 흐려지지 않는다. `FilePublishRequestFingerprint`도 같은 방식이다.
## FilePublicationCanonicalDigests 참조 위치
:::evidence key="adapter-outbound-fileserver-c05" alt="코드베이스에서 FilePublicationCanonicalDigests 를 검색한 출력 6줄. 이 기록이 세는 참조가 그 출력에 그대로 보인다." caption="FilePublicationCanonicalDigests 코드베이스 검색 — 6줄 · exit 0" zoom="true"
:::
## 잘린 토큰이 만들 수 있는 유일한 문제
`routeToken`은 정책 다이제스트의 앞 31자에 `r`을 붙인 것이라 **잘린 값**이다. 그래서 `FileserverBindingCompiler.deriveUniqueRouteTokens`가 컴파일 시점에 토큰 충돌을 검사하고, 충돌하면 두 destination 이름을 모두 담아 거부한다. 잘림이 만들 수 있는 유일한 문제를 그 자리에서 닫는다.
## 값이 아니라 관계를 다시 계산해 대조한다
컴파일 후에도 `compiled.forEach`로 각 destination의 토큰이 레지스트리와 같은지 다시 확인한다. `CompiledFileDestination`의 compact 생성자는 넘겨받은 `effectivePolicyDigest`를 **다시 계산해 대조**하고, `routeToken`이 그 다이제스트에서 유도됐는지, `formatPolicyDigest`가 정본과 같은지도 확인한다.
<!-- body:end -->