Skip to main content

Module memory_adopt

Module memory_adopt 

Source
Expand description

Adopting an agent’s memory from its earlier accounts (SPEC_MEMORY_FOLLOWS_THE_AGENT_2026_09_24.md §2.1.4, phase M3c).

An agent’s memory folder is keyed by account, so every account it ever ran under left a folder behind. The agent’s own live folder is adopted automatically at first sighting (§2.1.2); every other folder is only offered:

  • list enumerates the candidates — the same project folder under every account on this machine, minus the agent’s own and any folder another agent uses — and issues the list a list_id. Paths never leave the server.
  • adopt takes (list_id, index, dir hash) choices only. It is reached through the host’s confirmation window, never an agent-held credential (the service gates it on the host secret). A folder that changed since the list was issued is refused.

Merging never replaces the agent’s current memory: a file the record already has keeps its head, the adopted bodies are kept as its history; a file it doesn’t have is adopted, newest by modification time as the head. The MEMORY.md indexes are unioned line by line, deduplicated by link target, so no adopted topic becomes invisible to Claude. The next spawn writes the result into the agent’s folder.

Structs§

AdoptReport 🔒
AdoptionList 🔒
Candidate 🔒
One folder offered for adoption. No path: the client refers to it by index and dir_hash.
CandidateFile 🔒
Issued 🔒
IssuedDir 🔒
One listed folder, as the server remembers it.

Enums§

AdoptError 🔒

Constants§

INDEX_FILE 🔒
LIST_TTL 🔒
How long an issued list stays valid.

Functions§

account_project_roots 🔒
Every account’s projects folder on this machine: each linked account’s (identities/<acct>/claude/projects), and the unlinked default home’s.
adopt 🔒
Adopt the chosen folders of list list_id into agent_uid’s record. Choices are (index, dir_hash) from the list; nothing else from the caller is trusted.
adopt_under_lease 🔒
dir_hash 🔒
folder_files 🔒
A folder’s memory files, sorted by name — only only’s, when given. Unreadable and oversized files are left out.
issued 🔒
link_target 🔒
The link target of an index line ([title](target)), if it has one.
list 🔒
The candidates for an agent, from its verified memory folder. None when the agent has none yet (no spawn, no working directory).
list_in 🔒
The candidates for agent_uid, whose own live folder is own_dir, among the accounts under shared.
union_index 🔒
base with every line of others it lacks: a linked line when its target is new, any other line when no line of base equals it. Returns the union and how many lines were added.