Skip to main content

Store

Struct Store 

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

Persistent graph store. Point queries never load the whole graph.

Implementations§

Source§

impl Store

Source

pub fn nodes_named(&self, name: &str) -> Result<Vec<Node>, StoreError>

Nodes whose name matches exactly (case-sensitive).

Source

pub fn nodes_with_token(&self, word: &str) -> Result<Vec<Node>, StoreError>

Nodes indexed under this exact lowercase token (see node_tokens).

Source

pub fn candidates_for_terms( &self, terms: &[String], ) -> Result<Vec<Node>, StoreError>

Recall candidates for query terms: union over each term as an exact token plus its trailing-s singular variant. Deduped by node id, sorted by id — deterministic. The consumer re-scores.

Source

pub fn search(&self, query: &str, limit: usize) -> Result<Vec<Node>, StoreError>

Fuzzy candidates: nodes sharing the most trigrams with the query, best first, capped at limit.

Source§

impl Store

Source

pub const CURRENT_SCHEMA: u32 = SCHEMA_VERSION

The schema version this binary writes.

Source

pub fn schema_of(path: impl AsRef<Path>) -> Result<Option<u32>, StoreError>

Read a database’s schema stamp without opening for write and without triggering the wipe-on-mismatch in Store::create.

Source§

impl Store

Source

pub fn create(path: impl AsRef<Path>) -> Result<Self, StoreError>

Create or open the database and ensure all tables exist. An existing database with a different schema version is deleted and recreated — the next build re-derives everything from source.

Source

pub fn open(path: impl AsRef<Path>) -> Result<Self, StoreError>

Source

pub fn schema(&self) -> Result<Option<u32>, StoreError>

The schema stamp of this open database, if any.

Source

pub fn write_graph(&self, graph: &Graph) -> Result<(), StoreError>

Persist a whole graph in one transaction (test/export convenience; the incremental path goes through update_files).

Source

pub fn unresolved_count(&self) -> Result<u64, StoreError>

Total stored unresolved references.

Source

pub fn all_unresolved(&self) -> Result<Vec<Reference>, StoreError>

Every stored unresolved reference — cross-repo boundary resolution input (a workspace resolves these against other members’ symbols).

Source

pub fn unresolved_refs( &self, file: Option<&str>, name: Option<&str>, ) -> Result<Vec<Reference>, StoreError>

Stored unresolved references, optionally narrowed to one file and/or a name (final-segment match, same rule as Store::unresolved_named). The sinter unresolved listing.

Source

pub fn references_in(&self, file: &str) -> Result<Vec<Reference>, StoreError>

Unresolved references recorded for one file.

Source

pub fn resolve_fingerprint( &self, key: &str, ) -> Result<Option<String>, StoreError>

The fingerprint a non-source resolution input (key: “scip”, “module_roots”) was last resolved against, if any.

Source

pub fn set_resolve_fingerprint( &self, key: &str, fingerprint: Option<&str>, ) -> Result<(), StoreError>

Idempotent: an unchanged fingerprint opens no write transaction, keeping a clean build write-free (parallel readers never queue behind redb’s exclusive writer for a no-op).

Source

pub fn unresolved_named(&self, name: &str) -> Result<usize, StoreError>

Unresolved references whose written name ends in this name — the honest-empty signal for blast-radius queries: a nonzero count means the graph may be missing dependents of a symbol with that name.

Source

pub fn node(&self, id: &NodeId) -> Result<Option<Node>, StoreError>

Source

pub fn node_count(&self) -> Result<u64, StoreError>

Source

pub fn edge_count(&self) -> Result<u64, StoreError>

Source

pub fn out_edges(&self, id: &NodeId) -> Result<Vec<Edge>, StoreError>

Edges leaving id.

Source

pub fn in_edges(&self, id: &NodeId) -> Result<Vec<Edge>, StoreError>

Edges arriving at id.

Source

pub fn file_hashes(&self) -> Result<Vec<(String, FileStamp)>, StoreError>

(file, stamp) for every stored file — the changed-set diff base.

Source

pub fn facts(&self, file: &str) -> Result<Option<FileFacts>, StoreError>

Source

pub fn compact(&mut self) -> Result<bool, StoreError>

Reclaim free pages. Worth running after bulk rebuilds; skipped on incremental updates (it rewrites the file and would blow the <1s one-file-edit budget). redb compaction is iterative — repeat until it reports no further progress (bounded).

Source

pub fn all_imports(&self) -> Result<Vec<Reference>, StoreError>

Every stored import reference — re-export chain-walking input.

Source

pub fn all_nodes(&self) -> Result<Vec<Node>, StoreError>

Every stored node — resolution index input. Compact scan of the node table; queries never need this.

Source

pub fn in_degrees(&self) -> Result<Vec<(String, usize)>, StoreError>

Non-Contains in-degree per node id, streamed straight off the IN_EDGES table — hub ranking without materializing (and re-validating) the whole graph. Nodes with zero such in-edges are omitted.

Source

pub fn read_graph(&self) -> Result<Graph, StoreError>

Rebuild the full in-memory graph, re-validating every invariant. Export/debug path only — queries must not need this.

Source§

impl Store

Source

pub fn dependents( &self, id: &NodeId, filter: &EdgeFilter, max_depth: usize, ) -> Result<Vec<Reached>, StoreError>

Reverse blast radius: everything transitively depending on id (incoming non-Contains edges), breadth-first, deduplicated.

Source

pub fn dependencies( &self, id: &NodeId, filter: &EdgeFilter, max_depth: usize, ) -> Result<Vec<Reached>, StoreError>

Forward transitive closure: everything id depends on (outgoing non-Contains edges), breadth-first, deduplicated. A file start seeds through its Contains edges (a file’s dependencies live in the symbols it contains), silently — containment is not a dependency.

Source

pub fn shortest_path( &self, from: &NodeId, to: &NodeId, filter: &EdgeFilter, ) -> Result<Option<Vec<Edge>>, StoreError>

Shortest edge path from -> to over outgoing edges, or None.

Source§

impl Store

Source

pub fn update_files( &self, changed: &[FileFacts], removed: &[String], ) -> Result<NameDelta, StoreError>

Apply extraction results: changed files get their derived state replaced, removed files get theirs deleted. One transaction.

The returned delta is also merged into a persistent pending record committed atomically with this transaction; it survives a crash between this call and the resolution pass, and the pipeline clears it (see Store::clear_pending_delta) only after hash stamps commit. Replaying it on the next build recovers dependent-file bindings that would otherwise be lost with their in-edges.

Source

pub fn pending_delta(&self) -> Result<NameDelta, StoreError>

The crash-residue delta: the union of every Store::update_files delta since the last Store::clear_pending_delta. Empty on a cleanly finished build.

Source

pub fn clear_pending_delta(&self) -> Result<(), StoreError>

Mark the current build’s derivation fully resolved and stamped. Call only after hash stamps commit; a crash before this leaves the pending delta for the next build to replay (idempotent — replay re-resolves files into the same edges).

Source

pub fn commit_hashes(&self, changed: &[FileFacts]) -> Result<(), StoreError>

Mark files fully derived by recording their content hashes. Call only after every derived table (edges, unresolved) is consistent. Stores a bare hash (no stat stamp), so the next scan re-hashes these files once; the build path uses Store::commit_stamps.

Source

pub fn commit_stamps( &self, rows: &[(String, FileStamp)], ) -> Result<(), StoreError>

Store::commit_hashes with the stat identity attached: the scan reuses each stored hash while (mtime, len) still match. Also the stamp-refresh path for touched-but-unchanged files. Empty input opens no write transaction (the clean-build no-op path).

Source

pub fn ref_files( &self, names: &BTreeSet<String>, ) -> Result<BTreeSet<String>, StoreError>

Files containing references with any of these names — the set an update invalidates beyond the changed files themselves.

Source

pub fn dynamic_edge_dst_files( &self, files: &BTreeSet<String>, ) -> Result<BTreeSet<String>, StoreError>

Read-only lookahead for Store::apply_resolution: the dst files of Dynamic edges whose src node lives in one of these files. Those files’ trait-impl facts must join the re-resolution set or their fan-out edges would be silently lost (dynamic edges are src-owned like every resolution edge, but derived from dst-file facts).

Source

pub fn apply_resolution( &self, teardown: &BTreeSet<String>, edges: &[Edge], unresolved_files: &BTreeSet<String>, unresolved: &[Reference], ) -> Result<(), StoreError>

Commit one resolution pass atomically: drop non-structural (resolution) edges whose src node lives in a teardown file, insert the re-derived edges (both directions), and replace the unresolved set for unresolved_files. One transaction — a crash leaves either the old resolution state or the new one, never a torn-down middle.

Source

pub fn insert_edges(&self, edges: &[Edge]) -> Result<(), StoreError>

Insert resolution edges (both directions).

Auto Trait Implementations§

§

impl !RefUnwindSafe for Store

§

impl !UnwindSafe for Store

§

impl Freeze for Store

§

impl Send for Store

§

impl Sync for Store

§

impl Unpin for Store

§

impl UnsafeUnpin for Store

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.