fix!: 재리뷰가 찾은 결함과 색인에서 빠졌던 발견 5건을 고친다
문제: 성숙도 리뷰 수정을 다시 읽은 재리뷰(Critical 0, 회귀 0)가 Important 27건·Minor 41건을 찾았다. 수정이 새로 만든 결함이 많았다. @SystemInvoked가 권한 규칙의 탈출구가 됐고, 데모 계정 거부가 정확히 prod일 때만 걸렸고, outbox 순서 번호가 업그레이드 때 뒤로 갔고, GraphQL union 아래 복잡도가 0이었고, 서블릿 오류 응답이 success:true로 나갔고, 호출자 deadline이 breaker를 열었다. 원래 리뷰 색인이 06 영역 발견 5건(06-10~14)을 빠뜨려 그동안 처리되지 않았다. 방법: 영역별 7묶음이 test-driven-development 절차로 실패 테스트를 먼저 쓰고 고쳤다. 결정은 재리뷰 README 4절에 적었다: 순서 번호는 V21이 기록한 전역 floor부터, 데모 계정은 local·test·demo 허용 목록, @SystemInvoked bean은 기동 실패, complete 단계 실패는 IDEMPOTENCY_COMPLETION_UNKNOWN(결과 불명), 캐시 조건부 쓰기는 별도 SCRIPT lane, strict lane 정책은 build cache 입력, 끝나지 않는 재시도 행은 원인 코드·지표·PARKED 절차. 레지스트리가 선언만 하고 아무 코드도 내보내지 않던 redis.capability.* 지표 6개는 빼고 runbook을 실제 지표(redis.lane.*) 기준으로 고쳤다. 위험·한계: V21을 V22 없이 직접 고쳤다(어느 배포에도 아직 없음). 이 브랜치의 V21을 적용한 개발 DB는 다시 만들어야 한다. 서블릿 오류 디스패치를 보안 체인이 허용한다. 발행·저장소 포트 시그니처가 바뀌어 파생 서비스 코드가 깨진다. prod에서 fixture-로 시작하는 설정값은 기동을 막는다. httpclient failure-injection lane의 main 단계 중복 실행은 이전 결정대로 남겼다. 실제 CI runner 실행은 확인하지 못했다. 검증: ci, mainCheck, :integrationCheck, -p optional-platforms ci integrationCheck performanceCheck, :performanceCheck, :releaseCheck (-PgitRevision), verify-compose-profile-contracts(18 lane) 통과. 첫 실행의 실패 2건(FindSecBugs 1, sample 동시 생성 테스트의 v4 event id)은 고친 뒤 ci·integrationCheck·mainCheck를 다시 돌려 통과했다. Refs: docs/reviews/2026-11-03-rereview/README.md 3·4·6·7절 BREAKING CHANGE: outbox 발행 포트와 저장소 포트 시그니처, 순서 번호 첫 값(V21 floor 다음), 샘플 데모 계정 프로필 허용 목록, 새 오류 코드 IDEMPOTENCY_COMPLETION_UNKNOWN, prod의 fixture- 값 거부, 기동 rule은 static·의존 없음이어야 한다.
This commit is contained in:
+51
@@ -0,0 +1,51 @@
|
||||
package dev.caskeleton.domain.__feature__.testkit;
|
||||
|
||||
import dev.caskeleton.domain.__feature__.__Feature__;
|
||||
import dev.caskeleton.domain.__feature__.__Feature__Id;
|
||||
import dev.caskeleton.domain.__feature__.__Feature__Repository;
|
||||
import java.util.Optional;
|
||||
import java.util.function.Supplier;
|
||||
|
||||
/**
|
||||
* Round-trip probe, never generated into a feature: a repository that refuses work outside its
|
||||
* caller's transaction, as docs/manual/04-persistence.md teaches a real adapter to, inherits the
|
||||
* generated contract and passes it (review 2026-11-03 RR-01-01).
|
||||
*/
|
||||
class CallerTransaction__Feature__RepositoryContractTest extends __Feature__RepositoryContract {
|
||||
|
||||
private final InMemory__Feature__Repository rows = new InMemory__Feature__Repository();
|
||||
private boolean transactionActive;
|
||||
|
||||
@Override
|
||||
protected __Feature__Repository repository() {
|
||||
return new __Feature__Repository() {
|
||||
@Override
|
||||
public __Feature__ save(__Feature__ aggregate) {
|
||||
requireTransaction();
|
||||
return rows.save(aggregate);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Optional<__Feature__> findById(__Feature__Id id) {
|
||||
requireTransaction();
|
||||
return rows.findById(id);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
@Override
|
||||
protected <T> T inTransaction(Supplier<T> work) {
|
||||
transactionActive = true;
|
||||
try {
|
||||
return work.get();
|
||||
} finally {
|
||||
transactionActive = false;
|
||||
}
|
||||
}
|
||||
|
||||
private void requireTransaction() {
|
||||
if (!transactionActive) {
|
||||
throw new IllegalStateException("requires an active caller transaction");
|
||||
}
|
||||
}
|
||||
}
|
||||
+10
-3
@@ -19,15 +19,22 @@ import org.springframework.context.annotation.Import;
|
||||
*
|
||||
* <p>Turns itself on from what is on the classpath: a {@link __Feature__Repository} adapter and a
|
||||
* {@link TransactionPort}. Until a repository adapter exists the feature is absent rather than half
|
||||
* present (docs/manual/02-new-feature.md step 5). When the adapter comes from another
|
||||
* auto-configuration, name it in {@code afterName} so this condition sees its bean.
|
||||
* present (docs/manual/02-new-feature.md step 5).
|
||||
*
|
||||
* <p>{@code @ConditionalOnBean} only sees beans of auto-configurations processed before this one,
|
||||
* and nothing orders them by itself: without {@code afterName} the feature would be on or off
|
||||
* depending on the class names' alphabetical order. {@code TransactionPort} comes from
|
||||
* persistence-jpa's {@code PersistenceJpaAutoConfiguration}, named here. When the repository adapter
|
||||
* comes from another auto-configuration, add its name to the list.
|
||||
*
|
||||
* <p>The use cases are beans, not objects the controller builds, because the method security
|
||||
* advisor proxies beans: {@code @RequiresPermission} on create is enforced by that proxy. Grant
|
||||
* {@code __feature_kebab__:create} to a role under {@code app.authz.role-permissions}; until then
|
||||
* every create is refused (docs/manual/07-authorization.md).
|
||||
*/
|
||||
@AutoConfiguration
|
||||
@AutoConfiguration(
|
||||
afterName =
|
||||
"dev.caskeleton.adapter.outbound.persistence.autoconfigure.PersistenceJpaAutoConfiguration")
|
||||
@ConditionalOnWebApplication(type = ConditionalOnWebApplication.Type.SERVLET)
|
||||
@ConditionalOnBean({__Feature__Repository.class, TransactionPort.class})
|
||||
@Import(__Feature__Controller.class)
|
||||
|
||||
+24
-6
@@ -6,12 +6,17 @@ import dev.caskeleton.domain.__feature__.__Feature__;
|
||||
import dev.caskeleton.domain.__feature__.__Feature__Id;
|
||||
import dev.caskeleton.domain.__feature__.__Feature__Repository;
|
||||
import java.util.Optional;
|
||||
import java.util.function.Supplier;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
/**
|
||||
* What every {@link __Feature__Repository} promises. {@link InMemory__Feature__Repository} extends
|
||||
* it in domain-core's tests; a real adapter extends it in a lane that runs against its real store
|
||||
* (docs/manual/04-persistence.md). Add a test here before adding a repository method.
|
||||
*
|
||||
* <p>Every repository call goes through {@link #inTransaction(Supplier)}. A real adapter refuses
|
||||
* work outside its caller's transaction ({@code CallerTransaction.require}), so its contract test
|
||||
* opens one there; the fake needs none and keeps the default.
|
||||
*/
|
||||
public abstract class __Feature__RepositoryContract {
|
||||
|
||||
@@ -25,13 +30,25 @@ public abstract class __Feature__RepositoryContract {
|
||||
*/
|
||||
protected abstract __Feature__Repository repository();
|
||||
|
||||
/**
|
||||
* Runs one repository call the way a use case does, inside its transaction. The default runs it
|
||||
* directly; an adapter that requires a caller transaction opens and commits one here.
|
||||
*
|
||||
* @param work one call on the repository
|
||||
* @param <T> what the call returns
|
||||
* @return what the call returned
|
||||
*/
|
||||
protected <T> T inTransaction(Supplier<T> work) {
|
||||
return work.get();
|
||||
}
|
||||
|
||||
@Test
|
||||
void aSaved__Feature__IsFoundByItsId() {
|
||||
// given
|
||||
repository().save(__Feature__.create(FIRST, "first"));
|
||||
inTransaction(() -> repository().save(__Feature__.create(FIRST, "first")));
|
||||
|
||||
// when
|
||||
Optional<__Feature__> found = repository().findById(FIRST);
|
||||
Optional<__Feature__> found = inTransaction(() -> repository().findById(FIRST));
|
||||
|
||||
// then
|
||||
assertThat(found.map(__Feature__::name)).contains("first");
|
||||
@@ -39,18 +56,19 @@ public abstract class __Feature__RepositoryContract {
|
||||
|
||||
@Test
|
||||
void anIdNothingWasSavedUnderIsNotFound() {
|
||||
assertThat(repository().findById(UNKNOWN)).isEmpty();
|
||||
assertThat(inTransaction(() -> repository().findById(UNKNOWN))).isEmpty();
|
||||
}
|
||||
|
||||
@Test
|
||||
void savingTheSameIdAgainReplacesTheStoredState() {
|
||||
// given
|
||||
repository().save(__Feature__.create(FIRST, "first"));
|
||||
inTransaction(() -> repository().save(__Feature__.create(FIRST, "first")));
|
||||
|
||||
// when
|
||||
repository().save(__Feature__.restore(FIRST, "renamed"));
|
||||
inTransaction(() -> repository().save(__Feature__.restore(FIRST, "renamed")));
|
||||
|
||||
// then
|
||||
assertThat(repository().findById(FIRST).map(__Feature__::name)).contains("renamed");
|
||||
assertThat(inTransaction(() -> repository().findById(FIRST)).map(__Feature__::name))
|
||||
.contains("renamed");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -12,6 +12,9 @@
|
||||
# 그 전에 템플릿 패키지 이름(Operation, Notification, Common)을 넣어 거절되는지와 아무것도 쓰지
|
||||
# 않는지 확인한다.
|
||||
#
|
||||
# 생성물의 테스트가 모두 실제로 돌았는지 템플릿 목록으로 확인하고, 생성된 저장소 계약을 호출자
|
||||
# 트랜잭션을 요구하는 저장소로 한 번 더 돌린다(scripts/feature-scaffold/probes, 기능에는 생성되지 않는다).
|
||||
#
|
||||
# 루트 Gradle 태스크 `verifyFeatureScaffold`가 이 스크립트를 부르고 mainCheck에 들어 있다.
|
||||
set -euo pipefail
|
||||
|
||||
@@ -92,18 +95,68 @@ cd "$copy/src"
|
||||
:app-bootstrap:check \
|
||||
architectureCheck
|
||||
|
||||
# 생성된 테스트가 실제로 실행되었는지: 각 leaf의 테스트 결과에 기능 테스트 클래스가 있어야 한다.
|
||||
# 생성된 테스트가 실제로 실행되었는지: 템플릿의 테스트 클래스 하나하나가 자기 leaf의 결과 XML을
|
||||
# 남겨야 한다. 목록을 손으로 적지 않고 템플릿에서 만든다 — 손으로 적은 목록은 8개 중 4개만 보았고,
|
||||
# 필터·태그가 바뀌어 나머지가 실행되지 않아도 녹색이었다(review 2026-11-03 RR-01-10).
|
||||
scaffold_templates="$copy/scripts/feature-scaffold/templates/src"
|
||||
mapfile -t test_templates < <(cd "$scaffold_templates" && find . -path '*/src/test/java/*' -name '*Test.java.tmpl' | sort)
|
||||
[ "${#test_templates[@]}" -gt 0 ] || { echo "템플릿에 테스트가 없다: $scaffold_templates" >&2; exit 1; }
|
||||
|
||||
# 결과 XML 하나를 확인한다: 있고, 한 건 이상 돌았고, 실패·오류가 없다.
|
||||
require_test_result() {
|
||||
local result="$1" what="$2"
|
||||
[ -f "$result" ] || { echo "$what 실행되지 않았다: $result" >&2; exit 1; }
|
||||
if grep -q 'tests="0"' "$result"; then
|
||||
echo "$what 한 건도 돌지 않았다: $result" >&2
|
||||
exit 1
|
||||
fi
|
||||
if grep -q '<failure\|<error' "$result"; then
|
||||
echo "$what 실패했다: $result" >&2
|
||||
exit 1
|
||||
fi
|
||||
}
|
||||
|
||||
# 템플릿 경로(<leaf>/src/test/java/<패키지 경로>/<클래스>.java.tmpl)를 그 leaf의 결과 XML 경로로.
|
||||
result_of() {
|
||||
local template="${1#./}" name="$2" package_name="$3"
|
||||
local leaf="${template%%/src/test/java/*}"
|
||||
local class_path="${template#*/src/test/java/}"
|
||||
class_path="${class_path%.java.tmpl}"
|
||||
local fqcn
|
||||
fqcn="$(printf '%s' "$class_path" | sed -e "s/__Feature__/$name/g" -e "s/__feature__/$package_name/g" | tr '/' '.')"
|
||||
printf '%s/build/test-results/test/TEST-%s.xml' "$leaf" "$fqcn"
|
||||
}
|
||||
|
||||
for name in "${names[@]}"; do
|
||||
for result in \
|
||||
"domain-core/build/test-results/test/TEST-dev.caskeleton.domain.$(printf '%s' "$name" | tr '[:upper:]' '[:lower:]').${name}Test.xml" \
|
||||
"application-core/build/test-results/test/TEST-dev.caskeleton.application.$(printf '%s' "$name" | tr '[:upper:]' '[:lower:]').Create${name}UseCaseTest.xml" \
|
||||
"adapter/inbound/web/build/test-results/test/TEST-dev.caskeleton.adapter.inbound.web.$(printf '%s' "$name" | tr '[:upper:]' '[:lower:]').${name}ControllerTest.xml" \
|
||||
"app-bootstrap/build/test-results/test/TEST-dev.caskeleton.bootstrap.autoconfigure.$(printf '%s' "$name" | tr '[:upper:]' '[:lower:]').${name}ConfigTest.xml"; do
|
||||
[ -f "$result" ] || { echo "생성된 테스트가 실행되지 않았다: $result" >&2; exit 1; }
|
||||
if grep -q '<failure\|<error' "$result"; then
|
||||
echo "생성된 테스트가 실패했다: $result" >&2
|
||||
exit 1
|
||||
fi
|
||||
package_name="$(printf '%s' "$name" | tr '[:upper:]' '[:lower:]')"
|
||||
for template in "${test_templates[@]}"; do
|
||||
require_test_result "$(result_of "$template" "$name" "$package_name")" "생성된 테스트가"
|
||||
done
|
||||
done
|
||||
|
||||
# 생성된 저장소 계약은 실제 adapter가 상속할 수 있어야 한다. 매뉴얼 04장의 adapter는 호출자
|
||||
# 트랜잭션 밖의 호출을 거부하므로, 그렇게 하는 저장소로 계약을 돌려 본다(review 2026-11-03 RR-01-01).
|
||||
# 탐침은 기능에 생성되지 않는 테스트라 PR 게이트(check)와 따로 test 태스크만 돌린다.
|
||||
probe_templates="$copy/scripts/feature-scaffold/probes/src"
|
||||
mapfile -t probes < <(cd "$probe_templates" && find . -type f -name '*.java.tmpl' | sort)
|
||||
probe_filters=()
|
||||
for name in "${names[@]}"; do
|
||||
package_name="$(printf '%s' "$name" | tr '[:upper:]' '[:lower:]')"
|
||||
for probe in "${probes[@]}"; do
|
||||
target="$(printf '%s' "${probe#./}" | sed -e "s/__Feature__/$name/g" -e "s/__feature__/$package_name/g")"
|
||||
target="${target%.tmpl}"
|
||||
mkdir -p "$(dirname "$copy/src/$target")"
|
||||
sed -e "s/__Feature__/$name/g" -e "s/__feature__/$package_name/g" \
|
||||
"$probe_templates/${probe#./}" > "$copy/src/$target"
|
||||
class_path="${target#*/src/test/java/}"
|
||||
probe_filters+=(--tests "$(printf '%s' "${class_path%.java}" | tr '/' '.')")
|
||||
done
|
||||
done
|
||||
./gradlew --console=plain :domain-core:test "${probe_filters[@]}"
|
||||
for name in "${names[@]}"; do
|
||||
package_name="$(printf '%s' "$name" | tr '[:upper:]' '[:lower:]')"
|
||||
for probe in "${probes[@]}"; do
|
||||
require_test_result "$(result_of "$probe" "$name" "$package_name")" "저장소 계약 탐침이"
|
||||
done
|
||||
done
|
||||
echo "feature scaffold 왕복 통과: ${names[*]}"
|
||||
|
||||
Reference in New Issue
Block a user