fix(db): restore postgres backend compile and sqlite/postgres parity#4966
Merged
Conversation
- memory: SqliteStore::upsert_agent_session bound `turns` as a bare `u32`, which only implements `sqlx::Type<Sqlite>` (Postgres has no unsigned integers); this pinned the query to the SQLite driver and broke the Postgres backend with E0271 on any build activating the `postgres` feature. Bind `turns.cast_signed()` (i32, matching the INTEGER column) and decode the read tuple slot as i32. The Postgres backend now compiles end-to-end. (#4964) - db,memory: data-layer consumer crates that depend on zeph-memory/zeph-db without selecting a backend (zeph-sanitizer, zeph-acp, zeph-bench, zeph-tui, and zeph-skills via its optional qdrant dep) could not be built or doc-checked in isolation. Give each the standard default=["sqlite"]/sqlite/postgres feature trio forwarding to zeph-memory, matching the existing zeph-mcp/zeph-index pattern, and gate the backend-only imports in migrate.rs so a no-backend build surfaces only the clear compile_error!. (#4956) - db: the Postgres migration set was missing fact_access_log plus the messages.memory_tier/qdrant_promoted columns and the implicit_conflict_candidates table, all present only in SQLite, so Postgres ran a divergent schema. Add forward-only Postgres migrations 101_five_signal_retrieval and 102_implicit_conflict_candidates (BIGINT to match the i64 accessors) and a SQLite parity placeholder 101_trajectory_memory_cascade. Add a migration_parity integration test asserting file-count, logical-name and defined-table equivalence between dialects (system-invariant 001 §13). (#4957)
bug-ops
enabled auto-merge (squash)
June 6, 2026 19:26
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Restores the PostgreSQL backend and the SQLite/PostgreSQL schema parity for the data layer. Three closely related data-layer correctness defects, fixed together:
zeph-memory agent_sessions: SqliteStore fails to compile when postgres feature is also enabled (--all-features) #4964 — PostgreSQL backend did not compile.
SqliteStore::upsert_agent_sessionbound theturnscount as a bareu32, which only implementssqlx::Type<Sqlite>(PostgreSQL has no unsigned integer types). This pinned the query to the SQLite driver and broke the PostgreSQL backend withE0271("expectedSqlite, foundPostgres") on any build that activates thepostgresfeature.turnsis now bound viacast_signed()(i32, matching theINTEGERcolumn) and the read tuple decodes it asi32so PostgreSQL does not reject theINTEGER/INT4 column as ani64mismatch. A full-workspacecargo check --no-default-features --features postgresnow compiles cleanly — this was the only PostgreSQL-breaking bind site in the workspace.zeph-db pool.rs: connect() body empty without sqlite/postgres features causes compile error #4956 — consumer crates could not be built/doc-checked in isolation. Crates depending on
zeph-memory/zeph-dbwithout selecting a backend (zeph-sanitizer,zeph-acp,zeph-bench,zeph-tui, andzeph-skillsvia its optionalqdrantdependency) tripped thezeph-dbcompile_error!plus a follow-on cascade, because thedefault-features = falseworkspace deps stripped the default backend. Each crate now carries the standarddefault = ["sqlite"]/sqlite/postgresfeature trio forwarding tozeph-memory, matching the establishedzeph-mcp/zeph-indexpattern. The backend-only imports inzeph-db/src/migrate.rsare gated behindany(feature = "sqlite", feature = "postgres")so a genuine no-backend build surfaces only the clearcompile_error!.zeph-db sqlite/postgres migration sequences diverge (file count + content parity) #4957 — SQLite/PostgreSQL migration sequences diverged (P2, system-invariant 001 §13). PostgreSQL was missing the
fact_access_logtable andmessages.memory_tier/messages.qdrant_promotedcolumns (five-signal SYNAPSE retrieval, feat(memory): extend SYNAPSE to five-signal retrieval + async consolidation daemon #4374) and theimplicit_conflict_candidatestable (graph conflict detection) — present only in SQLite, so PostgreSQL deployments ran a divergent schema. Added forward-only PostgreSQL migrations101_five_signal_retrieval.sqland102_implicit_conflict_candidates.sql(integer columns sizedBIGINTto match thei64Rust accessors), plus a SQLite parity placeholder101_trajectory_memory_cascade.sql(the cascade is inline on SQLite but needs a dedicated drop-and-re-add migration on PostgreSQL) to keep file counts equal (101 = 101). A newmigration_parityintegration test fails the build if the dialects ever diverge in file count, logical migration name, or defined table set.Verification
cargo +nightly fmt --check— cleancargo clippy --workspace --all-targets -- -D warnings— cleancargo nextest run --workspace --lib --bins— 10555 passed, 0 failed, 21 skippedcargo test -p zeph-db --test migration_parity— 3 passed (file-count / logical-name / table-set parity)cargo nextest run -p zeph-memory -E 'test(agent_session)'— 8 passedcargo check --no-default-features --features postgres— clean (PostgreSQL backend compiles end-to-end)cargo check -p {zeph-sanitizer,zeph-acp,zeph-bench,zeph-tui} --liband-p zeph-skills --lib --features qdrant— all clean (previously failed)RUSTFLAGS="-D warnings" cargo check --workspace --all-targets --features desktop,ide,server,chat,pdf,scheduler --locked— cleanRUSTDOCFLAGS="--deny rustdoc::broken_intra_doc_links" cargo doc --no-deps --all-features -p zeph-db -p zeph-memory— clean (one pre-existing private-intra-doc warning, not introduced here)cargo test --doc -p zeph-db -p zeph-memory— 39 passedNotes / follow-ups
Stringto theagent_sessionsTIMESTAMPTZcolumns) is a separate, runtime-only concern not exercised by any current CI job; tracked as a follow-up.compile_error!"). The code only errors on no backend. The invariant text should be reconciled with the implemented behavior in a follow-up.Closes #4964
Closes #4956
Closes #4957