fix: harden authoring schema and contract projections

This commit is contained in:
lda
2026-08-29 21:08:05 +07:00 Verified
parent 8b16c6403d
commit 0570ef8a78
14 changed files with 243 additions and 359 deletions
@@ -61,6 +61,35 @@ describe("run operation registry", () => {
});
});
it("preserves explicit null and empty contract replacement semantics", async () => {
const { getOperationMeta } = await import("./method-registry.js");
const operation = getOperationMeta("workflow.draft_workspaces.set_contract");
if (operation === undefined) throw new Error("missing set contract operation");
const cli = operation.equivalentCli({
workspace_id: "console.demo",
revision: 7,
input_schema: null,
outcomes: [],
});
expect(cli).toContain("input_schema=null (no equivalent CLI clear flag)");
expect(cli).toContain("outcomes=[] (no equivalent CLI clear flag)");
expect(cli).not.toContain("--outcome");
});
it("renders non-empty contract outcomes as repeated CLI flags", async () => {
const { getOperationMeta } = await import("./method-registry.js");
const operation = getOperationMeta("workflow.draft_workspaces.set_contract");
if (operation === undefined) throw new Error("missing set contract operation");
expect(operation.equivalentCli({
workspace_id: "console.demo",
revision: 7,
outcomes: ["ok", "cancelled"],
})).toContain("--outcome ok --outcome cancelled");
});
it("decodes start results with the start success schema", async () => {
vi.doMock("./rpcs.js", async () => {
const actual = await vi.importActual<typeof import("./rpcs.js")>(