Skip to main content

CodeGraph

Struct CodeGraph 

Source
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: CfgOps

CFG block operations module

Implementations§

Source§

impl CodeGraph

Source

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

Source

pub fn symbol_by_entity_id(&self, entity_id: i64) -> Result<SymbolInfo, Error>

Get symbol information by entity ID

§Arguments
  • entity_id - Entity ID (i64 database row ID)
§Returns

SymbolInfo with metadata from the symbol node

Source

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)?; ```

Source

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 analyze
  • max_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)?; ```

Source

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); } ```

Source

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(”?“)); } } ```

Source

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()); } ```

Source

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); } ```

Source

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(”?“)); } ```

Source

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(”?“)); } ```

Source

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 return
  • revisit_cap: Maximum number of times a single node can be revisited (prevents infinite loops)
§Arguments
  • start_symbol_id - Starting symbol ID or FQN
  • end_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

Source

pub fn get_ast_nodes_by_file( &self, file_path: &str, ) -> Result<Vec<AstNodeWithText>, Error>

Get all AST nodes for a specific file

§Arguments
  • file_path - The file path to query
§Returns

Vector of AstNodeWithText for all nodes in the file

§Note

Uses SideTables trait for backend-agnostic storage. For V3 backend, this requires prefix scan support (not yet implemented).

Source

pub fn get_ast_children(&self, node_id: i64) -> Result<Vec<AstNode>, Error>

Get direct children of an AST node

§Arguments
  • node_id - The database ID of the parent node
§Returns

Vector of child AstNode structs

Source

pub fn get_ast_node_at_position( &self, _file_path: &str, position: usize, ) -> Result<Option<AstNode>, Error>

Get the AST node at a specific byte position

§Arguments
  • file_path - The file path
  • position - Byte offset in the file
§Returns

Option if a node is found at the position

Source

pub fn get_ast_nodes_by_kind(&self, kind: &str) -> Result<Vec<AstNode>, Error>

Get all AST nodes of a specific kind

§Arguments
  • kind - The node kind to filter by (e.g., “if_expression”)
§Returns

Vector of matching AstNode structs

§Note

Uses SideTables trait for backend-agnostic storage.

Source

pub fn get_ast_roots(&self) -> Result<Vec<AstNode>, Error>

Get the root AST nodes (nodes without parents)

§Returns

Vector of root-level AstNode structs

§Note

This operation requires scanning all nodes to find those without parents. For V3 backend, this returns empty until prefix scan is implemented.

Source

pub fn count_ast_nodes(&self) -> Result<usize, Error>

Count all AST nodes in the database

§Returns

Total number of AST nodes

Source§

impl CodeGraph

Source

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.

Source

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)

Source

pub fn get_all_labels(&self) -> Result<Vec<String>, Error>

Get all labels currently in use

Source

pub fn count_entities_by_label(&self, label: &str) -> Result<usize, Error>

Get count of entities with a specific label

Source

pub fn get_symbols_by_label( &self, label: &str, ) -> Result<Vec<SymbolQueryResult>, Error>

Get symbols by label with full metadata

Source

pub fn get_symbols_by_labels( &self, labels: &[&str], ) -> Result<Vec<SymbolQueryResult>, Error>

Get symbols by multiple labels (AND semantics) with full metadata

Source

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

Source

pub fn db_path(&self) -> &Path

Get the database file path

Source

pub fn open<P>(db_path: P) -> Result<CodeGraph, Error>
where P: AsRef<Path>,

Open a graph database at the given path

§Arguments
  • db_path - Path to the database file (created if not exists)
§Returns

A new CodeGraph instance

Source

pub fn checkpoint_wal(&self) -> Result<(), Error>

Checkpoint the SQLite WAL to prevent unbounded growth.

Source

pub fn index_file(&mut self, path: &str, source: &[u8]) -> Result<usize, Error>

Index a file into the graph (idempotent)

§Behavior
  1. Compute SHA-256 hash of file contents
  2. Upsert File node with path and hash
  3. DELETE all existing Symbol nodes and DEFINES edges for this file
  4. Parse symbols from source code
  5. Insert new Symbol nodes
  6. Create DEFINES edges from File to each Symbol
  7. Index calls (CALLS edges)
§Arguments
  • path - File path
  • source - File contents as bytes
§Returns

Number of symbols indexed

Source

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

Source

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

Source

pub fn symbols_in_file(&mut self, path: &str) -> Result<Vec<SymbolFact>, Error>

Query all symbols defined in a file

§Arguments
  • path - File path
§Returns

Vector of SymbolFact for all symbols in the file

Source

pub fn symbols_in_file_with_kind( &mut self, path: &str, kind: Option<SymbolKind>, ) -> Result<Vec<SymbolFact>, Error>

Query symbols defined in a file, optionally filtered by kind

§Arguments
  • path - File path
  • kind - Optional symbol kind filter (None returns all symbols)
§Returns

Vector of SymbolFact matching the kind filter

Source

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.

Source

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 path
  • name - Symbol name
§Returns

Option - Some(node_id) if found, None if not found

§Note

This is a minimal query helper for testing. It reuses existing graph queries and maintains determinism. No new indexes or caching.

Source

pub fn index_references( &mut self, path: &str, source: &[u8], ) -> Result<usize, Error>

Index references for a file into the graph

§Behavior
  1. Parse symbols from source
  2. Extract references to those symbols
  3. Insert Reference nodes
  4. Create REFERENCES edges from Reference to Symbol
§Arguments
  • path - File path
  • source - File contents as bytes
§Returns

Number of references indexed

Source

pub fn references_to_symbol( &mut self, symbol_id: i64, ) -> Result<Vec<ReferenceFact>, Error>

Query all references to a specific symbol

§Arguments
  • symbol_id - Node ID of the target symbol
§Returns

Vector of ReferenceFact for all references to the symbol

Source

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.

Source

pub fn index_calls(&mut self, path: &str, source: &[u8]) -> Result<usize, Error>

Index calls for a file into the graph

§Behavior
  1. Get file node ID
  2. Get all symbols for this file
  3. Extract calls from source
  4. Insert Call nodes and CALLS edges
§Arguments
  • path - File path
  • source - File contents as bytes
§Returns

Number of calls indexed

Source

pub fn calls_from_symbol( &mut self, path: &str, name: &str, ) -> Result<Vec<CallFact>, Error>

Query all calls FROM a specific symbol (forward call graph)

§Arguments
  • path - File path containing the symbol
  • name - Symbol name
§Returns

Vector of CallFact for all calls from this symbol

Source

pub fn callers_of_symbol( &mut self, path: &str, name: &str, ) -> Result<Vec<CallFact>, Error>

Query all calls TO a specific symbol (reverse call graph)

§Arguments
  • path - File path containing the symbol
  • name - Symbol name
§Returns

Vector of CallFact for all calls to this symbol

Source

pub fn count_files(&self) -> Result<usize, Error>

Count total number of files in the graph

Source

pub fn count_symbols(&self) -> Result<usize, Error>

Count total number of symbols in the graph

Source

pub fn count_references(&self) -> Result<usize, Error>

Count total number of references in the graph

Source

pub fn count_calls(&self) -> Result<usize, Error>

Count total number of calls in the graph

Source

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.

Source

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.

Source

pub fn get_stats(&self) -> Result<GraphStats, Error>

Get combined statistics for the graph

Returns symbol count, file count, and cfg block count

Source

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.

Source

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.

Source

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
  1. Walk directory recursively
  2. Find all .rs files
  3. Index each file (symbols + references)
  4. Report progress via callback
§Arguments
  • dir_path - Directory to scan
  • progress - 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
Source

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 recursively
  • progress - Optional callback for progress updates (current, total)
§Returns

Number of files indexed

Source

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

Source

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

Source

pub fn get_file_node(&mut self, path: &str) -> Result<Option<FileNode>, Error>

Get the FileNode for a given file path

§Arguments
  • path - File path to query
§Returns

Option with file metadata including timestamps, or None if not found

Source

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

Source

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

Source

pub fn get_code_chunks(&self, file_path: &str) -> Result<Vec<CodeChunk>, Error>

Get code chunks for a specific file.

§Arguments
  • file_path - File path to query
§Returns

Vector of CodeChunk for all chunks in the file

Source

pub fn get_code_chunks_for_symbol( &self, file_path: &str, symbol_name: &str, ) -> Result<Vec<CodeChunk>, Error>

Get code chunks for a specific symbol in a file.

§Arguments
  • file_path - File path containing the symbol
  • symbol_name - Symbol name to query
§Returns

Vector of CodeChunk for the symbol (may be multiple for overloads)

Source

pub fn get_code_chunk_by_span( &self, file_path: &str, byte_start: usize, byte_end: usize, ) -> Result<Option<CodeChunk>, Error>

Get a code chunk by exact byte span.

§Arguments
  • file_path - File path containing the chunk
  • byte_start - Starting byte offset
  • byte_end - Ending byte offset
§Returns

Option if found, None otherwise

Source

pub fn store_code_chunks(&self, chunks: &[CodeChunk]) -> Result<Vec<i64>, Error>

Store code chunks for a file.

§Arguments
  • chunks - Code chunks to store
§Returns

Vector of inserted chunk IDs

Source

pub fn count_chunks(&self) -> Result<usize, Error>

Count total code chunks stored.

Source

pub fn execution_log(&self) -> &ExecutionLog

Get the execution log for recording command execution

Source

pub fn metrics(&self) -> &MetricsOps

Get the metrics operations module

Source

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)

Source

pub fn cache_stats(&self) -> CacheStats

Get cache statistics for monitoring cache effectiveness

§Returns

CacheStats with hits, misses, size, and hit rate

Source

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
Source

pub fn clear_cache(&mut self)

Clear all cache entries

This resets the cache to empty state, useful for testing or after bulk operations.

Source

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)
Source

pub fn get_symbol_by_entity_id(&self, entity_id: i64) -> Option<SymbolNode>

Get symbol node by entity ID

Returns the full SymbolNode data for a given entity ID. Works with both SQLite and V3 backends.

§Arguments
  • entity_id - The entity ID to look up
§Returns

Some(SymbolNode) if found and is a Symbol, None otherwise

Source

pub fn add_label(&self, entity_id: i64, label: &str) -> Result<(), Error>

Add a label to an entity (uses side_tables)

§Arguments
  • entity_id - The entity ID to label
  • label - The label to add
Source

pub fn get_labels_for_entity( &self, entity_id: i64, ) -> Result<Vec<String>, Error>

Get all labels for an entity (uses side_tables)

§Arguments
  • entity_id - The entity ID

Trait Implementations§

Source§

impl AmbiguityOps for CodeGraph

Source§

fn create_ambiguous_group( &mut self, display_fqn: &str, symbol_ids: &[i64], ) -> Result<(), Error>

Create or update an ambiguity group for a Display FQN Read more
Source§

fn resolve_by_symbol_id( &mut self, display_fqn: &str, preferred_symbol_id: &str, ) -> Result<Option<SymbolNode>, Error>

Resolve a Display FQN to a specific Symbol by SymbolId Read more
Source§

fn get_candidates( &mut self, display_fqn: &str, ) -> Result<Vec<(i64, SymbolNode)>, Error>

Enumerate all SymbolIds for a Display FQN Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts 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
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more