pub struct CodeGraph {
pub cfg_ops: CfgOps,
/* private fields */
}Expand description
Graph database wrapper for Magellan
Provides deterministic, idempotent operations for persisting code facts.
Fields§
§cfg_ops: CfgOpsCFG block operations module
Implementations§
Source§impl CodeGraph
impl CodeGraph
Sourcepub fn resolve_symbol_entity(
&self,
symbol_id_or_fqn: &str,
) -> Result<i64, Error>
pub fn resolve_symbol_entity( &self, symbol_id_or_fqn: &str, ) -> Result<i64, Error>
Resolve a stable symbol ID or FQN to its entity ID
First tries to lookup by symbol_id (32-char BLAKE3 hash). If not found, falls back to FQN lookup for convenience.
§Arguments
symbol_id_or_fqn- Stable symbol ID (32-char BLAKE3 hash) or FQN
§Returns
The entity ID (i64 database row ID) for the symbol
§Errors
Returns an error if the symbol is not found in the database
Sourcepub fn symbol_by_entity_id(&self, entity_id: i64) -> Result<SymbolInfo, Error>
pub fn symbol_by_entity_id(&self, entity_id: i64) -> Result<SymbolInfo, Error>
Sourcepub fn reachable_symbols(
&self,
symbol_id: &str,
_max_depth: Option<usize>,
) -> Result<Vec<SymbolInfo>, Error>
pub fn reachable_symbols( &self, symbol_id: &str, _max_depth: Option<usize>, ) -> Result<Vec<SymbolInfo>, Error>
Find all symbols reachable from a given symbol (forward reachability)
Computes the transitive closure of the call graph starting from the specified symbol. Returns all symbols that can be reached by following CALLS edges from the starting symbol.
§Graph View
This operates on the call graph (CALLS edges only), not other edge types. The starting symbol itself is NOT included in the results.
§Arguments
symbol_id- Stable symbol ID to start from (or FQN as fallback)max_depth- Optional maximum depth limit (None = unlimited)
§Returns
Vector of SymbolInfo for reachable symbols, sorted deterministically
§Example
```no_run
§use magellan::CodeGraph;
§let mut graph = CodeGraph::open(“test.db”).unwrap();
// Find all functions called from main (directly or indirectly) let reachable = graph.reachable_symbols(“main”, None)?; ```
Sourcepub fn reverse_reachable_symbols(
&self,
symbol_id: &str,
_max_depth: Option<usize>,
) -> Result<Vec<SymbolInfo>, Error>
pub fn reverse_reachable_symbols( &self, symbol_id: &str, _max_depth: Option<usize>, ) -> Result<Vec<SymbolInfo>, Error>
Find all symbols that can reach a given symbol (reverse reachability)
Computes the reverse transitive closure of the call graph. Returns all symbols from which the specified symbol can be reached by following CALLS edges (i.e., all callers that directly or indirectly call this symbol).
§Graph View
This operates on the call graph (CALLS edges only).
§Arguments
symbol_id- Stable symbol ID to analyzemax_depth- Optional maximum depth limit (None = unlimited)
§Returns
Vector of SymbolInfo for symbols that can reach the target, sorted deterministically
§Example
```no_run
§use magellan::CodeGraph;
§let mut graph = CodeGraph::open(“test.db”).unwrap();
// Find all functions that directly or indirectly call ‘helper_function’ let callers = graph.reverse_reachable_symbols(“helper_symbol_id”, None)?; ```
Sourcepub fn dead_symbols(
&self,
entry_symbol_id: &str,
) -> Result<Vec<DeadSymbol>, Error>
pub fn dead_symbols( &self, entry_symbol_id: &str, ) -> Result<Vec<DeadSymbol>, Error>
Find dead code unreachable from an entry point symbol
Identifies all symbols in the call graph that cannot be reached from
the specified entry point (e.g., main, test_main). This is useful
for detecting unused functions and dead code.
§Graph View
This operates on the call graph (CALLS edges only). Symbols not participating in call edges are not considered.
§Limitations
- Only considers the call graph. Symbols called via reflection, function pointers, or dynamic dispatch may be incorrectly flagged.
- Test functions, benchmark code, and platform-specific code may appear as dead code if not reachable from the specified entry point.
§Arguments
entry_symbol_id- Stable symbol ID of the entry point (e.g., main function)
§Returns
Vector of DeadSymbol for unreachable symbols, sorted deterministically
§Example
```no_run
§use magellan::CodeGraph;
§let mut graph = CodeGraph::open(“test.db”).unwrap();
// Find all functions unreachable from main let dead = graph.dead_symbols(“main_symbol_id”)?; for dead_symbol in dead { println!(“Dead: {} in {} ({})”, dead_symbol.symbol.fqn.as_deref().unwrap_or(“?”), dead_symbol.symbol.file_path, dead_symbol.reason); } ```
Sourcepub fn detect_cycles(&self) -> Result<CycleReport, Error>
pub fn detect_cycles(&self) -> Result<CycleReport, Error>
Detect cycles in the call graph using SCC decomposition
Finds all strongly connected components (SCCs) with more than one member, which indicate cycles or mutual recursion in the call graph.
§Graph View
This operates on the call graph (CALLS edges only).
§Cycle Detection
Uses Tarjan’s SCC algorithm to find strongly connected components. Only SCCs with more than one member are reported as cycles (MutualRecursion). Single-node SCCs are not cycles (unless they have self-loops).
§Returns
CycleReport containing all detected cycles
§Example
```no_run
§use magellan::CodeGraph;
§let mut graph = CodeGraph::open(“test.db”).unwrap();
let report = graph.detect_cycles()?; println!(“Found {} cycles”, report.total_count); for cycle in &report.cycles { println!(“Cycle with {} members:”, cycle.members.len()); for member in &cycle.members { println!(“ - {}“, member.fqn.as_deref().unwrap_or(”?“)); } } ```
Sourcepub fn find_cycles_containing(
&self,
symbol_id: &str,
) -> Result<Vec<Cycle>, Error>
pub fn find_cycles_containing( &self, symbol_id: &str, ) -> Result<Vec<Cycle>, Error>
Find cycles containing a specific symbol
Returns only the cycles that include the specified symbol in their member set.
§Arguments
symbol_id- Stable symbol ID or FQN to search for
§Returns
Vector of Cycle containing the specified symbol
§Example
```no_run
§use magellan::CodeGraph;
§let mut graph = CodeGraph::open(“test.db”).unwrap();
let cycles = graph.find_cycles_containing(“problematic_function”)?; if cycles.is_empty() { println!(“No cycles found containing this symbol”); } else { println!(“Found {} cycles containing this symbol”, cycles.len()); } ```
Sourcepub fn condense_call_graph(&self) -> Result<CondensationResult, Error>
pub fn condense_call_graph(&self) -> Result<CondensationResult, Error>
Condense the call graph by collapsing SCCs into supernodes
Creates a condensation DAG by collapsing each strongly connected component into a single “supernode”. The resulting graph is always acyclic, making it suitable for topological analysis and safe refactoring.
§Graph View
This operates on the call graph (CALLS edges only).
§Use Cases
- Topological Sorting: Condensation graph is a DAG, enabling topo sort
- Mutual Recursion Detection: Large supernodes indicate tight coupling
- Impact Analysis: Changing one symbol affects its entire SCC
§Returns
CondensationResult with the condensed DAG and symbol-to-supernode mapping
§Example
```no_run
§use magellan::CodeGraph;
§let mut graph = CodeGraph::open(“test.db”).unwrap();
let condensed = graph.condense_call_graph()?;
println!(“Condensed to {} supernodes”, condensed.graph.supernodes.len()); println!(“Condensed graph has {} edges”, condensed.graph.edges.len());
// Check which SCC a symbol belongs to if let Some(supernode_id) = condensed.original_to_supernode.get(“some_symbol_id”) { println!(“Symbol is in SCC {}”, supernode_id); } ```
Sourcepub fn backward_slice(&self, symbol_id: &str) -> Result<SliceResult, Error>
pub fn backward_slice(&self, symbol_id: &str) -> Result<SliceResult, Error>
Compute a backward program slice (what affects this symbol)
Returns all symbols that can affect the target symbol through the call graph. This is useful for bug isolation - finding all code that could influence a given symbol’s behavior.
§Graph View (Call-Graph Fallback)
Current implementation uses call-graph reachability as a fallback. Full CFG-based program slicing requires control dependence graph (CDG) which needs post-dominators and AST CFG integration not yet available.
The fallback implementation uses reverse reachability on the call graph, finding all callers that directly or indirectly call this symbol.
§Limitations
- Uses call-graph reachability instead of full CFG-based slicing
- Does not include data flow dependencies within functions
- Does not include control flow from conditionals/loops
- Full slicing will be available when AST CFG edges are integrated
§Arguments
symbol_id- Stable symbol ID or FQN to slice from
§Returns
SliceResult containing the slice and statistics
§Example
```no_run
§use magellan::CodeGraph;
§let mut graph = CodeGraph::open(“test.db”).unwrap();
// Find what affects ‘helper_function’ let slice_result = graph.backward_slice(“helper_function”)?; println!(“{} symbols affect this function”, slice_result.slice.symbol_count); for symbol in &slice_result.slice.included_symbols { println!(“ - {}“, symbol.fqn.as_deref().unwrap_or(”?“)); } ```
Sourcepub fn forward_slice(&self, symbol_id: &str) -> Result<SliceResult, Error>
pub fn forward_slice(&self, symbol_id: &str) -> Result<SliceResult, Error>
Compute a forward program slice (what this symbol affects)
Returns all symbols that the target symbol can affect through the call graph. This is useful for refactoring safety - finding all code that could be impacted by changes to this symbol.
§Graph View (Call-Graph Fallback)
Current implementation uses call-graph reachability as a fallback. Full CFG-based program slicing requires control dependence graph (CDG) which needs post-dominators and AST CFG integration not yet available.
The fallback implementation uses forward reachability on the call graph, finding all callees that this symbol directly or indirectly calls.
§Limitations
- Uses call-graph reachability instead of full CFG-based slicing
- Does not include data flow dependencies within functions
- Does not include control flow from conditionals/loops
- Full slicing will be available when AST CFG edges are integrated
§Arguments
symbol_id- Stable symbol ID or FQN to slice from
§Returns
SliceResult containing the slice and statistics
§Example
```no_run
§use magellan::CodeGraph;
§let mut graph = CodeGraph::open(“test.db”).unwrap();
// Find what ‘main_function’ affects let slice_result = graph.forward_slice(“main_function”)?; println!(“{} symbols are affected by this function”, slice_result.slice.symbol_count); for symbol in &slice_result.slice.included_symbols { println!(“ - {}“, symbol.fqn.as_deref().unwrap_or(”?“)); } ```
Sourcepub fn enumerate_paths(
&self,
start_symbol_id: &str,
end_symbol_id: Option<&str>,
max_depth: usize,
max_paths: usize,
) -> Result<PathEnumerationResult, Error>
pub fn enumerate_paths( &self, start_symbol_id: &str, end_symbol_id: Option<&str>, max_depth: usize, max_paths: usize, ) -> Result<PathEnumerationResult, Error>
Enumerate execution paths from a starting symbol
Finds all execution paths from start_symbol_id to end_symbol_id (if provided)
or all paths starting from start_symbol_id (if end_symbol_id is None).
Path enumeration uses bounded DFS to prevent infinite traversal in cyclic graphs:
max_depth: Maximum path length (number of edges)max_paths: Maximum number of paths to returnrevisit_cap: Maximum number of times a single node can be revisited (prevents infinite loops)
§Arguments
start_symbol_id- Starting symbol ID or FQNend_symbol_id- Optional ending symbol ID or FQN (if None, enumerates all paths from start)max_depth- Maximum path depth (default: 100)max_paths- Maximum number of paths to return (default: 1000)
§Returns
Returns a PathEnumerationResult containing:
- All discovered paths
- Whether enumeration hit bounds
- Statistics about path lengths and unique symbols
§Example
```no_run
§use magellan::CodeGraph;
§fn main() -> anyhow::Result<()> {
let mut graph = CodeGraph::open(“codegraph.db”)?;
// Find all paths from main to any leaf function let result = graph.enumerate_paths(“main”, None, 50, 100)?;
println!(“Found {} paths”, result.total_enumerated); println!(“Average length: {:.2}”, result.statistics.avg_length); for (i, path) in result.paths.iter().enumerate() { println!(“Path {}: {:?}”, path.symbols.iter().map(|s| s.fqn.as_deref().unwrap_or(“?”)).collect::<Vec<_>>()); }
§Ok(())
§}
```
Source§impl CodeGraph
impl CodeGraph
Sourcepub fn get_ast_nodes_by_file(
&self,
file_path: &str,
) -> Result<Vec<AstNodeWithText>, Error>
pub fn get_ast_nodes_by_file( &self, file_path: &str, ) -> Result<Vec<AstNodeWithText>, Error>
Sourcepub fn get_ast_node_at_position(
&self,
_file_path: &str,
position: usize,
) -> Result<Option<AstNode>, Error>
pub fn get_ast_node_at_position( &self, _file_path: &str, position: usize, ) -> Result<Option<AstNode>, Error>
Source§impl CodeGraph
impl CodeGraph
Sourcepub fn get_entities_by_label(&self, label: &str) -> Result<Vec<i64>, Error>
pub fn get_entities_by_label(&self, label: &str) -> Result<Vec<i64>, Error>
Get all entity IDs that have a specific label
Uses raw SQL to query the graph_labels table directly.
Sourcepub fn get_entities_by_labels(&self, labels: &[&str]) -> Result<Vec<i64>, Error>
pub fn get_entities_by_labels(&self, labels: &[&str]) -> Result<Vec<i64>, Error>
Get all entity IDs that have all of the specified labels (AND semantics)
Sourcepub fn count_entities_by_label(&self, label: &str) -> Result<usize, Error>
pub fn count_entities_by_label(&self, label: &str) -> Result<usize, Error>
Get count of entities with a specific label
Sourcepub fn get_symbols_by_label(
&self,
label: &str,
) -> Result<Vec<SymbolQueryResult>, Error>
pub fn get_symbols_by_label( &self, label: &str, ) -> Result<Vec<SymbolQueryResult>, Error>
Get symbols by label with full metadata
Sourcepub fn get_symbols_by_labels(
&self,
labels: &[&str],
) -> Result<Vec<SymbolQueryResult>, Error>
pub fn get_symbols_by_labels( &self, labels: &[&str], ) -> Result<Vec<SymbolQueryResult>, Error>
Get symbols by multiple labels (AND semantics) with full metadata
Sourcepub fn search_symbols_by_name(
&self,
name: &str,
) -> Result<Vec<SymbolQueryResult>, Error>
pub fn search_symbols_by_name( &self, name: &str, ) -> Result<Vec<SymbolQueryResult>, Error>
Search for symbols by name across all files
Uses the graph_entities table directly to find symbols matching
the given name. This is the correct way to find a symbol by its
actual name (as opposed to get_symbols_by_label which searches
by kind label like “fn” or “struct”).
§Arguments
name- Symbol name to search for (exact match)
§Returns
Vector of SymbolQueryResult for all matching symbols
Source§impl CodeGraph
impl CodeGraph
Sourcepub fn checkpoint_wal(&self) -> Result<(), Error>
pub fn checkpoint_wal(&self) -> Result<(), Error>
Checkpoint the SQLite WAL to prevent unbounded growth.
Sourcepub fn index_file(&mut self, path: &str, source: &[u8]) -> Result<usize, Error>
pub fn index_file(&mut self, path: &str, source: &[u8]) -> Result<usize, Error>
Index a file into the graph (idempotent)
§Behavior
- Compute SHA-256 hash of file contents
- Upsert File node with path and hash
- DELETE all existing Symbol nodes and DEFINES edges for this file
- Parse symbols from source code
- Insert new Symbol nodes
- Create DEFINES edges from File to each Symbol
- Index calls (CALLS edges)
§Arguments
path- File pathsource- File contents as bytes
§Returns
Number of symbols indexed
Sourcepub fn delete_file(&mut self, path: &str) -> Result<DeleteResult, Error>
pub fn delete_file(&mut self, path: &str) -> Result<DeleteResult, Error>
Delete a file and all derived data from the graph
This delegates to delete_file_facts which removes all file-derived facts
(symbols, references, calls, chunks, file node).
§Returns
DeleteResult with counts of deleted entities
Sourcepub fn delete_file_facts(&mut self, path: &str) -> Result<DeleteResult, Error>
pub fn delete_file_facts(&mut self, path: &str) -> Result<DeleteResult, Error>
Delete ALL facts derived from a file path.
This is the authoritative deletion path used by reconcile.
§Returns
DeleteResult with counts of deleted entities
Sourcepub fn symbols_in_file(&mut self, path: &str) -> Result<Vec<SymbolFact>, Error>
pub fn symbols_in_file(&mut self, path: &str) -> Result<Vec<SymbolFact>, Error>
Sourcepub fn symbols_in_file_with_kind(
&mut self,
path: &str,
kind: Option<SymbolKind>,
) -> Result<Vec<SymbolFact>, Error>
pub fn symbols_in_file_with_kind( &mut self, path: &str, kind: Option<SymbolKind>, ) -> Result<Vec<SymbolFact>, Error>
Sourcepub fn symbol_nodes_in_file(
&mut self,
path: &str,
) -> Result<Vec<(i64, SymbolFact)>, Error>
pub fn symbol_nodes_in_file( &mut self, path: &str, ) -> Result<Vec<(i64, SymbolFact)>, Error>
Query symbol facts along with their node IDs for deterministic ordering/output.
Sourcepub fn symbol_id_by_name(
&mut self,
path: &str,
name: &str,
) -> Result<Option<i64>, Error>
pub fn symbol_id_by_name( &mut self, path: &str, name: &str, ) -> Result<Option<i64>, Error>
Query the node ID of a specific symbol by file path and symbol name
§Arguments
path- File pathname- Symbol name
§Returns
Option
§Note
This is a minimal query helper for testing. It reuses existing graph queries and maintains determinism. No new indexes or caching.
Sourcepub fn references_to_symbol(
&mut self,
symbol_id: i64,
) -> Result<Vec<ReferenceFact>, Error>
pub fn references_to_symbol( &mut self, symbol_id: i64, ) -> Result<Vec<ReferenceFact>, Error>
Sourcepub fn symbol_extents(
&mut self,
path: &str,
name: &str,
) -> Result<Vec<(i64, SymbolFact)>, Error>
pub fn symbol_extents( &mut self, path: &str, name: &str, ) -> Result<Vec<(i64, SymbolFact)>, Error>
Lookup symbol extent (byte + line span) for a specific symbol name in a file.
Sourcepub fn calls_from_symbol(
&mut self,
path: &str,
name: &str,
) -> Result<Vec<CallFact>, Error>
pub fn calls_from_symbol( &mut self, path: &str, name: &str, ) -> Result<Vec<CallFact>, Error>
Sourcepub fn callers_of_symbol(
&mut self,
path: &str,
name: &str,
) -> Result<Vec<CallFact>, Error>
pub fn callers_of_symbol( &mut self, path: &str, name: &str, ) -> Result<Vec<CallFact>, Error>
Sourcepub fn count_files(&self) -> Result<usize, Error>
pub fn count_files(&self) -> Result<usize, Error>
Count total number of files in the graph
Sourcepub fn count_symbols(&self) -> Result<usize, Error>
pub fn count_symbols(&self) -> Result<usize, Error>
Count total number of symbols in the graph
Sourcepub fn count_references(&self) -> Result<usize, Error>
pub fn count_references(&self) -> Result<usize, Error>
Count total number of references in the graph
Sourcepub fn count_calls(&self) -> Result<usize, Error>
pub fn count_calls(&self) -> Result<usize, Error>
Count total number of calls in the graph
Sourcepub fn count_cfg_blocks(&self) -> Result<usize, Error>
pub fn count_cfg_blocks(&self) -> Result<usize, Error>
Count total number of CFG blocks in the graph
Note: Returns 0 for SQLite backend. CFG blocks are only stored in geometric backend databases.
Sourcepub fn check_coverage_schema(&self) -> Result<bool, Error>
pub fn check_coverage_schema(&self) -> Result<bool, Error>
Check if coverage schema tables exist in the database.
Returns true if all three coverage tables are present.
Sourcepub fn get_stats(&self) -> Result<GraphStats, Error>
pub fn get_stats(&self) -> Result<GraphStats, Error>
Get combined statistics for the graph
Returns symbol count, file count, and cfg block count
Sourcepub fn reconcile_file_path(
&mut self,
path: &Path,
path_key: &str,
) -> Result<ReconcileOutcome, Error>
pub fn reconcile_file_path( &mut self, path: &Path, path_key: &str, ) -> Result<ReconcileOutcome, Error>
Reconcile a file path against filesystem + content hash.
This is the deterministic primitive used by scan and watcher updates.
Sourcepub fn reconcile_file_path_with_source(
&mut self,
path: &Path,
path_key: &str,
source: &[u8],
) -> Result<ReconcileOutcome, Error>
pub fn reconcile_file_path_with_source( &mut self, path: &Path, path_key: &str, source: &[u8], ) -> Result<ReconcileOutcome, Error>
Reconcile a file path using pre-read source bytes.
Same as reconcile_file_path but avoids re-reading from disk.
Sourcepub fn scan_directory(
&mut self,
dir_path: &Path,
progress: Option<&(dyn Fn(usize, usize, &str) + Sync + Send + 'static)>,
) -> Result<usize, Error>
pub fn scan_directory( &mut self, dir_path: &Path, progress: Option<&(dyn Fn(usize, usize, &str) + Sync + Send + 'static)>, ) -> Result<usize, Error>
Scan a directory and index all Rust files found
§Behavior
- Walk directory recursively
- Find all .rs files
- Index each file (symbols + references)
- Report progress via callback
§Arguments
dir_path- Directory to scanprogress- Optional callback for progress reporting (current, total)
§Returns
Number of files indexed
§Guarantees
- Only .rs files are processed
- Files are indexed in sorted order for determinism
- Non-.rs files are silently skipped
Sourcepub async fn scan_directory_async(
&mut self,
dir_path: &Path,
progress: Option<&(dyn Fn(usize, usize, &str) + Sync + Send + 'static)>,
) -> Result<usize, Error>
pub async fn scan_directory_async( &mut self, dir_path: &Path, progress: Option<&(dyn Fn(usize, usize, &str) + Sync + Send + 'static)>, ) -> Result<usize, Error>
Async version of scan_directory with parallel file reading
Uses tokio for async file I/O, improving performance on slow filesystems. Graph operations remain synchronous (CodeGraph is not Send).
§Arguments
dir_path- Directory to scan recursivelyprogress- Optional callback for progress updates (current, total)
§Returns
Number of files indexed
Sourcepub fn backfill_metrics(
&mut self,
progress: Option<&(dyn Fn(usize, usize, &str) + Sync + Send + 'static)>,
) -> Result<BackfillResult, Error>
pub fn backfill_metrics( &mut self, progress: Option<&(dyn Fn(usize, usize, &str) + Sync + Send + 'static)>, ) -> Result<BackfillResult, Error>
Backfill metrics for all existing files in the database
This is called automatically after database migration to schema version 5. Can also be called manually to recompute metrics.
§Arguments
progress- Optional callback for progress updates (current, total)
§Returns
BackfillResult with total files processed and any errors
Sourcepub fn export_json(&mut self) -> Result<String, Error>
pub fn export_json(&mut self) -> Result<String, Error>
Export all graph data to JSON format
§Returns
JSON string containing all files, symbols, references, and calls
Sourcepub fn all_file_nodes(&mut self) -> Result<HashMap<String, FileNode>, Error>
pub fn all_file_nodes(&mut self) -> Result<HashMap<String, FileNode>, Error>
Get all FileNodes from the database
§Returns
HashMap of file path -> FileNode for all files in the database
Sourcepub fn all_file_nodes_readonly(
&self,
) -> Result<HashMap<String, FileNode>, Error>
pub fn all_file_nodes_readonly( &self, ) -> Result<HashMap<String, FileNode>, Error>
Get all FileNodes from the database (read-only, doesn’t require mutation).
§Returns
HashMap of file path -> FileNode for all files in the database
Sourcepub fn get_code_chunks_for_symbol(
&self,
file_path: &str,
symbol_name: &str,
) -> Result<Vec<CodeChunk>, Error>
pub fn get_code_chunks_for_symbol( &self, file_path: &str, symbol_name: &str, ) -> Result<Vec<CodeChunk>, Error>
Sourcepub fn get_code_chunk_by_span(
&self,
file_path: &str,
byte_start: usize,
byte_end: usize,
) -> Result<Option<CodeChunk>, Error>
pub fn get_code_chunk_by_span( &self, file_path: &str, byte_start: usize, byte_end: usize, ) -> Result<Option<CodeChunk>, Error>
Sourcepub fn count_chunks(&self) -> Result<usize, Error>
pub fn count_chunks(&self) -> Result<usize, Error>
Count total code chunks stored.
Sourcepub fn execution_log(&self) -> &ExecutionLog
pub fn execution_log(&self) -> &ExecutionLog
Get the execution log for recording command execution
Sourcepub fn metrics(&self) -> &MetricsOps
pub fn metrics(&self) -> &MetricsOps
Get the metrics operations module
Sourcepub fn validate_graph(&mut self) -> ValidationReport
pub fn validate_graph(&mut self) -> ValidationReport
Validate graph invariants post-run
Checks for orphan references, orphan calls, and other structural issues. This is a convenience method that calls validation::validate_graph().
§Returns
ValidationReport with validation results (errors, warnings, passed status)
Sourcepub fn cache_stats(&self) -> CacheStats
pub fn cache_stats(&self) -> CacheStats
Get cache statistics for monitoring cache effectiveness
§Returns
CacheStats with hits, misses, size, and hit rate
Sourcepub fn invalidate_cache(&mut self, path: &str)
pub fn invalidate_cache(&mut self, path: &str)
Invalidate cache entry for a specific file path
This should be called when a file is modified or deleted to ensure cache doesn’t return stale data.
§Arguments
path- File path to invalidate
Sourcepub fn clear_cache(&mut self)
pub fn clear_cache(&mut self)
Clear all cache entries
This resets the cache to empty state, useful for testing or after bulk operations.
Sourcepub fn rebuild_fts5_index(db_path: &Path) -> Result<(), Error>
pub fn rebuild_fts5_index(db_path: &Path) -> Result<(), Error>
Rebuild FTS5 symbol search index
Rebuilds the FTS5 virtual table (symbol_fts) that indexes symbol names from graph_entities for fast prefix and full-text search.
This should be called after batch indexing operations to ensure the FTS5 index is synchronized with graph_entities.
§Performance
Typically ~500ms for 1,000 files. Call after batch completion, not per-file.
§Arguments
db_path- Path to the database file (needed for direct SQLite connection)
Sourcepub fn get_symbol_by_entity_id(&self, entity_id: i64) -> Option<SymbolNode>
pub fn get_symbol_by_entity_id(&self, entity_id: i64) -> Option<SymbolNode>
Trait Implementations§
Source§impl AmbiguityOps for CodeGraph
impl AmbiguityOps for CodeGraph
Source§fn create_ambiguous_group(
&mut self,
display_fqn: &str,
symbol_ids: &[i64],
) -> Result<(), Error>
fn create_ambiguous_group( &mut self, display_fqn: &str, symbol_ids: &[i64], ) -> Result<(), Error>
Source§fn resolve_by_symbol_id(
&mut self,
display_fqn: &str,
preferred_symbol_id: &str,
) -> Result<Option<SymbolNode>, Error>
fn resolve_by_symbol_id( &mut self, display_fqn: &str, preferred_symbol_id: &str, ) -> Result<Option<SymbolNode>, Error>
Source§fn get_candidates(
&mut self,
display_fqn: &str,
) -> Result<Vec<(i64, SymbolNode)>, Error>
fn get_candidates( &mut self, display_fqn: &str, ) -> Result<Vec<(i64, SymbolNode)>, Error>
Auto Trait Implementations§
impl Freeze for CodeGraph
impl !RefUnwindSafe for CodeGraph
impl !Send for CodeGraph
impl !Sync for CodeGraph
impl Unpin for CodeGraph
impl UnsafeUnpin for CodeGraph
impl !UnwindSafe for CodeGraph
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more