// The search service of a deployment whose vectors backend has no vector store (no Qdrant linked, // no explicit pgvector choice). It is not a fake: it is the honest answer of such a deployment. // Readiness says `unavailable` with the reason a person can act on; an index job fails its row with // the stable `vector_store_unavailable` code instead of retrying forever; a search or a removal is // refused with a typed problem. Nothing is written anywhere, so choosing a store later (enabling // document AI links a managed Qdrant) starts from a clean state. import { AppError } from "@conusai-kit/core" import type { KnowledgeSearchService } from "../core/ports.js" function unavailable(reason: string): AppError { return new AppError({ type: "/problems/runtime_unavailable", title: "The knowledge search service is unavailable", status: 503, code: "runtime_unavailable", detail: reason, }) } export function unavailableKnowledgeSearch(reason: string): KnowledgeSearchService { return { async readiness() { return { state: "unavailable", reasons: [reason] } }, async index() { // A permanent failure: the row records why, and a retry of the same job cannot succeed until // the deployment binds a store (a new deployment, which re-runs the job). throw Object.assign(new Error(reason), { permanent: "vector_store_unavailable" }) }, async search() { throw unavailable(reason) }, async remove() { throw unavailable(reason) }, } }