Skip to main content

Module memory_source

Module memory_source 

Source
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 [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();
assert!(format!("{err}").contains("invalid memory source"));

Enums§

MemorySource
Enumerates the five values accepted by the memories.source CHECK constraint.

Functions§

validate_source
Validates a raw memories.source string against the CHECK constraint domain.