Expand description
Is a memory directory this agent’s alone? (SPEC_MEMORY_FOLLOWS_THE_AGENT_2026_09_24.md §2.1.2, phase M3b.)
A Claude memory directory is keyed by account + working directory, not by agent, so two agents can share one — the same account and working directory, or two unlinked agents with the same working directory. The memory record may project into, capture from, or delete in a directory only when it is proven exclusive; a shared one is left exactly as it is.
A directory is shared unless proven exclusive:
- Known shared locations — a blank working directory (the
~/.agentmux/agents/<slug>default, shared across same-name tabs),$HOME, or an ancestor of another agent’s working directory. And any folder the CLI keys by a whole repository rather than this working directory alone: a subdirectory or linked worktree of a repository, or a main checkout with linked worktrees (crate::backend::claude_layout::memory_project_root). - Vetoes — any other agent whose directory resolves, by any route, to the same canonical directory. Guesses count here (a veto only ever removes a directory; the resolver never uses one to find memory).
- A machine-wide claim — zone
memory-dir:<hash>in the global store. Every spawn that uses the folder records one, a shared one too: channels shareprojects/folders, and an agent in another channel is visible here only through its claim. A claim by another UID makes the folder shared. A claim is released only by the channel store that wrote it, once that store no longer has the agent and no active shared definition does — another channel can’t tell a live agent of its neighbour’s from a deleted one.
Structs§
- Claim 🔒
- Claimed
Folder 🔒 - A folder an agent has claimed, for the human “release this folder” action (spec §2.1.2).
- Claims 🔒
Enums§
Constants§
Functions§
- check_
and_ 🔒claim - Decide whether
dir— the memory directoryuid’s spawn uses, from working directorycwd— is exclusive touid, recordinguid’s claim. Checks that can’t finish bydeadlineleave the directoryUnproven, i.e. shared. - claim_
is_ 🔒stale - Whether a claim can be shown to be stale: only the store that wrote it can say its agent is gone.
- claims_
of 🔒 - Every folder
uidholds a claim on, on this machine. - claims_
zone 🔒 - dir_id 🔒
- A directory’s canonical form: symlinks resolved as far as the path
exists (the per-channel
projects/links into the shared store), the rest kept as given. Two routes to one folder get one id. - held_
exclusively 🔒 - Whether
uidstill holds the only claim ondir— the re-check before every capture while the agent runs (spec §2.1.3). Read-only: the full check ran at spawn; this sees any agent that has claimed it since. - known_
shared_ 🔒or_ vetoed - Rules 1 and 2: no store writes.
- release 🔒
- Remove
uid’s claim inzone— a human released the folder. Returns whether there was one. The agent re-claims it at its next spawn there. - used_
by_ 🔒another - Whether another agent uses
dir: it has claimed it (in any channel), or resolves to it in this channel’s store. Read-only. For offering a folder for adoption (spec §2.1.4), which must exclude folders shared with another agent.