Skip to main content

MemoryLinkRelation

Enum MemoryLinkRelation 

Source
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

Source

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.

Source

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.

Source

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.

Source

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.

Source

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

Source§

fn clone(&self) -> MemoryLinkRelation

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Copy for MemoryLinkRelation

Source§

impl Debug for MemoryLinkRelation

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for MemoryLinkRelation

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl<'de> Deserialize<'de> for MemoryLinkRelation

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl Display for MemoryLinkRelation

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Eq for MemoryLinkRelation

Source§

impl FromStr for MemoryLinkRelation

Source§

type Err = String

The associated error which can be returned from parsing.
Source§

fn from_str(s: &str) -> Result<Self, Self::Err>

Parses a string s to return a value of this type. Read more
Source§

impl Hash for MemoryLinkRelation

Source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl PartialEq for MemoryLinkRelation

Source§

fn eq(&self, other: &MemoryLinkRelation) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl Serialize for MemoryLinkRelation

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl StructuralPartialEq for MemoryLinkRelation

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Boilerplate for T
where T: Copy + Send + Sync + Debug + PartialEq + 'static,

Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

Source§

impl<T> DynClone for T
where T: Clone,

Source§

fn __clone_box(&self, _: Private) -> *mut ()

Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
Source§

impl<T> ErasedDestructor for T
where T: 'static,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> FromRef<T> for T
where T: Clone,

Source§

fn from_ref(input: &T) -> T

Converts to this type from a reference to the input type.
Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts 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 more
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToCompactString for T
where T: Display,

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
Source§

impl<T> ToStringFallible for T
where T: Display,

Source§

fn try_to_string(&self) -> Result<String, TryReserveError>

ToString::to_string, but without panic on OOM.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more