Expand description
BFS reachability search and orphan/stub detection.
Structs§
- Connectivity
- One entity’s degree counts.
total == incoming + outgoing; kept explicit so the JSON wire shape is self-describing and callers don’t re-derive it. - Reached
Via - One entity reached by
reachable_via: the edge label it was first reached by, the depth of that first reach (1 = direct neighbour), and the direction that reaching edge was traversed in — so abothwalk stays interpretable per hit.
Enums§
- Traversal
Direction - Traversal direction relative to the seed, applied at EVERY hop —
depth > 1 is a pure transitive closure in the chosen direction,
never a mixed walk (an entity reachable only by alternating
directions is not in an
outorinresult at any depth; that per-hop property is what makes a fall-through analysis correct).
Functions§
- cmp_
by_ dependency - Centrality ordering: dependency degree (
typed_total) descending first, then rawtotaldescending, thenidlexicographic ascending as a stable deterministic tie-break. Ranking bytyped_totalkeeps a co-mention-inflated hub from outranking a real dependency hub. - connectivity_
for - Compute one entity’s raw and typed degree.
incoming_countsdecides which incoming edges contribute (e.g. source-in-mem scoping for a mem-filtered health view); every outgoing edge always counts. Typed degree excludesEdgeSource::BodyLink(auto-emitted mention) edges. - find_
orphans - Find orphan entities — non-stub entities with no edges at all (completely isolated).
- find_
orphans_ with_ schemas - Schema-aware orphan scan: like
find_orphans, but entities whose type declaresleaf: truein their mem’s schema are exempt — a leaf is edge-less BY CONSTRUCTION, so counting it as an orphan is noise that masks real orphans (agent-trust plan 06). The exempted population stays visible throughleaf_population. An empty schema map (tests, ad-hoc callers) reproduces the schema-blind behaviour exactly. - find_
stubs - Find stub entities — entities created from unresolved references. Returns each stub with the list of entities that reference it.
- leaf_
population - The leaf population health reports beside the orphan axis: for
every leaf-declared type with at least one real entity, the count
of its entities, keyed
<schema_ref>:<type>. Visible, never vanished — the reader still sees the population the orphan exemption covers. - most_
connected - Find the most connected non-stub entities, ranked by dependency degree
(typed edges) — see
cmp_by_dependency. Returns up tolimitentries. - reachable_
distances - Returns each reached entity’s hop-distance from
from— the depth at which BFS first reaches it (fromitself is 0), following only edges admitted bydirectionat every hop. The distances drive proximity ranking of arelated_toneighbourhood: nearer first. - reachable_
via - Find all entities reachable from
fromby walking only edges whoserel_typeis inedge_types, up tomax_depthhops, following only edges admitted bydirectionat every hop. Returns oneReachedViaper reached entity — neverfromitself. - would_
cycle - Would adding an edge
from --rel_type--> toclose a cycle in the subgraph restricted to edges ofrel_type? Returns the back-path as[to, …, from]when a cycle exists,Noneotherwise.