5.8 KiB
5.8 KiB
id, title, status, wave, depends_on, plan, requirements, acceptance_criteria, system_design
| id | title | status | wave | depends_on | plan | requirements | acceptance_criteria | system_design | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 01-postgres-coverage | Prove PostgreSQL source and cleanup behavior | done | 1 | plan.md |
|
|
|
Task 01: Prove PostgreSQL source and cleanup behavior
Summary
Add actual PostgreSQL tests for the replacement and run them on a disposable database. Resolve demonstrated dialect defects while preserving the approved source and receipt contract.
In scope
- Own repository PostgreSQL test coverage and any resulting source, receipt, or cleanup fixes.
- Reuse
testutil.PostgresDSNFromEnvandtestutil.OpenIsolatedPostgres; never target user data. - Add named tests
TestConversationPostgresSource,TestConversationPostgresReceipts, andTestConversationPostgresCleanupinconversation_source_postgres_test.go(new). - Cover fresh and legacy schemas, direct SQL changes, inserts/updates/deletes, cross-session moves, turn completion, session/task cascades, atomic rollback, and revision-row bounds.
- Exercise real concurrent connections, deterministic revision locks, and complete receipt intervals.
- Cover repeatable-read pages, keyset boundaries, task/author filters, and expected-revision mismatch.
- Build legacy PostgreSQL fixtures from the comparison base's DDL, not translated SQLite SQL.
- Verify exact old tables, triggers, and functions disappear without unrelated object removal. Inject cleanup failure, prove rollback and successful retry, and preserve source bytes and indexes.
- Run existing previous-stable upgrade conformance. Record which dialect each subtest actually uses.
Out of scope
SQLite performance reruns, production upgrades, automatic compaction, and new durable storage.
Acceptance
- All three named PostgreSQL tests run without skipping and cover the listed matrix.
- Fresh, repeated, interrupted, and legacy upgrades preserve source data and remove legacy copies.
- Concurrent writes and consistent reads meet the existing revision/receipt contract; evidence includes PostgreSQL version, connection concurrency, counts, command output, and tested commit without credentials.
Verification
Run from the repository root after adding the named tests. Missing tests or skips fail this gate. Provision a disposable PostgreSQL service through available local tooling, or report the missing DSN.
: "${KANDEV_TEST_POSTGRES_DSN:?Set a disposable PostgreSQL test DSN}"
(cd apps/backend && go test -race ./internal/task/repository/sqlite -run '^TestConversationPostgres' -count=1 -v)
(cd apps/backend && go test -race ./internal/task/repository/sqlite -run '^TestConversation' -count=1)
(cd apps/backend && go test -race ./internal/persistence/storeconformance -run 'PreviousStableUpgrade|UpgradeFixtureManifest' -count=1 -v)
(cd apps/backend && go run ./cmd/sqlguard ./internal)
Files likely touched
apps/backend/internal/task/repository/sqlite/conversation_source_postgres_test.go(new)apps/backend/internal/task/repository/sqlite/conversation_source.goapps/backend/internal/task/repository/sqlite/conversation_receipts.goapps/backend/internal/task/repository/sqlite/conversation_journal_cleanup.goapps/backend/internal/persistence/storeconformance/upgrade_test.go- Reuse helpers from
workspace_orphan_postgres_test.goandinternal/testutil.
Risks
An existing PostgreSQL initialization failure can block the matrix. Isolate it against the base; fix narrow prerequisites with regression evidence, and document any larger required design change.
Dependencies
None. Run sequentially in the recommended order.
Parallelism
sequential
Inputs
- Host requirements and source reconciliation design.
- Architecture decision.
- Implementation commit
c0a048bc128f7ef9a1051caf95ed442627faf9df; comparison base88c6c0fe0a6ae5d25332070d603b99f7d9241645. - Original package and its recorded evidence.
Results
- Added
conversation_source_postgres_test.gowith the three required named tests. They cover source-page filters and keyset paging, repeatable-read consistency, direct source updates/deletes and session moves, turn completion, cascades, transaction rollback, revision bounds, transaction-bound receipts, concurrent writers, incomplete intervals, cleanup rollback/retry, source sentinels, index preservation, and unrelated PostgreSQL objects. - On disposable PostgreSQL 16.15,
KANDEV_TEST_POSTGRES_DSN=<redacted> go test -race ./internal/task/repository/sqlite -run '^TestConversationPostgres' -count=1 -vpassed all 3/3 named tests in 5.721s. The receipt test used two repository connections for concurrent writes. go test -race ./internal/task/repository/sqlite -run '^TestConversation' -count=1passed.go test -race ./internal/persistence/storeconformance -run 'PreviousStableUpgrade|UpgradeFixtureManifest' -count=1 -vpassed with the SQLite and PostgreSQL dynamic conformance routes.go run ./cmd/sqlguard ./internalpassed.- No PostgreSQL test was skipped. The database was disposable and was removed after verification. No production source or cleanup fix was required.
- Tested code revision:
213492517315abb38697b765e91e6fe0ea5388c7.