Skip to main content

Module store_builder

Module store_builder 

Source
Expand description

Shared helper for turning ParseResults into a populated Store.

The runtime engine calls this during Engine::init + reload and attach_read_mem. The strict validator calls it during V1 graph construction. Having one implementation guarantees both paths use identical stub + edge semantics.

Structs§

LoadCollector
Context passed to push_entities_into_store for load-time drift detection. Load-path call sites pass Some(LoadCollector { .. }) so authored nested-prefix wiki-links (the classic mem-rename drift footprint) emit a SuspiciousNestedPrefix warning — mutation-path call sites pass None to stay silent (an author editing an entity that still has a drifted link should not see the warning refire on every save; load already caught it).

Functions§

last_segment_suffix
Extract the last --separated segment of a mem name (e.g. test-mem-pluginplugin). Used to derive the known-mem-suffix set from the roster.
make_stub
Minimal placeholder entity for a wiki-link target that has no markdown file. Tagged StubKind::LoadTime — this constructor fires from parser-driven paths (boot, reload, attach) where the stub is auto-emitted from a wiki-link to a not-yet-present target. Mutation paths that need ForwardReference / Residual use the engine-internal make_stub in engine/mutation/mod.rs which takes an explicit kind.
push_entities_into_store
Upsert parse results into the store, adding explicit relationship edges and auto-stubbing any unknown targets. Body wiki-links are not edge sources — under the alias model every edge originates from the auto-managed ## Relationships section.
reconstruct_incoming_cross_mem_edges
Re-add edges that point INTO reloaded_mem from entities living in other mems, after a per-mem reload of reloaded_mem.
remap_alias_target_edge_sources
Remap edge sources to reflect each source mem’s alias_target_rel_type schema pointer: edges whose rel_type equals the pointer are flipped from Explicit to BodyLink. Idempotent — running it repeatedly produces the same result.
validate_loaded_relations
Validate every loaded entity’s ## Relationships entries against the source mem’s schema and the wiki-link grammar. Invalid relations are dropped from both the store’s edge index and the entity’s in-memory relationships list; each drop emits a PARSED_RELATION_INVALID warning naming the offending entity, rel-type, target, and reason.