Merge remote-tracking branch 'origin/main' into claude/v1-vuln-fix-e089b9
main(b3f63be6, 문서 2단계 통합 PR #3)을 V1 브랜치에 합친다. 충돌은 없었다. - docs/web/repository-adaptation.md: V1이 숫자를 고쳤다가 되돌려(23f04afb) 기준과 같았으므로 main의 번역(숫자 없이 카탈로그를 가리킴)이 그대로 들어왔다. - src/adapter/outbound/persistence-jpa/README.md: V1의 Querydsl 문장(71~75줄)과 main의 번역이 자동으로 함께 남았다. - docs/work/reference/decisions.md, docs/upgrade/2026-11-maturity-review.md: V1이 더한 행과 main의 행이 모두 남았다. - main 쪽에서 들어온 workflow 변경은 없다. 검증(노트북, 합친 트리): check-docs.py rc=0(넓어진 숫자 검사 포함 걸림 0), 자기 시험 OK, check-work-docs.py rc=0, check-repo-layout.py rc=0. 게이트는 desktop에서 이 커밋으로 돌린다.
This commit is contained in:
@@ -1,72 +1,68 @@
|
||||
# shared-contract — skeleton-wide operational contract
|
||||
# shared-contract — 골격 전체가 쓰는 운영 계약
|
||||
|
||||
## Registered identity
|
||||
## 등록 정보
|
||||
|
||||
- Module ID: `shared-contract`
|
||||
- Gradle path: `:shared-contract`
|
||||
- Focused test (derived from Gradle path): `./gradlew :shared-contract:test --console=plain`
|
||||
- Runtime baseline: Java 21; repository framework baseline: Spring Boot 4.0.0.
|
||||
- Registry SSOT: `src/config/architecture/modules.json`.
|
||||
- 모듈 ID: `shared-contract`
|
||||
- Gradle 경로: `:shared-contract`
|
||||
- 이 모듈만 시험(Gradle 경로에서 나온 명령): `./gradlew :shared-contract:test --console=plain`
|
||||
- 실행 기준: Java 21. 프레임워크 기준인 Spring Boot 버전은 `src/gradle/libs.versions.toml`이 정한다.
|
||||
- registry 정본: `src/config/architecture/modules.json`.
|
||||
|
||||
Package root: `dev.caskeleton.shared`.
|
||||
패키지 루트: `dev.caskeleton.shared`.
|
||||
|
||||
Design decisions previously kept as code comments (error-code classification, response
|
||||
envelope shape, metric cardinality bounds, tracing seam, domain-context propagation) live in
|
||||
[README.md](README.md). This file stays the SSOT for module rules.
|
||||
예전에 코드 주석에 두던 설계 결정(오류 코드 분류, 응답 envelope 모양, metric cardinality 한계,
|
||||
tracing 이음매, domain-context 전파)은 [README.md](README.md)에 있다. 이 파일은 모듈 규칙의 정본으로
|
||||
남는다.
|
||||
|
||||
## Responsibility
|
||||
- Response envelope (`response/Envelope`, `response/ApiError`, `response/BulkEnvelope`, `response/BulkItemResult`).
|
||||
- Error code contract (`error/ApiErrorCode` interface, `error/OperationalError` enum,
|
||||
`error/ApiErrorCarrier`) and the one client-facing wording table (`error/ClientErrorMessages`,
|
||||
Korean, one message per `Category`, used by every transport).
|
||||
- Cross-cutting mapper sentinel (`error/MappingException`).
|
||||
- Request value contract (`request/Patch`).
|
||||
- Tracing contract types (`tracing/TraceParent`, `tracing/SpanErrorRecorder`) — W3C
|
||||
`traceparent` value type and the span-error-recording seam (feature-distributed-tracing-contract; the OTel
|
||||
tracer runtime is a fork-activated seam, so these stay Java-stdlib-only).
|
||||
- Stdlib helpers every leaf used to copy (moved here in the 2026-09-25 review follow-up): `digest/Sha256` (the
|
||||
SHA-256 digest value and the one `MessageDigest.getInstance("SHA-256")`), `digest/HmacSha256`
|
||||
(sign and constant-time verify), `retry/Backoff` (capped exponential ceiling; "full jitter" means
|
||||
`U[0, ceiling]` and nothing else). Vendored `messaging:*` and the optional gRPC build do not depend
|
||||
on this module and keep their own copies; each family's CLAUDE.md says why (a different product,
|
||||
decided after the 2026-08-14 messaging module review). Every template leaf that needs one of these has the `shared-contract` edge and uses them
|
||||
instead of copying: identifier, persistence-mongo, application-objectstorage and redis-sdk took the
|
||||
edge for exactly this (decided 2026-11-03), each with a test
|
||||
that pins its output to a vector computed outside the JVM.
|
||||
- `observability/MdcKeys`: the snake_case MDC key names (registry `docs/registries/mdc-keys.yaml`)
|
||||
every transport puts a request's correlation under — web, GraphQL, STOMP and gRPC alike.
|
||||
- `ratelimit/`: the provider-neutral edge rate-limit port (`EdgeRateLimitPort`) and its value types,
|
||||
between the web edge and the Redis adapter (README 「ratelimit」).
|
||||
- `security/Permission`: the `resource:action` permission value `AuthorizationPort` is asked about
|
||||
(README 「security」).
|
||||
- `concurrency/`: the domain-context propagation port and its `ThreadLocal` default (README
|
||||
「concurrency」).
|
||||
- `runtime/RuntimeEnvironment`: the one runtime-profile vocabulary every leaf answers "is this
|
||||
production?" with.
|
||||
- `metrics/ForbiddenMetricTags`: the high-cardinality tag keys no metric may carry.
|
||||
- These are the module's packages and the only ones it may have:
|
||||
`ForbiddenApiArchitectureTest.SHARED_CONTRACT_CONTAINS_ONLY_OPERATIONAL_CONTRACT_PACKAGES` refuses a
|
||||
class in any other package below `dev.caskeleton.shared` or directly in the root, which holds only
|
||||
its `package-info`. A new contract package goes into that test's `SHARED_CONTRACT_PACKAGES` and
|
||||
into this list together; `SharedContractPackageRuleTest` fails when `SHARED_CONTRACT_PACKAGES` and
|
||||
the module's packages differ.
|
||||
- Registry-rule mirrors read only by contract tests live in `testFixtures`, not `main`:
|
||||
## 책임 (Responsibility)
|
||||
- 응답 envelope(`response/Envelope`, `response/ApiError`, `response/BulkEnvelope`, `response/BulkItemResult`).
|
||||
- 오류 코드 계약(`error/ApiErrorCode` 인터페이스, `error/OperationalError` enum,
|
||||
`error/ApiErrorCarrier`)과 클라이언트에 보여 줄 문구 표 하나(`error/ClientErrorMessages`.
|
||||
한국어이고 `Category`마다 문구 하나이며 모든 전송 계층이 쓴다).
|
||||
- 계층을 가로지르는 mapper 표지 예외(`error/MappingException`).
|
||||
- 요청 값 계약(`request/Patch`).
|
||||
- tracing 계약 타입(`tracing/TraceParent`, `tracing/SpanErrorRecorder`) — W3C `traceparent` 값 타입과
|
||||
span 오류 기록 이음매(feature-distributed-tracing-contract. OTel tracer 런타임은 fork가 켜는
|
||||
이음매라서 이 타입들은 Java 표준 라이브러리만 쓴다).
|
||||
- 모든 leaf가 복사해 쓰던 표준 라이브러리 도우미(2026-09-25 리뷰 후속으로 여기로 옮겼다):
|
||||
`digest/Sha256`(SHA-256 digest 값과 유일한 `MessageDigest.getInstance("SHA-256")`),
|
||||
`digest/HmacSha256`(서명과 상수 시간 검증), `retry/Backoff`(상한 있는 지수 ceiling. "full jitter"는
|
||||
`U[0, ceiling]`이고 다른 뜻이 아니다). 들여온 `messaging:*`와 optional gRPC 빌드는 이 모듈에
|
||||
의존하지 않고 자기 사본을 둔다. 각 제품의 CLAUDE.md가 이유를 적는다(다른 제품이다. 2026-08-14 메시징
|
||||
모듈 리뷰 뒤에 정했다). 이 도우미가 필요한 템플릿 leaf는 모두 `shared-contract` edge를 두고 복사하지
|
||||
않고 쓴다. identifier, persistence-mongo, application-objectstorage, redis-sdk가 바로 이 때문에
|
||||
edge를 받았고(2026-11-03에 정함), 각각 JVM 밖에서 계산한 벡터로 출력을 고정하는 시험이 있다.
|
||||
- `observability/MdcKeys`: 모든 전송 계층(web, GraphQL, STOMP, gRPC)이 요청의 correlation을 넣는
|
||||
snake_case MDC 키 이름(registry `docs/registries/mdc-keys.yaml`).
|
||||
- `ratelimit/`: web edge와 Redis 어댑터 사이에 있는 provider 중립 edge rate-limit 포트
|
||||
(`EdgeRateLimitPort`)와 그 값 타입(README 「ratelimit」).
|
||||
- `security/Permission`: `AuthorizationPort`에 묻는 `resource:action` 권한 값(README 「security」).
|
||||
- `concurrency/`: domain-context 전파 포트와 그 `ThreadLocal` 기본 구현(README 「concurrency」).
|
||||
- `runtime/RuntimeEnvironment`: 모든 leaf가 「운영 환경인가?」에 답할 때 쓰는 유일한 runtime profile
|
||||
어휘.
|
||||
- `metrics/ForbiddenMetricTags`: 어떤 metric도 실으면 안 되는 high-cardinality tag 키.
|
||||
- 이 모듈의 패키지는 위가 전부이고 다른 패키지는 둘 수 없다:
|
||||
`ForbiddenApiArchitectureTest.SHARED_CONTRACT_CONTAINS_ONLY_OPERATIONAL_CONTRACT_PACKAGES`가
|
||||
`dev.caskeleton.shared` 아래 다른 패키지에 있는 클래스와 루트에 바로 있는 클래스를 거절한다. 루트에는
|
||||
`package-info`만 있다. 새 계약 패키지는 그 시험의 `SHARED_CONTRACT_PACKAGES`와 이 목록에 함께
|
||||
넣는다. `SharedContractPackageRuleTest`는 `SHARED_CONTRACT_PACKAGES`와 모듈의 패키지가 다르면
|
||||
실패한다.
|
||||
- 계약 시험만 읽는 registry 규칙 사본은 `main`이 아니라 `testFixtures`에 둔다:
|
||||
`metrics/MetricNaming`, `metrics/CardinalityBounds`, `metrics/AlertSeverity`,
|
||||
`tracing/BaggageAllowlist`. Move one to `main` only when production code consumes it.
|
||||
- Generic messaging envelope schema resources under `contracts/messaging/envelope/`.
|
||||
They own transport-neutral envelope metadata only; feature payload schemas remain in their
|
||||
feature-owner modules. Resource presence is not runtime discovery or registration.
|
||||
`tracing/BaggageAllowlist`. 운영 코드가 쓰게 될 때만 `main`으로 옮긴다.
|
||||
- `contracts/messaging/envelope/` 아래의 범용 메시징 envelope schema 리소스. 전송 중립 envelope
|
||||
metadata만 가진다. 기능 payload schema는 그 기능을 가진 모듈에 남는다. 리소스가 있다고 런타임에
|
||||
찾아지거나 등록되는 것은 아니다.
|
||||
|
||||
## Allowed
|
||||
- Java standard library ONLY. No Spring, no Jackson, no JPA imports.
|
||||
## 허용
|
||||
- Java 표준 라이브러리**만**. Spring, Jackson, JPA import는 없다.
|
||||
|
||||
## Forbidden
|
||||
- business/domain concept (domain error codes belong in the consuming module).
|
||||
- framework imports (HTTP status is expressed as transport-neutral `int`; the web module maps it).
|
||||
- claiming Draft 2020-12 validator compatibility before the messaging adapter's Task 6 validator
|
||||
qualification exists.
|
||||
## 금지 (Forbidden)
|
||||
- 업무·도메인 개념(도메인 오류 코드는 그것을 쓰는 모듈에 둔다).
|
||||
- 프레임워크 import(HTTP 상태는 전송 중립 `int`로 나타내고 web 모듈이 대응시킨다).
|
||||
- 메시징 어댑터의 Task 6 validator 검증이 생기기 전에 Draft 2020-12 validator 호환을 주장하기.
|
||||
|
||||
## Test
|
||||
## 테스트
|
||||
```bash
|
||||
cd src
|
||||
./gradlew :shared-contract:test
|
||||
|
||||
@@ -508,7 +508,7 @@ Spring 배선(`DomainContextConfig`)은 `composition:service-runtime` 에 있고
|
||||
흐르는 값도 없다. 도메인은 필요해질 때 자기 키를 선언한다(그 전까지 seam 은 관측 가능한 동작이
|
||||
없다 — route 가 없는 `RateLimitKeyResolver` 와 같다).
|
||||
- **`ScopedValue`/`StructuredTaskScope` strategy:** Java 21 preview API 이고 빌드에 `--enable-preview`
|
||||
가 없어(빌드 사실 C1) 운영에서 컴파일되지 않는다. `domain_context_propagation_primitives_stay_unshipped`
|
||||
가 없어(빌드 사실 C1) 운영에서 컴파일되지 않는다. `DOMAIN_CONTEXT_PROPAGATION_PRIMITIVES_STAY_UNSHIPPED`
|
||||
ArchUnit 규칙(app-bootstrap `ForbiddenApiArchitectureTest`)이, 해당 구현이 추가되기 전까지
|
||||
이를 운영 코드에서 배제한다.
|
||||
|
||||
@@ -534,7 +534,7 @@ Spring 배선(`DomainContextConfig`)은 `composition:service-runtime` 에 있고
|
||||
살고 inbound 필터가 virtual thread 에서 전파한다(B6 + D11). 이 propagator 는 **도메인 채널** — 별개의
|
||||
관심사다.
|
||||
- **명시적 핸드오프(S3):** 구현은 스레드 간 암묵적 상속에 의존해선 안 된다(`InheritableThreadLocal` 은
|
||||
`no_inheritable_thread_local` ArchUnit 규칙으로 금지). 스레드/`fork()` 경계를 넘는 코드는
|
||||
`NO_INHERITABLE_THREAD_LOCAL` ArchUnit 규칙으로 금지). 스레드/`fork()` 경계를 넘는 코드는
|
||||
`wrap()` 또는 `capture()`+`restore()` 로 컨텍스트를 명시적으로 재확립한다.
|
||||
|
||||
### 전략이 하나뿐인 이유
|
||||
@@ -545,13 +545,13 @@ Spring 배선(`DomainContextConfig`)은 `composition:service-runtime` 에 있고
|
||||
- `io.micrometer:context-propagation` 의 `ContextSnapshot`/`ContextRegistry`. 다중 키나 Reactor
|
||||
bridge 가 필요할 때 고른다(C7: 활성화 전에 virtual-thread 동작을 확인할 것).
|
||||
- Java 21 `ScopedValue`. PREVIEW 라 `--enable-preview` 가 필요한데 현재 빌드는 켜지 않는다(C1) →
|
||||
`domain_context_propagation_primitives_stay_unshipped` ArchUnit 규칙으로 guard 된다.
|
||||
`DOMAIN_CONTEXT_PROPAGATION_PRIMITIVES_STAY_UNSHIPPED` ArchUnit 규칙으로 guard 된다.
|
||||
|
||||
### ThreadLocalDomainContextPropagator (기본 구현)
|
||||
- plain `ThreadLocal` 이 현재 스레드의 도메인 컨텍스트 맵을 들고, 스레드 경계는 명시적 capture/restore
|
||||
로 넘긴다(D4/D6).
|
||||
- **왜 plain `ThreadLocal` 인가:** `InheritableThreadLocal` 이 아니라서 pooled carrier 스레드 너머로
|
||||
조용히 새지 않고 `no_inheritable_thread_local` ArchUnit 규칙(B6)을 지킨다. virtual thread 는 각자
|
||||
조용히 새지 않고 `NO_INHERITABLE_THREAD_LOCAL` ArchUnit 규칙(B6)을 지킨다. virtual thread 는 각자
|
||||
자기 copy 를 갖는다(Oracle Java 21 docs, TL-VT-C1) → 같은 스레드 read 는 동작하지만 fork 시 상속은
|
||||
없다 — 그래서 핸드오프가 `wrap()`/`capture()` 로 **명시적**이어야 하는 것이다.
|
||||
- multi-key 고빈도 변경이나 Reactor bridging 용이 아니다 — 그건 context-propagation 기반 구현의 일이다. 이
|
||||
|
||||
Reference in New Issue
Block a user