Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 30 additions & 0 deletions src/workflow.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -273,6 +273,36 @@ describe("dynamic-workflow parity", () => {
expect(warnings[0]).toMatchObject({ type: "warning", message: expect.stringContaining("2") });
});

it("call.text returns a string — maps to await agent(prompt) without a schema", async () => {
// The most common Claude dynamic-workflow call: `await agent(prompt)` → `await call.text(prompt)`.
// Returns string | null; null signals an agent failure, not an empty string.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[/tdd] The comment documents that call.text returns string | null (null = agent failure), but the test only covers the success path — the null case is unverified.

💡 Suggested addition
it("call.text returns null on agent failure", async () => {
  configureAgent(() => ({
    ask: async () => { throw new Error("engine failure"); },
    close: async () => {},
  }));

  const definition = workflow({
    meta: { name: "call-text-null", description: "call.text null on failure" },
    body: ({ call }) => call.text("ping"),
  });

  await expect(runWorkflow(definition)).resolves.toBeNull();
});

Without this, a regression that changes the null-on-failure contract would go undetected in the parity block — the very block a Claude-workflow developer reads to gain confidence.

configureAgent(() => ({
ask: async () => '"pong"',
close: async () => {},
}));

const definition = workflow({
meta: { name: "call-text", description: "call.text returns string" },
body: ({ call }) => call.text("Reply with one word: pong."),
});

await expect(runWorkflow(definition)).resolves.toBe("pong");
});

it("log emits a log event visible in the onEvent stream", async () => {
// Claude dynamic workflows emit log(message); rig surfaces it as a { type: "log" } event.
const events: WorkflowEvent[] = [];
const definition = workflow({
meta: { name: "log-event", description: "log emits event" },
body: ({ log: wfLog }) => { wfLog("scanning repository"); },
});

await runWorkflow(definition, { onEvent: (event) => events.push(event) });
const logEvents = events.filter((event) => event.type === "log");
expect(logEvents).toHaveLength(1);
expect(logEvents[0]).toMatchObject({ type: "log", message: "scanning repository" });
});

it("call.json accepts a non-object schema (s.enum) — rig advantage over Claude dynamic workflows", async () => {
// Claude dynamic workflows only support object schemas in agent(prompt, { schema }).
// rig's call.json accepts any s.* schema: s.enum, s.array, s.string, etc.
Expand Down