feat(cli): add workflow semantic validation before execution
Implements validateWorkflow() that performs deep semantic checks on parsed WorkflowPayload before registration or execution: - Role reference integrity (unknown roles, orphans, reserved names) - Graph structure (/ constraints, reachability, edge targets) - Status-edge consistency (single/multi-exit matching) - Mustache template variable existence - oneOf discriminant validity ( const check) All errors collected (not fail-fast). Integrated into: - uwf workflow add (before CAS registration) - uwf thread start (local workflow materialization) Closes #506
This commit is contained in:
@@ -15,6 +15,7 @@ import {
|
||||
type UwfStore,
|
||||
} from "../store.js";
|
||||
import { checkWorkflowFilenameConsistency, parseWorkflowPayload } from "../validate.js";
|
||||
import { validateWorkflow } from "../validate-semantic.js";
|
||||
|
||||
export type WorkflowOrigin = "local" | "global";
|
||||
|
||||
@@ -136,6 +137,11 @@ export async function cmdWorkflowAdd(
|
||||
fail(filenameError);
|
||||
}
|
||||
|
||||
const semanticErrors = validateWorkflow(payload);
|
||||
if (semanticErrors.length > 0) {
|
||||
fail(`workflow validation failed:\n${semanticErrors.map((e) => ` - ${e}`).join("\n")}`);
|
||||
}
|
||||
|
||||
const uwf = await createUwfStore(storageRoot);
|
||||
const materialized = await materializeWorkflowPayload(uwf, payload);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user