Opt-in exact vector admission for MongoDB's Python search mode.
Atlas requires a verified scope_path filter index before its ANN limit; this
path refuses Atlas until that deployment prerequisite can be established.
search_with_admission
async
search_with_admission(backend: Any, scope: TenantScope, query_embedding: list[float], top_k: int, allowed_scope_paths: tuple[str, ...], similarity: Any) -> list[dict[str, Any]]
Select exact owners before cosine scoring and top_k.
Source code in src/symfonic/memory/backends/mongodb_vector_admission.py
| async def search_with_admission(
backend: Any,
scope: TenantScope,
query_embedding: list[float],
top_k: int,
allowed_scope_paths: tuple[str, ...],
similarity: Any,
) -> list[dict[str, Any]]:
"""Select exact owners before cosine scoring and top_k."""
if backend._vector_search_mode == "atlas":
raise NotImplementedError(
"Atlas read admission requires a verified scope_path filter index"
)
results: list[dict[str, Any]] = []
async for doc in backend._col.find({"tenant_id": scope.tenant_id}):
if stored_scope_path(doc, scope.tenant_id) not in allowed_scope_paths:
continue
results.append({
"id": doc["_id"],
"score": similarity(query_embedding, doc["embedding"]),
"metadata": doc.get("metadata", {}),
"document": doc.get("document", ""),
})
results.sort(key=lambda row: row["score"], reverse=True)
return results[:top_k]
|