Skip to content

[Database] Implement FAISS vector store wrapper + hybrid metadata retrieval #23

@saviornt

Description

@saviornt

Description

Create a clean, persistent FAISS vector store abstraction that links vectors to SQLite metadata (incidents / model versions) for efficient RAG-style retrieval in the Assistant (and limited edge use).

Type

  • Task

Focus Area (pick one)

  • Shared Utils & Models

Priority

  • Medium

Acceptance Criteria

  • File: shared/src/database/faiss.py — low-level wrapper
  • File: shared/src/database/faiss_service.py — higher-level service
  • Supports:
    • add_vectors(vectors: np.ndarray, metadata: list[dict]) → list[int]
    • search(query_vector: np.ndarray, k: int = 5) → list[dict] (with score + metadata)
  • Default index: IndexFlatL2 (MVP); future path for IndexIVFFlat
  • Persistent save/load via faiss.write_index / faiss.read_index
  • Index path from Pydantic Settings
  • Metadata rows inserted into faiss_vectors_metadata table (vector_id FK)
  • Async-friendly (run FAISS sync calls in thread if needed)
  • Health check: index size, dimension consistency
  • Unit tests: mock vectors, search recall, persistence round-trip
  • Google-style docstrings + full type hints

Blocker / Dependencies

  • [Database] Define Pydantic v2 models and initial relational schema
  • [Database] Implement robust async SQLite session factory + connection pooling

Notes / Links

  • Related files: shared/src/database/schemas.py, shared/src/core/settings.py
  • Reference: FAISS wiki + Python bindings documentation

Metadata

Metadata

Assignees

Labels

databaseneeds-triageNew issue that hasn't been reviewed/prioritized yettaskGeneral work item (implementation, setup, cleanup) – most common label

Projects

Status

Manual QA Testing

Relationships

None yet

Development

No branches or pull requests

Issue actions