/**
 * TaskGraph — Intermediate Representation for the evaluation compiler.
 *
 * The TaskGraph is a directed acyclic graph (DAG) of tasks with dependency
 * edges, shared fixtures, and compilation targets. It sits between the
 * user-authored task definitions and the generated Promptfoo configs.
 *
 * Compilation pipeline:
 *   GeneralizedTaskDefinitions → parse → TaskGraph → optimize → PromptfooConfig[]
 *                                       ↘ validate ↗
 *
 * These types are introduced in Phase 0 but not consumed until Phase 2
 * (the compiler). They establish the IR vocabulary early so all design
 * discussions and subsequent phases use the same type language.
 *
 * Design decision: DAG-only (no cycles). See domain-model.md.
 *
 * @see docs/design-docs/architecture-overhaul/domain-model.md (canonical)
 */
import type { VariableEnvelope } from "./variable-envelope.js";
/** A resolved fixture ready for injection into evaluations */
export interface ResolvedFixture {
    /** Fixture identifier */
    id: string;
    /** Human-readable name */
    name: string;
    /** Fixture type */
    type: "static" | "fetched" | "generated";
    /** Resolved content (null if generation failed or content is deferred) */
    content: string | null;
    /** Content hash for cache invalidation */
    contentHash?: string;
    /** Time-to-live in seconds (for fetched/generated fixtures) */
    ttlSeconds?: number;
}
/**
 * A single node in the task graph — one task with its resolved context.
 */
export interface TaskNode {
    /** The task identifier */
    taskId: string;
    /** The evaluation mode this task belongs to (from GeneralizedTaskDefinition.mode) */
    mode?: string;
    /** Resolved prompt template (after variable interpolation) */
    resolvedPrompt: string;
    /** All variables available to this task, with provenance tracking */
    resolvedVariables: VariableEnvelope;
    /** Task IDs this node depends on (must complete before this node runs) */
    dependsOn: string[];
    /** Execution priority (lower = higher priority). Used for topological tie-breaking. */
    priority: number;
}
/**
 * A directed edge between two tasks in the graph.
 *
 * Edge types:
 * - `data` — the downstream task consumes output from the upstream task
 * - `ordering` — pure execution ordering constraint (no data flow)
 * - `fixture` — both tasks share a fixture; the fixture must be resolved first
 */
export interface DependencyEdge {
    /** Source task (upstream — must complete first) */
    from: string;
    /** Target task (downstream — depends on `from`) */
    to: string;
    /** Relationship type */
    type: "data" | "ordering" | "fixture";
}
/**
 * The complete task graph IR — the compilation unit for the eval pipeline.
 *
 * Invariants:
 * - The graph is a DAG (no cycles). The compiler rejects cyclic graphs.
 * - Every `taskId` in `edges` must exist as a key in `nodes`.
 * - Every `fixtureId` referenced by a node must exist in `fixtures`.
 */
export interface TaskGraph {
    /** All task nodes, keyed by task ID */
    nodes: Map<string, TaskNode>;
    /** Dependency edges between tasks */
    edges: DependencyEdge[];
    /** Resolved fixtures shared across tasks, keyed by fixture ID */
    fixtures: Map<string, ResolvedFixture>;
    /** The backend this graph compiles to */
    compilationTarget: "promptfoo" | "custom";
}
