Skip to content

fix(memory): WAL checkpoint after FTS5 entity inserts — fix cross-session SYNAPSE seeds=0#2168

Merged
bug-ops merged 1 commit intomainfrom
fix-2166-synapse-fts5-wal
Mar 23, 2026
Merged

fix(memory): WAL checkpoint after FTS5 entity inserts — fix cross-session SYNAPSE seeds=0#2168
bug-ops merged 1 commit intomainfrom
fix-2166-synapse-fts5-wal

Conversation

@bug-ops
Copy link
Owner

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

Summary

  • FTS5 shadow tables are written via trigger on entity upsert, but SQLite WAL mode buffers these writes. New connections opened after extraction see stale FTS5 indexes — find_entities_fuzzy returns 0 rows, SYNAPSE produces seeds=0 for all cross-session queries.
  • Added PRAGMA wal_checkpoint(PASSIVE) in extract_and_store (primary fix) and at graph store startup (safety net).
  • Added GraphStore::checkpoint_wal() helper method.
  • Added two regression tests: unit test for the helper, integration test through extract_and_store using a file DB (tempfile) to reproduce the cross-session visibility issue.

Test plan

  • cargo nextest run -p zeph-memory --lib — 794 tests pass including new regression tests
  • New test extract_and_store_fts5_cross_session_visibility exercises full production path: session A extracts entities, session B opens new pool, FTS5 query returns results
  • Live session: send entity-containing message, restart, query about the entity — SYNAPSE should report seeds=N (non-zero)

Closes #2166

…s-session SYNAPSE seed lookup

FTS5 shadow tables are updated via trigger on entity upsert, but SQLite WAL
mode buffers these writes. New connections opened after extraction see stale
FTS5 indexes and find_entities_fuzzy returns 0 rows, causing SYNAPSE to
produce seeds=0 for all cross-session queries.

Fix: call PRAGMA wal_checkpoint(PASSIVE) in two places:
- After entity+edge loops in extract_and_store (semantic/graph.rs) — primary fix
- At graph store open after migrations (sqlite/mod.rs) — startup safety net

Also adds GraphStore::checkpoint_wal() helper and two regression tests:
one unit test for the helper, one integration test through extract_and_store
using a file DB (tempfile) to reproduce the cross-session WAL visibility issue.

Closes #2166
@github-actions github-actions bot added documentation Improvements or additions to documentation memory zeph-memory crate (SQLite) rust Rust code changes bug Something isn't working size/M Medium PR (51-200 lines) labels Mar 23, 2026
@bug-ops bug-ops enabled auto-merge (squash) March 23, 2026 16:17
@bug-ops bug-ops merged commit 213eb99 into main Mar 23, 2026
25 checks passed
@bug-ops bug-ops deleted the fix-2166-synapse-fts5-wal branch March 23, 2026 16:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working documentation Improvements or additions to documentation memory zeph-memory crate (SQLite) rust Rust code changes size/M Medium PR (51-200 lines)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

fix(memory): SYNAPSE seeds=0 immediately after entity extraction (FTS5+WAL visibility)

1 participant