"""Vector store interface and value objects.

Collections are created lazily on first upsert (dimension inferred from the
vectors), so callers never need to know the embedding dimension up front.
"""

from __future__ import annotations

from dataclasses import dataclass, field
from typing import Protocol, runtime_checkable


@dataclass
class VectorRecord:
    id: str
    vector: list[float]
    payload: dict = field(default_factory=dict)


@dataclass
class SearchHit:
    id: str
    score: float
    payload: dict


@runtime_checkable
class VectorStore(Protocol):
    def upsert(self, collection: str, records: list[VectorRecord]) -> None: ...

    def search(self, collection: str, vector: list[float], top_k: int = 5) -> list[SearchHit]: ...

    def delete_by_document(self, collection: str, document_id: str) -> int: ...

    def delete_collection(self, collection: str) -> None: ...
