Add PostgreSQL foundation, UUIDv7 IDs and coverage policy #39
No reviewers
Labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
primatekuntech/rag-rust!39
Loading…
Reference in a new issue
No description provided.
Delete branch "feat/8-postgres-foundation"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Summary
Adds canonical conversation/message persistence for #8 with separate migration and runtime identities.
Migration 0001 stays unchanged; 0002 adds lifecycle/ordering invariants and RLS. Runtime startup rejects missing/tampered migrations, table ownership, role memberships and excess privileges. Readiness probes are bounded; shutdown drains and closes storage. CI now requires real PostgreSQL 17 contracts.
Repository owner selectors are query scope, not identity proofs. Trusted identity/ABAC and chat routes remain subsequent issues. Initial appends require the parent's exact marking/policy version.
User-requested SRS FR-DATA-006 standardizes application-generated IDs on UUIDv7 throughout. PostgreSQL 17 stores UUIDv7; Rust generates it. Forward migration 0003 removes UUIDv4 defaults and rejects new/changed primary IDs of other versions/variants. Existing IDs/references remain intact; audit correlation/outbox aggregate columns use native UUID.
Closes #8.
Evidence
After: all regressions pass; 14 real PostgreSQL tests cover migrations/checksums, concurrent sequences, cancellation/rollback, owner/org isolation, indexed bounded history, non-bypass RLS, role restrictions, pool exhaustion and dependency recovery.
cargo fmt --all -- --check;cargo clippy --workspace --all-targets --locked -- -D warnings;cargo test --workspace --locked: pass (20 behavioral tests and 6 compile-fail doctests; service tests explicitly run separately).bash scripts/test-postgres.sh --local: 14 passed, zero skipped.npm run typecheck && npm run build: pass. Compose validation and normalized actionlint pass.e12e70a78a209359f0da985336f26d4b6930b478, including all 14 required PostgreSQL contracts: branch run 17, PR run 18.Merge Danger
Door: one-way
Migrations 0002/0003 change database invariants, grants, identifier defaults and row visibility; audit existing data/grants and back up before applying. Legacy rows with incomplete markings are quarantined. Migration 0003 fails transactionally on legacy non-UUID audit correlation/outbox aggregate text; resolve those references explicitly before retrying. Existing primary IDs are never regenerated. API now requires a separately migrated database and restricted runtime credentials. Bootstrap must be applied explicitly to existing development volumes; see
docs/operations/postgres.md.Blast Radius: persistence
CI provisions PostgreSQL 17 from the signed official PGDG repository inside each isolated Debian job container, tests over loopback and always stops the cluster. Pinned runner source confirmed missing service-port context and ignored workflow host mappings; shared runner settings and host ports are unchanged. UUIDv7 regression first returned version 4 instead of 7; it now passes, along with database guards and legacy migration/repair tests.
SRS NFR-MAINT-007 now requires at least 80% line coverage, measured separately for Rust and frontend, with explicit reasons/risk/remediation for shortfalls. Rust application-only coverage is 87.29% (632/724 lines) from unit/contracts plus all 14 instrumented PostgreSQL tests; the 80% threshold command passed. An existing inline unit test was moved into its own excluded test module; API/migration entry points remain in the denominator.
Frontend coverage shortfall: unmeasured because the scaffold currently has typecheck/build only, with no behavior-test/coverage instrumentation; UI behavior is not covered by those checks. P0 #40 adds meaningful frontend tests and separate backend/frontend coverage enforcement in CI. The current workflow does not yet enforce coverage. Recorded baseline, scope and commands.
WIP: Add PostgreSQL foundation and scoped conversation repositoriesto WIP: Add PostgreSQL foundation, UUIDv7 IDs and coverage policyWIP: Add PostgreSQL foundation, UUIDv7 IDs and coverage policyto Add PostgreSQL foundation, UUIDv7 IDs and coverage policy