Files
clean-architecture-backend-…/src/adapter/outbound/persistence-jpa/build.gradle
T
DongHyeonka 6ec0c4f7fa fix(migration): 실패한 동시 인덱스 마이그레이션 복구와 검사기 설명을 실제 동작에 맞춘다
문제 (재리뷰 round7 영속성 RR7-03-01~05)
- 실패한 동시 인덱스 마이그레이션의 복구를 가이드·검사기·학습 문서가
  "DROP INDEX 하나"로 안내한다. Flyway는 트랜잭션 밖에서 실패한 버전의
  이력 행(success = false)을 남기고, 다음 배포의 validate가 그 행 때문에
  다시 멈춘다. runbook에는 이 경우가 없고 이력 수정은 금지다.
  docs/jpa/runbooks.md "An invalid index exists"도 같은 이유로 재적용에서
  멈춘다.
- 검사기 Javadoc·학습 문서가 "섞인 파일은 부분 적용되지 않는다"고 쓴다.
  가이드가 요구하는 executeInTransaction=false를 붙이면 Flyway가 문장마다
  커밋해 앞 문장이 남는다.
- 가이드·검사기 Javadoc·실패 메시지·학습 문서가 "Flyway는 REINDEX …
  CONCURRENTLY를 트랜잭션 안에서 돌린다"고 쓴다. REINDEX SCHEMA|DATABASE
  CONCURRENTLY는 Flyway가 스스로 트랜잭션 밖에서 돌린다.
- LockWaitMigrationInspector는 .sql.conf가 executeInTransaction=true면
  SET LOCAL 뒤의 VACUUM FULL·REINDEX SCHEMA를 통과시킨다. Javadoc은
  "늘 거부"라고 쓴다.
- ledger 잠금 대기 IT가 동시 인덱스 파일을 "이 테스트에 예외로 적으라"고
  안내하지만 예외를 적을 곳이 없다. 같은 원인으로 ledger의 다른 IT 두 개
  (GrpcOperationLedgerPostgresIT, JpaGrpcOperationLedgerContractIT)도
  모든 파일을 한 문자열로 실행해, 동시 인덱스 파일이 생기면 "cannot be
  executed within a pipeline"으로 실패한다.

고른 방법
- 복구(RR7-03-03): 소유자 결정(2026-11-06)대로 migration-failed.md에
  "Recover a failed concurrent index migration" 절을 둔다. 진행 중 빌드
  확인 → 무효 인덱스 DROP INDEX CONCURRENTLY → 원인 정리 → 그 버전의
  실패 행만 DELETE → 재배포. "Do not"에 이 한 가지 예외를 적고
  flyway repair는 계속 금지한다. SQL 세 블록에 runbook-sql 표시를 달고
  postgresqlConcurrentIndexMigrationIntegrationTest가 runbook에서 읽어
  실 PostgreSQL에서 돌린다(outbox runbook과 같은 방식). 가이드·검사기
  Javadoc·메시지·학습 문서·jpa/runbooks.md는 그 절을 가리킨다.
- 섞인 파일(RR7-03-04)·REINDEX(RR7-03-02): 문장을 고치고, 같은 IT와
  잠금 대기 IT에 사실을 고정한다(섞인 파일 두 경우, REINDEX 다섯 형태).
- 검사기(RR7-03-05): 트랜잭션 안에서 돌 수 없는 잠금 문장은 .sql.conf와
  상관없이 거부한다(리뷰 권장안). 버린 안: Javadoc만 좁히기 — 그 파일은
  PostgreSQL이 배포 때 25001로 거부하므로 검사기가 먼저 알려 주는 쪽이
  맞다. 잠그지 않는 문장(plain VACUUM 등)은 이 검사기의 범위가 아니라
  그대로 둔다.
- ledger(RR7-03-01): IT에 RUN_OUTSIDE_A_TRANSACTION(파일 → 이유) 목록을
  두고 잠금 대기 케이스에서 뺀다. 목록의 파일은 같은 IT가 동시 인덱스
  문장 하나·executeInTransaction=false인지 ConcurrentIndexMigration
  Inspector로 본다. optional 빌드는 testkit에 의존할 수 없어
  sharedMigrationFileSources가 그 파일과 MigrationResource를 복사한다
  (VersionedMigrationFiles와 같은 방식). ledger IT 셋은 마이그레이션을
  파일마다 따로 실행한다(Flyway처럼). 버린 안: 안내만 "다룰 수 없다"로
  바꾸기 — 다음 동시 인덱스 파일이 생길 때 같은 질문이 다시 남는다.

위험·한계
- 검사기 변경으로 서비스의 자기 스트림 검사가 새로 실패할 수 있다.
  걸리는 파일은 PostgreSQL이 배포 때 거부하는 파일뿐이라 배포된 적이
  없다(업그레이드 안내 4.1에 적음).
- runbook의 DELETE는 운영자가 version을 옮겨 적는다. NOT success라
  성공한 행은 지우지 못하지만, 다른 버전의 실패 행을 잘못 적으면 그 행이
  지워진다. 한 행만 지워야 하고 0행이면 다시 분류하라고 적었다.
- ledger 복사 파일 두 개도 JDK만 써야 한다(각 Javadoc에 적음).
- Spotless 검사는 같은 worktree에서 spotlessApply가 변경 없이 끝난 직후라
  UP-TO-DATE로 처리됐다.

검증 (desktop, 공유 잠금, 로그 ~/r8-f3-logs/)
RED — 기준 73d39212 + 이 커밋의 테스트(+ 기준 문서 주장을 단언하는 임시
메서드, + 임시 ledger V004):
- persistence-jpa test --tests LockWaitMigrationInspectorTest: 80건 중
  2건 실패, 검사기가 빈 목록(통과)을 돌려줌 (red-unit.log)
- postgresqlMigrationLockWaitIntegrationTest: 47건 중 4건 실패 — 옛 주장
  대로면 거부여야 할 REINDEX SCHEMA|DATABASE CONCURRENTLY가 applied,
  conf=true VACUUM FULL·REINDEX SCHEMA를 PostgreSQL은 25001로 거부하는데
  검사기는 통과 (red2-lockwait.log)
- postgresqlConcurrentIndexMigrationIntegrationTest: 9건 중 3건 실패 —
  옛 절차(DROP INDEX) 뒤 재배포가 "Detected failed migration to version
  2", conf를 붙인 섞인 파일이 행 3001·무효 인덱스·실패 이력을 남김,
  runbook 블록이 없어 복구 테스트 준비 실패(RED로 세지 않음)
  (red2-concurrent.log)
- ledger integrationTest(V004 동시 인덱스): 6건 중 4건 실패 — 잠금 대기
  IT "name it as an exception here", 다른 IT 둘 "cannot be executed within
  a pipeline" (red-ledger.log)
GREEN — 이 커밋의 트리 b49369e7:
- :adapter:outbound:persistence-jpa:check rc=0 (test 666건 실패 0),
  :testQualityCheck rc=0
- postgresqlMigrationLockWaitIntegrationTest rc=0 (42건 실패 0)
- postgresqlConcurrentIndexMigrationIntegrationTest rc=0 (7건 실패 0)
- -p optional-platforms :grpc:grpc-operation-ledger-jpa:check
  integrationTest testQualityCheck rc=0 (IT 3+2+42건 실패 0)
- :app-bootstrap:documentContractTest rc=0 (66건 실패 0)
- 두 빌드의 verifyStrictLaneStages --dry-run rc=0
- ledger 탐침(임시 V004): 목록에 없으면 잠금 대기 케이스만 실패하고
  메시지가 RUN_OUTSIDE_A_TRANSACTION을 가리킴(48건 중 1건), 목록에 넣으면
  rc=0, 목록에 넣고 SET LOCAL을 섞으면 목록 검사가 "mixes a concurrent
  index statement"로 거부
- python3 scripts/check-work-docs.py --links docs: 깨진 링크 0

Refs: docs/reviews/2026-11-03-rereview/round7/03-persistence.md
2026-11-07 01:14:09 +09:00

363 lines
24 KiB
Groovy

plugins {
id 'ca.spring-library'
id 'ca.spring-config'
id 'java-test-fixtures'
id 'ca.api-surface'
}
// Shared test code as a Gradle test-fixtures variant — ADR-BUILD-001.
// JPA persistence adapter — merged RDBMS base + PostgreSQL vendor module.
// Owns JPA entities, Spring Data repositories, mappers, transaction/audit/lock/outbox port
// implementations, and the vendor-neutral SPI interfaces (OutboxClaimRepository /
// SqlStateErrorMapping). The PostgreSQL driver, flyway-database-postgresql dialect, and vendor
// Flyway migrations live only under the .postgresql subpackage (ArchUnit keeps the base neutral).
// The JPA relational persistence platform (docs/superpowers/specs/2026-08-11-jpa-persistence-
// platform-design.md) models itself as 18 Stable library modules. This repository's fail-closed
// module registry outranks that layout, so those modules are packages here and
// JpaModuleBoundaryTest enforces the design's module dependency table. The full mapping is in
// docs/jpa/repository-adaptation.md.
//
// The testkit is its own source set rather than part of `test` because more than one lane consumes
// it and because a source set whose dependencies are declared only on the test configurations gives
// the design's "no production module depends on the testkit" guarantee without a new Gradle project.
testing {
suites {
postgresqlIntegrationTest(JvmTestSuite) {
// testFixtures as well as the project: java-test-fixtures wires only `test` on its own,
// so the integration lane has to say so (ADR-BUILD-001).
dependencies {
implementation project()
implementation testFixtures(project())
}
}
jpaPlatformPerformanceTest(JvmTestSuite) {
dependencies {
implementation project()
implementation testFixtures(project())
}
}
}
}
configurations {
postgresqlIntegrationTestImplementation.extendsFrom testImplementation
postgresqlIntegrationTestCompileOnly.extendsFrom testCompileOnly
postgresqlIntegrationTestRuntimeOnly.extendsFrom testRuntimeOnly
postgresqlIntegrationTestAnnotationProcessor.extendsFrom testAnnotationProcessor
jpaPlatformPerformanceTestImplementation.extendsFrom testImplementation
jpaPlatformPerformanceTestRuntimeOnly.extendsFrom testRuntimeOnly
}
dependencies {
implementation project(':application-core')
// No `application-fileserver` and no `application-notification`. Each capability's entities,
// repositories and adapters were a package in this leaf, and that is how every application with
// a database also resolved that capability's use cases. They are
// `adapter:outbound:persistence-fileserver` and `adapter:outbound:persistence-notification` now.
implementation project(':shared-contract')
// Typed startup failures, the EnvironmentPostProcessor order, the readiness-group merge and the
// module-defaults loader this leaf's startup policy and shipped settings go through.
implementation project(':adapter:outbound:support')
// Structured fields on the migration, relay and lock log lines (StructuredArguments).
implementation libs.logstash.logback.encoder
// The read-only /actuator/jpaplatform view. compileOnly: this module does not bring actuator;
// the endpoint is registered only when the application already has it.
compileOnly 'org.springframework.boot:spring-boot-actuator'
testImplementation 'org.springframework.boot:spring-boot-actuator'
implementation 'org.springframework.boot:spring-boot-starter-data-jpa'
// feature-distributed-lock-contract: Spring Integration JDBC LockRegistry backs the
// multi-instance distributedLockProvider. Version managed by Spring Boot BOM.
implementation 'org.springframework.integration:spring-integration-jdbc'
// Vendor (PostgreSQL): Flyway migration API + PostgreSQL driver/dialect. Used only by the
// .postgresql subpackage; the RDBMS base stays vendor-neutral (PERSISTENCE_RDBMS_STAYS_VENDOR_NEUTRAL).
implementation 'org.springframework.boot:spring-boot-starter-flyway'
runtimeOnly 'org.postgresql:postgresql'
runtimeOnly 'org.flywaydb:flyway-database-postgresql'
// Vendor (H2): the in-memory driver of the `bootRunH2` developer task and of this leaf's tests.
// The .h2 subpackage reaches it through JDBC/JPA, never by importing org.h2 types, so it compiles
// without it. It is not a runtime dependency (review 09-09): it used to ride into every
// service artifact that selected JPA (2.7 MB, one more engine to scan for CVEs) although no
// deployed profile runs on H2 — `local` defaults to the Compose PostgreSQL (JPA-INT-003) and
// PersistenceVendorProdSafetyValidator refuses H2 under prod. app-bootstrap's
// bootRunH2Classpath adds the driver for the one task that asks for H2 by name.
testRuntimeOnly 'com.h2database:h2'
// JPA platform observability (design §37). Micrometer's observation API already arrives with
// Spring; the meter registry does not, and MicrometerQueryObservation (library API, not composed)
// needs it. Version managed by the Spring Boot BOM.
implementation 'io.micrometer:micrometer-core'
// Querydsl and Envers are Advanced opt-ins (design §4.2): the platform implements their
// contracts, but the Stable runtime classpath must not carry either. compileOnly keeps them off
// every deployment while still compiling the support classes; a deployment that opts in adds the
// artifact itself, and the guards refuse the capability when the classes are absent.
compileOnly 'com.querydsl:querydsl-jpa:5.1.0:jakarta'
compileOnly 'org.hibernate.orm:hibernate-envers'
testImplementation 'com.querydsl:querydsl-jpa:5.1.0:jakarta'
testImplementation 'org.hibernate.orm:hibernate-envers'
testImplementation libs.archunit.junit5
// FlywaySchemaPolicyTest reads the PostgreSQL lock setting FlywaySchemaPolicy hands Flyway. Test
// scope only: production code outside .postgresql stays free of flyway-database-postgresql types.
testImplementation 'org.flywaydb:flyway-database-postgresql'
// Application-owned provider-neutral contract kit. The adapter supplies real PostgreSQL
// implementations; the fixture supplies only the port semantics every implementation must obey.
// The Fileserver capability's persistence moved to its own leaf, and three of this lane's
// qualifications exercise it against real PostgreSQL. They stay here rather than following the
// code: this lane already owns the container, the Flyway wiring and the vendor fixtures, and
// duplicating that infrastructure into the new leaf for three files would add a source set for
// no isolation that does not already exist. The edge is test-scope only, so the production
// dependency graph — the thing Build Composition governs — is untouched.
postgresqlIntegrationTestImplementation project(':adapter:outbound:persistence-fileserver')
postgresqlIntegrationTestImplementation project(':application-fileserver')
// The fileserver port contracts (`*PortContract`) the in-memory fakes also pass (review 04-14).
postgresqlIntegrationTestImplementation testFixtures(project(':application-fileserver'))
// The notification capability's persistence moved out the same way, and its real-PostgreSQL
// qualifications stay here for the same reason: this lane owns the container, the Flyway wiring
// and the readiness cards that name those tests (config/jpa/readiness-cards.yaml). Test scope
// only.
postgresqlIntegrationTestImplementation project(':adapter:outbound:persistence-notification')
postgresqlIntegrationTestImplementation project(':application-notification')
// The application-owned store contracts the notification adapters are held to, the same ones
// the in-memory fakes pass (review 04-14).
postgresqlIntegrationTestImplementation testFixtures(project(':application-notification'))
// The provider-event replay worker lives in the notification adapter and only fails against a
// real JPA stack with no caller transaction, so its real-DB test runs here beside the
// notification stores. Test scope only, like the Fileserver edge. Non-transitive: the worker
// needs only application-notification, which this lane already has, and the adapter's
// mail/Thymeleaf/actuator graph has no business on a database lane.
postgresqlIntegrationTestImplementation(project(':adapter:outbound:notification')) {
transitive = false
}
postgresqlIntegrationTestImplementation testFixtures(project(':application-core'))
postgresqlIntegrationTestImplementation 'org.testcontainers:testcontainers-postgresql'
postgresqlIntegrationTestImplementation 'org.testcontainers:testcontainers-junit-jupiter'
postgresqlIntegrationTestImplementation 'org.testcontainers:testcontainers-toxiproxy'
postgresqlIntegrationTestRuntimeOnly 'org.postgresql:postgresql'
// Declared rather than inherited: the `testkit` source set extended testImplementation, so the
// fixtures compiled against every test library this leaf declared without stating any of them
// (ADR-BUILD-001). Listing them makes the fixtures' own surface reviewable.
// The public error hierarchy (`api.error.JpaPersistenceException`) extends the shared
// `PersistenceFailureException`; the fixtures that throw it compile against that supertype.
testFixturesImplementation project(':shared-contract')
testFixturesImplementation 'jakarta.persistence:jakarta.persistence-api'
testFixturesImplementation 'org.hibernate.orm:hibernate-envers'
testFixturesImplementation 'org.flywaydb:flyway-core'
testFixturesImplementation 'org.springframework:spring-jdbc'
// The rule pack names Spring Data's Repository marker in a rule; it needs the type on the
// compile classpath even though it never calls it.
testFixturesImplementation 'org.springframework.data:spring-data-commons'
testFixturesImplementation 'org.junit.jupiter:junit-jupiter-api'
testFixturesImplementation libs.toxiproxy.java
testFixturesImplementation 'org.testcontainers:testcontainers'
testFixturesImplementation 'org.testcontainers:testcontainers-postgresql'
testFixturesImplementation 'org.testcontainers:testcontainers-junit-jupiter'
testFixturesImplementation 'org.testcontainers:testcontainers-toxiproxy'
testFixturesImplementation libs.archunit.junit5
testFixturesRuntimeOnly 'org.postgresql:postgresql'
// The performance lane starts its own servers: pool saturation is only observable against a
// real database, because the thing being measured is what happens when every connection to it
// is already held.
jpaPlatformPerformanceTestImplementation 'org.testcontainers:testcontainers'
jpaPlatformPerformanceTestImplementation 'org.testcontainers:testcontainers-postgresql'
jpaPlatformPerformanceTestImplementation 'org.testcontainers:testcontainers-junit-jupiter'
jpaPlatformPerformanceTestRuntimeOnly 'org.postgresql:postgresql'
}
// Real-PostgreSQL lanes. A readiness lane runs one named class (the security lane also names the
// runtime-role namespace-denial method), a platform lane selects a tag, and the pool lane has a
// source set of its own. release.yml (jpa-release-gate) and config/jpa/*.{json,yaml} name these tasks.
def jpaEvidenceImage = providers.gradleProperty('jpaPostgreSqlEvidenceImage').orElse(testContainerImages['postgres-16']).get()
def jpaMatrixVersions = providers.gradleProperty('jpa.matrix.versions').orElse('16').get()
def readinessLanes = [
postgresqlLifecycleIntegrationTest : ['PostgreSqlLifecycleIntegrationTest'],
postgresqlSecurityBaselineIntegrationTest : ['PostgreSqlSecurityBaselineIntegrationTest',
'runtimeRoleCannotCreateInApplicationSchemaOrTempAndUsesTrustedSearchPath'],
postgresqlMigrationIntegrationTest : ['PostgreSqlMigrationIntegrationTest'],
postgresqlMigrationLockWaitIntegrationTest : ['PostgreSqlMigrationLockWaitIntegrationTest'],
postgresqlConcurrentIndexMigrationIntegrationTest : ['PostgreSqlConcurrentIndexMigrationIntegrationTest'],
postgresqlIntLockMigrationCompatibilityIntegrationTest : ['PostgreSqlIntLockMigrationCompatibilityIntegrationTest'],
postgresqlTransactionIntegrationTest : ['PostgreSqlTransactionIntegrationTest'],
postgresqlDistributedLockIntegrationTest : ['PostgreSqlDistributedLockIntegrationTest'],
postgresqlAggregateIntegrationTest : ['PostgreSqlAggregateIntegrationTest'],
postgresqlQueryIntegrationTest : ['PostgreSqlQueryIntegrationTest'],
postgresqlIdempotencyIntegrationTest : ['PostgreSqlIdempotencyIntegrationTest'],
postgresqlOutboxAppendTransactionalIntegrationTest : ['PostgreSqlOutboxAppendTransactionalIntegrationTest'],
postgresqlOutboxConcurrentRelayIntegrationTest : ['PostgreSqlOutboxConcurrentRelayIntegrationTest'],
postgresqlOutboxRowLifecycleIntegrationTest : ['PostgreSqlOutboxRowLifecycleIntegrationTest'],
postgresqlOutboxAggregateSequenceIntegrationTest : ['PostgreSqlOutboxAggregateSequenceIntegrationTest'],
postgresqlOutboxOrderKeyRunbookIntegrationTest : ['PostgreSqlOutboxOrderKeyRunbookIntegrationTest'],
postgresqlOutboxDispositionRunbookIntegrationTest : ['PostgreSqlOutboxDispositionRunbookIntegrationTest'],
postgresqlFileserverMigrationIntegrationTest : ['PostgreSqlFileserverMigrationIntegrationTest'],
postgresqlFileserverMetadataIntegrationTest : ['PostgreSqlFileserverMetadataStoreIntegrationTest'],
postgresqlFileserverReclamationIntegrationTest : ['PostgreSqlFileserverReclamationIntegrationTest'],
postgresqlNotificationSchemaActivationIntegrationTest : ['PostgreSqlNotificationSchemaActivationIntegrationTest'],
]
def platformLanes = [
jpaPlatformContractTest : ['jpa-contract', 'Runs the JPA platform contract suite against real PostgreSQL (design §40).'],
jpaPlatformMigrationTest: ['jpa-migration', 'Runs the Flyway upgrade snapshot scenarios (design §31).'],
jpaPlatformFailureTest : ['jpa-failure', 'Reproduces deadlock, serialization, and commit-ambiguity failures (design §39).'],
jpaPlatformQueryPlanTest: ['jpa-queryplan', 'Asserts query plan structure and planner estimate error (design §33).'],
jpaPlatformSecurityTest : ['jpa-security', 'Verifies runtime role privileges and search_path safety (design §36).'],
]
// Every scenario a readiness card cites (config/jpa/readiness-cards.yaml `evidence.scenarios`) is a
// required test of the lane that runs its class, and a readiness lane rejects skips. That is what the
// deleted JPA evidence manifest used to establish from JUnit XML after the fact; JpaReadinessRegistryTest
// checks the cards themselves.
def readinessScenarios = new groovy.json.JsonSlurper()
.parse(rootProject.file('config/jpa/readiness-cards.yaml'))
.cards.values()
.findAll { it.state != 'not-implemented' }
.collectMany { card -> (card.evidence?.scenarios ?: []).collect { it.selector } }
strictTestLanes {
readinessLanes.each { taskName, selection ->
String testClass = 'dev.caskeleton.adapter.outbound.persistence.readiness.' + selection[0]
lane(taskName) {
integration()
sourceSet = 'postgresqlIntegrationTest'
description = 'Runs the no-skip real PostgreSQL readiness scenario ' + testClass + '.'
requires testClass
selection.drop(1).each { method -> requires testClass + '.' + method }
readinessScenarios.findAll { it.startsWith(testClass + '#') }.each { selector ->
String method = testClass + '.' + selector.substring(selector.indexOf('#') + 1)
if (!selection.drop(1).contains(selector.substring(selector.indexOf('#') + 1))) {
requires method
}
}
rejectSkipped = true
jvmArgs '-Djpa.evidence.postgresql.image=' + jpaEvidenceImage
}
}
platformLanes.each { taskName, selection ->
lane(taskName) {
integration()
sourceSet = 'postgresqlIntegrationTest'
tag = selection[0]
description = selection[1]
systemProperty 'jpa.matrix.versions', jpaMatrixVersions
}
}
lane('jpaPlatformPoolContractTest') {
performance()
sourceSet = 'jpaPlatformPerformanceTest'
description = 'Verifies Hikari pool and REQUIRES_NEW connection behaviour (design §38).'
}
}
// The outbox runbooks give an operator SQL to run: the V21 pre-deploy check and cleanup (review
// 2026-11-01, README 15 decision), the manual dispositions of a DEAD row (re-review 2026-11-03
// RR-05-01), and finding, parking, resuming and skipping a row that is retried without end
// (RR-05-03). Each lane reads its blocks out of the runbooks, so the documents are its inputs:
// editing a block reruns the lane against real PostgreSQL.
['postgresqlOutboxOrderKeyRunbookIntegrationTest', 'postgresqlOutboxDispositionRunbookIntegrationTest'].each { laneName ->
tasks.named(laneName, Test) {
def outboxRunbook = new File(rootProject.projectDir.parentFile, 'docs/runbooks/outbox-dead-letter.md')
inputs.file(outboxRunbook).withPathSensitivity(PathSensitivity.RELATIVE).withPropertyName('outboxRunbook')
systemProperty 'outbox.runbook', outboxRunbook.absolutePath
def publishFailedRunbook = new File(rootProject.projectDir.parentFile, 'docs/runbooks/outbox-publish-failed.md')
inputs.file(publishFailedRunbook).withPathSensitivity(PathSensitivity.RELATIVE).withPropertyName('publishFailedRunbook')
systemProperty 'outbox.publish-failed.runbook', publishFailedRunbook.absolutePath
}
}
// The recovery of a failed concurrent index migration (re-review 2026-11-03 round 7, RR7-03-03) is
// SQL the migration runbook gives an operator; the lane reads it out of the runbook the same way.
tasks.named('postgresqlConcurrentIndexMigrationIntegrationTest', Test) {
def migrationFailedRunbook = new File(rootProject.projectDir.parentFile, 'docs/runbooks/migration-failed.md')
inputs.file(migrationFailedRunbook).withPathSensitivity(PathSensitivity.RELATIVE).withPropertyName('migrationFailedRunbook')
systemProperty 'migration.failed.runbook', migrationFailedRunbook.absolutePath
}
tasks.named('postgresqlSecurityBaselineIntegrationTest') {
// Cross-leaf task edge: see the handoff. verifyCleanArchitectureDependencies inspects
// configurations, not the task graph, so this edge is invisible to it.
dependsOn ':adapter:inbound:web:jpaPersistenceRedactionContractTest'
}
// Which JPA lanes block a release is declared by config/jpa/release-registry.json (jpaReleaseQualification below).
// This leaf declares the lanes and how each runs; it does not own release orchestration.
// The unit lane reads three files that are not Java sources: the release registry and its two
// renderings. Without declaring them, Gradle calls the lane up-to-date after a registry demotion or
// a workflow edit — so the drift check that exists to catch exactly that edit never runs on it.
// The unit lane reads files that are not Java sources: the release registry, its two renderings,
// and the documents that describe the pool lane. Without declaring them, Gradle calls the lane
// up-to-date after a registry demotion or a workflow edit — so the drift checks that exist to catch
// exactly those edits never run on them.
tasks.named('test') {
inputs.file(rootProject.file('config/jpa/release-registry.json'))
// JpaReadinessRegistryTest: the readiness cards, the lanes they name and the scenarios they cite.
inputs.file(rootProject.file('config/jpa/readiness-cards.yaml'))
inputs.dir(file('src/postgresqlIntegrationTest/java')).withPropertyName('readinessScenarioSources')
inputs.file(new File(rootProject.projectDir.parentFile, 'docs/jpa/support-matrix.md'))
inputs.file(new File(rootProject.projectDir.parentFile, 'docs/jpa/repository-adaptation.md'))
// The whole directory, not the two named workflows: the Experimental-major check asks whether
// *some* lane records that major as its target, so adding or deleting any workflow can change
// its answer. Naming files here would leave the lane that matters outside the up-to-date check.
inputs.dir(new File(rootProject.projectDir.parentFile, '.github/workflows'))
inputs.file(file('build.gradle'))
inputs.dir(file('src/jpaPlatformPerformanceTest/java'))
// AppliedMigrationImmutabilityTest pins the notification and fileserver streams where they live.
inputs.dir(file('../persistence-notification/src/main/resources/db/migration'))
.withPropertyName('notificationMigrations')
inputs.dir(file('../persistence-fileserver/src/main/resources/db/migration'))
.withPropertyName('fileserverMigrations')
// ...and the messaging platform's tree, whose inbox range the consume side applies here.
inputs.dir(file('../../../messaging/messaging-reliability-jdbc-postgresql/src/main/resources/db/migration'))
.withPropertyName('messagingMigrations')
}
// verifyJpaApiSurface — every public type this leaf exposes is a committed decision.
//
// The GraphQL and Mongo leaves already carried this; the largest of the three did not, so the one
// public surface with the most adopters was the one nothing had an opinion about. The convention
// plugin is opt-in per leaf, and opting in was simply never done here.
//
// This baseline is also a hard growth ceiling. Updating the committed surface may record removals
// freely, but a larger type count is rejected unless the reviewer separately supplies
// -PraiseJpaApiSurfaceCeiling in addition to the normal change approval. That makes "one more
// public type" a deliberate compatibility-budget decision rather than a routine baseline refresh.
// `api` is the intended adopter surface; implementation packages remain candidates for further
// internalization, and every removal pays down that compatibility debt.
apiSurface {
label = 'Jpa'
baseline = rootProject.file('../docs/architecture/jpa-api-surface.txt')
description = 'JPA persistence leaf public API surface — every public top-level type in src/main/java.'
rationale = [
'A public type in a single-jar leaf is reachable from every adopter\'s code, so',
'additions are reviewed rather than discovered. `api` is the intended external',
'surface; the rest is implementation that has not been moved under an internal',
'root yet.',
]
// The reviewed subset other leaves' production code may import. The two leaves that implement
// JPA persistence (this one and persistence-fileserver) are the implementation, not adopters.
// This used to be JpaAdopterApiSurfaceTest, a regular-expression import scan beside the
// convention (review 2026-09-24 BUILD-중복-3); the convention parses imports with javac now.
adopterBaseline = rootProject.file('../docs/architecture/jpa-adopter-api-surface.txt')
adopterSources = fileTree(rootProject.projectDir) {
include '*/**/src/main/java/**/*.java'
exclude '**/build/**', 'adapter/outbound/persistence-jpa/**', 'adapter/outbound/persistence-fileserver/**',
'adapter/outbound/persistence-notification/**',
'build-logic/**', 'optional-platforms/**'
}
}
// The release registry (config/jpa/release-registry.json) names the blocking release gates; this
// aggregate runs exactly those. It replaced the build-tools `ca.jpa-qualification` plugin (review
// 2026-09-24 BUILD-O3-2): a gate that names a task that does not exist fails when the task graph is
// built, which is the whole of what `verifyJpaReleaseGateTasks` used to check.
tasks.register('jpaReleaseQualification') {
group = 'verification'
description = 'Runs exactly the blocking JPA release gates declared by config/jpa/release-registry.json.'
dependsOn(new groovy.json.JsonSlurper()
.parse(rootProject.file('config/jpa/release-registry.json'))
.gates.findAll { it.blocking }.collect { it.task })
}