Skip to main content

CodeGraph

Struct CodeGraph 

Source
pub struct CodeGraph { /* private fields */ }

Implementations§

Source§

impl CodeGraph

Source

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.

Source

pub fn serves_symbol(&self, path: &str, name: &str) -> bool

Whether a reference to the symbol name of path may be served now.

Source

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.

Source

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 a test named 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

Source

pub fn open(project_root: &str) -> Result<Self>

Source

pub fn open_in_memory() -> Result<Self>

Source

pub fn db_path(&self) -> &Path

Source

pub fn connection(&self) -> &Connection

Source

pub fn upsert_node(&self, node: &Node) -> Result<i64>

Source

pub fn upsert_edge(&self, edge: &Edge) -> Result<()>

Source

pub fn get_node_by_path(&self, file_path: &str) -> Result<Option<Node>>

Source

pub fn get_node_by_symbol( &self, name: &str, file_path: &str, ) -> Result<Option<Node>>

Source

pub fn remove_file_nodes(&self, file_path: &str) -> Result<()>

Source

pub fn edges_from(&self, node_id: i64) -> Result<Vec<Edge>>

Source

pub fn edges_to(&self, node_id: i64) -> Result<Vec<Edge>>

Source

pub fn dependents(&self, file_path: &str) -> Result<Vec<String>>

Source

pub fn dependencies(&self, file_path: &str) -> Result<Vec<String>>

Source

pub fn impact_analysis( &self, file_path: &str, max_depth: usize, ) -> Result<ImpactResult>

Source

pub fn dependency_chain( &self, from: &str, to: &str, ) -> Result<Option<DependencyChain>>

Source

pub fn related_files( &self, file_path: &str, limit: usize, ) -> Result<Vec<(String, f64)>>

Source

pub fn file_connectivity( &self, file_path: &str, ) -> Result<HashMap<String, (usize, usize)>>

Source

pub fn node_count(&self) -> Result<usize>

Source

pub fn edge_count(&self) -> Result<usize>

Source

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.

Source

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.

Source

pub fn has_semantic_answers(&self) -> Result<bool>

Whether a semantic backend has answered for this graph at all.

Source

pub fn semantic_prune( &self, live_hashes: &HashMap<String, String>, ) -> Result<usize>

Removes cached answers for vanished or changed caller files.

Source

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.

Source

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

Source

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.

Source

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

Source

pub fn all_cross_source_edges(&self) -> Vec<IndexEdge>

All cross-source edges as IndexEdges, ready for cross_source_hints.

Source

pub fn cross_source_edge_count(&self) -> Result<usize>

Source

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.

Source

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.

Source

pub fn clear(&self) -> Result<()>

Source

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.

Source

pub fn upsert_file_catalog(&self, entry: &FileCatalogEntry) -> Result<()>

Source

pub fn get_file_catalog(&self, path: &str) -> Result<Option<FileCatalogEntry>>

Source

pub fn file_catalog_count(&self) -> Result<usize>

Source

pub fn file_catalog_paths(&self) -> Result<Vec<String>>

Source

pub fn find_symbols( &self, name: &str, file_filter: Option<&str>, kind_filter: Option<&str>, ) -> Result<Vec<Node>>

Source

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.

Source

pub fn symbol_count(&self) -> Result<usize>

Source

pub fn file_node_count(&self) -> Result<usize>

Count of file nodes (accurate on both builder paths). Backed by node::file_count.

Source

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

Source

pub fn all_edges_flat(&self) -> Result<Vec<(String, String, String, f64)>>

Trait Implementations§

Source§

impl GraphSource for CodeGraph

Source§

fn store(&self) -> &Connection

The connection the rows are read from.
Source§

fn checks_sources(&self) -> bool

Whether this source asks current sources at all. 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

Whether the file path may be used now.
Source§

fn symbol_served(&self, path: &str, name: &str) -> bool

Whether the symbol name of path may be used now.
Source§

fn rankable_files( &self, files: Vec<String>, edges: &[(String, String)], seeds: &[String], ) -> HashSet<String>

The files of files that may enter a computation over the whole graph (GraphGate::ranking_files).

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<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<A, B, T> HttpServerConnExec<A, B> for T
where B: Body,

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> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

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 = !

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

fn try_from(value: U) -> Result<T, !>

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