Expand description
Unified graph architecture for cross-language code analysis Unified graph architecture for cross-language code analysis
This module implements the core data structures and algorithms for sqry’s unified graph architecture, enabling cross-language queries, visualization, and advanced analysis.
§Architecture
The graph architecture consists of:
- Nodes: Code entities (functions, classes, modules)
- Edges: Relationships (calls, imports, HTTP, FFI)
- Indices: Fast lookup structures for queries
- Builders: Language-specific graph construction
§Memory Optimization
Per AGENTS.md:149-151, strings are interned via Arc<str> to reduce memory
usage in symbol-heavy data structures (saves 10-50 MB for typical repos).
§Concurrency
The graph uses interior mutability (DashMap) to allow concurrent graph building while maintaining a shared reference (&CodeGraph).
§Example
use sqry_core::graph::node::{NodeId, Language};
// Create node identifiers with string interning
let node_id = NodeId::new(Language::Cpp, "main.cpp", "main");
assert_eq!(node_id.to_string(), "cpp:main.cpp:main");
// Node name extraction works across languages
let cpp_id = NodeId::new(Language::Cpp, "utils.cpp", "std::vector::push_back");
assert_eq!(cpp_id.symbol_name(), "push_back");
let py_id = NodeId::new(Language::Python, "api.py", "User.authenticate");
assert_eq!(py_id.symbol_name(), "authenticate");Re-exports§
pub use unified::concurrent::CodeGraph;pub use unified::ConcurrentCodeGraph;pub use unified::GraphSnapshot;pub use body_hash::BodyHash128;pub use body_hash::HASH_SEED_0;pub use body_hash::HASH_SEED_1;pub use builder::GraphBuilder;pub use call_sites::CallSite;pub use call_sites::CallSiteExtras;pub use call_sites::CallSiteMetadata;pub use edge::CodeEdge;pub use edge::DetectionMethod;pub use edge::EdgeId;pub use edge::EdgeKind;pub use edge::EdgeMetadata;pub use edge::FFIType;pub use edge::TableWriteOp;pub use error::GraphBuilderError;pub use error::GraphResult;pub use node::CodeNode;pub use node::Language;pub use node::NodeId;pub use node::NodeKind;pub use node::Position;pub use node::Span;pub use path_resolver::normalize_path;pub use path_resolver::resolve_import_path;pub use path_resolver::resolve_python_import;
Modules§
- body_
hash - 128-bit deterministic body hashing using dual xxh64
- builder
- Graph builder trait.
- call_
sites - Normalized representation of call edges returned by query helpers.
- diff
- Graph comparison and diff functionality.
- edge
- Edge types for the unified code graph
- error
- Error types used by graph builders.
- local_
scopes - Shared local scope tracking and reference resolution infrastructure.
- node
- Node types for the unified code graph
- path_
resolver - Path resolution for import statements across languages
- unified
- Unified graph architecture with Arena+CSR storage.