Skip to main content

memory_identity

Function memory_identity 

Source
pub fn memory_identity() -> Schema
Expand description

The identity preset: SAME_AS rules over the aliases list, and over the declared alias_keys list.

Opt-in, never part of memory_defaults: a store gains rules only when someone asks (SKILL.md: never create a rule silently), so this is applied by mushroomdb schema apply <db> --memory-identity and nothing else.

Sixteen rules, all global (namespace: None):

  • one same-label rule per entity label and for the provisional label — Person→Person, …, Entity→Entity — Overlap on aliases at SAME_AS_FLOOR. A same-label rule derives both directions, which crate::memory::identity::same_as_pairs reads as one claim;
  • one directed rule from the provisional label to each entity label — Entity→Person, … — the same Overlap. A stub remember made from an about key is an Entity for life, and a Person→Person rule never sees it, so without these the case identity exists for — a subject named before it was described — could never link;
  • one directed rule from each entity label to the provisional label — Person→Entity, … — KeyMatch on alias_keys: an entity that declares an alias equal to a stub’s key links that stub, at 1.0. Overlap cannot: a stub keyed matt holds one alias, and a declared alias is not among the entity’s own — those are its key, its name and the name’s words. It reads alias_keys, not aliases, because aliases holds derived name words, and an entity merely named “Alex” must not claim a stub keyed alex. The rules key on labels, and a node about created keeps Entity for life: a stub that was later described can still be claimed, and cannot itself claim.

The KeyMatch rules stand alone rather than under an Any beside the Overlap: Any is never KeyMatch-rooted, so it would lose the engine’s foreign-key fast path (core_rules::is_keymatch_rooted). A pair both kinds link carries one edge per direction, each owned by its own rule, and is still one claim, at the higher score.

weight_prop and max_edges are set explicitly: apply_schema takes a RuleDef as given, without the defaults MCP create_rule fills in.