Expand description
Type-safe enumeration of the five memories.source CHECK constraint values.
Replaces the footgun pub source: String to prevent G29-style regressions.
Type-safe enumeration of the memories.source column domain.
The CHECK constraint on the memories table accepts exactly five values:
agent, user, system, import, sync. Any other literal is rejected
at runtime by SQLite with SQLITE_CONSTRAINT_CHECK.
This enum eliminates the silent footgun of pub source: String by forcing
every call-site to pick a typed variant that maps deterministically to one
of the five allowed CHECK values via crate::memory_source::MemorySource::as_str.
§Examples
use sqlite_graphrag::memory_source::MemorySource;
let src = MemorySource::Agent;
assert_eq!(src.as_str(), "agent");
let parsed = MemorySource::try_from("user").expect("user is valid");
assert_eq!(parsed, MemorySource::User);
let err = MemorySource::try_from("enrich").unwrap_err();
// Locale-safe, mirroring `rejects_unknown_source` below: the message comes
// from the `crate::i18n::validation` catalog and follows the host locale,
// so asserting only the English wording fails on a `pt-BR` machine.
let msg = format!("{err}");
assert!(
msg.contains("invalid memory source") || msg.contains("fonte de memória inválida"),
"unexpected message: {msg}"
);Enums§
- Memory
Source - Enumerates the five values accepted by the
memories.sourceCHECK constraint.
Functions§
- validate_
source - Validates a raw
memories.sourcestring against the CHECK constraint domain.