pub struct Graph {
pub seeds: Vec<(EntityId, f32)>,
pub hops: usize,
pub k: usize,
pub graph: String,
/* private fields */
}Expand description
Graph-anchored retrieval operator.
Construction is fluent — wire at recall()-build time, the network call
only happens at .retrieve() time. The entity_ids come from the
RETRIEVE-13 planner stub (extracted from query text) per D-13. Empty
entity_ids short-circuits to an empty result set without touching
storage (the planner returns no entities when the query has no entity
mentions; treat that as “graph branch contributes nothing” rather than an
error).
Fields§
§seeds: Vec<(EntityId, f32)>Anchor seeds with per-seed confidence in [0.0, 1.0]. The operator
snapshots a HashMap<EntityId, f32> from this vector at construction
for O(1) confidence lookup after Cypher returns.
hops: usize§k: usize§graph: StringImplementations§
Source§impl Graph
impl Graph
Sourcepub fn anchored(seeds: Vec<(EntityId, f32)>, hops: usize) -> Graph
pub fn anchored(seeds: Vec<(EntityId, f32)>, hops: usize) -> Graph
Graph::anchored(seeds, hops) — primary constructor per D-13.
seeds carries (EntityId, confidence) pairs where confidence is
the planner’s belief that the entity is actually relevant to the
query. Values are clamped to [0.0, 1.0]. Duplicates collapse to
MAX (safe default — never demote a high-confidence anchor by passing
a low-confidence duplicate).
hops is clamped to [1, MAX_GRAPH_HOPS] (D-14):
hopsgreater than 5 — clamped to 5 (DoS defense; bounded BFS fan-out)hops == 0— clamped up to 1 (zero-hop traversal would only return the anchor entities, which the caller already has)
k defaults to DEFAULT_GRAPH_K (matches Vector/Keyword default of
30) and is clamped via super::clamp_k.
Sourcepub fn with_decay(self, decay: GraphDecay) -> Graph
pub fn with_decay(self, decay: GraphDecay) -> Graph
Apply recency decay to the traversal (ADD task ft-navigate-recall).
The λ rides StoragePort::graph_traverse_decayed; backends without
capabilities().graph_decay_native surface NotSupported — gate on
the capability before composing decay into a recall.
Sourcepub fn entity_ids(&self) -> Vec<EntityId>
pub fn entity_ids(&self) -> Vec<EntityId>
Convenience: list of seed EntityIds (without confidence). Mirrors
the pre-Wave-4 entity_ids field for callers that only need the keys.
Sourcepub fn with_k(self, k: usize) -> Graph
pub fn with_k(self, k: usize) -> Graph
Override the candidate count. Clamped at super::MAX_K.
Sourcepub fn with_graph(self, graph: impl Into<String>) -> Graph
pub fn with_graph(self, graph: impl Into<String>) -> Graph
Override the graph name (defaults to LUNARIS_GRAPH_NAME). Useful
for tenant-isolated deployments that scope each tenant to its own
AGE / Moon graph.
Sourcepub fn and<R>(self, other: R) -> AndRetrieverwhere
R: Retriever + 'static,
pub fn and<R>(self, other: R) -> AndRetrieverwhere
R: Retriever + 'static,
Concurrent fan-out — runs THIS graph branch alongside other and
concatenates results (per-source ranking preserved via
SourceOp). Downstream fuse_rrf groups by source_op to fold
per-branch rankings.
Sourcepub fn or<R>(self, other: R) -> OrRetrieverwhere
R: Retriever + 'static,
pub fn or<R>(self, other: R) -> OrRetrieverwhere
R: Retriever + 'static,
Concurrent fan-out — runs THIS graph branch alongside other and
unions results by id (max score wins on duplicate id).
Sourcepub fn then<R>(self, other: R) -> ThenRetrieverwhere
R: Retriever + 'static,
pub fn then<R>(self, other: R) -> ThenRetrieverwhere
R: Retriever + 'static,
Sequential narrow — runs THIS graph branch first, then passes its hit
ids as a Filter::Or(Filter::Eq{id, …}) to other.
Sourcepub fn top(self, n: usize) -> TopRetriever
pub fn top(self, n: usize) -> TopRetriever
Cap the final result set after the graph traversal resolves.
Sourcepub fn rerank(self, reranker: Arc<dyn Reranker>) -> RerankRetriever
pub fn rerank(self, reranker: Arc<dyn Reranker>) -> RerankRetriever
Wrap with a cross-encoder rerank pass (Plan 02-03).
Sourcepub fn degraded_fallback<R>(self, fallback: R) -> DegradedFallbackRetrieverwhere
R: Retriever + 'static,
pub fn degraded_fallback<R>(self, fallback: R) -> DegradedFallbackRetrieverwhere
R: Retriever + 'static,
Wrap with a fallback retriever — if THIS graph path errors (e.g., a
backend without graph support returns NotSupported, or Moon
GRAPH.QUERY hits a transient disconnect), switch to fallback and
tag returned hits with degraded: true (Plan 02-03).
Trait Implementations§
Source§impl Retriever for Graph
impl Retriever for Graph
Source§fn retrieve<'life0, 'life1, 'async_trait>(
&'life0 self,
ctx: &'life1 QueryContext,
) -> Pin<Box<dyn Future<Output = Result<Vec<RawHit>, LunarisError>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
Graph: 'async_trait,
fn retrieve<'life0, 'life1, 'async_trait>(
&'life0 self,
ctx: &'life1 QueryContext,
) -> Pin<Box<dyn Future<Output = Result<Vec<RawHit>, LunarisError>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
Graph: 'async_trait,
ctx and return the unranked-or-ranked
raw hits this operator produces. The downstream stage (combinator
or fuse_rrf) decides what to do with them.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&dyn Any so the RRF routing dispatcher can
recover the concrete operator type. Concrete operators override with
fn as_any(&self) -> &dyn Any { self }. The default returns a sentinel
&() so unknown operators downcast as None (and the dispatcher falls
back to client-side RRF instead of misrouting).Auto Trait Implementations§
impl Freeze for Graph
impl RefUnwindSafe for Graph
impl Send for Graph
impl Sync for Graph
impl Unpin for Graph
impl UnsafeUnpin for Graph
impl UnwindSafe for Graph
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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