Skip to content

feat: add context manager support to EmbeddingStore #260

@VaibhavDangaich

Description

@VaibhavDangaich

Description:
Problem

EmbeddingStore in code_review_graph/embeddings.py:357-388 opens a SQLite
connection in init but does not implement enter/exit. If an
exception occurs during usage before .close() is called, the connection leaks.

store = EmbeddingStore(db_path)
store.embed_nodes(nodes) # if this raises, connection is never closed
store.close()

Expected Behavior

Add context manager support, consistent with GraphStore which already
implements this pattern:

class EmbeddingStore:
...
def enter(self):
return self

  def __exit__(self, *exc):                                                 
      self.close()

This enables safe usage:
with EmbeddingStore(db_path) as store:
store.embed_nodes(nodes)

Impact

Connection leaks under error conditions, especially relevant for long-running
processes like watch mode or MCP server.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions