feat(FN-4368): complete Step 6 — workflow defaults and schema v73 assertions

Fusion-Task-Id: FN-4368
Fusion-Task-Lineage: ac9b12e6-2101-4b51-89a0-6422fd7850ed
This commit is contained in:
Fusion
2026-05-14 06:57:28 -07:00
committed by gsxdsm
parent cb7f31e546
commit e7785bee54
2 changed files with 52 additions and 0 deletions

View File

@@ -29,6 +29,7 @@ describe("TaskStore Workflow Steps", () => {
expect(ws.name).toBe("Documentation Review");
expect(ws.description).toBe("Verify all public APIs have documentation");
expect(ws.mode).toBe("prompt");
expect(ws.gateMode).toBe("advisory");
expect(ws.prompt).toBe("Review the task changes and verify that all new public functions have docs.");
expect(ws.scriptName).toBeUndefined();
expect(ws.enabled).toBe(true);
@@ -46,6 +47,7 @@ describe("TaskStore Workflow Steps", () => {
expect(ws.name).toBe("QA Check");
expect(ws.description).toBe("Run tests and verify they pass");
expect(ws.mode).toBe("prompt"); // Default mode
expect(ws.gateMode).toBe("advisory"); // prompt default gate mode
expect(ws.prompt).toBe(""); // Empty when not provided
expect(ws.enabled).toBe(true); // Default enabled
});
@@ -61,6 +63,7 @@ describe("TaskStore Workflow Steps", () => {
expect(ws.id).toBe("WS-001");
expect(ws.name).toBe("Run Tests");
expect(ws.mode).toBe("script");
expect(ws.gateMode).toBe("gate");
expect(ws.prompt).toBe("");
expect(ws.scriptName).toBe("test");
expect(ws.modelProvider).toBeUndefined();
@@ -68,6 +71,33 @@ describe("TaskStore Workflow Steps", () => {
expect(ws.enabled).toBe(true);
});
it("should round-trip gateMode create/list/update", async () => {
const promptStep = await store.createWorkflowStep({
name: "Prompt advisory",
description: "advisory default",
mode: "prompt",
prompt: "review",
});
const scriptStep = await store.createWorkflowStep({
name: "Script gate",
description: "gate default",
mode: "script",
scriptName: "test",
});
expect(promptStep.gateMode).toBe("advisory");
expect(scriptStep.gateMode).toBe("gate");
await store.updateWorkflowStep(promptStep.id, { gateMode: "gate" });
await store.updateWorkflowStep(scriptStep.id, { gateMode: "advisory" });
const listed = await store.listWorkflowSteps();
const updatedPrompt = listed.find((step) => step.id === promptStep.id);
const updatedScript = listed.find((step) => step.id === scriptStep.id);
expect(updatedPrompt?.gateMode).toBe("gate");
expect(updatedScript?.gateMode).toBe("advisory");
});
it("should reject script mode without scriptName", async () => {
await expect(
store.createWorkflowStep({
@@ -157,6 +187,7 @@ describe("TaskStore Workflow Steps", () => {
templateId: "my-step",
name: "My Plugin Step",
mode: "script",
gateMode: "gate",
phase: "pre-merge",
scriptName: "my-plugin:run-step",
defaultOn: false,
@@ -169,6 +200,7 @@ describe("TaskStore Workflow Steps", () => {
id: "plugin:my-plugin:my-step",
templateId: "my-step",
mode: "script",
gateMode: "gate",
phase: "pre-merge",
scriptName: "my-plugin:run-step",
defaultOn: false,
@@ -201,6 +233,7 @@ describe("TaskStore Workflow Steps", () => {
id: "plugin:my-plugin:prompt-step",
templateId: "prompt-step",
mode: "prompt",
gateMode: "advisory",
prompt: "Run plugin checks",
});
});

View File

@@ -2579,6 +2579,7 @@ export class TaskStore extends EventEmitter<TaskStoreEvents> {
description: template.description,
mode: "prompt",
phase: "pre-merge",
gateMode: "advisory",
prompt: template.prompt,
gateMode: "advisory",
toolMode: template.toolMode || "readonly",
@@ -2595,6 +2596,7 @@ export class TaskStore extends EventEmitter<TaskStoreEvents> {
description: string;
mode: string;
phase: string | null;
gateMode: string | null;
prompt: string;
gateMode: string | null;
toolMode: string | null;
@@ -2613,6 +2615,9 @@ export class TaskStore extends EventEmitter<TaskStoreEvents> {
description: row.description,
mode: row.mode === "script" ? "script" : "prompt",
phase: row.phase === "post-merge" ? "post-merge" : "pre-merge",
gateMode: row.gateMode === "advisory" || row.gateMode === "gate"
? row.gateMode
: (row.mode === "script" ? "gate" : "advisory"),
prompt: row.prompt || "",
gateMode: row.gateMode === "gate" || row.gateMode === "advisory"
? row.gateMode
@@ -2657,6 +2662,9 @@ export class TaskStore extends EventEmitter<TaskStoreEvents> {
if (!Object.prototype.hasOwnProperty.call(legacy, "phase")) {
normalized.phase = undefined;
}
if (!Object.prototype.hasOwnProperty.call(legacy, "gateMode")) {
normalized.gateMode = normalized.mode === "script" ? "gate" : "advisory";
}
return normalized;
}
@@ -7150,6 +7158,7 @@ ${stepsSection}`;
const id = `WS-${String(nextWsId).padStart(3, "0")}`;
const mode = input.mode || "prompt";
const gateMode = input.gateMode || (mode === "script" ? "gate" : "advisory");
// Validate: script mode requires scriptName
if (mode === "script" && !input.scriptName?.trim()) {
@@ -7164,6 +7173,7 @@ ${stepsSection}`;
description: input.description,
mode,
phase: input.phase || "pre-merge",
gateMode,
prompt: mode === "prompt" ? (input.prompt || "") : "",
gateMode: input.gateMode || (mode === "script" ? "gate" : "advisory"),
toolMode: mode === "prompt" ? (input.toolMode || "readonly") : undefined,
@@ -7184,6 +7194,7 @@ ${stepsSection}`;
description,
mode,
phase,
gateMode,
prompt,
gateMode,
toolMode,
@@ -7202,6 +7213,7 @@ ${stepsSection}`;
step.description,
step.mode,
step.phase || "pre-merge",
step.gateMode,
step.prompt,
step.gateMode ?? (step.mode === "script" ? "gate" : "advisory"),
step.toolMode ?? null,
@@ -7245,6 +7257,7 @@ ${stepsSection}`;
description: entry.template.description,
mode: entry.template.mode ?? "prompt",
phase: entry.template.phase ?? "pre-merge",
gateMode: (entry.template.mode ?? "prompt") === "script" ? "gate" : "advisory",
prompt: entry.template.prompt ?? "",
gateMode: entry.template.gateMode ?? ((entry.template.mode ?? "prompt") === "script" ? "gate" : "advisory"),
scriptName: entry.template.scriptName,
@@ -7309,6 +7322,7 @@ ${stepsSection}`;
description: string;
mode: string;
phase: string | null;
gateMode: string | null;
prompt: string;
gateMode: string | null;
toolMode: string | null;
@@ -7335,6 +7349,7 @@ ${stepsSection}`;
description: string;
mode: string;
phase: string | null;
gateMode: string | null;
prompt: string;
gateMode: string | null;
toolMode: string | null;
@@ -7368,6 +7383,7 @@ ${stepsSection}`;
description: string;
mode: string;
phase: string | null;
gateMode: string | null;
prompt: string;
gateMode: string | null;
toolMode: string | null;
@@ -7414,6 +7430,7 @@ ${stepsSection}`;
if (updates.name !== undefined) step.name = updates.name;
if (updates.description !== undefined) step.description = updates.description;
if (updates.phase !== undefined) step.phase = updates.phase;
if (updates.gateMode !== undefined) step.gateMode = updates.gateMode;
if (updates.prompt !== undefined && step.mode === "prompt") step.prompt = updates.prompt;
if (updates.toolMode !== undefined && step.mode === "prompt") step.toolMode = updates.toolMode;
if (updates.gateMode !== undefined) step.gateMode = updates.gateMode;
@@ -7436,6 +7453,7 @@ ${stepsSection}`;
description = ?,
mode = ?,
phase = ?,
gateMode = ?,
prompt = ?,
gateMode = ?,
toolMode = ?,
@@ -7452,6 +7470,7 @@ ${stepsSection}`;
step.description,
step.mode,
step.phase || "pre-merge",
step.gateMode,
step.prompt,
step.gateMode ?? (step.mode === "script" ? "gate" : "advisory"),
step.toolMode ?? null,