fix: prevent P2 from owning Qdrant lifecycle
This commit is contained in:
+23
-1
@@ -222,6 +222,9 @@ class QdrantConfig(BaseModel):
|
||||
type: Literal["qdrant"]
|
||||
base_url: str
|
||||
collection: str = Field(min_length=1)
|
||||
# Internal runtime policy. Registry-rendered configs must not create or alter
|
||||
# the workspace-owned semantic collection; legacy configs retain compatibility.
|
||||
collection_lifecycle: Literal["create_if_missing", "require_existing"] = "create_if_missing"
|
||||
|
||||
|
||||
VectorResourceConfig = Annotated[
|
||||
@@ -547,6 +550,25 @@ def load_config(path: Path) -> Config:
|
||||
_validate_internal_embedding_contract(expanded, path)
|
||||
_validate_internal_vector_contract(expanded, path)
|
||||
translated, used_legacy = translate_legacy_config(expanded)
|
||||
vectors = translated.get("vectors")
|
||||
resource_vector = expanded.get("resources", {}).get("vector") if isinstance(
|
||||
expanded.get("resources"), dict
|
||||
) else None
|
||||
if (
|
||||
isinstance(vectors, dict)
|
||||
and vectors.get("type") == "qdrant"
|
||||
and isinstance(resource_vector, dict)
|
||||
and "collection_lifecycle" in resource_vector
|
||||
):
|
||||
vectors["collection_lifecycle"] = resource_vector["collection_lifecycle"]
|
||||
# runtime_identity is the registry marker. The lifecycle is an internal
|
||||
# runtime policy, never a descriptor-controlled option.
|
||||
if (
|
||||
isinstance(translated.get("runtime_identity"), dict)
|
||||
and isinstance(vectors, dict)
|
||||
and vectors.get("type") == "qdrant"
|
||||
):
|
||||
vectors["collection_lifecycle"] = "require_existing"
|
||||
_populate_legacy_views(translated)
|
||||
try:
|
||||
cfg = Config.model_validate(translated)
|
||||
@@ -662,7 +684,7 @@ def _validate_internal_vector_contract(raw: dict[str, Any], path: Path) -> None:
|
||||
engine = vector.get("engine")
|
||||
base_url = vector.get("base_url")
|
||||
collection = vector.get("collection")
|
||||
allowed = {"engine", "base_url", "collection"}
|
||||
allowed = {"engine", "base_url", "collection", "collection_lifecycle"}
|
||||
unexpected = sorted(set(vector) - allowed)
|
||||
if unexpected:
|
||||
raise ConfigError(
|
||||
|
||||
Reference in New Issue
Block a user