Skip to main content

Module sqlite

Module sqlite 

Source
Expand description

The SQLite implementation of the crate::stores contract: facts with privacy and channel provenance, episodes, the claim graph, structured personal memory, people and learned habits.

SqliteMemory works on a pool the host opens, so memory can share one database file (and its encryption) with the host’s other tables.

Structs§

ConflictCandidate
An active fact as the numeric-conflict planner sees it.
ExactChannelIds
Exact channel-id comparison, no channel derived from session ids.
ExportFile
One file of a readable export.
FoldCandidate
An active fact as the fold planner sees it.
MemoryClaimRecord
MemoryRetention
One pass of retention over a database holding the memory tables.
MemoryRetentionPolicy
How long each kind of memory is kept, in days. Zero keeps it forever.
MemoryRetentionStats
Rows removed by one pass.
NumericConflict
Two active facts that look like one attribute with two values.
PlannedFold
One fact to retire into the fact that keeps its knowledge.
SqliteMemory
Long-term memory in SQLite.

Enums§

ConflictVerdict
What to do with one conflicting pair.
FoldRule
Which rule found a fold.
FoldScope
Who can see a fact, as far as merging copies of it goes. Two facts in one class are visible to exactly the same audiences, so one can stand in for the other without hiding or widening anything.

Constants§

NUMERIC_CONFLICT_MIN_SIMILARITY
Whole-fact similarity at which two facts whose numbers differ are taken as one attribute holding two values (db_probe --fact-conflict-audit measured it on a live store).
ONE_VALUE_MIN_SIMILARITY
Full-fact similarity at which a value of two or more words, identical under another key, is the same fact. Measured on a live store of 4,747 facts: from here up pairs are reworded keys for one value; below it different things start to share a value (two sites on one platform).
ONE_WORD_VALUE_MIN_SIMILARITY
The same for a one-word value (ddev, Rust), which also needs a key word in common: one word is shared by many unrelated attributes.
OWNER_QUOTED_SOURCE
Source of a per-turn fact the owner asserted, with a verbatim quote from their own message checked against it. Not owner-authored (the quote proves the words, not that the value follows from them, nor who wrote pasted text), but above anything a background extractor inferred.

Traits§

ChannelIds
How the host’s channel identifiers relate. The defaults suit a host whose ids are stable and carry no channel in the session id.

Functions§

build_fact_embedding_text
Build a natural-language embedding text for a fact.
detect_overlaps
Identify active facts that look like conceptual duplicates or overlaps of another active fact so the Memory UI can highlight them for review without mutating or losing distinct constraints automatically.
detect_overlaps_excluding
detect_overlaps, never pairing two facts in distinct (pairs in overlap_pair form a reviewer judged distinct). A fact whose only match was such a pair is checked against the next representative, so a verdict on one pair never hides a different duplicate.
fact_category_is_personal
Categories whose keys name a person or their attributes, where a key that differs by an entity token must stay separate even at high similarity.
fact_source_rank
How close a fact’s source is to the owner’s own words: 2 stated explicitly, 1 quoted from the owner’s message, 0 inferred. A write may replace a different value only at equal or higher rank, and a restatement never lowers a row’s rank.
facts_are_restatements
Whether two active facts in one category are the same knowledge.
facts_hold_one_value
Whether two active facts hold one piece of knowledge under different keys: the same normalized value, similar enough as whole facts, and, when either is about a person, keys naming the same attribute (pet_name and daughter_name are both Mia, birth_place and hometown one city).
fold_scope_key
The visibility class of a fact stored with privacy and channel_id. Every merge of facts (fold, write-time restatement, numeric conflict) compares this, never the raw columns: an owner DM’s private fact and the same fact from an app conversation are one audience, while a group channel never merges with either.
is_owner_app_channel
Whether a stored channel id is one of the owner’s app conversations.
is_owner_authored_fact_source
Sources that record the owner’s own words. Background extractors can never overwrite these, only restate or add beside them.
keys_name_same_attribute
Whether two keys name one attribute (editor / preferred_editor, oauth_expiry / oauth_expiration), as opposed to two attributes that share a word (dog_name_old / dog_name_new, age / child_age).
migrate
Create or upgrade the memory tables in pool.
numeric_conflict_retirements
The retirements the resolved conflicts call for, as (retired, kept): most similar pair first, each fact retired at most once, and no fact both kept and retired in one pass, so nothing is retired into a row that is itself going away (a chain resolves over later passes).
overlap_pair
The canonical form of an unordered fact pair: (smaller id, larger id).
parse_fact_timestamp
A stored fact timestamp (first_seen_at, updated_at) as ConflictCandidate::seen reads it: RFC 3339, or SQLite’s datetime('now') form.
plan_folds
Plan every fold in candidates.
plan_numeric_conflicts
Every pair of candidates that may be one attribute with two values: one fold_scope_key class, not behavior (left to --retire-inferred-behavior), different numbers, and whole-fact similarity of at least NUMERIC_CONFLICT_MIN_SIMILARITY.
project_message_span
Index a user message from the host’s log as a searchable span. The host passes only messages memory may learn from. channels derives the span’s channel from its session.
rebuild_memory_fts_projections
Recreate the memory search indexes from their authoritative source tables.
value_numbers
The tokens of a value that carry a digit (0.9.10, 8080, 2026), lowercased: the part of a value an embedding barely sees.