/** * Config workflow state machine — turn transition logic, state creation, * and advancement. Pure functions only — no I/O, no side effects. * * Pattern: follows task-status.ts — static ordering + canAdvance guard. * * @module config-workflow/workflow-state */ import type { ConfigWorkflowState, WorkflowTurn } from "./workflow-types.js"; /** Ordered turn names for the 8-turn configuration workflow. */ export declare const TURN_NAMES: WorkflowTurn[]; /** Total number of turns in the workflow. */ export declare const TOTAL_TURNS = 8; /** * Create a new workflow state at Turn 0 (Discovery). * * @param options - Workflow creation parameters (type, targetPrimitives, scope, mode). * @returns A fresh {@link ConfigWorkflowState} with all turns pending. */ export declare function createWorkflowState(options: { type: ConfigWorkflowState["type"]; targetPrimitives: ConfigWorkflowState["targetPrimitives"]; scope: ConfigWorkflowState["scope"]; mode: ConfigWorkflowState["mode"]; }): ConfigWorkflowState; /** * Check if advancing from current turn to target turn is valid. * * Transition rules: * - Forward: `targetTurn === currentTurn + 1` → always allowed * - Skip-back: `targetTurn <= currentTurn` → always allowed (re-do a turn) * - Skip-forward: `targetTurn > currentTurn + 1` → REJECTED * - Out-of-range: `targetTurn < 0 || targetTurn > 7` → REJECTED * * @param state - Current workflow state. * @param targetTurn - Turn index to advance to (0-7). * @returns `true` if the transition is valid, `false` otherwise. */ export declare function canAdvanceTurn(state: ConfigWorkflowState, targetTurn: number): boolean; /** * Advance to a specific turn. Returns a **new** state — does not mutate input. * * @param state - Current workflow state (not mutated). * @param targetTurn - Turn index to advance to (0-7). * @returns A new {@link ConfigWorkflowState} with updated `currentTurn`. * @throws {Error} `[Hivemind]` error if the transition is invalid. */ export declare function advanceTurn(state: ConfigWorkflowState, targetTurn: number): ConfigWorkflowState; /** * Mark the current turn as complete with output data. * Returns a **new** state — does not mutate input. * * @param state - Current workflow state (not mutated). * @param output - Arbitrary output data from the completed turn. * @returns A new {@link ConfigWorkflowState} with the current turn marked complete. */ export declare function completeCurrentTurn(state: ConfigWorkflowState, output: Record): ConfigWorkflowState; /** * Get the name of a turn by its numeric index. * * @param turnIndex - Turn index (0-7). * @returns The turn name string. * @throws {Error} If the turn index is out of range. */ export declare function getTurnName(turnIndex: number): WorkflowTurn; /** * Check if a workflow is complete (all 8 turns done, or the final turn is complete). * * @param state - Current workflow state. * @returns `true` if the workflow has completed all turns. */ export declare function isWorkflowComplete(state: ConfigWorkflowState): boolean; /** * Deep-clone a workflow state for safe return (prevents mutation aliasing). * * @param state - Workflow state to clone. * @returns A deep copy of the state. */ export declare function cloneWorkflowState(state: ConfigWorkflowState): ConfigWorkflowState; //# sourceMappingURL=workflow-state.d.ts.map