Repository navigation
fix(mcp): refuse overwrites resolving to another path - #1525
phernandez wants to merge 2 commits into
Conversation
Signed-off-by: phernandez <[email protected]>
|
@codex review |
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. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: f4bc316c39
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
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".
Signed-off-by: phernandez <[email protected]>
|
@codex review |
|
Codex Review: Didn't find any major issues. 🎉 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". |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 6cc9e83fbe
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
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".
| existing = await knowledge_client.resolve_entity_response( | ||
| requested_path, strict=True | ||
| ) |
There was a problem hiding this comment.
Check only path identity before refusing writes
When another note's title happens to equal the requested filename, this general-purpose resolver returns that note even though it does not own the path, causing a valid overwrite=True create to return NOTE_PATH_CONFLICT. For example, an archived note titled README.md makes writing a new root note titled README fail because resolving README.md matches the archived note by title. This preflight should query exact path ownership and only separately check the retained-permalink case, rather than treating every strict title/permalink resolution as a path conflict.
Useful? React with 👍 / 👎.
Why
Refs #1479. With the default retained permalink, renaming a note leaves its old identity live while its title-derived file path is free.
write_note(overwrite=True)currently creates a second file instead of updating or refusing.This draft makes option B (refuse and return the current location) concrete for policy review. The choice between refusal and following a move is still open; this PR does not authorize landing that choice.
What Changed
Before an overwrite-enabled create, resolve the requested path strictly. If that identity resolves to a different current path, return
NOTE_PATH_CONFLICTin JSON or an actionable text refusal naming the path and stable note ID. No file is written. Normal creates and same-path overwrites retain their existing behavior.Implementation Details
Uses the existing project-routed typed resolver; no fuzzy search, title guessing, or new API contract. Only a real HTTP 404 permits creation to continue; operational errors propagate. A retained permalink makes the reported rename discoverable. Moves that deliberately update permalinks are outside this identity-based guard.
Strict explicit Markdown paths select the current file owner before generated permalink aliases. This lets a replacement at a vacated path be overwritten without touching the moved note. Verbatim custom permalinks retain their existing precedence.
The preflight adds one resolution request to overwrite-enabled calls. It is not a transaction or a concurrent-move guarantee. The implementation preserves the existing canonical write safeguards and does not follow a moved target automatically.
Testing
uv run pytest test-int/mcp/test_moved_note_overwrite.py --no-cov -q: 2 passed after fix; unchanged moved-file bytes and no second Markdown file.BASIC_MEMORY_TEST_POSTGRES=1 uv run pytest test-int/mcp/test_moved_note_overwrite.py test-int/mcp/test_write_note_integration.py --no-cov -q: 17 passed.just fast-check,just doctor,just man-regen, andgit diff --check: passed.Risks / Follow-ups
Policy approval is still required before marking this draft ready to land. Strict resolution can conservatively refuse aliases that resolve to another path; it never writes to that alternate path. Explicit
overwrite=Falseremains ordinary create/conflict behavior. No claim is made that arbitrary same-title notes or changed permalinks identify a moved note.