feat: define workspace diagnostic contracts
This commit is contained in:
@@ -20,6 +20,8 @@ dwh:
|
||||
semantic_index:
|
||||
vector_store:
|
||||
engine: pgvector
|
||||
database: postgres
|
||||
schema: vectors
|
||||
collection: clinical_documents
|
||||
dimensions: 768
|
||||
distance: cosine
|
||||
@@ -68,6 +70,57 @@ test("accepts optional connection ports and timeouts but rejects unsafe values",
|
||||
.toThrow(/timeout/i);
|
||||
});
|
||||
|
||||
test("requires explicit vector database and schema identities with strict diagnostic declarations", () => {
|
||||
const diagnosticWorkspace = validYaml.replace(
|
||||
" engine: pgvector\n database: postgres",
|
||||
" engine: pgvector\n database: vector_database",
|
||||
).replace(
|
||||
"llm_policy:\n",
|
||||
"diagnostics:\n"
|
||||
+ " dwh_rest:\n"
|
||||
+ " method: POST\n"
|
||||
+ " path: /rpc/ping\n"
|
||||
+ " auth: bearer\n"
|
||||
+ " response:\n"
|
||||
+ " database: database\n"
|
||||
+ " schema: schema\n"
|
||||
+ " vector_rest:\n"
|
||||
+ " metadata:\n"
|
||||
+ " method: GET\n"
|
||||
+ " path: /metadata\n"
|
||||
+ " auth: bearer\n"
|
||||
+ " response:\n"
|
||||
+ " collection: collection\n"
|
||||
+ " dimensions: dimensions\n"
|
||||
+ " distance: distance\n"
|
||||
+ " reversible_probe:\n"
|
||||
+ " method: POST\n"
|
||||
+ " path: /rpc/diagnostic_vector_probe\n"
|
||||
+ " auth: bearer\n"
|
||||
+ " embedding:\n"
|
||||
+ " method: GET\n"
|
||||
+ " path: /models\n"
|
||||
+ " auth: none\n"
|
||||
+ " response:\n"
|
||||
+ " model: model\n"
|
||||
+ " dimensions: dimensions\n"
|
||||
+ "llm_policy:\n",
|
||||
);
|
||||
|
||||
expect(parseWorkspaceYaml(diagnosticWorkspace).semantic_index.vector_store).toMatchObject({
|
||||
database: "vector_database",
|
||||
schema: "vectors",
|
||||
});
|
||||
expect(() => parseWorkspaceYaml(diagnosticWorkspace.replace("database: vector_database", 'database: " "')))
|
||||
.toThrow(/database/i);
|
||||
expect(() => parseWorkspaceYaml(diagnosticWorkspace.replace("schema: vectors", 'schema: " "')))
|
||||
.toThrow(/schema/i);
|
||||
expect(() => parseWorkspaceYaml(diagnosticWorkspace.replace("method: POST", "method: PATCH")))
|
||||
.toThrow(/method/i);
|
||||
expect(() => parseWorkspaceYaml(diagnosticWorkspace.replace(" distance: distance", " distance: distance\n extra: ignored")))
|
||||
.toThrow(/unrecognized key/i);
|
||||
});
|
||||
|
||||
test("serializes canonical YAML that parses back to the same workspace", () => {
|
||||
const workspace = parseWorkspaceYaml(validYaml);
|
||||
const serialized = serializeWorkspaceYaml(workspace);
|
||||
|
||||
Reference in New Issue
Block a user