fix: close internal semantic review gaps

This commit is contained in:
2026-08-08 23:27:58 +02:00
parent 43d8063922
commit 2c4534d968
18 changed files with 806 additions and 77 deletions
+43
View File
@@ -1,6 +1,21 @@
import { expect, test } from "vitest";
import { ReadinessManager } from "../src/runtime/readiness-manager.js";
const workspace = {
workspace: { schema_version: 3, id: "psd", name: "PSD", language: "it" },
dwh: {
engine: "postgres", database: "warehouse", schema: "public",
supported_transports: ["postgres_direct"],
},
semantic_index: {
vector_store: { engine: "qdrant", collection: "psd", dimensions: 1024, distance: "cosine" },
embedding: {
provider: "ollama_internal", model: "qwen3-embedding:0.6b", dimensions: 1024,
},
},
llm_policy: { allowed: ["zai/glm-5.2"] },
} as const;
function deferred<T>() {
let resolve!: (value: T) => void;
const promise = new Promise<T>((r) => { resolve = r; });
@@ -60,3 +75,31 @@ test("readiness does not cache failed results", async () => {
await expect(readiness.ensure("psd")).resolves.toMatchObject({ ok: true });
expect(calls).toBe(2);
});
test("readiness checks Qdrant before Ollama and skips Ollama on semantic incompatibility", async () => {
let ollamaCalls = 0;
const tht = {
qdrantEnsure: async () => ({ ok: false, code: "semantic_index_incompatible" }),
ollamaEnsure: async () => { ollamaCalls += 1; return { ok: true }; },
} as any;
const readiness = new ReadinessManager(tht, 60);
await expect(readiness.ensure("/registry/psd.yaml", undefined, workspace as any)).resolves.toEqual({
ok: false,
code: "semantic_index_incompatible",
});
expect(ollamaCalls).toBe(0);
});
test("readiness returns a sanitized activation code when a semantic probe throws", async () => {
const tht = {
qdrantEnsure: async () => { throw new Error("dial http://qdrant:6333/private"); },
ollamaEnsure: async () => ({ ok: true }),
} as any;
const readiness = new ReadinessManager(tht, 60);
await expect(readiness.ensure("/registry/psd.yaml", undefined, workspace as any)).resolves.toEqual({
ok: false,
code: "workspace_not_activatable",
});
});