pub enum EditSource {
Human,
Llm,
Hook,
Agent,
}Expand description
v0.7.0 Provenance Gap 5 (issue #888) — typed edit-source
discriminator gating the storage::update write-path branch.
EditSource::Human(default) — direct in-place mutation, the v0.6.x / pre-Gap-5 behaviour. Content is overwritten; the row’sversionis bumped; no archive is created.EditSource::Llm/EditSource::Hook— append-and-archive. A NEW memory row is minted carrying the patched content; asupersedeslink is written pointing new→old; the OLD row is archived witharchive_reason = 'superseded'so callers can rewind viamemory_archive_listto read the pre-edit state.
The split exists so caller intent (human-typed correction vs. curator/LLM rewrite) is preserved in the audit trail. Mem9’s pattern: in-place for human edits, append-and-archive for programmatic rewrites where the new content semantically replaces the old.
Variants§
Human
Direct in-place mutation of the existing row. Default.
Llm
Append-and-archive: mint a NEW row + supersedes link + archive
the OLD row with archive_reason='superseded'.
Hook
Append-and-archive: same shape as EditSource::Llm but
records that a substrate hook triggered the rewrite.
Agent
v0.7.x issue #1600 — direct in-place mutation performed by an
AI/NHI agent. Mutation semantics are IDENTICAL to
EditSource::Human (does NOT route through
append-and-archive); the variant exists so the audit trail can
distinguish a human-typed correction from an agent-initiated
in-place edit. When edit_source is omitted on memory_update
the default is derived from the resolved caller id via
EditSource::default_for_agent_id.
Implementations§
Source§impl EditSource
impl EditSource
Sourcepub const ALL: [Self; 4]
pub const ALL: [Self; 4]
#1600 — the closed wire vocabulary, in declaration order. The
memory_update validation error names the valid set from this
const so the message can never drift from the parser below.
Sourcepub fn as_str(&self) -> &'static str
pub fn as_str(&self) -> &'static str
Column-wire string used in audit log entries + the archive
row’s archive_reason-adjacent metadata.
Sourcepub fn from_str(s: &str) -> Option<Self>
pub fn from_str(s: &str) -> Option<Self>
Parse the column-wire string. Returns None on unrecognised
values; per #1600 the MCP memory_update surface now surfaces
None as a validation ERROR naming EditSource::ALL instead
of silently defaulting to EditSource::Human.
Sourcepub fn default_for_agent_id(agent_id: &str) -> Self
pub fn default_for_agent_id(agent_id: &str) -> Self
#1600 — default edit-source for an UPDATE whose caller omitted
edit_source, derived from the resolved caller agent id: ids
under crate::identity::sentinels::AI_AGENT_ID_PREFIX
(ai:…) default to EditSource::Agent; every other shape
(host:…, anonymous:…, bare operator ids) keeps the
historical EditSource::Human default.
Sourcepub fn appends_and_archives(&self) -> bool
pub fn appends_and_archives(&self) -> bool
true when the edit-source semantics call for the
append-and-archive write path (vs. in-place mutation).
Trait Implementations§
Source§impl Clone for EditSource
impl Clone for EditSource
Source§fn clone(&self) -> EditSource
fn clone(&self) -> EditSource
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 EditSource
Source§impl Debug for EditSource
impl Debug for EditSource
Source§impl Default for EditSource
impl Default for EditSource
Source§fn default() -> EditSource
fn default() -> EditSource
Source§impl<'de> Deserialize<'de> for EditSource
impl<'de> Deserialize<'de> for EditSource
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>,
impl Eq for EditSource
Source§impl PartialEq for EditSource
impl PartialEq for EditSource
Source§fn eq(&self, other: &EditSource) -> bool
fn eq(&self, other: &EditSource) -> bool
self and other values to be equal, and is used by ==.Source§impl Serialize for EditSource
impl Serialize for EditSource
impl StructuralPartialEq for EditSource
Auto Trait Implementations§
impl Freeze for EditSource
impl RefUnwindSafe for EditSource
impl Send for EditSource
impl Sync for EditSource
impl Unpin for EditSource
impl UnsafeUnpin for EditSource
impl UnwindSafe for EditSource
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 more