Metadata-Version: 2.4
Name: concierge-graph
Version: 4.1.1
Summary: Long-Term Memory (LTM) Palace for AI Agents — hybrid search, semantic graphs, and MCP tools for Cursor, Claude Desktop, and autonomous agents.
Author: LuisinTheLegend
License-Expression: MIT
Project-URL: Homepage, https://github.com/LuisinTheLegend/ConciergeGraph
Project-URL: Repository, https://github.com/LuisinTheLegend/ConciergeGraph
Project-URL: Issues, https://github.com/LuisinTheLegend/ConciergeGraph/issues
Keywords: mcp,memory,graph,ai-agents,rag,semantic-search,vector-database,llm,cursor,claude-desktop,embeddings
Classifier: Development Status :: 4 - Beta
Classifier: Intended Audience :: Developers
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Programming Language :: Python :: 3.14
Classifier: Topic :: Software Development :: Libraries
Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
Requires-Python: >=3.10
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: chromadb>=1.0
Requires-Dist: mcp<2,>=1.27
Requires-Dist: sentence-transformers>=3.0
Requires-Dist: python-dotenv>=1.0
Requires-Dist: starlette>=0.36
Provides-Extra: gemini
Requires-Dist: google-genai>=0.1.0; extra == "gemini"
Provides-Extra: qdrant
Requires-Dist: qdrant-client>=1.7; extra == "qdrant"
Provides-Extra: openai
Requires-Dist: openai>=1.0; extra == "openai"
Provides-Extra: dev
Requires-Dist: pytest>=7.0; extra == "dev"
Requires-Dist: pytest-timeout>=2.2.0; extra == "dev"
Requires-Dist: flake8>=6.0; extra == "dev"
Requires-Dist: mypy>=1.0; extra == "dev"
Requires-Dist: rich>=13.0; extra == "dev"
Requires-Dist: packaging>=21.0; extra == "dev"
Requires-Dist: setuptools>=77.0.0; extra == "dev"
Requires-Dist: qdrant-client>=1.7; extra == "dev"
Requires-Dist: google-genai>=0.1.0; extra == "dev"
Requires-Dist: openai>=1.0; extra == "dev"
Provides-Extra: all
Requires-Dist: qdrant-client>=1.7; extra == "all"
Requires-Dist: google-genai>=0.1.0; extra == "all"
Requires-Dist: openai>=1.0; extra == "all"
Dynamic: license-file

English · [Português (Brasil)](README.pt-BR.md)
---

# Concierge Graph (V4 Core)

**Open-Source, Local-First Long-Term Memory (LTM), Hybrid Search & MCP Governance Server for AI Agents and IDEs**

[![MIT License](https://img.shields.io/badge/License-MIT-green.svg)](LICENSE)
[![Python 3.10+](https://img.shields.io/badge/python-3.10%2B-blue.svg)](pyproject.toml)
[![Protocol MCP](https://img.shields.io/badge/Protocol-MCP-purple.svg)](https://modelcontextprotocol.io/)
[![MCP Tools](https://img.shields.io/badge/MCP%20Tools-31-blue.svg)](docs-grafo-concierge/README.md)
[![Tests Passing](https://img.shields.io/badge/Tests-379%20Passed-brightgreen.svg)](tests/)

Concierge Graph is a local-first memory server built around the **Model Context Protocol (MCP)** that gives AI coding assistants (Cursor, Claude Desktop, and autonomous agents) persistent project memory, hybrid retrieval, recursive call-chain queries, durable agent checkpoints, and governed tool disclosure — backed by **SQLite WAL (with FTS5)** and pluggable vector storage (**ChromaDB** by default, optional **Qdrant**).

> **V4 Core Consolidation Note:** Experimental modules from earlier iterations have been moved to quarantine under [`archive/v4-experimental/`](archive/v4-experimental/) so that the active V4 core remains lean, deterministic, and audited.

---

## Core Capabilities (V4 Core)

1. **SQLite WAL + FTS5 Relational Graph (`storage/`)**: Stores projects, code nodes, call/import edges, semantic facts, memory commits, and durable agent checkpoints (`agent_checkpoints`) in a local SQLite database with WAL mode and full-text indexing.
2. **Tri-Signal Hybrid Search v4 (`core/hybrid_search.py`)**: Blends dense vector similarity (`sentence-transformers` + ChromaDB/Qdrant), SQLite FTS5 BM25 lexical scoring, and topological/recency signals with strict project/wing scoping and query-time orphan vector filtering.
3. **Python AST Ingestion & Self-Healing Vectors (`ingestion/`, `services/janitor.py`)**: Crawls repositories, extracts Python AST chunks and call edges, repairs missing embeddings during mining with honest failure reporting, and supports on-demand vector reconciliation (`concierge sync-vector`).
4. **Recursive Call-Chain GraphRAG (`core/graph_rag.py`)**: Traverses multi-hop `calls` dependencies over SQLite `edges` using `WITH RECURSIVE` CTEs protected by strict pipe-delimited cycle guards (`|node|`).
5. **Durable Agent Checkpoints with Ownership Binding (`core/checkpointer.py`)**: Persists and retrieves structured agent state dictionaries in `agent_checkpoints` via `agent_save_checkpoint`, `agent_get_checkpoint`, and `agent_list_checkpoints` with strict argument resolution, corrupt-JSON detection, and SHA-256 `owner_hash` namespace verification (`GRAFO_AGENT_TOKEN` over `stdio`, or `X-Grafo-Agent-Token` over HTTP/SSE decoupled from `Authorization: Bearer`, falling back to an ephemeral per-`ServerSession` secret).
6. **Least-Privilege MCP Governance (`core/mcp_governor.py`)**: Classifies all **31 live MCP tools** into `READ_ONLY` (18), `LOCAL_MUTATION` (11), and `DANGEROUS` (2) across a 3-state hierarchy (`PLANNING < EXECUTION < MAINTENANCE`), defaulting to `PLANNING` (`GRAFO_DEFAULT_STATE`) as a hard privilege ceiling (`max_state`). Sessions are bound server-side to the MCP transport (`WeakKeyDictionary`), undeclared tool arguments are rejected, and both `list_tools` (`ListToolsRequest`) and runtime execution enforce fail-closed governance filtering.
7. **Domain Neutrality & Free-Form Wings**: Project wings are strictly user- or agent-defined free-form strings — no hardcoded business taxonomies exist in product code, enforced by AST guard tests (`tests/test_domain_neutrality_guard.py`).
8. **Optional Lightweight Mode & Zero-Cost LLM Defaults**: Set `GRAFO_LIGHTWEIGHT_MODE=true` to operate using SQLite FTS5 BM25 at **~108 MB RSS (~5.8x less RAM than default mode)** without vector model overhead or spurious embedding failure reports, and `LLMAdapter` automatically runs at **zero cost** (`is_enabled=False`) when no provider API key is configured (or when `GRAFO_LLM_MODEL=none`).

---

## Architecture Overview

```
    ┌───────────────────────────┐      ┌───────────────────────────┐
    │      Cursor / Windsurf    │      │       Claude Desktop      │
    └─────────────┬─────────────┘      └─────────────┬─────────────┘
                  │                                  │
                  │     MCP (stdio default / SSE)    │
                  └─────────────────┬────────────────┘
                                    │
                                    ▼
                     ┌─────────────────────────────┐      ┌─────────────────────┐
                     │  Concierge Graph MCP Server │      │   concierge CLI     │
                     │  concierge-mcp (Port 8000)  │      │   (10 subcommands)  │
                     └──────────────┬──────────────┘      └──────────┬──────────┘
                                    │                                │
                                    └───────────────┬────────────────┘
                                                    ▼
                                     ┌──────────────────────────────┐
                                     │   GrafoConcierge Facade      │
                                     │   + MCPToolGovernor (31)     │
                                     └──────────────┬───────────────┘
                                                    ▼
                                     ┌──────────────────────────────┐
                                     │  SQLite WAL/FTS5 + ChromaDB  │
                                     │  (or optional Qdrant)        │
                                     └──────────────────────────────┘
```

---

## Quick Start

### Quick Install (`v4.1.1`)

> **Release & PyPI Status:** Version `4.1.1` builds on `v4.1.0` (which superseded the legacy `v3.8.2` PyPI release and pre-audit `V4.0.0` GitHub tag).

1. **Install via pip (or from source in editable mode):**
   ```bash
   # Package installation:
   pip install concierge-graph

   # Or editable source checkout:
   git clone https://github.com/LuisinTheLegend/ConciergeGraph.git
   cd ConciergeGraph
   python -m venv .venv
   # Linux / macOS: source .venv/bin/activate
   # Windows PowerShell: .venv\Scripts\Activate.ps1
   pip install --upgrade pip
   pip install -e .
   ```
   For development and running tests (or install via `pip install -r requirements-dev.txt`; `requirements.txt` contains production runtime packages only):
   ```bash
   pip install -e ".[dev]"
   ```

2. **Configure environment variables (`.env`):**
   ```bash
   cp .env.example .env
   ```
   Minimal local-first configuration (zero external LLM cost when no API key is set; read-only `PLANNING` mode by default):
   ```env
   GRAFO_LLM_MODEL=none
   GRAFO_TRANSPORT=stdio
   GRAFO_DEFAULT_STATE=PLANNING   # 18 READ_ONLY tools (default, safest); set EXECUTION to allow register/mine/commit/write tools
   GRAFO_DB_PATH=./data/concierge.db
   GRAFO_CHROMA_PATH=./data/chroma
   ```
   > **Governance mode tip:** MCP sessions start in `GRAFO_DEFAULT_STATE=PLANNING` (read-only: search, wakeup, resume, checkpoints, call chains). To allow agents to call `concierge_register`, `concierge_mine`, `concierge_commit`, or memory writes, set `GRAFO_DEFAULT_STATE=EXECUTION` in `.env` or your MCP client config and restart the server.
   To run over HTTP/SSE instead of `stdio`:
   ```env
   GRAFO_TRANSPORT=sse
   GRAFO_HOST=127.0.0.1
   GRAFO_PORT=8000
   GRAFO_API_KEY=your_optional_bearer_token
   ```

3. **Run the MCP Server or CLI:**
   ```bash
   # Launch MCP server (uses GRAFO_TRANSPORT: stdio default, or sse on port 8000)
   concierge-mcp --help
   concierge-mcp --version
   concierge-mcp --transport sse

   # Or start via Docker Compose (non-root UID 10001, SSE + /health check)
   docker compose up -d --build

   # Use the terminal CLI (10 subcommands)
   concierge --help
   concierge register --name my-project --wing backend/core
   concierge mine --path /path/to/my-project --name my-project
   concierge search --query "authentication flow" --project <project-uuid>
   ```
   When running over HTTP/SSE, `GET /health` and `HEAD /health` return `200 {"status": "ok"}` without requiring `GRAFO_API_KEY`, while `/sse`, `/messages/`, and all other paths remain protected by pure ASGI `Authorization: Bearer` validation.

---

## MCP Tools (31 Live Tools)

| Category | Count | Tools |
| :--- | :---: | :--- |
| **`READ_ONLY`** | 18 | `concierge_search`, `concierge_wakeup`, `concierge_resume`, `concierge_load`, `concierge_status`, `concierge_list_projects`, `concierge_list_facts`, `concierge_get_memory`, `get_full_topology`, `get_trajectories`, `find_similar`, `search_symbols`, `get_implementations`, `get_callers`, `concierge_get_call_chain`, `count_embeddings`, `agent_get_checkpoint`, `agent_list_checkpoints` |
| **`LOCAL_MUTATION`** | 11 | `concierge_register`, `concierge_mine`, `concierge_commit`, `concierge_set_state`, `concierge_store_fact`, `concierge_set_memory`, `concierge_feedback`, `update_project`, `add_reference_wing`, `remove_reference_wing`, `agent_save_checkpoint` |
| **`DANGEROUS`** | 2 | `delete_project`, `reset_collection` |

See [`docs-grafo-concierge/README.md`](docs-grafo-concierge/README.md) for architecture details and the full list of CLI subcommands.

---

## Testing & Verification

The active V4 core is covered by **379 passing automated tests** (verified in normal and `--reverse` order, plus CI across Linux, Windows, and real container `docker-smoke`):

```bash
python -m pytest tests/ -q
```

---

## Contributing & Lineage

- Read [`CONTRIBUTING.md`](CONTRIBUTING.md) for architectural pillars, testing rules, and MCP governance contracts.
- Read [`ATTRIBUTION_AND_LINEAGE.md`](ATTRIBUTION_AND_LINEAGE.md) for technical credits and the active vs. quarantined status matrix.
- Read [`CHANGELOG.md`](CHANGELOG.md) for recent changes and breaking-change migration notes.

## License

Distributed under the MIT License. See [`LICENSE`](LICENSE) for details.
