pub struct CodeUnit {Show 22 fields
pub id: u64,
pub unit_type: CodeUnitType,
pub language: Language,
pub name: String,
pub qualified_name: String,
pub file_path: PathBuf,
pub span: Span,
pub signature: Option<String>,
pub doc_summary: Option<String>,
pub visibility: Visibility,
pub complexity: u32,
pub is_async: bool,
pub is_generator: bool,
pub created_at: u64,
pub last_modified: u64,
pub change_count: u32,
pub stability_score: f32,
pub collective_usage: u64,
pub content_hash: [u8; 32],
pub feature_vec: Vec<f32>,
pub edge_offset: u64,
pub edge_count: u32,
}Expand description
A single code unit — the atomic element of the code graph.
Code units are the nodes of the semantic graph. Each represents an identifiable piece of code: a function, class, module, import, etc.
Fields§
§id: u64Unique identifier (assigned sequentially during compilation).
unit_type: CodeUnitTypeType of code unit.
language: LanguageProgramming language.
name: StringSimple name (e.g., “process_payment”).
qualified_name: StringFully qualified name (e.g., “payments.stripe.process_payment”).
file_path: PathBufSource file path (relative to repo root).
span: SpanLocation in source file.
signature: Option<String>Type signature if applicable (e.g., “(amount: Decimal) -> bool”).
doc_summary: Option<String>First line of documentation.
visibility: VisibilityVisibility level.
complexity: u32Cyclomatic complexity (0 for non-functions).
is_async: boolIs this async/await?
is_generator: boolIs this a generator/iterator?
created_at: u64First seen timestamp (git commit time, or compile time if no git).
last_modified: u64Last modified timestamp.
change_count: u32Total changes in git history.
stability_score: f32Stability score: 0.0 = constantly changing, 1.0 = never changes.
collective_usage: u64Global usage count from collective (0 if private code).
content_hash: [u8; 32]Content hash for deduplication (Blake3).
feature_vec: Vec<f32>Feature vector for similarity (dimension = DEFAULT_DIMENSION).
edge_offset: u64Byte offset into edge table.
edge_count: u32Number of outgoing edges.
Implementations§
Source§impl CodeUnit
impl CodeUnit
Sourcepub fn new(
unit_type: CodeUnitType,
language: Language,
name: String,
qualified_name: String,
file_path: PathBuf,
span: Span,
) -> Self
pub fn new( unit_type: CodeUnitType, language: Language, name: String, qualified_name: String, file_path: PathBuf, span: Span, ) -> Self
Create a new code unit with required fields only.
Optional fields are initialized to their defaults:
idis 0 (set by the graph on insertion)visibilityisUnknownstability_scoreis 1.0 (stable by default)feature_vecis zero-filled withDEFAULT_DIMENSIONelements