1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
//! Analyzed AST - Phase 2 of the Two-Phase IR Architecture.
//!
//! This module contains the validated, resolved AST types. All string
//! references have been replaced with interned identifiers (TaskId, etc.),
//! and all semantic validations have passed.
//!
//! # Two-Phase Architecture
//!
//! ```text
//! ┌─────────────────┐
//! │ YAML Source │ workflow.nika.yaml
//! └────────┬────────┘
//! │ marked_yaml
//! ▼
//! ┌─────────────────┐
//! │ raw::Workflow │ (see ast/raw/)
//! │ ├── Spanned<T> │ All nodes have line:col
//! │ └── strings │ Unresolved references
//! └────────┬────────┘
//! │ analyze() ← Phase 2 happens here
//! ▼
//! ┌─────────────────────┐
//! │ analyzed::Workflow │ ← THIS MODULE
//! │ ├── TaskId(u32) │ Interned identifiers
//! │ ├── resolved refs │ All references validated
//! │ └── validated │ No cycles, unique IDs
//! └─────────────────────┘
//! ```
//!
//! # Benefits
//!
//! 1. **O(1) Comparison**: TaskId(u32) vs String comparison
//! 2. **Memory Efficient**: Strings stored once in lookup tables
//! 3. **Validated**: No cycles, no duplicate IDs, valid schema
//! 4. **Ready for Execution**: Can be directly consumed by runtime
//!
//! # Example
//!
//! ```ignore
//! use nika::ast::raw;
//! use nika::ast::analyzed::{AnalyzedWorkflow, analyze};
//! use nika::source::SourceRegistry;
//!
//! let mut sources = SourceRegistry::new();
//! let file_id = sources.add_file("workflow.yaml", content);
//!
//! // Phase 1: Parse to raw AST
//! let raw_workflow = raw::parse(&content, file_id)?;
//!
//! // Phase 2: Analyze to resolved AST
//! let analyzed = analyze(&sources, raw_workflow)?;
//!
//! // Now use analyzed workflow
//! for task in analyzed.iter_tasks() {
//! println!("Task {}: {:?}", task.name, task.action.verb_name());
//! }
//! ```
pub use ;
pub use ;
pub use ;