Skip to content

Introduce BASIC_MEMORY_PROJECT_ROOT to replace cloud mode path constraints #333

@phernandez

Description

@phernandez

Problem

Currently, BASIC_MEMORY_HOME has dual, conflicting semantics:

  1. Original intent: Path to the "main" (default) project directory
  2. Cloud mode usage: Root directory where ALL projects must be created

This creates confusion and doesn't properly separate concerns.

Example of the Issue

With BASIC_MEMORY_HOME=/app/data/basic-memory:

  • Main project files: /app/data/basic-memory/*.md (at the root)
  • New project "test": /app/data/basic-memory/test/ (subdirectory)
  • Result: Main project files and other project directories are mixed together

Current Cloud Mode Implementation

In PR #332, we implemented path validation that constrains projects to BASIC_MEMORY_HOME when cloud mode is enabled. However, this couples path restriction to cloud mode, when really it's about filesystem constraints.

Proposed Solution

Introduce a new environment variable that explicitly handles project path constraints:

BASIC_MEMORY_PROJECT_ROOT

Behavior:

  • If set: ALL projects must be created underneath this directory (path sanitization enforced)
  • If not set: Projects can be created anywhere (current default behavior)

Semantics:

  • BASIC_MEMORY_HOME: Location of the "main" project (backward compatible, unchanged)
  • BASIC_MEMORY_PROJECT_ROOT: Optional root directory for all projects

Benefits

  1. Decouples path restriction from cloud mode (useful for any constrained environment)
  2. Backward compatible - existing users with custom BASIC_MEMORY_HOME unaffected
  3. More explicit - "project root" is clearer than overloading "home"
  4. Flexible - works in both cloud and local constrained environments

Example Usage

Cloud Mode

BASIC_MEMORY_HOME=/app/data/basic-memory  # main project location
BASIC_MEMORY_PROJECT_ROOT=/app/data       # all projects must be under /app/data

Results:

  • Input: /tmp/test/app/data/tmp/test (sanitized)
  • Input: test/app/data/test
  • Main project: /app/data/basic-memory/ (unchanged)

Local Mode with Constraints

BASIC_MEMORY_HOME=~/basic-memory          # main project
BASIC_MEMORY_PROJECT_ROOT=~/my-projects   # all projects under here

Local Mode Unrestricted (Default)

BASIC_MEMORY_HOME=~/basic-memory          # main project
# BASIC_MEMORY_PROJECT_ROOT not set - projects can be anywhere

Implementation Changes

  1. config.py - Add BASIC_MEMORY_PROJECT_ROOT field to BasicMemoryConfig
  2. project_service.py - Update add_project() to check BASIC_MEMORY_PROJECT_ROOT instead of cloud_mode_enabled
  3. Dockerfile (basic-memory-cloud) - Set BASIC_MEMORY_PROJECT_ROOT=/app/data instead of BASIC_MEMORY_CLOUD_MODE
  4. Tests - Update cloud mode tests to use BASIC_MEMORY_PROJECT_ROOT
  5. Documentation - Update docs to explain the new variable and deprecation of relying on cloud mode for path constraints

Migration Path

  • BASIC_MEMORY_HOME continues to work as-is (no breaking changes)
  • Cloud deployments update to use BASIC_MEMORY_PROJECT_ROOT
  • BASIC_MEMORY_CLOUD_MODE can remain for other cloud-specific behaviors if needed

Related

cc: @phernandez

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions