Skip to content

Adding local XMem setup#200

Merged
Ankit-Kotnala merged 6 commits into
mainfrom
feature/Local-Setup
May 23, 2026
Merged

Adding local XMem setup#200
Ankit-Kotnala merged 6 commits into
mainfrom
feature/Local-Setup

Conversation

@Ankit-Kotnala
Copy link
Copy Markdown
Collaborator

Summary

Adds local XMem setup directly inside the main XortexAI/XMem repo.

This removes the need for a separate xmem-dev wrapper repo. Users can now create and run a local XMem workspace with:

npx create-xmem@latest
cd xmem
npm run dev

@github-actions
Copy link
Copy Markdown

github-actions Bot commented May 23, 2026

Fails
🚫

🔐 This PR modifies sensitive files: src/config/settings.py. These require review by a core maintainer (@ishaanxgupta or @ved015) before merging.

Warnings
⚠️

📦 This PR changes 2363 lines (additions + deletions). Large PRs are harder to review thoroughly — consider splitting it.

Messages
📖

📝 No CHANGELOG.md update detected. If this PR introduces a user-visible change, please add an entry.

📖

✅ Targeting main. Please squash commits before merging to keep the git history clean.

Generated by 🚫 dangerJS against f7ee0af

@github-actions
Copy link
Copy Markdown

✅ Staging Deployment Report

Item Value
Branch feature/Local-Setup
Commit c85836e
Environment Staging
Health http://13.232.74.176:8001/health
API Docs http://13.232.74.176:8001/docs
Smoke Tests success

🟢 Staging is live and healthy! Test your changes at the staging URL above.

Ready to ship? Comment /promote on this PR to merge to main and deploy to production.

Copy link
Copy Markdown

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request introduces a comprehensive local-first development environment for XMem, including a new create-xmem scaffolding package, Docker-based local storage (Postgres/pgvector, MongoDB, Neo4j), and a suite of scripts for setup, diagnostics, and context management. Key code changes include improved API exception handling, user ID normalization, and configurable LLM timeouts. Feedback highlights several cross-platform compatibility issues in the PowerShell scripts—specifically regarding the hardcoded powershell executable name and the Windows-only System.Drawing assembly. Additionally, a security risk was identified where static keys could allow user impersonation in production if not properly guarded by environment checks, and an improvement was suggested for the greedy argument parsing logic in the workspace creation script.

Comment thread scripts/install.ps1 Outdated
Write-Step ".env already exists; leaving it unchanged"
}

Invoke-Native { powershell -ExecutionPolicy Bypass -File (Join-Path $Root "scripts\configure-xmem-env.ps1") -EnvPath $envTarget }
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

high

Hardcoding powershell will fail on non-Windows systems where the executable is named pwsh. Since this script is already running in a PowerShell host, you should use the call operator & to execute the script in the current session, which is more efficient and cross-platform.

Invoke-Native { & (Join-Path $PSScriptRoot "configure-xmem-env.ps1") -EnvPath $envTarget }

Comment thread scripts/install.ps1 Outdated
}

Write-Step "Patching extension for local API"
Invoke-Native { powershell -ExecutionPolicy Bypass -File (Join-Path $Root "scripts\patch-extension-local.ps1") -ExtensionDir $ExtensionDir }
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

high

Hardcoding powershell will fail on non-Windows systems where the executable is named pwsh. Use the call operator & to execute the script in the current session for better compatibility and performance.

Invoke-Native { & (Join-Path $PSScriptRoot "patch-extension-local.ps1") -ExtensionDir $ExtensionDir }

Comment thread scripts/patch-extension-local.ps1 Outdated
[string]$Path
)

Add-Type -AssemblyName System.Drawing
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

high

The System.Drawing assembly is a Windows-specific GDI+ wrapper and is not available in PowerShell Core (pwsh) on Linux or macOS. This will cause the setup script to fail on non-Windows platforms. Consider wrapping this in a platform check or providing pre-built icons.

    if (-not $IsWindows) { return }
    Add-Type -AssemblyName System.Drawing

Comment thread src/api/routes/memory.py Outdated
Comment on lines +138 to +141
if requested_user_id and (
user.get("email") == "static@xmem.ai" or user.get("name") == "Static Key User"
):
return requested_user_id
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

security-high high

This logic allows a user authenticated with a 'static' key to impersonate any user_id by providing it in the request. While useful for local development, this is a security risk if the static key is ever configured in a production-like environment. This check should be strictly guarded by an environment check to ensure it only runs in development or local modes.

Suggested change
if requested_user_id and (
user.get("email") == "static@xmem.ai" or user.get("name") == "Static Key User"
):
return requested_user_id
if requested_user_id and settings.environment.lower() in {"development", "dev", "local"} and (
user.get("email") == "static@xmem.ai" or user.get("name") == "Static Key User"
):
return requested_user_id

Comment thread packages/create-xmem/bin/create-xmem.js Outdated
usage(1);
}

options.target = arg;
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

medium

The positional argument handling is greedy and will overwrite options.target with every non-option argument provided. This could lead to unexpected behavior if extra arguments are passed. Consider ensuring the target is only set once if it's not the default value.

    if (options.target === "xmem") {
      options.target = arg;
    }

@github-actions
Copy link
Copy Markdown

🔍 API Schema Diff

---REPORT---

🔄 Modified

  • 🟡 CHANGED: root['components']['schemas']['IngestRequest']['properties']['user_id']['description']

Auto-generated by API Schema Diff workflow

@greptile-apps
Copy link
Copy Markdown

greptile-apps Bot commented May 23, 2026

Greptile Summary

This PR bundles a local XMem development environment directly into the main repo, eliminating the need for a separate xmem-dev wrapper. It adds the create-xmem npm package, a local workspace runner (scripts/xmem.js), Docker Compose configuration, and an env template alongside a set of API-layer quality improvements.

  • Local workspace tooling: npx create-xmem@latest clones the repo, strips git metadata, and leaves a ready-to-run workspace; scripts/xmem.js dispatches npm run dev/setup/start/verify/doctor to PowerShell scripts.
  • Error message sanitization: _public_exception_message now gates all exception detail behind an environment check, redacting ConnectionError, ValueError, and RuntimeError messages in production; a new RequestValidationError handler returns structured, user-friendly field-level errors.
  • user_id normalization: The strict regex on user_id fields is replaced by normalize_user_id, which strips/collapses special characters before Pydantic validates length; configurable LLM and ingest timeouts are exposed via settings.

Confidence Score: 5/5

Safe to merge; the core API logic changes are well-tested and the local tooling is self-contained.

The production code changes (error redaction, per-item user_id in batch ingest, configurable timeouts, user_id normalization) are all covered by new tests and fix previously reported issues. The two findings are limited to an edge case in the normalization helper (integer 0) and a polling loop in a local-only verification script — neither affects production data paths.

scripts/verify.py (tight polling loop) and src/api/schemas.py (normalize_user_id falsy-value edge case).

Important Files Changed

Filename Overview
src/api/app.py Adds RequestValidationError and HTTPException handlers, plus _public_exception_message to safely redact internal error details in production; previous issues with raw ConnectionError/ValueError/TimeoutError leakage are resolved.
src/api/routes/memory.py Fixes per-item user_id in batch ingest, introduces _scoped_ingest_payload and _current_user_id with static-key local override, makes ingest timeouts configurable, and sanitizes 5xx error details in production.
src/api/schemas.py Removes strict regex on user_id in favour of normalize_user_id; the normalization function uses value or "" which silently drops falsy non-None primitives (e.g. integer 0) before stringifying.
src/agents/base.py LLM timeout is now configurable via settings.llm_timeout_seconds; asyncio.TimeoutError is re-raised as TimeoutError with a helpful message including agent name, model, and an Ollama hint.
src/config/settings.py Adds llm_timeout_seconds (default 45s) and memory_ingest_timeout_seconds (default 120s) fields.
scripts/verify.py New smoke-test script that polls /health and runs ingest/search/retrieve; sleep(3) is only in the exception handler so a reachable-but-not-ready API causes a tight polling loop.
packages/create-xmem/bin/create-xmem.js New CLI tool that clones the XMem repo into a local workspace directory; straightforward and safe.
templates/xmem.env.local Environment template for local dev; secrets are left empty with placeholders; JWT_SECRET_KEY is clearly labelled dev-only.
scripts/xmem.js Main CLI dispatcher for local workspace commands (dev, setup, start, verify, doctor, context export/import); delegates to PowerShell scripts on all platforms.

Fix All in Cursor Fix All in Codex Fix All in Claude Code

Reviews (5): Last reviewed commit: "Redact production ValueError responses" | Re-trigger Greptile

Comment thread src/api/routes/memory.py
Comment thread src/api/routes/memory.py
@github-actions
Copy link
Copy Markdown

✅ Staging Deployment Report

Item Value
Branch feature/Local-Setup
Commit d1789bb
Environment Staging
Health http://13.232.74.176:8001/health
API Docs http://13.232.74.176:8001/docs
Smoke Tests success

🟢 Staging is live and healthy! Test your changes at the staging URL above.

Ready to ship? Comment /promote on this PR to merge to main and deploy to production.

@github-actions
Copy link
Copy Markdown

🔍 API Schema Diff

---REPORT---

🔄 Modified

  • 🟡 CHANGED: root['components']['schemas']['IngestRequest']['properties']['user_id']['description']

Auto-generated by API Schema Diff workflow

@github-actions
Copy link
Copy Markdown

✅ Staging Deployment Report

Item Value
Branch feature/Local-Setup
Commit b39bf7c
Environment Staging
Health http://13.232.74.176:8001/health
API Docs http://13.232.74.176:8001/docs
Smoke Tests success

🟢 Staging is live and healthy! Test your changes at the staging URL above.

Ready to ship? Comment /promote on this PR to merge to main and deploy to production.

@github-actions
Copy link
Copy Markdown

🔍 API Schema Diff

---REPORT---

🔄 Modified

  • 🟡 CHANGED: root['components']['schemas']['IngestRequest']['properties']['user_id']['description']

Auto-generated by API Schema Diff workflow

@github-advanced-security
Copy link
Copy Markdown

You are seeing this message because GitHub Code Scanning has recently been set up for this repository, or this pull request contains the workflow file for the Code Scanning tool.

What Enabling Code Scanning Means:

  • The 'Security' tab will display more code scanning analysis results (e.g., for the default branch).
  • Depending on your configuration and choice of analysis tool, future pull requests will be annotated with code scanning analysis results.
  • You will be able to see the analysis results for the pull request's branch on this overview once the scans have completed and the checks have passed.

For more information about GitHub Code Scanning, check out the documentation.

@github-actions
Copy link
Copy Markdown

✅ Staging Deployment Report

Item Value
Branch feature/Local-Setup
Commit ffb8c08
Environment Staging
Health http://13.232.74.176:8001/health
API Docs http://13.232.74.176:8001/docs
Smoke Tests success

🟢 Staging is live and healthy! Test your changes at the staging URL above.

Ready to ship? Comment /promote on this PR to merge to main and deploy to production.

@github-actions
Copy link
Copy Markdown

🔍 API Schema Diff

---REPORT---

🔄 Modified

  • 🟡 CHANGED: root['components']['schemas']['IngestRequest']['properties']['user_id']['description']

Auto-generated by API Schema Diff workflow

@Ankit-Kotnala Ankit-Kotnala self-assigned this May 23, 2026
Comment thread src/api/app.py Outdated
@github-actions
Copy link
Copy Markdown

✅ Staging Deployment Report

Item Value
Branch feature/Local-Setup
Commit 558fcff
Environment Staging
Health http://13.232.74.176:8001/health
API Docs http://13.232.74.176:8001/docs
Smoke Tests success

🟢 Staging is live and healthy! Test your changes at the staging URL above.

Ready to ship? Comment /promote on this PR to merge to main and deploy to production.

@github-actions
Copy link
Copy Markdown

🔍 API Schema Diff

---REPORT---

🔄 Modified

  • 🟡 CHANGED: root['components']['schemas']['IngestRequest']['properties']['user_id']['description']

Auto-generated by API Schema Diff workflow

@Ankit-Kotnala Ankit-Kotnala merged commit 9bf030d into main May 23, 2026
12 of 13 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants