feat: edit qdrant workspace collections
This commit is contained in:
@@ -59,6 +59,10 @@ async function ensureWorkspaceSelectionPolicy(): Promise<WorkspacePreference> {
|
||||
throw new WorkspaceSelectionError(WORKSPACE_SUMMARY_ERROR);
|
||||
}
|
||||
if (workspacePreferences.load().workspaceId !== workspaceId) continue;
|
||||
if (workspace?.revision.state === "migration_required") {
|
||||
workspacePolicyGate.rejectSummary(workspaceId);
|
||||
throw new WorkspaceSelectionError(WORKSPACE_POLICY_ERROR);
|
||||
}
|
||||
if (!workspace?.revision) {
|
||||
workspacePolicyGate.allowLegacy(workspaceId);
|
||||
return workspacePreferences.load();
|
||||
|
||||
@@ -4,11 +4,11 @@ import { server } from "../test/msw";
|
||||
import { asWorkspaceConflict, importWorkspace, publishWorkspace, type CanonicalWorkspace } from "./workspaces";
|
||||
|
||||
const workspace: CanonicalWorkspace = {
|
||||
workspace: { schema_version: 2, id: "psd-clinical", name: "PSD Clinical", language: "en" },
|
||||
workspace: { schema_version: 3, id: "psd-clinical", name: "PSD Clinical", language: "en" },
|
||||
dwh: { engine: "postgres", database: "clinical", schema: "datawarehouse", supported_transports: ["postgres_direct"] },
|
||||
semantic_index: {
|
||||
vector_store: { engine: "pgvector", database: "vectors", schema: "public", collection: "clinical", dimensions: 768, distance: "cosine", supported_transports: ["pgvector_direct"] },
|
||||
embedding: { provider: "ollama_compatible", model: "nomic-embed-text", dimensions: 768 },
|
||||
vector_store: { engine: "qdrant", collection: "clinical", dimensions: 1024, distance: "cosine" },
|
||||
embedding: { provider: "ollama_internal", model: "qwen3-embedding:0.6b", dimensions: 1024 },
|
||||
},
|
||||
llm_policy: { allowed: ["zai/glm-5.2"] },
|
||||
};
|
||||
@@ -42,33 +42,18 @@ test("rejects a conflict payload that attempts to surface a secret field", async
|
||||
const diagnosticConflictFields = [
|
||||
"diagnostics.dwh_rest.method", "diagnostics.dwh_rest.path", "diagnostics.dwh_rest.auth",
|
||||
"diagnostics.dwh_rest.response.database", "diagnostics.dwh_rest.response.schema",
|
||||
"diagnostics.vector_rest.metadata.method", "diagnostics.vector_rest.metadata.path", "diagnostics.vector_rest.metadata.auth",
|
||||
"diagnostics.vector_rest.metadata.response.collection", "diagnostics.vector_rest.metadata.response.dimensions",
|
||||
"diagnostics.vector_rest.metadata.response.distance", "diagnostics.vector_rest.reversible_probe.method",
|
||||
"diagnostics.vector_rest.reversible_probe.path", "diagnostics.vector_rest.reversible_probe.auth",
|
||||
"diagnostics.vector_rest.reversible_probe.response.operation", "diagnostics.embedding.method", "diagnostics.embedding.path",
|
||||
"diagnostics.embedding.auth", "diagnostics.embedding.response.model", "diagnostics.embedding.response.dimensions",
|
||||
] as const;
|
||||
|
||||
const optionalDiagnosticsConflictFields = [
|
||||
"diagnostics",
|
||||
"diagnostics.dwh_rest",
|
||||
"diagnostics.vector_rest",
|
||||
"diagnostics.vector_rest.reversible_probe",
|
||||
"diagnostics.embedding",
|
||||
] as const;
|
||||
|
||||
const diagnosticsWorkspace: CanonicalWorkspace = {
|
||||
...workspace,
|
||||
dwh: { ...workspace.dwh, supported_transports: ["postgres_direct", "rest_api"] },
|
||||
semantic_index: { ...workspace.semantic_index, vector_store: { ...workspace.semantic_index.vector_store, supported_transports: ["pgvector_direct", "rest_api"] } },
|
||||
diagnostics: {
|
||||
dwh_rest: { method: "POST", path: "/rpc/ping", auth: "bearer", response: { database: "database", schema: "schema" } },
|
||||
vector_rest: {
|
||||
metadata: { method: "GET", path: "/vector/metadata", auth: "bearer", response: { collection: "collection", dimensions: "dimensions", distance: "distance" } },
|
||||
reversible_probe: { method: "POST", path: "/vector/probe", auth: "x-api-key", response: { operation: "operation" } },
|
||||
},
|
||||
embedding: { method: "GET", path: "/models", auth: "none", response: { model: "model", dimensions: "dimensions" } },
|
||||
},
|
||||
};
|
||||
|
||||
@@ -89,14 +74,8 @@ test.each(diagnosticConflictFields)("accepts canonical diagnostic conflict leaf
|
||||
const diagnosticsWorkspace: CanonicalWorkspace = {
|
||||
...workspace,
|
||||
dwh: { ...workspace.dwh, supported_transports: ["postgres_direct", "rest_api"] },
|
||||
semantic_index: { ...workspace.semantic_index, vector_store: { ...workspace.semantic_index.vector_store, supported_transports: ["pgvector_direct", "rest_api"] } },
|
||||
diagnostics: {
|
||||
dwh_rest: { method: "POST", path: "/rpc/ping", auth: "bearer", response: { database: "database", schema: "schema" } },
|
||||
vector_rest: {
|
||||
metadata: { method: "GET", path: "/vector/metadata", auth: "bearer", response: { collection: "collection", dimensions: "dimensions", distance: "distance" } },
|
||||
reversible_probe: { method: "POST", path: "/vector/probe", auth: "x-api-key", response: { operation: "operation" } },
|
||||
},
|
||||
embedding: { method: "GET", path: "/models", auth: "none", response: { model: "model", dimensions: "dimensions" } },
|
||||
},
|
||||
};
|
||||
server.use(http.post("/api/workspaces/publish", () => HttpResponse.json({
|
||||
@@ -111,3 +90,20 @@ test.each(diagnosticConflictFields)("accepts canonical diagnostic conflict leaf
|
||||
|
||||
expect(asWorkspaceConflict(error)).toMatchObject({ actual: { commit: "c".repeat(40), blob: "d".repeat(40) }, fields: [field] });
|
||||
});
|
||||
|
||||
test("rejects a conflict payload that attempts to surface removed vector transport and credential branches", async () => {
|
||||
server.use(http.post("/api/workspaces/publish", () => HttpResponse.json({
|
||||
code: "workspace_conflict",
|
||||
message: "Workspace changed in the registry.",
|
||||
fields: ["diagnostics.vector_rest.reversible_probe.auth"],
|
||||
expected: { commit: "a".repeat(40), blob: "b".repeat(40) },
|
||||
actual: { commit: "c".repeat(40), blob: "d".repeat(40) },
|
||||
base: workspace,
|
||||
local: workspace,
|
||||
remote: workspace,
|
||||
}, { status: 409 })));
|
||||
|
||||
const error = await publishWorkspace({ action: "update", workspace, baseCommit: "a".repeat(40), baseBlob: "b".repeat(40) }).catch((cause: unknown) => cause);
|
||||
|
||||
expect(asWorkspaceConflict(error)).toBeUndefined();
|
||||
});
|
||||
|
||||
@@ -15,16 +15,11 @@ export interface RestDiagnosticRequest {
|
||||
|
||||
export interface CanonicalDiagnostics {
|
||||
dwh_rest?: RestDiagnosticRequest & { response: { database: string; schema: string } };
|
||||
vector_rest?: {
|
||||
metadata: RestDiagnosticRequest & { response: { collection: string; dimensions: string; distance: string } };
|
||||
reversible_probe?: RestDiagnosticRequest & { method: "POST"; auth: "bearer" | "x-api-key"; response: { operation: string } };
|
||||
};
|
||||
embedding?: RestDiagnosticRequest & { response: { model: string; dimensions: string } };
|
||||
}
|
||||
|
||||
export interface CanonicalWorkspace {
|
||||
workspace: {
|
||||
schema_version: 2;
|
||||
schema_version: 3;
|
||||
id: string;
|
||||
name: string;
|
||||
description?: string;
|
||||
@@ -40,22 +35,15 @@ export interface CanonicalWorkspace {
|
||||
};
|
||||
semantic_index: {
|
||||
vector_store: {
|
||||
engine: "pgvector";
|
||||
database: string;
|
||||
schema: string;
|
||||
engine: "qdrant";
|
||||
collection: string;
|
||||
dimensions: number;
|
||||
distance: "cosine" | "l2" | "inner_product";
|
||||
port?: number;
|
||||
timeout_ms?: number;
|
||||
supported_transports: ("pgvector_direct" | "rest_api" | "ssh_tunnel")[];
|
||||
};
|
||||
vector_writer?: Record<string, never>;
|
||||
dimensions: 1024;
|
||||
distance: "cosine";
|
||||
}
|
||||
embedding: {
|
||||
provider: "ollama_compatible" | "openai_compatible";
|
||||
model: string;
|
||||
dimensions: number;
|
||||
timeout_ms?: number;
|
||||
provider: "ollama_internal";
|
||||
model: "qwen3-embedding:0.6b";
|
||||
dimensions: 1024;
|
||||
};
|
||||
};
|
||||
llm_policy: { default?: `${string}/${string}`; allowed: `${string}/${string}`[] };
|
||||
@@ -137,20 +125,13 @@ export interface WorkspaceApiError {
|
||||
const conflictFields = new Set([
|
||||
"workspace.schema_version", "workspace.id", "workspace.name", "workspace.description", "workspace.language",
|
||||
"dwh.engine", "dwh.database", "dwh.schema", "dwh.port", "dwh.timeout_ms", "dwh.supported_transports",
|
||||
"semantic_index.vector_store.engine", "semantic_index.vector_store.database", "semantic_index.vector_store.schema", "semantic_index.vector_store.collection",
|
||||
"semantic_index.vector_store.dimensions", "semantic_index.vector_store.distance", "semantic_index.vector_store.port",
|
||||
"semantic_index.vector_store.timeout_ms", "semantic_index.vector_store.supported_transports",
|
||||
"semantic_index.vector_store.engine", "semantic_index.vector_store.collection",
|
||||
"semantic_index.vector_store.dimensions", "semantic_index.vector_store.distance",
|
||||
"semantic_index.embedding.provider", "semantic_index.embedding.model", "semantic_index.embedding.dimensions",
|
||||
"semantic_index.embedding.timeout_ms", "semantic_index.vector_writer", "llm_policy.default", "llm_policy.allowed",
|
||||
"diagnostics", "diagnostics.dwh_rest", "diagnostics.vector_rest", "diagnostics.vector_rest.reversible_probe", "diagnostics.embedding",
|
||||
"llm_policy.default", "llm_policy.allowed",
|
||||
"diagnostics", "diagnostics.dwh_rest",
|
||||
"diagnostics.dwh_rest.method", "diagnostics.dwh_rest.path", "diagnostics.dwh_rest.auth",
|
||||
"diagnostics.dwh_rest.response.database", "diagnostics.dwh_rest.response.schema",
|
||||
"diagnostics.vector_rest.metadata.method", "diagnostics.vector_rest.metadata.path", "diagnostics.vector_rest.metadata.auth",
|
||||
"diagnostics.vector_rest.metadata.response.collection", "diagnostics.vector_rest.metadata.response.dimensions",
|
||||
"diagnostics.vector_rest.metadata.response.distance", "diagnostics.vector_rest.reversible_probe.method",
|
||||
"diagnostics.vector_rest.reversible_probe.path", "diagnostics.vector_rest.reversible_probe.auth",
|
||||
"diagnostics.vector_rest.reversible_probe.response.operation", "diagnostics.embedding.method", "diagnostics.embedding.path",
|
||||
"diagnostics.embedding.auth", "diagnostics.embedding.response.model", "diagnostics.embedding.response.dimensions",
|
||||
]);
|
||||
|
||||
const workspaceErrorCodes = new Set<WorkspaceErrorCode>([
|
||||
|
||||
Reference in New Issue
Block a user