Skip to main content

UcmGraph

Struct UcmGraph 

Source
pub struct UcmGraph { /* private fields */ }
Expand description

The materialized context graph — primary queryable data structure.

Wraps petgraph’s StableGraph with typed operations and SCIP-identity → NodeIndex lookup.

Implementations§

Source§

impl UcmGraph

Source

pub fn new() -> Self

Source

pub fn add_entity(&mut self, entity: UcmEntity) -> Result<NodeIndex>

Add an entity to the graph. Returns the node index. If an entity with the same SCIP ID exists, returns error.

Source

pub fn upsert_entity(&mut self, entity: UcmEntity) -> NodeIndex

Add or update an entity (upsert semantics for replay safety).

Source

pub fn add_relationship( &mut self, from: &EntityId, to: &EntityId, edge: UcmEdge, ) -> Result<EdgeIndex>

Add a relationship between two entities.

Source

pub fn invalidate_file(&mut self, file_path: &str) -> Vec<EntityId>

Remove all entities and edges owned by a file path. This is the Glean-style “hide facts” operation for incremental updates.

Source

pub fn get_entity(&self, id: &EntityId) -> Option<&UcmEntity>

Get an entity by its SCIP ID.

Source

pub fn all_entities(&self) -> Vec<&UcmEntity>

Get all entities in the graph.

Source

pub fn dependencies(&self, id: &EntityId) -> Result<Vec<(&UcmEntity, &UcmEdge)>>

Get direct dependencies of an entity (outgoing edges).

Source

pub fn reverse_deps(&self, id: &EntityId) -> Result<Vec<(&UcmEntity, &UcmEdge)>>

Get reverse dependencies of an entity (incoming edges). “What depends on this entity?”

This is the core query for impact analysis — when entity X changes, which entities are affected? (Google TAP, Meta PTS)

Source

pub fn stats(&self) -> GraphStats

Get graph statistics.

Source

pub fn inner(&self) -> &StableGraph<UcmEntity, UcmEdge>

Get a read-only reference to the inner petgraph.

Source

pub fn entity_node_index(&self, id: &EntityId) -> Option<NodeIndex>

Resolve an EntityId to a NodeIndex, if it exists.

Source

pub fn entity_index_map(&self) -> &HashMap<String, NodeIndex>

Get a reference to the full entity index map.

Source

pub fn to_json(&self) -> Result<String>

Serialize the graph to JSON.

Trait Implementations§

Source§

impl Debug for UcmGraph

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for UcmGraph

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

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<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

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, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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.