feat: complete catalog-driven preprocessing
Publish documentation / publish (push) Successful in 2m12s
Publish documentation / publish (push) Successful in 2m12s
This commit is contained in:
@@ -30,11 +30,11 @@ function ok(operation: string): WorkspaceOperationResult {
|
||||
};
|
||||
}
|
||||
|
||||
test("entrypoint emits exactly one pristine JSON document and maps success/block/failure exits", async () => {
|
||||
test("entrypoint emits exactly one pristine JSON document and maps success/failure exits", async () => {
|
||||
const service = {
|
||||
inspect: vi.fn(async () => ok("inspect")),
|
||||
preprocessDwh: vi.fn(async () => ({ ...ok("preprocess dwh"), status: "blocked", code: "manual_review_required" as const })),
|
||||
run: vi.fn(async () => ({ ...ok("preprocess run"), status: "failed", code: "semantic_index_incompatible" as const })),
|
||||
clear: vi.fn(async () => ok("preprocess clear")),
|
||||
} as any;
|
||||
|
||||
const inspectIo = io(JSON.stringify({ schemaVersion: 1, workspaceId: "psd-clinical" }));
|
||||
@@ -42,13 +42,13 @@ test("entrypoint emits exactly one pristine JSON document and maps success/block
|
||||
expect(JSON.parse(inspectIo.stdout.join(""))).toMatchObject({ operation: "inspect", code: "ok" });
|
||||
expect(inspectIo.stderr.join("")).toBe("");
|
||||
|
||||
const blockedIo = io(JSON.stringify({ schemaVersion: 1, workspaceId: "psd-clinical" }));
|
||||
expect(await runWorkspaceMaintenanceCli(["node", "workspace-maintenance", "preprocess-dwh"], service, blockedIo)).toBe(3);
|
||||
expect(JSON.parse(blockedIo.stdout.join(""))).toMatchObject({ code: "manual_review_required" });
|
||||
|
||||
const failedIo = io(JSON.stringify({ schemaVersion: 1, workspaceId: "psd-clinical" }));
|
||||
expect(await runWorkspaceMaintenanceCli(["node", "workspace-maintenance", "preprocess-run"], service, failedIo)).toBe(1);
|
||||
expect(JSON.parse(failedIo.stdout.join(""))).toMatchObject({ code: "semantic_index_incompatible" });
|
||||
|
||||
const clearIo = io(JSON.stringify({ schemaVersion: 1, workspaceId: "psd-clinical" }));
|
||||
expect(await runWorkspaceMaintenanceCli(["node", "workspace-maintenance", "preprocess-clear"], service, clearIo)).toBe(0);
|
||||
expect(JSON.parse(clearIo.stdout.join(""))).toMatchObject({ operation: "preprocess clear", code: "ok" });
|
||||
});
|
||||
|
||||
test("malformed stdin, unknown commands, and extra fields fail with exit 2 but still return bounded JSON", async () => {
|
||||
@@ -84,31 +84,19 @@ test("raw exception text is redacted from stderr and stdout remains within the p
|
||||
expect(captured.stderr.join("")).not.toContain("SELECT *");
|
||||
});
|
||||
|
||||
test("vector-inspect and vector-rebuild dispatch to the service with the exact envelope", async () => {
|
||||
test("retired partial preprocessing commands are rejected without dispatch", async () => {
|
||||
const service = {
|
||||
vectorInspect: vi.fn(async () => ok("vector inspect")),
|
||||
vectorRebuild: vi.fn(async () => ok("vector rebuild")),
|
||||
preprocessDwh: vi.fn(),
|
||||
vectorInspect: vi.fn(),
|
||||
vectorRebuild: vi.fn(),
|
||||
} as any;
|
||||
|
||||
const inspectIo = io(JSON.stringify({ schemaVersion: 1, workspaceId: "psd-clinical" }));
|
||||
expect(await runWorkspaceMaintenanceCli(["node", "workspace-maintenance", "vector-inspect"], service, inspectIo)).toBe(0);
|
||||
expect(service.vectorInspect).toHaveBeenCalledWith({ workspaceId: "psd-clinical" });
|
||||
expect(JSON.parse(inspectIo.stdout.join(""))).toMatchObject({ operation: "vector inspect", code: "ok" });
|
||||
|
||||
const rebuildIo = io(JSON.stringify({ schemaVersion: 1, workspaceId: "psd-clinical", collection: "psd-clinical", confirm: "psd-clinical", destroy: true }));
|
||||
expect(await runWorkspaceMaintenanceCli(["node", "workspace-maintenance", "vector-rebuild"], service, rebuildIo)).toBe(0);
|
||||
expect(service.vectorRebuild).toHaveBeenCalledWith({
|
||||
workspaceId: "psd-clinical",
|
||||
collection: "psd-clinical",
|
||||
confirm: "psd-clinical",
|
||||
destroy: true,
|
||||
});
|
||||
});
|
||||
|
||||
test("vector-rebuild without exact confirmation is refused by the service", async () => {
|
||||
const service = {
|
||||
vectorRebuild: vi.fn(async () => ({ ...ok("vector rebuild"), status: "failed", code: "semantic_index_incompatible" as const })),
|
||||
} as any;
|
||||
const rebuildIo = io(JSON.stringify({ schemaVersion: 1, workspaceId: "psd-clinical", collection: "other", confirm: "other", destroy: true }));
|
||||
expect(await runWorkspaceMaintenanceCli(["node", "workspace-maintenance", "vector-rebuild"], service, rebuildIo)).toBe(1);
|
||||
for (const command of ["preprocess-dwh", "vector-inspect", "vector-rebuild"]) {
|
||||
const captured = io(JSON.stringify({ schemaVersion: 1, workspaceId: "psd-clinical" }));
|
||||
expect(await runWorkspaceMaintenanceCli(["node", "workspace-maintenance", command], service, captured)).toBe(2);
|
||||
expect(JSON.parse(captured.stdout.join(""))).toMatchObject({ status: "failed", operation: command });
|
||||
}
|
||||
expect(service.preprocessDwh).not.toHaveBeenCalled();
|
||||
expect(service.vectorInspect).not.toHaveBeenCalled();
|
||||
expect(service.vectorRebuild).not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user