Skip to main content

Module memory_history_import

Module memory_history_import 

Source
Expand description

The one-time import of an agent’s earlier memory history into its record (SPEC_MEMORY_FOLLOWS_THE_AGENT_2026_09_24.md §2.1.1, phase M3b).

Before the record, each channel kept its own history of an agent’s memory files (db_agent_native_memory_versions, in that channel’s identity store), so an agent’s past was split across every channel it ran in. At the agent’s first reconcile that proves its folder exclusive, the rows from every channel store on this machine are imported into the record, deduplicated by content.

Rows from agent_inferred (the m0024 backfill) and external_fs_write (drift) were attributed to agents by a registry lookup that could name the wrong agent, so they are unproven: imported only when the file of that name in the agent’s own proven folder holds that exact content. The rest wait for the adoption list (M3c).

History only: nothing here changes a head or touches the folder.

Constants§

PROVEN_SOURCES 🔒
Sources written by a path that knew which agent it was writing for.

Functions§

gather 🔒
uid’s rows from every history store, or None if deadline passed before they were all read (the import then waits for a later pass). A store that can’t be opened or read is skipped.
history_store_paths 🔒
Every store on this machine that may hold per-channel memory history: each channel’s and dev instance’s identity store, and the stable channel’s (the shared store).
history_store_paths_under 🔒
import_once 🔒
Import uid’s earlier history, once, from stores (every history store on the machine when None). disk_sha gives the content hash of a file in the agent’s proven folder. Returns how many versions were imported, or None when there was nothing to do (already imported, or out of time — retried next pass).
select 🔒
The rows to import: proven ones, and unproven ones whose content is what the agent’s own folder holds under that name (disk_sha).