Repository navigation
fix(mcp): refuse create_memory_project path mismatch - #1846
Conversation
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
Add regression coverage for #1811: same name with a different path must fail, while the same directory stays idempotent. Update the manual page and integration cases that previously encoded the bug. Signed-off-by: MbappeWU <MbappeWU@users.noreply.github.com>
When create_memory_project finds an existing name, compare normalized paths the same way the API add_project path does. Equal paths keep the idempotent re-index success. Different paths fail fast with both paths named and without re-indexing. Fixes #1811 Signed-off-by: MbappeWU <MbappeWU@users.noreply.github.com>
The mismatch now raises an ALREADY_EXISTS refusal instead of returning an error-shaped success, matching the other refusals in this tool (C11). Cloud creates skip the check. Hosted project paths are tenant-relative and derived from the project name, so a requested path never moves a cloud project, and normalizing it client-side resolved it against this process's working directory: a retry with path="manual" for a project stored at "/manual" would have been refused. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_018CoZ3jWnMJsyQsik4tPySk Signed-off-by: phernandez <paul@basicmachines.co>
5a199fb to
bc47bb4
Compare
|
@codex review |
|
Rebased onto The failed job had 12 setup errors in Local verification after rebase:
Full current-head CI and the fresh Codex review are running. No merge performed. |
|
Codex Review: Didn't find any major issues. More of your lovely PRs please. Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
|
Verification complete on bc47bb4: all 31 checks passed, including the formerly failing Postgres unit shard 3/3. Codex reviewed this exact head with no findings and left a thumbs-up at 2026-10-24T02:48:58Z; there are no review threads. The PR is ready to merge. No merge performed. |
#1989) Fixes #1988. With this change, the OpenClaw plugin starts on Basic Memory 1.0 when its project already exists in a different folder. Before, every plugin tool failed, including reads and `list_memory_projects`. ## The bug At startup the plugin calls `bm_project(command="create")` with its project name and `projectPath`. `projectPath` defaults to the workspace root. Since #1846, BM refuses a same-name create at a different path with `ALREADY_EXISTS`. Before #1846 it reused the project by name. The refusal failed startup. Every tool call waits on startup, and the retry sent the same create, so every tool call failed. The default `projectPath` has changed between plugin releases (`"."` and `~/.basic-memory/openclaw/`), so upgrading can trigger this with no config change. ## What changes - **`projectPath` not set** (`bm-client.ts`, `startupProjectPath`): startup lists projects. If a row with the plugin's name has a `local_path`, it creates the project at that folder, which BM treats as idempotent. Cloud-only rows are skipped, because their paths are tenant-relative. One info line names the folder used. - **`projectPath` set and mismatched:** the plugin keeps the refusal, because the user chose that path. The refusal no longer fails startup: - Calls routed to the plugin's project throw a `ProjectUnavailableError` carrying the refusal, which names both paths. Calls that name another project, by name or by `project_id`, still reach BM. It isn't a `BmToolError`, because `writeNote` would read its `ALREADY_EXISTS` as an existing note. - `listProjects` and `listWorkspaces` still work, so the user can see where the project is stored. - Memory `health()` reports `unavailable` with the refusal text, instead of `ready`. - **Only structured refusals are kept.** A plain tool failure, such as a locked database, still fails startup, and the next tool call retries it as before. - `config.ts` gains `projectPathConfigured`, which tells the default apart from an explicit `"."`. - **Docs:** the README and `BASIC_MEMORY.md` now describe how `projectPath` resolves. `BASIC_MEMORY.md` wrongly said it defaulted to `memoryDir` and had to be absolute. ## Regression tests - `bm-client.test.ts`, "an existing project at another folder": - Adopts the stored folder. - Creates at the default path when no project has the name. - Keeps a configured path, reports the refusal, and still lists projects. - Retries a create that failed without a refusal. - `basic-memory-capability.test.ts`: health reports the refused project as unavailable. - `integration/bm-client.integration.test.ts`: the same two startup cases against a real `bm mcp` from this checkout, so they exercise #1846's server-side refusal. The three regression unit tests fail when run against the old `bm-client.ts` and capability code, and pass with this change. ## Verification - `just package-check-openclaw`: exit 0, 286 tests pass (typecheck, lint, build, `npm pack --dry-run`). - `bun run test:int` (real `bm mcp`): both new tests pass. - **Known failure:** the existing test "round-trips Memory Quest fields" fails. It asserts the text `"Note already exists"`, but the tool now returns `"A note already exists at ..."`. It fails the same way with this PR's source changes reverted, and this PR doesn't touch `tools/`. CI doesn't run the integration suite, which is probably why nobody has noticed. - **Live gateway:** verified on OpenClaw 2026.10.9 with `5c5d0da6` and `bm` 1.0.0. The old build reproduces the bug, and this build fixes it. Details are in the PR comment with the live results. 🤖 Generated with [Claude Code](https://claude.com/claude-code) --------- Signed-off-by: Drew Cain <groksrc@gmail.com> Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
Salvages #1840 by @MbappeWU onto an in-repo branch so CI runs. Their two commits are kept as authored; one commit on top adjusts the fix.
Fixes #1811.
What changes
create_memory_project(andbm_project(command="create"), which calls it) used to answer "✓ Project already exists" when the name matched a project stored at another directory, then re-indexed that project. The requested path was ignored.ALREADY_EXISTSrefusal naming the stored path, raised before any indexing.Changes on top of #1840
# Error ...text or anerror: PATH_MISMATCHdict as a successful tool result. Every other refusal in this tool raisesrefusal(...), so this one does too.BASIC_MEMORY_PROJECT_ROOT), so a requested path never moves a cloud project. Normalizing it withos.path.abspathon the client resolved it against the MCP process's working directory: a retry withpath="manual"for a project stored at/manualwould have been refused.Verification
just fast-check: clean.just fast-testovertests/mcp/test_tool_project_management.py,tests/mcp/test_tool_bm_project.py,tests/test_man_pages.py, and the two touchedtest-int/mcpfiles: passing.path="manual"for a stored/manualreturnsalready_exists.🤖 Generated with Claude Code
https://claude.ai/code/session_018CoZ3jWnMJsyQsik4tPySk