267a644f4f
Prerequisite for RFC 001 (plugin spec, #743). Removes every direct `import chromadb` outside the ChromaDB backend itself so the core modules depend only on the backend abstraction layer. Extends ChromaBackend with make_client, get_or_create_collection, delete_collection, create_collection, and backend_version. Adds update() to the BaseCollection contract. Non-backend callers (mcp_server, dedup, repair, migrate, cli) now go through the abstraction; tests patch ChromaBackend instead of chromadb. With this landed, the RFC 001 spec can be enforced and PalaceStore (#643) can ship as a plugin without touching core modules.
50 lines
1.2 KiB
Python
50 lines
1.2 KiB
Python
"""Abstract collection interface for MemPalace storage backends."""
|
|
|
|
from abc import ABC, abstractmethod
|
|
from typing import Any, Dict, List, Optional
|
|
|
|
|
|
class BaseCollection(ABC):
|
|
"""Smallest collection contract the rest of MemPalace relies on."""
|
|
|
|
@abstractmethod
|
|
def add(
|
|
self,
|
|
*,
|
|
documents: List[str],
|
|
ids: List[str],
|
|
metadatas: Optional[List[Dict[str, Any]]] = None,
|
|
) -> None:
|
|
raise NotImplementedError
|
|
|
|
@abstractmethod
|
|
def upsert(
|
|
self,
|
|
*,
|
|
documents: List[str],
|
|
ids: List[str],
|
|
metadatas: Optional[List[Dict[str, Any]]] = None,
|
|
) -> None:
|
|
raise NotImplementedError
|
|
|
|
@abstractmethod
|
|
def update(self, **kwargs: Any) -> None:
|
|
"""Update existing records. Must raise if any ID is missing."""
|
|
raise NotImplementedError
|
|
|
|
@abstractmethod
|
|
def query(self, **kwargs: Any) -> Dict[str, Any]:
|
|
raise NotImplementedError
|
|
|
|
@abstractmethod
|
|
def get(self, **kwargs: Any) -> Dict[str, Any]:
|
|
raise NotImplementedError
|
|
|
|
@abstractmethod
|
|
def delete(self, **kwargs: Any) -> None:
|
|
raise NotImplementedError
|
|
|
|
@abstractmethod
|
|
def count(self) -> int:
|
|
raise NotImplementedError
|