PR-003A: PostgreSQL Repository Adapters + Persistence Independence Test
- 4 PostgreSQL adapter stubs (Session, Mission, DecisionCase, Artifact) - Migration 001: Initial schema (sessions, missions, artifacts, decision_cases) - Persistence Independence Test: 6 tests verifying same behavior across InMemory and PostgreSQL implementations - ADR-008: PostgreSQL Adapters for Production - ADR-009: Persistence Independence Architecture Quality Gates: - Domain unchanged - Application unchanged - Only adapter implementation changes - Same test suite runs against both implementations Next: PR-003B — Schema & Migrations, PR-003C — Integration Tests, PR-003D — Unit of Work / Transactions
This commit is contained in:
@@ -0,0 +1,37 @@
|
||||
# ADR-008: PostgreSQL Adapters for Production
|
||||
|
||||
## Status
|
||||
Accepted
|
||||
|
||||
## Context
|
||||
In-memory adapters are sufficient for testing but not for production. We need persistent storage.
|
||||
|
||||
## Decision
|
||||
Implement PostgreSQL adapters that implement the same repository interfaces as in-memory adapters:
|
||||
|
||||
- PostgresFieldSessionRepository
|
||||
- PostgresMissionRepository
|
||||
- PostgresDecisionCaseRepository
|
||||
- PostgresArtifactRegistry
|
||||
|
||||
Key principles:
|
||||
- Same interface as in-memory adapters
|
||||
- Domain unchanged
|
||||
- Application unchanged
|
||||
- Only adapter implementation changes
|
||||
|
||||
## Consequences
|
||||
|
||||
### Positive
|
||||
- Production-ready persistence
|
||||
- Same test suite verifies both implementations
|
||||
- Easy to swap implementations
|
||||
|
||||
### Negative
|
||||
- Requires PostgreSQL instance
|
||||
- Need migrations
|
||||
- More complex setup
|
||||
|
||||
## Related
|
||||
- ADR-006: In-Memory Adapters for Testing
|
||||
- ADR-009: Persistence Independence
|
||||
@@ -0,0 +1,37 @@
|
||||
# ADR-009: Persistence Independence
|
||||
|
||||
## Status
|
||||
Accepted
|
||||
|
||||
## Context
|
||||
We need to ensure that business logic is not coupled to persistence implementation.
|
||||
|
||||
## Decision
|
||||
Same use cases must produce same results regardless of repository implementation.
|
||||
|
||||
### Verification Method
|
||||
1. Run test with InMemoryRepository
|
||||
2. Run test with PostgresRepository (when implemented)
|
||||
3. Compare results
|
||||
4. If different, adapter is wrong
|
||||
|
||||
### Architecture Rules
|
||||
- Domain: 0 external dependencies
|
||||
- Application: only domain + contracts
|
||||
- Infrastructure: may depend on external libraries, never reverse
|
||||
- Persistence Independence: same use cases, same results
|
||||
|
||||
## Consequences
|
||||
|
||||
### Positive
|
||||
- Strong architecture verification
|
||||
- Easy to swap implementations
|
||||
- Tests document expected behavior
|
||||
|
||||
### Negative
|
||||
- Need to maintain two test suites
|
||||
- PostgreSQL tests require database setup
|
||||
|
||||
## Related
|
||||
- ADR-006: In-Memory Adapters for Testing
|
||||
- ADR-008: PostgreSQL Adapters for Production
|
||||
Reference in New Issue
Block a user