Skip to content

Commit d86a731

Browse files
feat(memory): unify memory store across codex+claude (Wave 5, Addendum 3)
Shared memory tree via RALPH_MEMORY_HOME (default ~/.ralph) + RALPH_PROJECT_ID override. Same target repo now resolves to an identical git-remote-hash project_id from either agent (verified byte-identical: afeb966196d34d86_<repo>), so a node written by codex's tree_store is read+ranked by claude's recall_v2 in the same shared tree, and vice versa. Schema + recall scoring were already identical; this converges storage root, layout, and project_id. Cross-agent round-trip verified both directions (codex write -> claude read score 57; claude write -> codex read). 111 memory tests; pyright 0/0. Note: codex-side changes (tree_store/recall_v2 layout+id alignment) are in the codex-ralph-vault-loop repo, uncommitted pending user decision on that repo. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
1 parent a332ee4 commit d86a731

1 file changed

Lines changed: 18 additions & 1 deletion

File tree

scripts/memory/tree_store.py

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,15 @@ def now_iso() -> str:
8282

8383

8484
def default_ralph_home() -> Path:
85-
return Path("~/.ralph").expanduser()
85+
"""Root for the SHARED durable memory tree.
86+
87+
Honors ``RALPH_MEMORY_HOME`` (default ``~/.ralph``) so the codex agent and
88+
the claude agent can converge on ONE shared memory tree root (Wave 5,
89+
Addendum 3, 2026-06-17). The default resolves to ``~/.ralph`` -- unchanged
90+
from before -- so existing data and the 111 memory tests keep passing.
91+
"""
92+
home = os.environ.get("RALPH_MEMORY_HOME", "").strip()
93+
return Path(home or "~/.ralph").expanduser()
8694

8795

8896
# ---------------------------------------------------------------------------
@@ -175,7 +183,16 @@ def compute_project_id(repo_root: Path) -> str:
175183
the same repo resolve to the SAME project id -- they share one durable
176184
memory tree (Addendum 2). Distinct repos still get distinct ids via the
177185
remote-hash and/or directory name.
186+
187+
``RALPH_PROJECT_ID`` override (Wave 5, Addendum 3, 2026-06-17): if the env
188+
var is set, it wins. This gives codex/claude an explicit escape hatch and
189+
keeps compatibility with codex's existing ``RALPH_PROJECT_ID`` convention.
190+
When unset, the git-remote-hash derivation below is used so the SAME target
191+
repo yields the SAME id from either agent.
178192
"""
193+
override = os.environ.get("RALPH_PROJECT_ID", "").strip()
194+
if override:
195+
return safe_segment(override, "project_id")
179196
main_repo = resolve_main_repo_root(repo_root)
180197
return safe_segment(
181198
f"{repo_remote_hash(main_repo)}_{workspace_instance_id(main_repo)}",

0 commit comments

Comments
 (0)