Files
document-haness/docs/clean-architecture-backend-template/final/evidence/raw/a01-f002-idfactory-newid.txt
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

74 lines
3.6 KiB
Plaintext

# 식별자 생성 포트 전문
package dev.caskeleton.domain.identifier;
/**
* Domain port for server-assigned resource identifier generation.
*
* <p>The domain owns the identity contract; the act of generation is performed by an infrastructure
* adapter and orchestrated by an application use case. Design rationale in the module README.
*
* @param <T> the resource identifier type produced by this factory
*/
public interface IdFactory<T extends ResourceId<?>> {
/** Mints a fresh, never-before-used identifier. */
T newId();
}
# 그 포트가 만드는 값의 계약
public interface ResourceId<SELF extends ResourceId<SELF>> {
/** The canonical 36-character UUID string (RFC 9562 UUIDv7). */
String value();
}
# 이 포트를 직접 구현하는 main 클래스: 0
# 샘플이 정의한 팩토리 인터페이스 넷
sample-portfolio/src/main/java/dev/caskeleton/sample/portfolio/domain/worklog/WorkLogIdFactory.java:9:public interface WorkLogIdFactory extends IdFactory<WorkLogId> {}
sample-portfolio/src/main/java/dev/caskeleton/sample/portfolio/domain/worklog/OutboxEventIdFactory.java:8:public interface OutboxEventIdFactory {
sample-portfolio/src/main/java/dev/caskeleton/sample/portfolio/domain/poster/PosterIdFactory.java:9:public interface PosterIdFactory extends IdFactory<PosterId> {}
sample-portfolio/src/main/java/dev/caskeleton/sample/portfolio/application/posterimage/PosterImageOperationIdFactory.java:7:public interface PosterImageOperationIdFactory {
# 그중 포트를 확장한 둘을 구현하는 어댑터
UuidPosterIdFactory.java:15:public class UuidPosterIdFactory implements PosterIdFactory {
UuidWorkLogIdFactory.java:15:public class UuidWorkLogIdFactory implements WorkLogIdFactory {
# 확장하는 둘은 메서드를 더하지 않는다
sample-portfolio/src/main/java/dev/caskeleton/sample/portfolio/domain/worklog/WorkLogIdFactory.java:9:public interface WorkLogIdFactory extends IdFactory<WorkLogId> {}
sample-portfolio/src/main/java/dev/caskeleton/sample/portfolio/domain/poster/PosterIdFactory.java:9:public interface PosterIdFactory extends IdFactory<PosterId> {}
# 확장하지 않는 둘은 반환형이 포트의 바운드를 만족하지 못한다
15: String newEventId();
9: AllocatedOperation allocate();
# 실제 구현이 무엇을 부르는가
@Override
public WorkLogId newId() {
return WorkLogId.of(UuidCreator.getTimeOrderedEpochPlus1().toString());
}
}
# 값 객체가 실제로 검사하는 것
/** Canonical UUID form (RFC 9562): 8-4-4-4-12 hexadecimal groups. */
private static final Pattern PATTERN =
Pattern.compile(
"^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}$");
public WorkLogId {
if (value == null || !PATTERN.matcher(value).matches()) {
throw new IllegalArgumentException("Invalid WorkLogId format: " + value);
}
}
# 모듈 README 가 적는 책임 분리
### `IdFactory` — 식별자 생성 포트
새 식별자를 발급하는 도메인 포트(인터페이스)다.
- **"발급할 책임"과 "실제 생성 행위"를 분리한다.** 식별자를 발급할 *책임* 은 도메인(이 포트)이
소유한다. 하지만 실제로 식별자를 *만드는 행위* 는 인프라 어댑터(예: UUIDv7 생성기)가
수행하고, 애플리케이션 유스케이스가 그 둘을 조율한다. 이렇게 나누면 도메인은 구체적인
난수·시계 같은 소스를 전혀 알지 못한 채, 식별자에 대한 계약만 소유한 순수한 상태로 남는다.
# 저장소 수준 유일성을 실제로 강제하는 곳
45: CONSTRAINT pk_work_log PRIMARY KEY (id)
27: CONSTRAINT pk_poster PRIMARY KEY (id)