pub enum MemoryLinkRelation {
RelatedTo,
Supersedes,
Contradicts,
DerivedFrom,
ReflectsOn,
DerivesFrom,
}Expand description
v0.7.0 fix campaign R1-M4 — typed relation closed-set for
memory_links.relation. Paired with the SQL-side CHECK constraint
added by the same R1-M4 migration: defense-in-depth so direct-SQL
writers can no longer slip an unknown relation past the Rust
validator.
#[serde(rename_all = "snake_case")] keeps the wire shape and the
memory_links.relation TEXT column byte-identical to the values
the v0.6.x codebase already writes ("related_to", "supersedes",
"contradicts", "derived_from", "reflects_on", plus the
v0.7.0 WT-1-A addition "derives_from" — distinct from
"derived_from" as the atomisation-provenance variant). The
MemoryLinkRelation::from_str / MemoryLinkRelation::as_str
helpers exist because the column is read as a String in many
call sites that are not deserialising through serde (e.g.
rusqlite::Row::get).
Variants§
RelatedTo
Generic association. Default for LinkBody::resolved and the
INSERT default in the SQL schema.
Supersedes
Source supersedes target (newer / authoritative version).
Contradicts
Source contradicts target (incompatible claims).
DerivedFrom
Source is derived from target (consolidation provenance).
ReflectsOn
Source is a reflection on target (recursive-learning provenance, v0.7.0 Task 1/8).
DerivesFrom
Source is an atomisation derivative of target — the typed,
signable, federation-safe expression of the structural
memories.atom_of FK introduced in v0.7.0 WT-1-A (schema v36
sqlite / v35 postgres). Atom row -> parent memory. Participates
in find_paths traversal alongside the other relations.
Distinct from DerivedFrom (consolidation provenance):
atomisation is a finer-grained, recoverable split that emits
one derives_from edge per atom; consolidation merges several
memories into one and emits derived_from edges from the
consolidated memory back to each source.
Implementations§
Source§impl MemoryLinkRelation
impl MemoryLinkRelation
Sourcepub const COUNT: usize = 6
pub const COUNT: usize = 6
Total number of MemoryLinkRelation variants. SSOT for the
“ai-memory supports N typed link relations at v0.7.0” narrative
in CLAUDE.md / README.md / ROADMAP.md / release-notes — adding
a new variant requires bumping this const AND the [all()]
slice in the same commit, or the parity test pin in
tests/memory_link_relation_count_invariant.rs fails the build.
Sourcepub fn from_str(s: &str) -> Option<Self>
pub fn from_str(s: &str) -> Option<Self>
Parse the string form stored in memory_links.relation.
Returns None for unknown values so callers can decide whether
to reject with a typed error or fall back to a default. The
canonical strings are the SQL-side CHECK constraint membership
list — keep this list in sync with the migration.
Sourcepub const fn as_str(&self) -> &'static str
pub const fn as_str(&self) -> &'static str
Canonical wire string for this variant. Mirrors the serde
rename_all and the literals every existing call site already
writes to the DB.
Sourcepub const fn default_relation() -> Self
pub const fn default_relation() -> Self
Canonical default — matches the DEFAULT 'related_to' clause
on memory_links.relation in the schema and the fallback in
LinkBody::resolved.
Sourcepub const fn all() -> &'static [Self; 6]
pub const fn all() -> &'static [Self; 6]
Canonical enumeration of every variant in declaration order
(related_to, supersedes, contradicts, derived_from,
reflects_on, derives_from). Use this anywhere external code
would otherwise hand-roll the list — kg traversal, federation
peer-handshake, capability advertisement, parity tests. The
length == COUNT invariant is pinned by
tests/memory_link_relation_count_invariant.rs.
Trait Implementations§
Source§impl Clone for MemoryLinkRelation
impl Clone for MemoryLinkRelation
Source§fn clone(&self) -> MemoryLinkRelation
fn clone(&self) -> MemoryLinkRelation
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreimpl Copy for MemoryLinkRelation
Source§impl Debug for MemoryLinkRelation
impl Debug for MemoryLinkRelation
Source§impl Default for MemoryLinkRelation
impl Default for MemoryLinkRelation
Source§impl<'de> Deserialize<'de> for MemoryLinkRelation
impl<'de> Deserialize<'de> for MemoryLinkRelation
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Source§impl Display for MemoryLinkRelation
impl Display for MemoryLinkRelation
impl Eq for MemoryLinkRelation
Source§impl FromStr for MemoryLinkRelation
impl FromStr for MemoryLinkRelation
Source§impl Hash for MemoryLinkRelation
impl Hash for MemoryLinkRelation
Source§impl PartialEq for MemoryLinkRelation
impl PartialEq for MemoryLinkRelation
Source§fn eq(&self, other: &MemoryLinkRelation) -> bool
fn eq(&self, other: &MemoryLinkRelation) -> bool
self and other values to be equal, and is used by ==.Source§impl Serialize for MemoryLinkRelation
impl Serialize for MemoryLinkRelation
impl StructuralPartialEq for MemoryLinkRelation
Auto Trait Implementations§
impl Freeze for MemoryLinkRelation
impl RefUnwindSafe for MemoryLinkRelation
impl Send for MemoryLinkRelation
impl Sync for MemoryLinkRelation
impl Unpin for MemoryLinkRelation
impl UnsafeUnpin for MemoryLinkRelation
impl UnwindSafe for MemoryLinkRelation
Blanket Implementations§
impl<T> Boilerplate for T
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,
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.impl<T> ErasedDestructor for Twhere
T: 'static,
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 moreSource§impl<T> Pointable for T
impl<T> Pointable for T
Source§impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> PolicyExt for Twhere
T: ?Sized,
Source§impl<T> ToCompactString for Twhere
T: Display,
impl<T> ToCompactString for Twhere
T: Display,
Source§fn try_to_compact_string(&self) -> Result<CompactString, ToCompactStringError>
fn try_to_compact_string(&self) -> Result<CompactString, ToCompactStringError>
ToCompactString::to_compact_string() Read moreSource§fn to_compact_string(&self) -> CompactString
fn to_compact_string(&self) -> CompactString
CompactString. Read moreSource§impl<T> ToStringFallible for Twhere
T: Display,
impl<T> ToStringFallible for Twhere
T: Display,
Source§fn try_to_string(&self) -> Result<String, TryReserveError>
fn try_to_string(&self) -> Result<String, TryReserveError>
ToString::to_string, but without panic on OOM.