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
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
//! Build pipeline for populating the unified graph from parsed source files.
//!
//! This module implements the 5-pass build pipeline:
//!
//! - **Pass 1**: Extract nodes from AST (`GraphBuilder` emits `NodeEntry` + DEFINES edges)
//! - **Pass 2**: Enrich node metadata (visibility, async, docs) during graph build
//! - **Pass 3**: Create intra-file edges (CALLS, REFERENCES within file)
//! - **Pass 4**: Cross-file linking (IMPORTS, cross-file CALLS via `ExportMap`)
//! - **Pass 5**: Cross-language linking (FFI declarations → C/C++ functions, HTTP requests → endpoints)
//!
//! # Architecture
//!
//! The build pipeline takes parsed ASTs from language plugins and populates
//! the unified graph (`CodeGraph`). Each pass operates on the graph in sequence:
//!
//! ```text
//! LanguagePlugin::build_unified_graph() → nodes + edges
//! ↓
//! ┌──────────────────────────────────────┐
//! │ Pass 1: AST to Nodes │
//! │ - GraphBuilder emits NodeEntry │
//! │ - File→Node DEFINES edges │
//! └──────────────────────────────────────┘
//! ↓
//! ┌──────────────────────────────────────┐
//! │ Pass 2: Enrichment │
//! │ - Add visibility, async flags │
//! │ - Add doc comments │
//! └──────────────────────────────────────┘
//! ↓
//! ┌──────────────────────────────────────┐
//! │ Pass 3: Intra-file Edges │
//! │ - CALLS edges within file │
//! │ - REFERENCES edges within file │
//! └──────────────────────────────────────┘
//! ↓
//! ┌──────────────────────────────────────┐
//! │ Pass 4: Cross-file Linking │
//! │ - IMPORTS edges │
//! │ - Cross-file CALLS via ExportMap │
//! └──────────────────────────────────────┘
//! ↓
//! ┌──────────────────────────────────────┐
//! │ Pass 5: Cross-language Linking │
//! │ - FFI declaration → C/C++ function │
//! │ - HTTP request → route endpoint │
//! └──────────────────────────────────────┘
//! ↓
//! CodeGraph (nodes + edges populated)
//! ```
//!
//! # Transactional Building
//!
//! The [`StagingGraph`] provides transactional semantics for builds:
//! - Collect all changes in a staging buffer
//! - Commit atomically on success
//! - Rollback (discard) on failure, leaving graph unchanged
//!
//! # Incremental Updates
//!
//! The [`incremental`] module provides efficient partial updates:
//! - Remove all nodes from a deleted file
//! - Add edges without full rebuild
// === Graph Build Phase Names (for progress reporting) ===
// These are `&'static str` constants to avoid allocations in progress events.
/// Phase 1: Extract nodes from symbols (AST to `NodeEntry` conversion)
pub const GRAPH_PHASE_1_NAME: &str = "AST extraction";
/// Phase 2: Enrich node metadata (visibility, async, docs)
pub const GRAPH_PHASE_2_NAME: &str = "Metadata enrichment";
/// Phase 3: Create intra-file edges (calls/references within file)
pub const GRAPH_PHASE_3_NAME: &str = "Intra-file edges";
/// Phase 4: Cross-file linking (imports, cross-file calls)
pub const GRAPH_PHASE_4_NAME: &str = "Cross-file resolution";
/// Phase 5: Cross-language linking (FFI calls, HTTP request→endpoint)
pub const GRAPH_PHASE_5_NAME: &str = "Cross-language linking";
// === Save Component Names (for progress reporting) ===
/// Component: Node index (main .sqry-index file)
pub const SAVE_COMPONENT_SYMBOLS: &str = "symbols";
/// Component: Trigram index for fuzzy search
pub const SAVE_COMPONENT_TRIGRAMS: &str = "trigrams";
/// Component: Relations (imports, references)
pub const SAVE_COMPONENT_RELATIONS: &str = "relations";
/// Component: Unified code graph snapshot
pub const SAVE_COMPONENT_GRAPH: &str = "unified graph";
// Re-exports
pub use ;
pub use ;
pub use ;
pub use ;
pub use ;
pub use ;
pub use ;
pub use ;
pub use GraphBuildProgressTracker;
pub use ;
// Body hash utilities for duplicate detection
pub use ;