Skip to main content

Crate nusy_codegraph

Crate nusy_codegraph 

Source
Expand description

nusy-codegraph — Code as a live Arrow object graph.

Parses Python source files via tree-sitter into CodeNodes (functions, classes, modules) and CodeEdges (calls, imports, inheritance, containment). All data stored as Arrow RecordBatches for zero-copy query and versioning via nusy-arrow-git.

§Architecture

Python source → tree-sitter CST → CodeNodes + CodeEdges → Arrow RecordBatches
                                    ↓
                             NameResolver (cross-file edge extraction)

Re-exports§

pub use edges::NameResolver;
pub use edges::extract_call_edges;
pub use edges::extract_cross_file_edges;
pub use edges::extract_edges;
pub use embeddings::HashEmbeddingProvider;
pub use embeddings::SearchResult;
pub use embeddings::attach_embeddings;
pub use embeddings::embed_nodes;
pub use executor::ExecutionResult;
pub use executor::ExecutorError;
pub use executor::execute_object;
pub use git_tools::CodeConflict;
pub use git_tools::CodeDiffChangeType;
pub use git_tools::CodeDiffEntry;
pub use git_tools::CodeDiffResult;
pub use git_tools::CodeMergeResult;
pub use git_tools::MergeWarning;
pub use git_tools::SmartMergeResult;
pub use git_tools::codegraph_diff;
pub use git_tools::codegraph_merge;
pub use git_tools::smart_merge;
pub use impact::ChangedNode;
pub use impact::ImpactReport;
pub use impact::ImpactStats;
pub use impact::format_impact_report;
pub use impact::impact_analysis;
pub use ingest::IngestResult;
pub use ingest::Language;
pub use ingest::callers_of;
pub use ingest::ingest_directory;
pub use ingest::ingest_files;
pub use ingest::ingest_python_directory;
pub use ingest::nodes_in_file;
pub use ingest_pipeline::GraphViolations;
pub use ingest_pipeline::WorkspaceIngestResult;
pub use ingest_pipeline::discover_workspace_crates;
pub use ingest_pipeline::ingest_workspace;
pub use ingest_pipeline::verify_graph;
pub use ingest_pipeline::write_graph_parquet;
pub use mcp_tools::McpToolError;
pub use mcp_tools::NodeUpdate;
pub use mcp_tools::QueryFilter;
pub use mcp_tools::QueryResult;
pub use mcp_tools::codegraph_add_edge;
pub use mcp_tools::codegraph_query_objects;
pub use mcp_tools::codegraph_remove_edge;
pub use mcp_tools::codegraph_update_object;
pub use metrics::CodebaseMetrics;
pub use metrics::FileCoverage;
pub use metrics::compute_codebase_metrics;
pub use metrics::enrich_with_coverage;
pub use metrics::enrich_with_git_timestamps;
pub use metrics::high_complexity_nodes;
pub use metrics::largest_nodes;
pub use metrics::low_coverage_nodes;
pub use metrics::parse_coverage_json;
pub use module_resolver::RustModuleResolver;
pub use parser::ImportInfo;
pub use parser::ParseError;
pub use parser::ParseResult;
pub use parser::parse_python_file;
pub use python_parser::PythonParseResult;
pub use python_parser::PythonParser;
pub use python_parser::PythonParserError;
pub use python_resolver::PythonModuleResolver;
pub use rename::RenameError;
pub use rename::rename_node;
pub use rust_parser::parse_rust_file;
pub use schema::CodeEdge;
pub use schema::CodeEdgePredicate;
pub use schema::CodeNode;
pub use schema::CodeNodeKind;
pub use schema::build_code_edges_batch;
pub use schema::build_code_nodes_batch;
pub use schema::code_edges_schema;
pub use schema::code_nodes_schema;
pub use schema::extract_file_path;
pub use scip_calls::ScipCallResult;
pub use scip_calls::extract_scip_call_edges;
pub use search::CodeSearch;
pub use search::callees;
pub use search::callers;
pub use search::children_of;
pub use search::find_sources;
pub use search::find_targets;
pub use search::search_nodes;
pub use search::tests_for;
pub use search::transitive_callers;
pub use search::transitive_deps;
pub use semantic_diff::AffectedEdge;
pub use semantic_diff::AffectedReason;
pub use semantic_diff::ChangeClassification;
pub use semantic_diff::DiffStats;
pub use semantic_diff::SemanticDiff;
pub use semantic_diff::SemanticDiffEntry;
pub use semantic_diff::format_semantic_diff;
pub use semantic_diff::semantic_diff;
pub use topo_sort::ParallelismStats;
pub use topo_sort::crate_parallelism_stats;
pub use topo_sort::sort_crates;
pub use topo_sort::sort_crates_parallel;
pub use topo_sort::sort_functions_in_crate;
pub use topo_sort::sort_functions_parallel;

Modules§

build_cache
Content-addressed build cache — V12-Spike-2.
cargo_parser
Parse Cargo.toml manifests into CrateManifest structs.
crate_graph
Build a crate-level dependency graph from a Cargo workspace.
crate_schema
Arrow schemas for the crate-level dependency graph.
edges
Edge extraction — build CodeEdges from parsed CodeNodes.
embeddings
Embedding generation and semantic search for code objects.
executor
CodeGraph execution layer — execute code objects from the graph.
git_tools
Git-integrated MCP tools for CodeGraph versioning.
impact
Impact analysis — compute the blast radius of code changes.
ingest
Batch ingestion — walk a directory tree, parse all Python files, build Arrow tables.
ingest_pipeline
High-level ingestion pipeline — workspace-wide self-ingest and graph coherence verification.
mcp_bridge
Generic MCP-to-NATS bridge.
mcp_tools
MCP tool implementations for CodeGraph query and update operations.
metrics
Code metrics computation — LOC, complexity, coverage, git history.
module_resolver
Rust module tree resolution for cross-file edge extraction.
nats_service
CodeGraph NATS service — exposes code graph tools via NatsServiceBuilder.
nats_sync
NATS-based code graph synchronization (EX-3184).
parser
tree-sitter Python parser — extract CodeNodes from Python source files.
python_parser
Python-specific tree-sitter parser — extracts CodeNodes with position metadata.
python_resolver
Python module resolver — maps dotted import paths to file paths.
rename
Graph-native rename — rename a code object, all edges follow.
rust_parser
tree-sitter Rust parser — extract CodeNodes from Rust source files.
schema
Arrow schemas for code graph objects.
scip_calls
SCIP-based call edge extraction.
search
Code search — graph-aware querying of CodeNodes and CodeEdges.
semantic_diff
Semantic diff — enriches object-level diffs with structural context.
test_discovery
Graph-native test discovery — find #[test] functions in the code graph.
topo_sort
Topological sorters for the NuSy crate dependency graph and function call graph.

Traits§

EmbeddingProvider
Trait for embedding providers.

Functions§

cosine_similarity
Cosine similarity between two vectors.