fix: nest internal semantic runtime resources
This commit is contained in:
@@ -90,3 +90,43 @@ Reason: the new typed internal semantic runtime config had to flow from backend
|
|||||||
## Concerns
|
## Concerns
|
||||||
|
|
||||||
- Host validation currently permits both `http` and `https` on the allowed internal hosts. That keeps the configuration flexible, but if the installation contract intended `http` only, that restriction is not enforced here.
|
- Host validation currently permits both `http` and `https` on the allowed internal hosts. That keeps the configuration flexible, but if the installation contract intended `http` only, that restriction is not enforced here.
|
||||||
|
|
||||||
|
## Fix round 1/5
|
||||||
|
|
||||||
|
Scope:
|
||||||
|
|
||||||
|
- moved schema-v3 internal embeddings under `resources.embeddings`
|
||||||
|
- enforced `http`-only internal semantic URLs
|
||||||
|
|
||||||
|
RED evidence:
|
||||||
|
|
||||||
|
`cd backend && npx vitest run test/workspace-runtime-renderer.test.ts test/config.test.ts`
|
||||||
|
|
||||||
|
Observed failures on `bc8afe0`:
|
||||||
|
|
||||||
|
- `workspace-runtime-renderer.test.ts`
|
||||||
|
- schema-v3 output omitted `resources.embeddings`
|
||||||
|
- schema-v3 still exposed top-level `embeddings`
|
||||||
|
- `config.test.ts`
|
||||||
|
- `https://qdrant:6333` was accepted
|
||||||
|
|
||||||
|
GREEN evidence:
|
||||||
|
|
||||||
|
`cd backend && npx vitest run test/workspace-runtime-renderer.test.ts test/config.test.ts`
|
||||||
|
|
||||||
|
Result:
|
||||||
|
|
||||||
|
- 2 test files passed
|
||||||
|
- 16 tests passed
|
||||||
|
|
||||||
|
Typecheck:
|
||||||
|
|
||||||
|
`cd backend && npx tsc --noEmit -p .`
|
||||||
|
|
||||||
|
Result:
|
||||||
|
|
||||||
|
- passed
|
||||||
|
|
||||||
|
Updated concerns:
|
||||||
|
|
||||||
|
- none for this round beyond future tightening if exact-port rejection is later requested explicitly.
|
||||||
|
|||||||
@@ -125,7 +125,7 @@ function internalServiceUrl(
|
|||||||
throw new Error(`${label} configuration is invalid`);
|
throw new Error(`${label} configuration is invalid`);
|
||||||
}
|
}
|
||||||
if (
|
if (
|
||||||
(parsed.protocol !== "http:" && parsed.protocol !== "https:")
|
parsed.protocol !== "http:"
|
||||||
|| parsed.username.length > 0
|
|| parsed.username.length > 0
|
||||||
|| parsed.password.length > 0
|
|| parsed.password.length > 0
|
||||||
|| parsed.pathname !== "/"
|
|| parsed.pathname !== "/"
|
||||||
|
|||||||
@@ -140,18 +140,18 @@ export function renderRuntimeConfig(
|
|||||||
...(installation.profile === undefined ? {} : { profile: installation.profile }),
|
...(installation.profile === undefined ? {} : { profile: installation.profile }),
|
||||||
language: descriptor.workspace.language,
|
language: descriptor.workspace.language,
|
||||||
database,
|
database,
|
||||||
embeddings: {
|
|
||||||
provider: "ollama_internal",
|
|
||||||
base_url: semanticRuntime.internalEmbeddingUrl,
|
|
||||||
model: semanticRuntime.internalEmbeddingModel,
|
|
||||||
dimensions: semanticRuntime.internalEmbeddingDimensions,
|
|
||||||
},
|
|
||||||
resources: {
|
resources: {
|
||||||
vector: {
|
vector: {
|
||||||
engine: "qdrant",
|
engine: "qdrant",
|
||||||
base_url: semanticRuntime.internalQdrantUrl,
|
base_url: semanticRuntime.internalQdrantUrl,
|
||||||
collection: descriptor.semantic_index.vector_store.collection,
|
collection: descriptor.semantic_index.vector_store.collection,
|
||||||
},
|
},
|
||||||
|
embeddings: {
|
||||||
|
provider: "ollama_internal",
|
||||||
|
base_url: semanticRuntime.internalEmbeddingUrl,
|
||||||
|
model: semanticRuntime.internalEmbeddingModel,
|
||||||
|
dimensions: semanticRuntime.internalEmbeddingDimensions,
|
||||||
|
},
|
||||||
},
|
},
|
||||||
roots: paths,
|
roots: paths,
|
||||||
paths,
|
paths,
|
||||||
|
|||||||
@@ -58,6 +58,10 @@ test("loadConfig accepts only the allowed internal semantic runtime hosts", () =
|
|||||||
.toThrow(/internal.*qdrant|host validation|invalid/i);
|
.toThrow(/internal.*qdrant|host validation|invalid/i);
|
||||||
expect(() => loadConfig({ THT_INTERNAL_EMBEDDING_URL: "http://example.com:11434" }))
|
expect(() => loadConfig({ THT_INTERNAL_EMBEDDING_URL: "http://example.com:11434" }))
|
||||||
.toThrow(/internal.*embedding|host validation|invalid/i);
|
.toThrow(/internal.*embedding|host validation|invalid/i);
|
||||||
|
expect(() => loadConfig({ THT_INTERNAL_QDRANT_URL: "https://qdrant:6333" }))
|
||||||
|
.toThrow(/internal.*qdrant|invalid/i);
|
||||||
|
expect(() => loadConfig({ THT_INTERNAL_EMBEDDING_URL: "https://embedding:11434" }))
|
||||||
|
.toThrow(/internal.*embedding|invalid/i);
|
||||||
});
|
});
|
||||||
|
|
||||||
test("loadConfig enables the legacy workspace request only through explicit local mode", () => {
|
test("loadConfig enables the legacy workspace request only through explicit local mode", () => {
|
||||||
|
|||||||
@@ -193,13 +193,14 @@ test("fails closed for v3 runtime rendering and session support", () => {
|
|||||||
base_url: "http://qdrant:6333",
|
base_url: "http://qdrant:6333",
|
||||||
collection: "psd-clinical",
|
collection: "psd-clinical",
|
||||||
},
|
},
|
||||||
});
|
embeddings: {
|
||||||
expect(rendered.embeddings).toMatchObject({
|
|
||||||
provider: "ollama_internal",
|
provider: "ollama_internal",
|
||||||
base_url: "http://embedding:11434",
|
base_url: "http://embedding:11434",
|
||||||
model: "qwen3-embedding:0.6b",
|
model: "qwen3-embedding:0.6b",
|
||||||
dimensions: 1024,
|
dimensions: 1024,
|
||||||
|
},
|
||||||
});
|
});
|
||||||
|
expect(rendered).not.toHaveProperty("embeddings");
|
||||||
});
|
});
|
||||||
|
|
||||||
test("schema v3 runtime rendering never exposes external semantic endpoints from bindings", () => {
|
test("schema v3 runtime rendering never exposes external semantic endpoints from bindings", () => {
|
||||||
@@ -227,12 +228,13 @@ test("schema v3 runtime rendering never exposes external semantic endpoints from
|
|||||||
base_url: "http://qdrant:6333",
|
base_url: "http://qdrant:6333",
|
||||||
collection: "psd-clinical",
|
collection: "psd-clinical",
|
||||||
});
|
});
|
||||||
expect(rendered.embeddings).toMatchObject({
|
expect(rendered.resources.embeddings).toMatchObject({
|
||||||
provider: "ollama_internal",
|
provider: "ollama_internal",
|
||||||
base_url: "http://embedding:11434",
|
base_url: "http://embedding:11434",
|
||||||
model: "qwen3-embedding:0.6b",
|
model: "qwen3-embedding:0.6b",
|
||||||
dimensions: 1024,
|
dimensions: 1024,
|
||||||
});
|
});
|
||||||
|
expect(rendered).not.toHaveProperty("embeddings");
|
||||||
expect(JSON.stringify(rendered)).not.toContain("vector.example.test");
|
expect(JSON.stringify(rendered)).not.toContain("vector.example.test");
|
||||||
expect(JSON.stringify(rendered)).not.toContain("embedding.example.test");
|
expect(JSON.stringify(rendered)).not.toContain("embedding.example.test");
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user