yaml-flow 2.1.0 → 2.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -748,6 +748,116 @@ See the [examples/graph-of-graphs/](./examples/graph-of-graphs/) directory for c
748
748
 
749
749
  ---
750
750
 
751
+ ## Execution Plan (Dry Run)
752
+
753
+ Compute the full execution plan from a graph config without running anything — like `terraform plan` for workflows.
754
+
755
+ ```typescript
756
+ import { planExecution } from 'yaml-flow/event-graph';
757
+
758
+ const plan = planExecution(graph);
759
+
760
+ plan.phases; // [['prep'], ['copy'], ['evidence'], ['synthesis'], ['analyze'], ['health', 'report'], ['archive']]
761
+ plan.depth; // 7
762
+ plan.maxParallelism; // 2
763
+ plan.entryPoints; // ['prep']
764
+ plan.leafTasks; // ['archive']
765
+ plan.conflicts; // { 'output-token': ['task-a', 'task-b'] } — multiple producers
766
+ plan.unreachableTokens; // ['human-approval'] — required but no task produces it
767
+ plan.blockedTasks; // ['approve'] — blocked by unreachable tokens
768
+ plan.dependencies; // { 'copy': ['prep'], 'evidence': ['copy'], ... }
769
+ ```
770
+
771
+ ---
772
+
773
+ ## Mermaid Diagrams
774
+
775
+ Generate Mermaid syntax from any config — useful for docs, debugging, and CI reports.
776
+
777
+ ```typescript
778
+ import { graphToMermaid, flowToMermaid } from 'yaml-flow/event-graph';
779
+
780
+ // Event graph → dependency diagram
781
+ console.log(graphToMermaid(graph));
782
+ // graph TD
783
+ // build([build])
784
+ // test[test]
785
+ // deploy[[deploy]]
786
+ // build -->|artifact| test
787
+ // test -->|tested| deploy
788
+
789
+ // Step machine → flowchart
790
+ console.log(flowToMermaid(flow));
791
+ // graph TD
792
+ // START(( ))
793
+ // START --> classify
794
+ // classify -->|billing| handle
795
+ // handle -->|resolved| done
796
+ // done([done: resolved])
797
+ ```
798
+
799
+ Options: `{ direction: 'LR' | 'TD', showTokens: boolean, title: string }`.
800
+ Entry points (no requires) get rounded shapes, leaf tasks get double-bracketed shapes, unreachable deps get warning markers.
801
+
802
+ ---
803
+
804
+ ## Graph Validation (Semantic)
805
+
806
+ Validate the logical correctness of a graph — catches issues that structural validation (`validateGraphConfig`) can't.
807
+
808
+ ```typescript
809
+ import { validateGraph } from 'yaml-flow/event-graph';
810
+
811
+ const result = validateGraph(graph);
812
+
813
+ result.valid; // true if no errors (warnings/info allowed)
814
+ result.errors; // issues that will break execution
815
+ result.warnings; // issues that may cause unexpected behavior
816
+ result.issues; // all issues (errors + warnings + info)
817
+
818
+ // Each issue
819
+ result.issues[0].severity; // 'error' | 'warning' | 'info'
820
+ result.issues[0].code; // e.g. 'CIRCULAR_DEPENDENCY'
821
+ result.issues[0].message; // human-readable description
822
+ result.issues[0].tasks; // affected task names
823
+ result.issues[0].tokens; // affected tokens
824
+ ```
825
+
826
+ | Issue Code | Severity | Description |
827
+ |---|---|---|
828
+ | `EMPTY_GRAPH` | error | Graph has no tasks |
829
+ | `DANGLING_REQUIRES` | error | Task requires a token that no task produces |
830
+ | `CIRCULAR_DEPENDENCY` | error | Cycle detected in task dependencies |
831
+ | `SELF_DEPENDENCY` | error | Task requires a token it provides itself |
832
+ | `UNREACHABLE_GOAL` | error | Goal token cannot be produced by any task |
833
+ | `MISSING_GOAL` | error | `goal-reached` strategy without goal array |
834
+ | `PROVIDE_CONFLICT` | warning | Multiple tasks produce the same token |
835
+ | `DEAD_END_TASK` | warning | Task has no provides — can't unblock downstream |
836
+ | `ISOLATED_TASK` | info | Disconnected task with no requires or dependents |
837
+
838
+ Use `validateGraphConfig()` for structural checks (JSON shape) and `validateGraph()` for semantic checks (logical correctness). Both are pure functions.
839
+
840
+ ---
841
+
842
+ ## Loading & Exporting Graph Configs
843
+
844
+ ```typescript
845
+ import { loadGraphConfig, exportGraphConfig, exportGraphConfigToFile } from 'yaml-flow/event-graph';
846
+
847
+ // Load from file, URL, JSON string, or object (validates automatically)
848
+ const graph = await loadGraphConfig('./pipeline.yaml');
849
+ const graph2 = await loadGraphConfig('https://example.com/graph.json');
850
+
851
+ // Export to string
852
+ const json = exportGraphConfig(graph); // JSON (default)
853
+ const yaml = exportGraphConfig(graph, { format: 'yaml' }); // YAML
854
+
855
+ // Export to file (format auto-detected from extension)
856
+ await exportGraphConfigToFile(graph, './output/pipeline.yaml');
857
+ ```
858
+
859
+ ---
860
+
751
861
  ## Package Exports
752
862
 
753
863
  ```typescript
@@ -761,6 +871,9 @@ import { applyStepResult, checkCircuitBreaker, createInitialState } from 'yaml-f
761
871
  // Event Graph only
762
872
  import { next, apply, applyAll, getCandidateTasks } from 'yaml-flow/event-graph';
763
873
  import { createInitialExecutionState, isExecutionComplete, detectStuckState } from 'yaml-flow/event-graph';
874
+ import { planExecution, graphToMermaid, flowToMermaid } from 'yaml-flow/event-graph';
875
+ import { loadGraphConfig, validateGraphConfig, exportGraphConfig } from 'yaml-flow/event-graph';
876
+ import { validateGraph } from 'yaml-flow/event-graph';
764
877
  import { TASK_STATUS, COMPLETION_STRATEGIES, CONFLICT_STRATEGIES } from 'yaml-flow/event-graph';
765
878
 
766
879
  // Stores
@@ -808,6 +921,14 @@ import { FlowEngine, createEngine } from 'yaml-flow'; // aliases for StepMachin
808
921
  | `isExecutionComplete(graph, state)` | Check completion against configured strategy |
809
922
  | `detectStuckState({graph, state, ...})` | Check if execution is stuck |
810
923
  | `addDynamicTask(graph, name, config)` | Immutably add a task to a graph config |
924
+ | `planExecution(graph)` | Dry-run: compute phases, parallelism, conflicts, unreachable tokens |
925
+ | `graphToMermaid(graph, options?)` | Generate Mermaid dependency diagram from an event-graph |
926
+ | `flowToMermaid(flow, options?)` | Generate Mermaid flowchart from a step-machine |
927
+ | `loadGraphConfig(source)` | Load + validate a YAML/JSON/URL graph config |
928
+ | `validateGraphConfig(config)` | Validate a GraphConfig, returns error strings |
929
+ | `exportGraphConfig(config, options?)` | Export a GraphConfig to JSON or YAML string |
930
+ | `exportGraphConfigToFile(config, path)` | Export a GraphConfig to a file |
931
+ | `validateGraph(graph)` | Semantic validation: cycles, dangling requires, unreachable goals, conflicts |
811
932
 
812
933
  ### Event Types (for `apply()`)
813
934
 
@@ -1,3 +1,5 @@
1
+ import { e as StepFlowConfig } from './types-FZ_eyErS.cjs';
2
+
1
3
  /**
2
4
  * Event Graph — Core Types
3
5
  *
@@ -311,6 +313,181 @@ declare function detectStuckState(params: {
311
313
  completionResult?: CompletionResult;
312
314
  }): StuckDetection;
313
315
 
316
+ /**
317
+ * Event Graph — Execution Plan (Dry Run)
318
+ *
319
+ * Compute the full execution plan from a GraphConfig without running anything.
320
+ * Shows phases (what runs in parallel), dependency edges, and potential issues.
321
+ *
322
+ * Pure function — no I/O, no side effects.
323
+ */
324
+
325
+ interface ExecutionPlan {
326
+ /** Ordered phases — tasks within a phase can run in parallel */
327
+ phases: string[][];
328
+ /** Dependency edges: taskName → tasks it depends on */
329
+ dependencies: Record<string, string[]>;
330
+ /** Tasks that provide conflicts (same output from multiple tasks) */
331
+ conflicts: Record<string, string[]>;
332
+ /** Tasks that have no requires (entry points) */
333
+ entryPoints: string[];
334
+ /** Tasks that nothing depends on (leaf nodes) */
335
+ leafTasks: string[];
336
+ /** Tokens required but not produced by any task */
337
+ unreachableTokens: string[];
338
+ /** Tasks blocked by unreachable tokens */
339
+ blockedTasks: string[];
340
+ /** Total number of phases (depth of the graph) */
341
+ depth: number;
342
+ /** Max parallelism (widest phase) */
343
+ maxParallelism: number;
344
+ }
345
+ /**
346
+ * Compute a full execution plan from a graph config.
347
+ *
348
+ * Shows the order tasks would execute, what can run in parallel,
349
+ * where conflicts exist, and what's unreachable — all without
350
+ * actually running anything.
351
+ *
352
+ * @param graph - The event-graph configuration
353
+ * @returns ExecutionPlan with phases, dependencies, conflicts, and diagnostics
354
+ */
355
+ declare function planExecution(graph: GraphConfig): ExecutionPlan;
356
+
357
+ /**
358
+ * Mermaid Diagram Export
359
+ *
360
+ * Generate Mermaid diagram strings from GraphConfig (event-graph)
361
+ * and StepFlowConfig (step-machine). Useful for documentation,
362
+ * debugging, and CI reports.
363
+ *
364
+ * Pure functions — no I/O, no side effects.
365
+ */
366
+
367
+ interface MermaidOptions {
368
+ /** Diagram direction: TB (top-bottom), LR (left-right), etc. Default: 'TD' */
369
+ direction?: 'TD' | 'TB' | 'LR' | 'RL' | 'BT';
370
+ /** Show token labels on edges. Default: true */
371
+ showTokens?: boolean;
372
+ /** Title comment at top. Default: graph.id or 'Event Graph' */
373
+ title?: string;
374
+ }
375
+ /**
376
+ * Generate a Mermaid dependency graph from an event-graph config.
377
+ *
378
+ * Tasks are nodes. Edges represent token dependencies:
379
+ * if task B requires token X and task A provides X, then A --> B.
380
+ *
381
+ * @param graph - Event graph configuration
382
+ * @param options - Diagram options
383
+ * @returns Mermaid diagram string
384
+ */
385
+ declare function graphToMermaid(graph: GraphConfig, options?: MermaidOptions): string;
386
+ /**
387
+ * Generate a Mermaid flowchart from a step-machine config.
388
+ *
389
+ * Steps are nodes. Transitions are labeled edges.
390
+ * Terminal states are shown as filled/rounded nodes.
391
+ *
392
+ * @param flow - Step machine flow configuration
393
+ * @param options - Diagram options
394
+ * @returns Mermaid diagram string
395
+ */
396
+ declare function flowToMermaid(flow: StepFlowConfig, options?: MermaidOptions): string;
397
+
398
+ /**
399
+ * Event Graph — Loader & Exporter
400
+ *
401
+ * Load GraphConfig from YAML/JSON files or strings, and export back.
402
+ * Mirrors the step-machine's loadStepFlow/validateStepFlowConfig pattern.
403
+ */
404
+
405
+ /**
406
+ * Validate a GraphConfig object. Returns an array of error strings.
407
+ * Empty array = valid config.
408
+ */
409
+ declare function validateGraphConfig(config: unknown): string[];
410
+ /**
411
+ * Load a GraphConfig from a file path, URL, JSON string, or object.
412
+ * Validates the config and throws if invalid.
413
+ *
414
+ * @param source - File path (.yaml/.yml/.json), URL, JSON string, or GraphConfig object
415
+ * @returns Validated GraphConfig
416
+ */
417
+ declare function loadGraphConfig(source: string | GraphConfig): Promise<GraphConfig>;
418
+ interface ExportOptions {
419
+ /** Output format. Default: 'json' */
420
+ format?: 'json' | 'yaml';
421
+ /** Indentation for JSON (default: 2) or YAML */
422
+ indent?: number;
423
+ }
424
+ /**
425
+ * Export a GraphConfig to a JSON or YAML string.
426
+ *
427
+ * @param config - The graph configuration to export
428
+ * @param options - Export format options
429
+ * @returns Serialized config string
430
+ */
431
+ declare function exportGraphConfig(config: GraphConfig, options?: ExportOptions): string;
432
+ /**
433
+ * Export a GraphConfig to a file.
434
+ *
435
+ * @param config - The graph configuration to export
436
+ * @param filePath - Output file path (.json or .yaml/.yml)
437
+ * @param options - Export format options (format auto-detected from extension if not specified)
438
+ */
439
+ declare function exportGraphConfigToFile(config: GraphConfig, filePath: string, options?: ExportOptions): Promise<void>;
440
+
441
+ /**
442
+ * Event Graph — Semantic Graph Validation
443
+ *
444
+ * Validates the logical correctness of a static graph configuration.
445
+ * Unlike validateGraphConfig() which checks JSON structure, this checks:
446
+ * - Dangling requires (tokens no task produces)
447
+ * - Circular dependencies
448
+ * - Provide conflicts (multiple tasks producing same token)
449
+ * - Unreachable goal tokens
450
+ * - Dead-end tasks (no provides)
451
+ * - Self-dependencies
452
+ * - Orphaned tasks (disconnected from the graph)
453
+ *
454
+ * Pure function — config in, diagnostics out.
455
+ */
456
+
457
+ type IssueSeverity = 'error' | 'warning' | 'info';
458
+ interface GraphIssue {
459
+ /** Severity: error = will break execution, warning = may cause problems, info = notable */
460
+ severity: IssueSeverity;
461
+ /** Machine-readable issue code */
462
+ code: string;
463
+ /** Human-readable description */
464
+ message: string;
465
+ /** Affected task names (if applicable) */
466
+ tasks?: string[];
467
+ /** Affected tokens (if applicable) */
468
+ tokens?: string[];
469
+ }
470
+ interface GraphValidationResult {
471
+ /** true if no errors (warnings/info are allowed) */
472
+ valid: boolean;
473
+ /** All issues found */
474
+ issues: GraphIssue[];
475
+ /** Just the errors */
476
+ errors: GraphIssue[];
477
+ /** Just the warnings */
478
+ warnings: GraphIssue[];
479
+ }
480
+ /**
481
+ * Validate the semantic correctness of a static event-graph configuration.
482
+ *
483
+ * Checks for logical issues that would cause execution failures, stuck states,
484
+ * or unexpected behavior. Does NOT check JSON structure (use validateGraphConfig for that).
485
+ *
486
+ * @param graph - The event-graph configuration to validate
487
+ * @returns Validation result with categorized issues
488
+ */
489
+ declare function validateGraph(graph: GraphConfig): GraphValidationResult;
490
+
314
491
  /**
315
492
  * Event Graph — Constants
316
493
  */
@@ -327,4 +504,4 @@ declare const DEFAULTS: {
327
504
  readonly MAX_ITERATIONS: 1000;
328
505
  };
329
506
 
330
- export { getRepeatableMax as $, type AgentActionEvent as A, getAllTasks as B, COMPLETION_STRATEGIES as C, DEFAULTS as D, EXECUTION_MODES as E, getCandidateTasks as F, type GraphConfig as G, getProvides as H, type InjectTokensEvent as I, getRequires as J, getTask as K, hasTask as L, isExecutionComplete as M, isNonActiveTask as N, isRepeatableTask as O, isTaskCompleted as P, isTaskRunning as Q, next as R, type SchedulerResult as S, type TaskConfig as T, type RepeatableConfig as U, type TaskCircuitBreakerConfig as V, type TaskMessage as W, type TaskProgressEvent as X, type TaskRetryConfig as Y, addKeyToProvides as Z, addKeyToRequires as _, CONFLICT_STRATEGIES as a, groupTasksByProvides as a0, hasOutputConflict as a1, removeKeyFromProvides as a2, removeKeyFromRequires as a3, type CompletionResult as b, type CompletionStrategy as c, type ConflictStrategy as d, EXECUTION_STATUS as e, type ExecutionConfig as f, type ExecutionMode as g, type ExecutionState as h, type ExecutionStatus as i, type GraphEvent as j, type GraphSettings as k, type StuckDetection as l, TASK_STATUS as m, type TaskCompletedEvent as n, type TaskCreationEvent as o, type TaskFailedEvent as p, type TaskStartedEvent as q, type TaskState as r, type TaskStatus as s, addDynamicTask as t, apply as u, applyAll as v, computeAvailableOutputs as w, createDefaultTaskState as x, createInitialExecutionState as y, detectStuckState as z };
507
+ export { isTaskCompleted as $, type AgentActionEvent as A, applyAll as B, COMPLETION_STRATEGIES as C, DEFAULTS as D, EXECUTION_MODES as E, computeAvailableOutputs as F, type GraphConfig as G, createDefaultTaskState as H, type InjectTokensEvent as I, createInitialExecutionState as J, detectStuckState as K, exportGraphConfig as L, type MermaidOptions as M, exportGraphConfigToFile as N, flowToMermaid as O, getAllTasks as P, getCandidateTasks as Q, getProvides as R, type SchedulerResult as S, type TaskConfig as T, getRequires as U, getTask as V, graphToMermaid as W, hasTask as X, isExecutionComplete as Y, isNonActiveTask as Z, isRepeatableTask as _, CONFLICT_STRATEGIES as a, isTaskRunning as a0, loadGraphConfig as a1, next as a2, planExecution as a3, validateGraph as a4, validateGraphConfig as a5, type RepeatableConfig as a6, type TaskCircuitBreakerConfig as a7, type TaskMessage as a8, type TaskProgressEvent as a9, type TaskRetryConfig as aa, addKeyToProvides as ab, addKeyToRequires as ac, getRepeatableMax as ad, groupTasksByProvides as ae, hasOutputConflict as af, removeKeyFromProvides as ag, removeKeyFromRequires as ah, type CompletionResult as b, type CompletionStrategy as c, type ConflictStrategy as d, EXECUTION_STATUS as e, type ExecutionConfig as f, type ExecutionMode as g, type ExecutionPlan as h, type ExecutionState as i, type ExecutionStatus as j, type ExportOptions as k, type GraphEvent as l, type GraphIssue as m, type GraphSettings as n, type GraphValidationResult as o, type IssueSeverity as p, type StuckDetection as q, TASK_STATUS as r, type TaskCompletedEvent as s, type TaskCreationEvent as t, type TaskFailedEvent as u, type TaskStartedEvent as v, type TaskState as w, type TaskStatus as x, addDynamicTask as y, apply as z };
@@ -1,3 +1,5 @@
1
+ import { e as StepFlowConfig } from './types-FZ_eyErS.js';
2
+
1
3
  /**
2
4
  * Event Graph — Core Types
3
5
  *
@@ -311,6 +313,181 @@ declare function detectStuckState(params: {
311
313
  completionResult?: CompletionResult;
312
314
  }): StuckDetection;
313
315
 
316
+ /**
317
+ * Event Graph — Execution Plan (Dry Run)
318
+ *
319
+ * Compute the full execution plan from a GraphConfig without running anything.
320
+ * Shows phases (what runs in parallel), dependency edges, and potential issues.
321
+ *
322
+ * Pure function — no I/O, no side effects.
323
+ */
324
+
325
+ interface ExecutionPlan {
326
+ /** Ordered phases — tasks within a phase can run in parallel */
327
+ phases: string[][];
328
+ /** Dependency edges: taskName → tasks it depends on */
329
+ dependencies: Record<string, string[]>;
330
+ /** Tasks that provide conflicts (same output from multiple tasks) */
331
+ conflicts: Record<string, string[]>;
332
+ /** Tasks that have no requires (entry points) */
333
+ entryPoints: string[];
334
+ /** Tasks that nothing depends on (leaf nodes) */
335
+ leafTasks: string[];
336
+ /** Tokens required but not produced by any task */
337
+ unreachableTokens: string[];
338
+ /** Tasks blocked by unreachable tokens */
339
+ blockedTasks: string[];
340
+ /** Total number of phases (depth of the graph) */
341
+ depth: number;
342
+ /** Max parallelism (widest phase) */
343
+ maxParallelism: number;
344
+ }
345
+ /**
346
+ * Compute a full execution plan from a graph config.
347
+ *
348
+ * Shows the order tasks would execute, what can run in parallel,
349
+ * where conflicts exist, and what's unreachable — all without
350
+ * actually running anything.
351
+ *
352
+ * @param graph - The event-graph configuration
353
+ * @returns ExecutionPlan with phases, dependencies, conflicts, and diagnostics
354
+ */
355
+ declare function planExecution(graph: GraphConfig): ExecutionPlan;
356
+
357
+ /**
358
+ * Mermaid Diagram Export
359
+ *
360
+ * Generate Mermaid diagram strings from GraphConfig (event-graph)
361
+ * and StepFlowConfig (step-machine). Useful for documentation,
362
+ * debugging, and CI reports.
363
+ *
364
+ * Pure functions — no I/O, no side effects.
365
+ */
366
+
367
+ interface MermaidOptions {
368
+ /** Diagram direction: TB (top-bottom), LR (left-right), etc. Default: 'TD' */
369
+ direction?: 'TD' | 'TB' | 'LR' | 'RL' | 'BT';
370
+ /** Show token labels on edges. Default: true */
371
+ showTokens?: boolean;
372
+ /** Title comment at top. Default: graph.id or 'Event Graph' */
373
+ title?: string;
374
+ }
375
+ /**
376
+ * Generate a Mermaid dependency graph from an event-graph config.
377
+ *
378
+ * Tasks are nodes. Edges represent token dependencies:
379
+ * if task B requires token X and task A provides X, then A --> B.
380
+ *
381
+ * @param graph - Event graph configuration
382
+ * @param options - Diagram options
383
+ * @returns Mermaid diagram string
384
+ */
385
+ declare function graphToMermaid(graph: GraphConfig, options?: MermaidOptions): string;
386
+ /**
387
+ * Generate a Mermaid flowchart from a step-machine config.
388
+ *
389
+ * Steps are nodes. Transitions are labeled edges.
390
+ * Terminal states are shown as filled/rounded nodes.
391
+ *
392
+ * @param flow - Step machine flow configuration
393
+ * @param options - Diagram options
394
+ * @returns Mermaid diagram string
395
+ */
396
+ declare function flowToMermaid(flow: StepFlowConfig, options?: MermaidOptions): string;
397
+
398
+ /**
399
+ * Event Graph — Loader & Exporter
400
+ *
401
+ * Load GraphConfig from YAML/JSON files or strings, and export back.
402
+ * Mirrors the step-machine's loadStepFlow/validateStepFlowConfig pattern.
403
+ */
404
+
405
+ /**
406
+ * Validate a GraphConfig object. Returns an array of error strings.
407
+ * Empty array = valid config.
408
+ */
409
+ declare function validateGraphConfig(config: unknown): string[];
410
+ /**
411
+ * Load a GraphConfig from a file path, URL, JSON string, or object.
412
+ * Validates the config and throws if invalid.
413
+ *
414
+ * @param source - File path (.yaml/.yml/.json), URL, JSON string, or GraphConfig object
415
+ * @returns Validated GraphConfig
416
+ */
417
+ declare function loadGraphConfig(source: string | GraphConfig): Promise<GraphConfig>;
418
+ interface ExportOptions {
419
+ /** Output format. Default: 'json' */
420
+ format?: 'json' | 'yaml';
421
+ /** Indentation for JSON (default: 2) or YAML */
422
+ indent?: number;
423
+ }
424
+ /**
425
+ * Export a GraphConfig to a JSON or YAML string.
426
+ *
427
+ * @param config - The graph configuration to export
428
+ * @param options - Export format options
429
+ * @returns Serialized config string
430
+ */
431
+ declare function exportGraphConfig(config: GraphConfig, options?: ExportOptions): string;
432
+ /**
433
+ * Export a GraphConfig to a file.
434
+ *
435
+ * @param config - The graph configuration to export
436
+ * @param filePath - Output file path (.json or .yaml/.yml)
437
+ * @param options - Export format options (format auto-detected from extension if not specified)
438
+ */
439
+ declare function exportGraphConfigToFile(config: GraphConfig, filePath: string, options?: ExportOptions): Promise<void>;
440
+
441
+ /**
442
+ * Event Graph — Semantic Graph Validation
443
+ *
444
+ * Validates the logical correctness of a static graph configuration.
445
+ * Unlike validateGraphConfig() which checks JSON structure, this checks:
446
+ * - Dangling requires (tokens no task produces)
447
+ * - Circular dependencies
448
+ * - Provide conflicts (multiple tasks producing same token)
449
+ * - Unreachable goal tokens
450
+ * - Dead-end tasks (no provides)
451
+ * - Self-dependencies
452
+ * - Orphaned tasks (disconnected from the graph)
453
+ *
454
+ * Pure function — config in, diagnostics out.
455
+ */
456
+
457
+ type IssueSeverity = 'error' | 'warning' | 'info';
458
+ interface GraphIssue {
459
+ /** Severity: error = will break execution, warning = may cause problems, info = notable */
460
+ severity: IssueSeverity;
461
+ /** Machine-readable issue code */
462
+ code: string;
463
+ /** Human-readable description */
464
+ message: string;
465
+ /** Affected task names (if applicable) */
466
+ tasks?: string[];
467
+ /** Affected tokens (if applicable) */
468
+ tokens?: string[];
469
+ }
470
+ interface GraphValidationResult {
471
+ /** true if no errors (warnings/info are allowed) */
472
+ valid: boolean;
473
+ /** All issues found */
474
+ issues: GraphIssue[];
475
+ /** Just the errors */
476
+ errors: GraphIssue[];
477
+ /** Just the warnings */
478
+ warnings: GraphIssue[];
479
+ }
480
+ /**
481
+ * Validate the semantic correctness of a static event-graph configuration.
482
+ *
483
+ * Checks for logical issues that would cause execution failures, stuck states,
484
+ * or unexpected behavior. Does NOT check JSON structure (use validateGraphConfig for that).
485
+ *
486
+ * @param graph - The event-graph configuration to validate
487
+ * @returns Validation result with categorized issues
488
+ */
489
+ declare function validateGraph(graph: GraphConfig): GraphValidationResult;
490
+
314
491
  /**
315
492
  * Event Graph — Constants
316
493
  */
@@ -327,4 +504,4 @@ declare const DEFAULTS: {
327
504
  readonly MAX_ITERATIONS: 1000;
328
505
  };
329
506
 
330
- export { getRepeatableMax as $, type AgentActionEvent as A, getAllTasks as B, COMPLETION_STRATEGIES as C, DEFAULTS as D, EXECUTION_MODES as E, getCandidateTasks as F, type GraphConfig as G, getProvides as H, type InjectTokensEvent as I, getRequires as J, getTask as K, hasTask as L, isExecutionComplete as M, isNonActiveTask as N, isRepeatableTask as O, isTaskCompleted as P, isTaskRunning as Q, next as R, type SchedulerResult as S, type TaskConfig as T, type RepeatableConfig as U, type TaskCircuitBreakerConfig as V, type TaskMessage as W, type TaskProgressEvent as X, type TaskRetryConfig as Y, addKeyToProvides as Z, addKeyToRequires as _, CONFLICT_STRATEGIES as a, groupTasksByProvides as a0, hasOutputConflict as a1, removeKeyFromProvides as a2, removeKeyFromRequires as a3, type CompletionResult as b, type CompletionStrategy as c, type ConflictStrategy as d, EXECUTION_STATUS as e, type ExecutionConfig as f, type ExecutionMode as g, type ExecutionState as h, type ExecutionStatus as i, type GraphEvent as j, type GraphSettings as k, type StuckDetection as l, TASK_STATUS as m, type TaskCompletedEvent as n, type TaskCreationEvent as o, type TaskFailedEvent as p, type TaskStartedEvent as q, type TaskState as r, type TaskStatus as s, addDynamicTask as t, apply as u, applyAll as v, computeAvailableOutputs as w, createDefaultTaskState as x, createInitialExecutionState as y, detectStuckState as z };
507
+ export { isTaskCompleted as $, type AgentActionEvent as A, applyAll as B, COMPLETION_STRATEGIES as C, DEFAULTS as D, EXECUTION_MODES as E, computeAvailableOutputs as F, type GraphConfig as G, createDefaultTaskState as H, type InjectTokensEvent as I, createInitialExecutionState as J, detectStuckState as K, exportGraphConfig as L, type MermaidOptions as M, exportGraphConfigToFile as N, flowToMermaid as O, getAllTasks as P, getCandidateTasks as Q, getProvides as R, type SchedulerResult as S, type TaskConfig as T, getRequires as U, getTask as V, graphToMermaid as W, hasTask as X, isExecutionComplete as Y, isNonActiveTask as Z, isRepeatableTask as _, CONFLICT_STRATEGIES as a, isTaskRunning as a0, loadGraphConfig as a1, next as a2, planExecution as a3, validateGraph as a4, validateGraphConfig as a5, type RepeatableConfig as a6, type TaskCircuitBreakerConfig as a7, type TaskMessage as a8, type TaskProgressEvent as a9, type TaskRetryConfig as aa, addKeyToProvides as ab, addKeyToRequires as ac, getRepeatableMax as ad, groupTasksByProvides as ae, hasOutputConflict as af, removeKeyFromProvides as ag, removeKeyFromRequires as ah, type CompletionResult as b, type CompletionStrategy as c, type ConflictStrategy as d, EXECUTION_STATUS as e, type ExecutionConfig as f, type ExecutionMode as g, type ExecutionPlan as h, type ExecutionState as i, type ExecutionStatus as j, type ExportOptions as k, type GraphEvent as l, type GraphIssue as m, type GraphSettings as n, type GraphValidationResult as o, type IssueSeverity as p, type StuckDetection as q, TASK_STATUS as r, type TaskCompletedEvent as s, type TaskCreationEvent as t, type TaskFailedEvent as u, type TaskStartedEvent as v, type TaskState as w, type TaskStatus as x, addDynamicTask as y, apply as z };