Skip to content

fix(mcp): stop a same-named note from being read as its own project - #1460

Merged
phernandez merged 5 commits into
basicmachines-co:mainfrom
mmaxjr:fix-project-permalink-note-collision
Sep 4, 2026
Merged

fix(mcp): stop a same-named note from being read as its own project#1460
phernandez merged 5 commits into
basicmachines-co:mainfrom
mmaxjr:fix-project-permalink-note-collision

Conversation

@mmaxjr

@mmaxjr mmaxjr commented Sep 3, 2026

Copy link
Copy Markdown
Contributor

Fixes #1458.

What changes

split_project_permalink_prefix matches leading path segments against known project permalinks. Because generate_permalink normally drops file extensions, a single-segment note whose file stem equals its project name—such as moby-dick.txt in project moby-dick—was mistaken for the project root. POSIX reads then rejected it as a project rather than reading the note.

The permalink-only parser now preserves an extension when a match would consume the entire identifier. That prevents moby-dick.txt from matching project permalink moby-dick; qualified paths such as moby-dick/moby-dick.txt and bare project permalinks such as moby-dick continue to work.

Project mount routing also retains exact display-name identity before falling back to permalink parsing. This matters for a valid project literally named docs.txt: the exact identifier docs.txt still routes to that project root even though its permalink is docs. The mount table is the correct layer for this exception because it knows both the display name and permalink; the generic parser cannot distinguish that project from a note using strings alone.

Workspace-qualified routing applies the same identity check against the projects discovered inside that workspace, so team/docs.txt can name the root of an extension-bearing project without weakening the permalink-only parser.

Testing

  • Added a pure parser regression for the same-named note case.
  • Added an end-to-end routing regression proving second-project.txt stays a note inside second-project.
  • Added an end-to-end routing regression proving an exact docs.txt project name still routes to its project root.
  • Added a cross-workspace regression proving team/docs.txt routes the same project root.
  • uv run pytest tests/mcp/test_project_path_routing.py -q — 71 passed.
  • just fast-check — Ruff checks and formatting passed; after installing the repository's milvus extra, the full ty check src tests test-int passed.

Other

  • Added an Unreleased changelog entry.
  • Both commits carry DCO sign-offs.

split_project_permalink_prefix matches a leading path segment against a
project's permalink via generate_permalink, which drops file
extensions. A single-segment identifier whose stem equals its
project's name (e.g. moby-dick.txt in project moby-dick) therefore
collapsed to the project's own permalink with an empty remainder, and
cat/find refused it with "names a project, not a note" instead of
resolving the note -- the layout the literary-analysis skill
prescribes (<work>.txt in project <work>).

A prefix claim that would leave no remainder now requires the raw
segment to spell the permalink exactly, extension included. A claim
that still has a remainder after it is unaffected -- extension
stripping there was never wrong, since a project name never carries a
real extension in that position.

Fixes basicmachines-co#1458

Signed-off-by: mmaxjr <mmaxmjunior@gmail.com>
@CLAassistant

CLAassistant commented Sep 3, 2026

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 0f2f73f964

ℹ️ 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".

Comment thread src/basic_memory/mcp/project_context_identifiers.py
Signed-off-by: phernandez <paul@basicmachines.co>
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Sep 4, 2026

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review Completed 2026-09-04T15:38:28.576176Z 826c570 Manual request
ℹ️ 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" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@phernandez

Copy link
Copy Markdown
Member

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 82e0223541

ℹ️ 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".

Comment thread src/basic_memory/mcp/project_context_identifiers.py
Signed-off-by: phernandez <paul@basicmachines.co>
@phernandez

Copy link
Copy Markdown
Member

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: c2c0dcbb21

ℹ️ 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".

Comment thread src/basic_memory/mcp/project_context_identifiers.py
Comment thread src/basic_memory/mcp/project_context.py
Signed-off-by: phernandez <paul@basicmachines.co>
@phernandez

Copy link
Copy Markdown
Member

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: b8bae86978

ℹ️ 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".

Comment thread src/basic_memory/mcp/project_context.py Outdated
Signed-off-by: phernandez <paul@basicmachines.co>
@phernandez

Copy link
Copy Markdown
Member

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Nice work!

Reviewed commit: 826c570ea2

ℹ️ 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".

@phernandez
phernandez merged commit f1b5867 into basicmachines-co:main Sep 4, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

A note named after its project cannot be read by bare identifier (cat refuses it as the project)

3 participants