Skip to content

fix(cli): allow disposable doctor project under configured root - #1324

Closed
mikemikimike wants to merge 2 commits into
basicmachines-co:mainfrom
mikemikimike:fix/1323-doctor-project-root
Closed

mikemikimike wants to merge 2 commits into
basicmachines-co:mainfrom
mikemikimike:fix/1323-doctor-project-root

Conversation

@mikemikimike

Copy link
Copy Markdown
Contributor

Fixes #1323\n\nAllow doctor-owned disposable projects to be created beneath BASIC_MEMORY_PROJECT_ROOT while preserving nested path validation for normal projects.\n\nTests: uv run --frozen pytest -q tests/services/test_project_service.py -k nested --no-cov

@mikemikimike

Copy link
Copy Markdown
Contributor Author

Validation evidence: uv run --frozen pytest -q tests/services/test_project_service.py -k nested --no-cov -> 2 passed, 1 skipped; python -m compileall -q src/basic_memory/services/project_service.py; git diff --check. Five-point review: (1) reproduces #1323 path collision in ProjectService.add_project; (2) only doctor-* projects bypass nested guard; (3) single-file diff, normal project behavior unchanged; (4) no concurrency/state-machine changes; (5) existing nested tests pass, with doctor-specific path requiring maintainer integration validation.

@mikemikimike mikemikimike changed the title fix(doctor): allow disposable project under configured root fix(cli): allow disposable doctor project under configured root Aug 25, 2026

@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: 63c5f0ca74

ℹ️ About Codex in GitHub

Codex has been enabled to automatically 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 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

)
# Doctor creates a disposable project inside the configured project root.
# It must be allowed to coexist with the existing root project.
if not name.startswith("doctor-"):

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Delete the disposable doctor's files during cleanup

When BASIC_MEMORY_PROJECT_ROOT is configured and an existing project owns that root, this exemption lets doctor write its API and manual test notes beneath the existing project's directory. However, _delete_doctor_project() calls ProjectClient.delete_project(project_id) with the default delete_notes=False, and the fallback cleanup likewise removes only configuration/database state. Every successful doctor run therefore leaves canonical test Markdown under the configured root, where the enclosing project can index it as user knowledge; cleanup must remove the exact doctor directory as well as its registration.

AGENTS.md reference: AGENTS.md:L156-L160

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Fixed in 8e471e7. Doctor cleanup now requests delete_notes=true, so the disposable project directory and its canonical Markdown are removed.

)
# Doctor creates a disposable project inside the configured project root.
# It must be allowed to coexist with the existing root project.
if not name.startswith("doctor-"):

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Restrict the nesting exemption to trusted doctor calls

For any ordinary API, CLI, or MCP create whose user-controlled name starts with doctor-, this skips all nested-path checks, even when BASIC_MEMORY_PROJECT_ROOT is unset. Such a caller can register a second project at or beneath an existing project's path; because project paths are not database-unique, both projects then operate on the same files, and deleting either with delete_notes=true can remove the other's canonical content. Pass an explicit trusted doctor-only capability or narrowly validate the exact disposable path instead of treating a public naming prefix as authorization to cross the project isolation boundary.

AGENTS.md reference: AGENTS.md:L391-L395

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Fixed in 8e471e7. Regular project creation always enforces nested-path isolation. The configured-root doctor flow now uses a dedicated server-generated disposable project endpoint, so user-provided doctor-* names cannot authorize nesting.

phernandez added a commit that referenced this pull request Aug 25, 2026
Add the tests the salvaged #1324 commits were missing: the service-level
nested-under-root regression for #1323 (including directory cleanup via
delete_notes), the doctor endpoint's 201 and 400 responses (dropping the
pragma on its now-tested error path), and the typed client's doctor call.
Also record the fix in the v0.23.1 changelog entry.

Co-Authored-By: Claude Fable 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01G4rbaeHJN3L7CREp5v38J9
Signed-off-by: phernandez <[email protected]>
@phernandez

Copy link
Copy Markdown
Member

Landed via #1327 with your commits and authorship preserved (cherry-picked so the full CI suite could run — fork PRs skip most of it). Test coverage for the new endpoint, service method, and client call was added on top, and the fix ships in v0.23.1, releasing today. Thanks for the well-designed fix — the keyword-only allow_nested with the server-generated name was exactly the right shape for the isolation boundary.

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.

bm doctor fails when BASIC_MEMORY_PROJECT_ROOT equals the project directory

2 participants