Files
clean-architecture-backend-…/docs/superpowers/specs/2026-09-18-postgresql-idempotency-composition-ownership.md
T

2.2 KiB

PostgreSQL Idempotency Composition Ownership

Goal

Remove the concrete PostgreSQL owner-safe idempotency store construction from app-bootstrap while keeping provider selection, lifecycle policy, and assembly validation application-owned.

Ownership

adapter:outbound:persistence-jpa owns:

  • construction of PostgreSqlOwnerSafeIdempotencyStore;
  • the provider=postgresql condition for that concrete store;
  • reachability only through PersistenceJpaAutoConfiguration, so the JPA master switch remains the structural prerequisite.

app-bootstrap owns:

  • IdempotencyProviderSettings and the provider selection;
  • IdempotencySettings TTL/reaper policy;
  • IdempotencyExecutorV2 lifecycle policy such as processing lease, response codec id, replay/failure retention and policy revision;
  • bean-count/exclusivity validation across JDBC, Redis and PostgreSQL providers;
  • startup dependency validation saying both jdbc and postgresql providers require JPA.

Boundary

The leaf configuration exposes only the application-owned IdempotencyStorePortV2 bean. It does not import app-bootstrap settings or construct the application executor. app-bootstrap consumes the port and no longer imports PostgreSqlOwnerSafeIdempotencyStore.

No new public JPA type is required; the store configuration remains package-private under the existing JPA autoconfigure package.

Compatibility

  • provider property and values are unchanged;
  • provider=postgresql still yields exactly one V2 store and one V2 executor when JPA is enabled;
  • other providers never receive the PostgreSQL store;
  • the existing executor policy constants are unchanged;
  • provider=postgresql with JPA disabled now fails during capability dependency validation rather than reaching a later missing-bean failure.

Verified result

  • app-bootstrap idempotency production imports from persistence concrete packages: 0;
  • persistence-jpa production imports from app-bootstrap: 0;
  • PostgreSQL store configuration is package-private and contributes only IdempotencyStorePortV2;
  • provider=postgresql with JPA disabled is rejected by capability dependency validation;
  • persistence-jpa check and verifyJpaApiSurface: PASS, public API unchanged;
  • app-bootstrap test and architectureTest: PASS;
  • git diff --check: PASS.