Skip to content

feat(postgres): fix call sites and add tests for postgres build#2384

Merged
bug-ops merged 1 commit intomainfrom
feat-postgres-fix-sqlitestore
Mar 29, 2026
Merged

feat(postgres): fix call sites and add tests for postgres build#2384
bug-ops merged 1 commit intomainfrom
feat-postgres-fix-sqlitestore

Conversation

@bug-ops
Copy link
Copy Markdown
Owner

@bug-ops bug-ops commented Mar 29, 2026

Closes #2374
Closes #2377
Closes #2378

Summary

  • Introduce resolve_db_url(config) helper in src/db_url.rs that returns database_url when set and non-empty, falling back to sqlite_path. Eliminates the duplicated inline logic that was in handle_db_migrate.
  • Replace hardcoded config.memory.sqlite_path across 6 files (skill.rs, memory.rs, sessions.rs, runner.rs, acp.rs, scheduler.rs) so all call sites work correctly under both --features sqlite and --features postgres.
  • Add cfg-gated unit tests for is_postgres_url predicate in src/commands/db.rs (test(db): add unit tests for db migrate URL validation branches #2377).
  • Add build_config unit tests for the postgres backend path in src/init.rs (test(init): add build_config test for postgres backend path #2378).

Pre-existing postgres check failures

cargo check --features postgres,... still fails with 27 E0271 errors in zeph-memory (Pool vs Sqlite type mismatches from Phase 2, PR #2372). Zero new errors are introduced by this PR — verified by checking that all failing file paths are in crates/zeph-memory/.

Test plan

  • cargo +nightly fmt --check — pass
  • cargo clippy --workspace --features full -- -D warnings — pass
  • cargo nextest run --workspace --features full --lib --bins — 7195 passed, 22 skipped
  • cargo check --features postgres,... 2>&1 | grep "^error\[" | grep -v "zeph-memory" — zero output (no new errors)

@github-actions github-actions bot added enhancement New feature or request size/M Medium PR (51-200 lines) labels Mar 29, 2026
@bug-ops bug-ops enabled auto-merge (squash) March 29, 2026 01:46
#2377, #2378)

Introduce `resolve_db_url(config)` helper that returns `database_url` when
set and non-empty, otherwise falls back to `sqlite_path`. This mirrors the
logic already present in `handle_db_migrate` (which is now also updated to
use the helper instead of inlining the same logic).

Replace hardcoded `config.memory.sqlite_path` references across six files
so all call sites resolve the correct URL under both sqlite and postgres
feature builds:

- src/commands/skill.rs (single extraction point, 8 indirect uses)
- src/commands/memory.rs
- src/commands/sessions.rs
- src/runner.rs
- src/acp.rs (3 sites)
- src/scheduler.rs (2 sites)

The `cargo check` postgres target still fails in `zeph-memory` due to
pre-existing Phase 2 debt (Pool<Postgres> vs Sqlite type mismatches) — no
new errors are introduced by this PR.

Tests added:
- src/commands/db.rs: cfg-gated unit tests for `is_postgres_url` predicate
  under both postgres and sqlite features (#2377)
- src/init.rs: unit tests for `build_config` postgres path — verifies
  `database_url` propagates and `sqlite_path` defaults correctly (#2378)
@bug-ops bug-ops force-pushed the feat-postgres-fix-sqlitestore branch from 7347269 to 60af647 Compare March 29, 2026 01:52
@bug-ops bug-ops merged commit a819299 into main Mar 29, 2026
27 checks passed
@bug-ops bug-ops deleted the feat-postgres-fix-sqlitestore branch March 29, 2026 01:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request size/M Medium PR (51-200 lines)

Projects

None yet

1 participant