pub struct SystemRanker<'a> { /* private fields */ }Expand description
Personalized PageRank over the HETEROGENEOUS entity reference graph.
Nodes are every rankable entity (id-sorted for determinism): symbols,
components, subsystems, services, flows, contracts, state, reactive,
routes, topics, queues, stores, schemas and files. Edges are trusted
relationships whose both endpoints are rankable entities and whose
predicate normalizes to a reference kind; weights follow the spec
formula. The global vector is computed once per epoch (Main caches the
SystemRanker); task vectors personalize from TaskSeeds with a
warm start blended from the global vector.
Implementations§
Source§impl<'a> SystemRanker<'a>
impl<'a> SystemRanker<'a>
Sourcepub fn new(view: &'a TrustedGraphView<'a>) -> SystemRanker<'a>
pub fn new(view: &'a TrustedGraphView<'a>) -> SystemRanker<'a>
Build the ranker from the trusted view. Deterministic; O(E) edges.
Sourcepub fn with_edge_adjust<F>(
view: &'a TrustedGraphView<'a>,
adjust: F,
) -> SystemRanker<'a>
pub fn with_edge_adjust<F>( view: &'a TrustedGraphView<'a>, adjust: F, ) -> SystemRanker<'a>
Build the ranker with a per-edge weight adjust hook (DoD 23):
adjust(subject, predicate, object, base) -> Option<(mode, value)>.
Modes: add | multiply | replace | veto. None keeps the base weight.
Veto (or non-positive/non-finite result) drops the edge. Deterministic
for a deterministic hook; every other construction step is unchanged.
Sourcepub fn with_edge_adjust_and_extra<F>(
view: &'a TrustedGraphView<'a>,
adjust: F,
extra: &[(String, String, String, f64)],
) -> SystemRanker<'a>
pub fn with_edge_adjust_and_extra<F>( view: &'a TrustedGraphView<'a>, adjust: F, extra: &[(String, String, String, f64)], ) -> SystemRanker<'a>
Build the ranker with an adjust hook plus extra rank-time edges
(§48): (subject, predicate, object, weight) triples that enter
diffusion without becoming canonical facts. Both endpoints must be
rankable universe nodes; unknown ids and non-positive/non-finite
weights are skipped (a bad contributor degrades to no extra edges,
never a failed build). Surviving edges take the same adjust +
rarity path as view edges.
Sourcepub fn with_edge_adjust_extra_and_nodes<F>(
view: &'a TrustedGraphView<'a>,
adjust: F,
extra: &[(String, String, String, f64)],
extra_nodes: &[(String, String)],
) -> SystemRanker<'a>
pub fn with_edge_adjust_extra_and_nodes<F>( view: &'a TrustedGraphView<'a>, adjust: F, extra: &[(String, String, String, f64)], extra_nodes: &[(String, String)], ) -> SystemRanker<'a>
Build the ranker with adjust + extra edges + extra rank nodes
(§124 item 17 RankNodeProvider): (id, kind) pairs merged into the
rank universe before edge indexing. Only ids with a rankable kind
enter (unknown kinds abstain — a contributor that cannot name a
real kind abstains); duplicates of view nodes are skipped; the
universe stays id-sorted and deterministic. Extra nodes are
rank-time only: no entity, relationship, or evidence is written.
Sourcepub fn nodes(&self) -> &[String]
pub fn nodes(&self) -> &[String]
Rankable entity ids in rank order (index i in every vector maps to
nodes()[i]; symbols are a subset).
Sourcepub fn kinds(&self) -> &[String]
pub fn kinds(&self) -> &[String]
Entity kinds parallel to SystemRanker::nodes (index i in
every vector maps to kinds()[i]). Powers ranking.universe.
Sourcepub fn rank_edges(&self) -> Vec<(String, String, String, f64)>
pub fn rank_edges(&self) -> Vec<(String, String, String, f64)>
Surviving rank-universe edges as (subject, predicate, object,
base weight): pre-aggregation triples, id-resolved. Deterministic
(construction order). Powers ranking.edges (§123.12).
Sourcepub fn symbols(&self) -> Vec<String>
pub fn symbols(&self) -> Vec<String>
Ranked symbol entity ids (subset of SystemRanker::nodes),
id-sorted. Symbol-only callers use this to walk the symbol slice of
the heterogeneous vectors.
Sourcepub fn index_of(&self, id: &str) -> Option<usize>
pub fn index_of(&self, id: &str) -> Option<usize>
Node index for a rankable entity id, if it is in the universe.
Sourcepub fn in_degree(&self, id: &str) -> usize
pub fn in_degree(&self, id: &str) -> usize
Distinct referencing sources of a node id (0 when absent).
Sourcepub fn global_vector(&self) -> Vec<f64>
pub fn global_vector(&self) -> Vec<f64>
Precomputed global PageRank vector (architecturally seeded; see
SystemRanker::global_personalization). Main caches the ranker per
epoch and reads this.
Sourcepub fn project_to_symbols(&self, vector: &[f64]) -> Vec<(String, f64)>
pub fn project_to_symbols(&self, vector: &[f64]) -> Vec<(String, f64)>
Project the heterogeneous node scores to surface-relevant symbol scores: a symbol’s score = its own score + 0.4 × the sum of the scores of the entities it OWNS/REGISTERS/PUBLISHES/READS/WRITES/ PARTICIPATES_IN/HANDLES/DEFINES, with the total bonus capped at 0.5. This is how component/flow/contract/state importance reaches the surface — and, via the HANDLES/DEFINES projection, how a hot Route/Schema node (task seed or PPR) reaches its handler/definer symbol. Deterministic: nodes and projection edges are id-sorted.
Returns (symbol id, projected score) pairs, id-sorted.
Sourcepub fn task_vector(&self, seeds: &[TaskSeed]) -> Vec<f64>
pub fn task_vector(&self, seeds: &[TaskSeed]) -> Vec<f64>
Task-personalized PageRank vector. Seeds come from TaskSeeds whose
id is a rankable entity id; the seed vector carries weight at
each matched index. Warm start: 0.3 × global + 0.7 × normalized
seeds. Unresolvable seed sets fall back to the global vector (never
panic).