Skip to content

Commit e3f1054

Browse files
fix(memory): decouple shared tree id from legacy RALPH_PROJECT_ID (Addendum 4)
Runtime cross-feed bug: codex hooks export RALPH_PROJECT_ID=p-<hash> (session id), which compute_project_id honored as an override -> codex wrote/read memory_tree/projects/p-<hash>/ while claude used <remote>_<repo>/ -> separate trees, no cross-feed despite identical schema/recall. Fix: the shared tree id is keyed ONLY by git-remote-hash; the dedicated env var RALPH_MEMORY_PROJECT_ID is the sole override. The legacy RALPH_PROJECT_ID is no longer honored for the tree (it stays free for codex's ledger/handoff subsystem). Verified (with RALPH_PROJECT_ID=p-legacy exported): both agents resolve the same git-remote id; codex-written node read by claude recall and vice versa, single physical tree dir. 111 tests; pyright 0/0. Mirror fix applied in codex-ralph-vault-loop. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
1 parent d86a731 commit e3f1054

2 files changed

Lines changed: 9 additions & 7 deletions

File tree

scripts/memory/recall_v2.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -469,7 +469,7 @@ def main() -> int:
469469
parser.add_argument("--project-root", default=".")
470470
parser.add_argument("--query", default="")
471471
parser.add_argument("--json", action="store_true")
472-
parser.add_argument("--project-id", default=os.environ.get("RALPH_PROJECT_ID", ""))
472+
parser.add_argument("--project-id", default=os.environ.get("RALPH_MEMORY_PROJECT_ID", ""))
473473
parser.add_argument(
474474
"--ralph-home", default=os.environ.get("RALPH_HOME", "~/.ralph")
475475
)

scripts/memory/tree_store.py

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -184,13 +184,15 @@ def compute_project_id(repo_root: Path) -> str:
184184
memory tree (Addendum 2). Distinct repos still get distinct ids via the
185185
remote-hash and/or directory name.
186186
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.
187+
Tree-id override (Wave 5, Addendum 4, 2026-06-17): the DEDICATED env var
188+
``RALPH_MEMORY_PROJECT_ID`` wins when set. We deliberately do NOT honor the
189+
legacy session var ``RALPH_PROJECT_ID`` here, because codex hooks set it to a
190+
per-session ``p-<hash>`` id that would split the shared tree. The shared
191+
memory tree is keyed by git-remote-hash so the SAME target repo yields the
192+
SAME id from either agent; ``RALPH_PROJECT_ID`` stays free for codex's own
193+
ledger/handoff subsystem.
192194
"""
193-
override = os.environ.get("RALPH_PROJECT_ID", "").strip()
195+
override = os.environ.get("RALPH_MEMORY_PROJECT_ID", "").strip()
194196
if override:
195197
return safe_segment(override, "project_id")
196198
main_repo = resolve_main_repo_root(repo_root)

0 commit comments

Comments
 (0)