refactor: make workspace descriptors schema v3 only
This commit is contained in:
@@ -1,13 +1,12 @@
|
||||
import { readFileSync } from "node:fs";
|
||||
import { resolve } from "node:path";
|
||||
import { parse } from "yaml";
|
||||
import { expect, test } from "vitest";
|
||||
import * as workspaceSchema from "../src/workspaces/schema.js";
|
||||
import {
|
||||
parseWorkspaceYaml,
|
||||
serializeWorkspaceYaml,
|
||||
validateCanonicalWorkspace,
|
||||
validateWorkspaceDescriptor,
|
||||
type WorkspaceDescriptor,
|
||||
} from "../src/workspaces/schema.js";
|
||||
|
||||
export const validYaml = `workspace:
|
||||
@@ -165,8 +164,8 @@ test("rejects legacy semantic connector fields and diagnostics in schema v3", ()
|
||||
))).toThrow(/unrecognized key|vector_rest/i);
|
||||
});
|
||||
|
||||
test("keeps v1 and v2 descriptors parseable but non-operational", () => {
|
||||
const v1Yaml = `workspace:
|
||||
test.each([
|
||||
["v1", `workspace:
|
||||
schema_version: 1
|
||||
id: psd-clinical
|
||||
name: Policlinico San Donato
|
||||
@@ -192,8 +191,8 @@ semantic_index:
|
||||
llm_policy:
|
||||
allowed:
|
||||
- zai/glm-5.2
|
||||
`;
|
||||
const v2Yaml = `workspace:
|
||||
`],
|
||||
["v2", `workspace:
|
||||
schema_version: 2
|
||||
id: psd-clinical
|
||||
name: Policlinico San Donato
|
||||
@@ -221,22 +220,17 @@ semantic_index:
|
||||
llm_policy:
|
||||
allowed:
|
||||
- zai/glm-5.2
|
||||
`;
|
||||
`],
|
||||
])("rejects schema %s descriptors at parser and object-validator boundaries", (_version, yaml) => {
|
||||
expect(() => parseWorkspaceYaml(yaml)).toThrow(/schema_version|invalid literal|3/i);
|
||||
expect(() => validateWorkspaceDescriptor(parse(yaml))).toThrow(/schema_version|invalid literal|3/i);
|
||||
});
|
||||
|
||||
const v1 = parseWorkspaceYaml(v1Yaml);
|
||||
const v2 = parseWorkspaceYaml(v2Yaml);
|
||||
const isOperationalWorkspace = (workspaceSchema as { isOperationalWorkspace?: unknown }).isOperationalWorkspace;
|
||||
test("does not expose the redundant canonical validator or v1 migration", () => {
|
||||
const legacyExports = workspaceSchema as Record<string, unknown>;
|
||||
|
||||
expect(v1.workspace.schema_version).toBe(1);
|
||||
expect(v2.workspace.schema_version).toBe(2);
|
||||
expect(validateCanonicalWorkspace(parseWorkspaceYaml(validYaml))).toMatchObject({
|
||||
workspace: { schema_version: 3 },
|
||||
});
|
||||
expect(() => validateCanonicalWorkspace(v1)).toThrow(/schema version 3|migration/i);
|
||||
expect(() => validateCanonicalWorkspace(v2)).toThrow(/schema version 3|migration/i);
|
||||
expect(isOperationalWorkspace).toBeTypeOf("function");
|
||||
expect((isOperationalWorkspace as (workspace: WorkspaceDescriptor) => boolean)(v1)).toBe(false);
|
||||
expect((isOperationalWorkspace as (workspace: WorkspaceDescriptor) => boolean)(v2)).toBe(false);
|
||||
expect(legacyExports.validateCanonicalWorkspace).toBeUndefined();
|
||||
expect(legacyExports.migrateWorkspaceV1ToV2).toBeUndefined();
|
||||
});
|
||||
|
||||
test("constructs diagnostic URLs only when the resolved URL remains on the service origin", () => {
|
||||
|
||||
Reference in New Issue
Block a user