pub struct CodeGraph { /* private fields */ }Implementations§
Source§impl CodeGraph
impl CodeGraph
Sourcepub fn serves_file(&self, path: &str) -> bool
pub fn serves_file(&self, path: &str) -> bool
Whether a reference to the file path of this graph may be served
now. A graph without a project root (in memory) has no source on
record to ask and is not gated.
Sourcepub fn serves_symbol(&self, path: &str, name: &str) -> bool
pub fn serves_symbol(&self, path: &str, name: &str) -> bool
Whether a reference to the symbol name of path may be served now.
Sourcepub fn serves_node(&self, node: &Node) -> bool
pub fn serves_node(&self, node: &Node) -> bool
Whether node may be named now — the one entry point for a node of
any kind. See Self::serves_node_parts.
Sourcepub fn serves_node_parts(
&self,
kind: &str,
file_path: &str,
name: &str,
metadata: Option<&str>,
) -> bool
pub fn serves_node_parts( &self, kind: &str, file_path: &str, name: &str, metadata: Option<&str>, ) -> bool
Self::serves_node for a row read as columns (nodes.kind, the
path, nodes.name, nodes.metadata).
- A node of a project file: a
symbol, or atestnamed other than its file, by the symbol rule; every other kind by the file rule. - A node without a file on record (commit, knowledge, issue, CI run): no node records a source binding that could be re-checked, so the originless rule decides its name and, when given, its metadata — withheld under protection, served in Community developer mode while today’s content rules leave the text unchanged. Pass the metadata whenever it is shown or exported.
Source§impl CodeGraph
impl CodeGraph
pub fn open(project_root: &str) -> Result<Self>
pub fn open_in_memory() -> Result<Self>
pub fn db_path(&self) -> &Path
pub fn connection(&self) -> &Connection
pub fn upsert_node(&self, node: &Node) -> Result<i64>
pub fn upsert_edge(&self, edge: &Edge) -> Result<()>
pub fn get_node_by_path(&self, file_path: &str) -> Result<Option<Node>>
pub fn get_node_by_symbol( &self, name: &str, file_path: &str, ) -> Result<Option<Node>>
pub fn remove_file_nodes(&self, file_path: &str) -> Result<()>
pub fn edges_from(&self, node_id: i64) -> Result<Vec<Edge>>
pub fn edges_to(&self, node_id: i64) -> Result<Vec<Edge>>
pub fn dependents(&self, file_path: &str) -> Result<Vec<String>>
pub fn dependencies(&self, file_path: &str) -> Result<Vec<String>>
pub fn impact_analysis( &self, file_path: &str, max_depth: usize, ) -> Result<ImpactResult>
pub fn dependency_chain( &self, from: &str, to: &str, ) -> Result<Option<DependencyChain>>
pub fn file_connectivity( &self, file_path: &str, ) -> Result<HashMap<String, (usize, usize)>>
pub fn node_count(&self) -> Result<usize>
pub fn edge_count(&self) -> Result<usize>
Sourcepub fn semantic_lookup(
&self,
site: SiteKey<'_>,
caller_hash: &str,
) -> Result<Option<CachedResolution>>
pub fn semantic_lookup( &self, site: SiteKey<'_>, caller_hash: &str, ) -> Result<Option<CachedResolution>>
Cached semantic answer for a call site, if the caller is unchanged and
every file the answer derives from — the caller and each target — is
served now (semantic_cache::lookup_served, G04). A withheld answer
is a miss: the backend is asked again.
Sourcepub fn semantic_store(
&self,
site: SiteKey<'_>,
caller_hash: &str,
value: &CachedResolution,
admission: &StoreAdmission,
) -> Result<bool>
pub fn semantic_store( &self, site: SiteKey<'_>, caller_hash: &str, value: &CachedResolution, admission: &StoreAdmission, ) -> Result<bool>
Keeps a semantic answer when its persisted text passes storage
admission under admission — one policy snapshot per enrichment run,
taken where the run starts, not per row. Ok(false): admission
refused the row and nothing was written.
Sourcepub fn has_semantic_answers(&self) -> Result<bool>
pub fn has_semantic_answers(&self) -> Result<bool>
Whether a semantic backend has answered for this graph at all.
Sourcepub fn semantic_prune(
&self,
live_hashes: &HashMap<String, String>,
) -> Result<usize>
pub fn semantic_prune( &self, live_hashes: &HashMap<String, String>, ) -> Result<usize>
Removes cached answers for vanished or changed caller files.
Sourcepub fn file_edges_of_kind(
&self,
kind: &EdgeKind,
) -> Result<Vec<(String, String, Option<String>)>>
pub fn file_edges_of_kind( &self, kind: &EdgeKind, ) -> Result<Vec<(String, String, Option<String>)>>
File→file edges of kind with their metadata, as
(source path, target path, metadata) — sorted for determinism.
Sourcepub fn upsert_edge_with_evidence(
&self,
source_id: i64,
target_id: i64,
kind: &EdgeKind,
evidence: &EdgeEvidence,
) -> Result<()>
pub fn upsert_edge_with_evidence( &self, source_id: i64, target_id: i64, kind: &EdgeKind, evidence: &EdgeEvidence, ) -> Result<()>
Upserts an edge carrying typed evidence. The incoming producer’s
contribution replaces only its own earlier one; other producers’
contributions on the same edge are kept
(crate::core::semantic::EdgeEvidence::merge).
Sourcepub fn withdraw_file_edge(
&self,
source: &str,
target: &str,
kind: &EdgeKind,
origin: EvidenceOrigin,
) -> Result<()>
pub fn withdraw_file_edge( &self, source: &str, target: &str, kind: &EdgeKind, origin: EvidenceOrigin, ) -> Result<()>
Withdraws origin’s contribution from the file→file edge
source → target: the edge is deleted only when no other producer
still derives it. Edges without typed evidence are left untouched.
Sourcepub fn upsert_cross_source_edge(
&self,
from: &str,
to: &str,
kind: &str,
weight: f32,
) -> Result<()>
pub fn upsert_cross_source_edge( &self, from: &str, to: &str, kind: &str, weight: f32, ) -> Result<()>
Persist a cross-source edge (code file ↔ external source URI) into the
dedicated cross_source_edges table. Keeps the higher weight on conflict
so repeated provider ingests don’t downgrade an established link (#682).
Sourcepub fn all_cross_source_edges(&self) -> Vec<IndexEdge>
pub fn all_cross_source_edges(&self) -> Vec<IndexEdge>
All cross-source edges as IndexEdges, ready for cross_source_hints.
pub fn cross_source_edge_count(&self) -> Result<usize>
Sourcepub fn delete_cross_source_edges_by_kind(&self, kind: &str) -> Result<usize>
pub fn delete_cross_source_edges_by_kind(&self, kind: &str) -> Result<usize>
Delete every cross-source edge of a given kind. Used by the code-health
fabric to replace its health_hotspot edges on each pass so resolved
hotspots never persist as stale hints. Returns the number removed.
Sourcepub fn delete_cross_source_edges_with_uri_prefix(
&self,
prefix: &str,
) -> Result<usize>
pub fn delete_cross_source_edges_with_uri_prefix( &self, prefix: &str, ) -> Result<usize>
Delete every cross-source edge with an end under the URI prefix
(both directions), so a re-indexed source replaces its own edges.
pub fn clear(&self) -> Result<()>
Sourcepub fn clear_code_graph(&self) -> Result<()>
pub fn clear_code_graph(&self) -> Result<()>
Clear only the code graph (nodes, edges, file catalog), preserving
provider cross_source_edges. Used by the graph_index→PG mirror (#682.1)
so rebuilding the code graph never drops lateral provider hints, which
live in their own table and are repopulated on a separate ingest cycle.
pub fn upsert_file_catalog(&self, entry: &FileCatalogEntry) -> Result<()>
pub fn get_file_catalog(&self, path: &str) -> Result<Option<FileCatalogEntry>>
pub fn file_catalog_count(&self) -> Result<usize>
pub fn file_catalog_paths(&self) -> Result<Vec<String>>
pub fn find_symbols( &self, name: &str, file_filter: Option<&str>, kind_filter: Option<&str>, ) -> Result<Vec<Node>>
Sourcepub fn resolve_symbol_def_files(&self, name: &str) -> Result<Vec<String>>
pub fn resolve_symbol_def_files(&self, name: &str) -> Result<Vec<String>>
Files that define a symbol named exactly name (GH #398 symbol-name
ctx_impact analyze fallback). Backed by node::resolve_symbol_def_files.
pub fn symbol_count(&self) -> Result<usize>
Sourcepub fn file_node_count(&self) -> Result<usize>
pub fn file_node_count(&self) -> Result<usize>
Count of file nodes (accurate on both builder paths). Backed by
node::file_count.
Sourcepub fn all_symbols(&self) -> Result<Vec<Node>>
pub fn all_symbols(&self) -> Result<Vec<Node>>
Every symbol node with its line span (unfiltered). Backend for the
call-graph symbol table after the graph_index teardown (#696).
pub fn all_edges_flat(&self) -> Result<Vec<(String, String, String, f64)>>
Trait Implementations§
Source§impl GraphSource for CodeGraph
impl GraphSource for CodeGraph
Source§fn store(&self) -> &Connection
fn store(&self) -> &Connection
Source§fn checks_sources(&self) -> bool
fn checks_sources(&self) -> bool
false for a store
without a project root: a caller that would name several files in one
row must then leave that row to a check that can decide them.Source§fn file_served(&self, path: &str) -> bool
fn file_served(&self, path: &str) -> bool
path may be used now.Auto Trait Implementations§
impl !Freeze for CodeGraph
impl !RefUnwindSafe for CodeGraph
impl !Sync for CodeGraph
impl !UnwindSafe for CodeGraph
impl Forget for CodeGraph
impl Move for CodeGraph
impl Send for CodeGraph
impl Unpin for CodeGraph
impl UnsafeUnpin 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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
impl<A, B, T> HttpServerConnExec<A, B> for Twhere
B: Body,
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