Skip to content

fix: vector index + SQLite dual-write consistency #182

Closed

Description

@ajianaz

Problem

In operations.rs, the remember() flow is:

  1. Write to vector index (usearch)
  2. Write to SQLite
  3. If SQLite fails → rollback vector index

If the process crashes between step 1 and 2, the vector index has an entry that does not exist in SQLite. This causes:

  • Stale vector results pointing to non-existent memories
  • Silent data drift over time

Similar risk exists for forget() — vector deleted but SQLite might not commit.

Current Mitigation

  • index.save() is called after each insert/delete
  • Rollback exists on SQLite failure

Gaps

  • No crash recovery between steps 1→2
  • No periodic integrity check to detect orphaned vectors
  • No uteke doctor --fix to reconcile

Proposed Fix

Short-term (v0.0.9)

  • Add uteke doctor command that compares vector index keys vs SQLite IDs
  • Report orphaned vectors and missing embeddings
  • --fix flag to auto-reconcile

Long-term (v0.1.0)

  • Write-ahead log: SQLite first (in transaction), then vector index
  • Periodic background reconciliation (server mode)

Code References

File Lines Issue
crates/uteke-core/src/operations.rs 50-80 remember() dual-write
crates/uteke-core/src/operations.rs 100-130 forget() dual-write

Activity

  1. ajianaz commented on Jun 7, 2026

    @ajianaz
    CollaboratorAuthor

    Fixed in v0.0.10 — SQLite-first dual-write pattern implemented. See CHANGELOG.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    scope:core

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions