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
25 changes: 24 additions & 1 deletion src/workflow.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import {
type WorkflowEvent,
} from "rig";
import { s } from "rig";
import { call as ambientCall } from "rig/globals";
import { call as ambientCall, pipeline as ambientPipeline, parallel as ambientParallel } from "rig/globals";

function fakeAgent<Input, Output>(
name: string,
Expand Down Expand Up @@ -468,4 +468,27 @@ describe("rig/globals", () => {
const worker = fakeAgent<number, number>("worker", (value) => value);
expect(() => ambientCall(worker, 1)).toThrow("requires an active workflow run");
});

it("pipeline() and parallel() from rig/globals run inside the active context — flat Claude workflow port pattern", async () => {
// Mirrors the incremental migration: import call/pipeline/parallel from "rig/globals"
// at the module top level so a flat Claude dynamic workflow can be ported without
// restructuring into a workflow({ body }) immediately.
const worker = fakeAgent<number, number>("worker", (value) => value * 10);
const definition = workflow({
meta: { name: "globals-pipeline-parallel", description: "flat port pattern" },
body: async () => {
const pipelineResult = await ambientPipeline([1, 2, 3], (item: number) => ambientCall(worker, item));
const parallelResult = await ambientParallel([
() => ambientCall(worker, 4),
() => ambientCall(worker, 5),
]);
return { pipelineResult, parallelResult };
},
});

await expect(runWorkflow(definition)).resolves.toEqual({
pipelineResult: [10, 20, 30],
parallelResult: [40, 50],
});
});

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] Missing out-of-context throw tests for pipeline() and parallel() — the existing call() out-of-context test (line 467) establishes a pattern not mirrored here. Without equivalent guard tests, a regression that silently swallows the out-of-context error for ambientPipeline/ambientParallel would go undetected.

});