import { describe, expect, it } from "vitest"; import { planOrchestratorAction } from "./convoy-driver"; describe("planOrchestratorAction", () => { const convoyId = "00000000-0000-4000-8000-000000000001"; it("pauses at convoy_review gate", () => { const action = planOrchestratorAction({ convoyId, status: "convoy_review", skipFlags: [], briefs: [], completedRoles: new Set(), completedBriefIds: new Set(), }); expect(action).toMatchObject({ type: "pause", gate: "1" }); }); it("dispatches first planning role on draft", () => { const action = planOrchestratorAction({ convoyId, status: "draft", skipFlags: [], briefs: [], completedRoles: new Set(), completedBriefIds: new Set(), }); expect(action).toMatchObject({ type: "dispatch", roleId: "role-ia-architect" }); }); it("skips ia when in skip flags", () => { const action = planOrchestratorAction({ convoyId, status: "draft", skipFlags: ["ia"], briefs: [], completedRoles: new Set(), completedBriefIds: new Set(), }); expect(action).toMatchObject({ type: "dispatch", roleId: "role-ux-reviewer" }); }); it("transitions to convoy_review when planning roles complete", () => { const action = planOrchestratorAction({ convoyId, status: "draft", skipFlags: ["ia", "ux"], briefs: [], completedRoles: new Set(["role-architect"]), completedBriefIds: new Set(), }); expect(action).toMatchObject({ type: "transition", toStatus: "convoy_review", actor: "role-architect", }); }); it("dispatches implementer for ready brief", () => { const action = planOrchestratorAction({ convoyId, status: "ready", skipFlags: [], briefs: [ { id: "00000000-0000-4000-8000-000000000010", briefNumber: 1, status: "ready", sliceDependencies: [], }, ], completedRoles: new Set(), completedBriefIds: new Set(), }); expect(action).toMatchObject({ type: "dispatch", roleId: "role-implementer", briefId: "00000000-0000-4000-8000-000000000010", }); }); });