import type { NodeId, WorkflowDefinition } from "../types"; import { MissingRuntimeExecutionMarker } from "./MissingRuntimeExecutionMarker"; import { type MissingRuntimeNodeDetail, WorkflowParityMismatchError } from "./WorkflowParityMismatchError"; export class MissingRuntimeParityGuard { constructor(private readonly marker: MissingRuntimeExecutionMarker) {} assertNone(workflow: WorkflowDefinition, nodeIds?: ReadonlyArray): void { const candidates = nodeIds ? workflow.nodes.filter((n) => nodeIds.includes(n.id)) : workflow.nodes; const missing: MissingRuntimeNodeDetail[] = candidates .filter((n) => this.marker.isMarked(n.config)) .map((n) => ({ nodeId: n.id, kind: n.kind as "node" | "trigger", missingTokenId: (n.config as Partial<{ missingTokenId: string }>).missingTokenId, })); if (missing.length > 0) { throw new WorkflowParityMismatchError(missing); } } }