concierge-graph 3.8.2__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,327 @@
1
+ Metadata-Version: 2.4
2
+ Name: concierge-graph
3
+ Version: 3.8.2
4
+ Summary: Long-Term Memory (LTM) Palace for AI Agents — hybrid search, semantic graphs, and MCP tools for Cursor, Claude Desktop, and autonomous agents.
5
+ Author: LuisinTheLegend
6
+ License: MIT License
7
+
8
+ Copyright (c) 2026 LuisinTheLegend / Grafo Concierge Team
9
+
10
+ Permission is hereby granted, free of charge, to any person obtaining a copy
11
+ of this software and associated documentation files (the "Software"), to deal
12
+ in the Software without restriction, including without limitation the rights
13
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
14
+ copies of the Software, and to permit persons to whom the Software is
15
+ furnished to do so, subject to the following conditions:
16
+
17
+ The above copyright notice and this permission notice shall be included in all
18
+ copies or substantial portions of the Software.
19
+
20
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
21
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
22
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
23
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
24
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
25
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
26
+ SOFTWARE.
27
+
28
+ Project-URL: Homepage, https://github.com/LuisinTheLegend/GrafoConcierge
29
+ Project-URL: Repository, https://github.com/LuisinTheLegend/GrafoConcierge
30
+ Project-URL: Issues, https://github.com/LuisinTheLegend/GrafoConcierge/issues
31
+ Keywords: mcp,memory,graph,ai-agents,rag,semantic-search,vector-database,llm,cursor,claude-desktop,embeddings
32
+ Classifier: Development Status :: 4 - Beta
33
+ Classifier: Intended Audience :: Developers
34
+ Classifier: License :: OSI Approved :: MIT License
35
+ Classifier: Operating System :: OS Independent
36
+ Classifier: Programming Language :: Python :: 3
37
+ Classifier: Programming Language :: Python :: 3.10
38
+ Classifier: Programming Language :: Python :: 3.11
39
+ Classifier: Programming Language :: Python :: 3.12
40
+ Classifier: Programming Language :: Python :: 3.13
41
+ Classifier: Programming Language :: Python :: 3.14
42
+ Classifier: Topic :: Software Development :: Libraries
43
+ Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
44
+ Requires-Python: >=3.10
45
+ Description-Content-Type: text/markdown
46
+ License-File: LICENSE
47
+ Requires-Dist: chromadb>=1.0
48
+ Requires-Dist: mcp>=1.0
49
+ Requires-Dist: sentence-transformers>=3.0
50
+ Requires-Dist: python-dotenv>=1.0
51
+ Requires-Dist: starlette>=0.36
52
+ Requires-Dist: sse-starlette>=2.0
53
+ Requires-Dist: uvicorn>=0.25
54
+ Requires-Dist: httpx>=0.25
55
+ Requires-Dist: pydantic>=2.0
56
+ Requires-Dist: rich>=13.0
57
+ Requires-Dist: tenacity>=8.0
58
+ Requires-Dist: pathspec>=0.11
59
+ Provides-Extra: qdrant
60
+ Requires-Dist: qdrant-client>=1.7; extra == "qdrant"
61
+ Provides-Extra: dev
62
+ Requires-Dist: pytest>=7.0; extra == "dev"
63
+ Requires-Dist: flake8>=6.0; extra == "dev"
64
+ Requires-Dist: mypy>=1.0; extra == "dev"
65
+ Dynamic: license-file
66
+
67
+ English · [Português (Brasil)](README.pt-BR.md)
68
+ ---
69
+
70
+ # 🧠 Concierge Graph v3.8.2
71
+
72
+ **The Open-Source Long-Term Memory (LTM) & Cognitive Palace for AI Agents, IDEs & Developer Environments**
73
+
74
+ [![MIT License](https://img.shields.io/badge/License-MIT-green.svg)](LICENSE)
75
+ [![Python 3.10+](https://img.shields.io/badge/python-3.10%2B-blue.svg)](pyproject.toml)
76
+ [![Protocol MCP](https://img.shields.io/badge/Protocol-MCP-purple.svg)](https://modelcontextprotocol.io/)
77
+ [![Docker Supported](https://img.shields.io/badge/Docker-Ready-blue)](docker-compose.yml)
78
+
79
+ Concierge Graph is a high-performance, local cognitive memory server designed to solve LLM "amnesia" and context window pollution. Unlike simple RAG (Retrieval-Augmented Generation) scripts, Concierge Graph acts as a bi-temporal, self-healing memory engine combining relational SQL persistence, vector search, hierarchical context synthesis (Zoom Gear), and autonomous background maintenance (Janitor Loop).
80
+
81
+ ---
82
+
83
+ ## 💡 What is Concierge Graph? (For Beginners & Senior Devs)
84
+
85
+ ### 👶 Simple Explanation (The Analogy)
86
+ > Imagine hiring a brilliant senior software engineer who suffers from short-term memory loss. Every time you open a new chat window in Cursor or Claude Desktop, they forget your project structure, coding standards, and past architectural decisions.
87
+ >
88
+ > **Concierge Graph is that engineer's permanent external brain.** Connected seamlessly via the Model Context Protocol (MCP), your AI assistant automatically consults, learns from, and updates this brain in milliseconds—without you ever copying and pasting context again!
89
+
90
+ ### 🧙‍♂️ Technical Deep-Dive (For Engineers)
91
+ Concierge Graph is a local/VPS daemon that provides:
92
+ 1. **Bi-Temporal Fact Persistence**: Stores semantic facts and code entities with explicit valid time and transaction time tracking.
93
+ 2. **Hybrid Search v4 Engine**: Balances dense vector embeddings (50%), precise keyword signatures via SQLite FTS5 BM25 (25%), and graph signals (25% combining centrality and exponential recency decay $W = W_0 \cdot e^{-\lambda t}$).
94
+ 3. **AST-Aware Apex Ingestion**: Parses Python, TypeScript, JS, Go, Rust, Java, C/C++ files into structural AST nodes with delta-hashing (SHA-256) to skip unmodified code.
95
+ 4. **Autonomous Self-Healing (Janitor Loop)**: Operates in a background thread to reconcile relational SQLite tables with vector collections, prune orphan embeddings, and decay inactive context.
96
+
97
+ ---
98
+
99
+ ## 🔌 Simultaneous Multi-Client Integration via MCP
100
+
101
+ Powered by Anthropic's **Model Context Protocol (MCP)**, a single Concierge Graph server instance communicates **simultaneously** with all your favorite tools:
102
+
103
+ ```
104
+ ┌───────────────────────────┐ ┌───────────────────────────┐
105
+ │ Cursor / Windsurf │ │ Claude Desktop │
106
+ └─────────────┬─────────────┘ └─────────────┬─────────────┘
107
+ │ │
108
+ │ JSON-RPC / SSE (MCP) │
109
+ └─────────────────┬────────────────┘
110
+
111
+
112
+ ┌─────────────────────────────┐
113
+ │ 🧠 Concierge Graph Server │
114
+ │ (Local / VPS - Port 8000) │
115
+ └─────────────────────────────┘
116
+ ```
117
+
118
+ * 💻 **Cursor & Windsurf**: Your IDE agent dynamically searches, recalls, and commits project memory as you write code.
119
+ * 💬 **Claude Desktop**: Grants your desktop AI assistant instant macro awareness of your repos.
120
+ * 🤖 **Autonomous Agents & Workflows**: Connect n8n, LangChain, AutoGen, or custom python scripts via SSE endpoints.
121
+
122
+ ---
123
+
124
+ ## ⚡ Quick Start Guide (3 Minutes)
125
+
126
+ ### Option 1: Install via PyPI (Recommended for Most Users)
127
+
128
+ ```bash
129
+ # Install Grafo Concierge package & CLI
130
+ pip install concierge-graph
131
+
132
+ # Uninstall anytime
133
+ pip install concierge-graph --upgrade # to update
134
+ pip uninstall concierge-graph # to uninstall
135
+ ```
136
+
137
+ ### Option 2: Local Setup from Source (For Developers & Contributors)
138
+
139
+ 1. **Clone & Install in Editable Mode**:
140
+ ```bash
141
+ git clone https://github.com/LuisinTheLegend/GrafoConcierge.git
142
+ cd GrafoConcierge
143
+ pip install -e .[dev]
144
+ ```
145
+
146
+ 2. **Configure Environment (`.env`)**:
147
+ ```bash
148
+ cp .env.example .env
149
+ ```
150
+ Add your Gemini or OpenAI key:
151
+ ```env
152
+ GRAFO_LLM_API_KEY=your_gemini_api_key_here
153
+ GRAFO_LLM_MODEL=gemini-2.0-flash
154
+ ```
155
+
156
+ 3. **Start the MCP Server**:
157
+ ```bash
158
+ concierge-mcp
159
+ # or: python main.py
160
+ ```
161
+
162
+ ---
163
+
164
+ ### Option 2: VPS Deployment (Direct `pip` or `Docker`) 🌐
165
+
166
+ You can host Concierge Graph on any Linux VPS (Ubuntu/Debian) in two ways:
167
+
168
+ #### A) Direct Installation (Native `pip`)
169
+ ```bash
170
+ # 1. Install directly on your VPS
171
+ pip install concierge-graph
172
+
173
+ # 2. Set your environment variables (or create a .env file)
174
+ export GRAFO_LLM_API_KEY="your_gemini_key"
175
+ export GRAFO_HOST="0.0.0.0"
176
+ export GRAFO_API_KEY="your_secure_vps_token"
177
+
178
+ # 3. Launch the server
179
+ concierge-mcp
180
+ ```
181
+
182
+ #### B) Containerized Installation (Docker 🐳)
183
+ ```bash
184
+ # Set your API Key for remote security in .env
185
+ echo "GRAFO_API_KEY=your_secure_vps_token" >> .env
186
+
187
+ # Boot the containerized server
188
+ docker compose up -d
189
+ ```
190
+
191
+ ---
192
+
193
+ ## 💻 1-Click Configuration for IDEs & Claude Desktop
194
+
195
+ ### For Claude Desktop (`claude_desktop_config.json`)
196
+ Add Concierge Graph to your configuration file:
197
+
198
+ ```json
199
+ {
200
+ "mcpServers": {
201
+ "concierge-graph": {
202
+ "command": "python",
203
+ "args": ["-m", "interface.mcp_server"],
204
+ "cwd": "/path/to/GrafoConcierge",
205
+ "env": {
206
+ "GRAFO_LLM_API_KEY": "your_api_key_here"
207
+ }
208
+ }
209
+ }
210
+ }
211
+ ```
212
+
213
+ ### For Remote VPS / SSE Connections (Cursor / Custom Scripts)
214
+ When running on a server:
215
+ ```json
216
+ {
217
+ "mcpServers": {
218
+ "concierge-graph": {
219
+ "url": "http://your-vps-ip:8000/sse",
220
+ "headers": {
221
+ "Authorization": "Bearer your_secure_remote_token"
222
+ }
223
+ }
224
+ }
225
+ }
226
+ ```
227
+
228
+ ---
229
+
230
+ ## 🚀 Performance Benchmarks (Colossus Protocol)
231
+
232
+ Tested against 20,000 code nodes under the **Colossus Protocol**:
233
+
234
+ | Metric | Result (20,000 nodes) |
235
+ | --- | --- |
236
+ | **Search Latency (P50)** | 41.69 ms |
237
+ | **Search Latency (P99)** | 112.75 ms |
238
+ | **Scalability Factor** | 0.93x (Linear performance preserved) |
239
+ | **Ingestion Throughput (SQLite)** | ~536 nodes/second |
240
+ | **Ingestion Throughput (ChromaDB)** | ~914 vectors/second |
241
+ | **Background Maintenance (Janitor)** | 20,000 orphan vectors reconciled in ~11s |
242
+
243
+ ---
244
+
245
+ ## 🛠️ Hybrid Search v4 Formula
246
+
247
+ Relevance scores are calculated by composing three distinct signals:
248
+
249
+ $$\text{Score} = (0.50 \times \text{Vector Similarity}) + (0.25 \times \text{Normalized FTS5 BM25}) + (0.25 \times \max(\text{Recency}, \text{Centrality}))$$
250
+
251
+ 1. **Vector Similarity (50%)**: Captures deep conceptual meaning using dense embeddings.
252
+ 2. **FTS5 BM25 (25%)**: Exact token signatures for function names, classes, and symbols.
253
+ 3. **Graph Signals (25%)**:
254
+ - **Centrality**: Relative connectivity of a node (in-degree normalized).
255
+ - **Recency**: Time-based exponential decay ensuring historical context ages gracefully:
256
+ $$W = W_0 \cdot e^{-\lambda t}$$
257
+
258
+ ---
259
+
260
+ ## 🔌 Core MCP Tools Reference
261
+
262
+ * **`concierge_mine`**: Ingests a directory, chunks code (AST), extracts tags, and generates L0/L1/L2 summaries.
263
+ * **`concierge_search`**: Runs the complete Hybrid Search v4 pipeline across indexed projects.
264
+ * **`concierge_wakeup`**: Reactivates agent consciousness on session start by returning the Context Compass, reference wings, and recent commits.
265
+ * **`concierge_resume`**: Retrieves macro summary of project context (ideal for system prompt injection).
266
+ * **`concierge_load`**: On-demand lazy loader for full node contents, edges, and dependencies.
267
+ * **`concierge_commit`**: Registers audited architectural changes to the cognitive ledger.
268
+ * **`concierge_store_fact`**: Records user preferences and architectural rules with bi-temporal invalidation.
269
+
270
+ ---
271
+
272
+ ## 🛠️ Global CLI Subcommands Reference (`concierge`)
273
+
274
+ After running `pip install concierge-graph`, two global terminal commands are installed via `pyproject.toml`:
275
+ 1. **`concierge-mcp`**: Boots the FastMCP Server daemon.
276
+ 2. **`concierge`**: Multifunctional CLI utility supporting the following subcommands:
277
+
278
+ ```bash
279
+ # 1. Register a new workspace/project
280
+ concierge register --name my-project --wing backend --privacy PUBLIC
281
+
282
+ # 2. Mine / Ingest a codebase directory into the memory graph
283
+ concierge mine --path /path/to/codebase --name my-project
284
+
285
+ # 3. Perform Hybrid Search v4 across indexed memory
286
+ concierge search --query "authentication middleware" --project my-project
287
+
288
+ # 4. Reactivate agent consciousness (Compass + Wings + Commits)
289
+ concierge wakeup --project my-project
290
+
291
+ # 5. Retrieve Context Compass macro summary
292
+ concierge resume --project my-project
293
+
294
+ # 6. Register audited architectural commit to ledger
295
+ concierge commit --project <uuid> --phase build --technical_changes "Added Auth JWT"
296
+
297
+ # 7. Lazy load a single node on demand
298
+ concierge load --node_id 42
299
+
300
+ # 8. Display system health, counts, and database status
301
+ concierge status
302
+
303
+ # 9. List all registered projects inside the local database
304
+ concierge projects
305
+
306
+ # 10. Purge a project and all associated relational & vector records
307
+ concierge delete --project my-project
308
+ ```
309
+
310
+ ---
311
+
312
+ ## 🧪 Test Suite & Health Diagnostics
313
+
314
+ Run all unit and stress tests:
315
+ ```bash
316
+ python -m pytest
317
+ ```
318
+
319
+ Run full memory diagnostics:
320
+ ```bash
321
+ python -m tests.check_brain
322
+ ```
323
+
324
+ ---
325
+
326
+ ## 📄 License
327
+ Distributed under the MIT License. See `LICENSE` for details.
@@ -0,0 +1,37 @@
1
+ main.py,sha256=OiwcJToPED-xo7cWvvgH42BxH8c97fWKyotv1zFuTqs,10831
2
+ agents/__init__.py,sha256=aiv-lzDZOuYJ1v1hy_L_qZMoBBH4zYB5icZ7A2x1R1A,316
3
+ agents/revisor_critico.py,sha256=5I3g3ecinZcVaEf_EEZwHrjn4SydeBam5gGbg59kG14,22859
4
+ concierge_graph-3.8.2.dist-info/licenses/LICENSE,sha256=beaj4SlugpnDBdWYB60ZFmz7jm1eNjdjkVezhbZdhaM,1095
5
+ core/__init__.py,sha256=OLHPSeAmiDlsQp49m5OzL0qtX5RxGll_jadoWT_-dmA,743
6
+ core/config.py,sha256=g2SzQkYfghXl_flMzAyAUHFTYctZtEO4LkYjTtgc_ZU,7600
7
+ core/hybrid_search.py,sha256=Zw3u03RniUGQFyuMaTjGOMz-Bgr3dVtTzNKL2M3KcJU,10901
8
+ core/memory_extractor.py,sha256=92hliQ95HOxMM04bz-H82h30bzR7xFMaU8WzvHFVW4s,9899
9
+ core/middleware.py,sha256=fz8kODNq5TK5kCdkEuo7eJUeYjf1mQ6ChmaHVVg7TlU,27275
10
+ core/probabilistic_retriever.py,sha256=shd15a-qcgVv1WVhUmxmAeOmULPeBmnesu1821YPw5M,3963
11
+ core/project_index.py,sha256=iXWw00SIoZl3pCdHnWU1OTwOp0_JFYIR1i0dDIbLrrM,11192
12
+ core/vector_backend.py,sha256=o_tAd-ryGQrhd2EIB4v4nY0guRdtMucjs3fQ8tvG8DA,17817
13
+ ingestion/__init__.py,sha256=lgVDHW1b_yGYujf5-QYOB6UxiaN0aXRI2SOwBAHIxEk,887
14
+ ingestion/crawler.py,sha256=3I5VlOhbIv9kiFmuBikNTCE51o_sXgow450hWQCmZN8,27092
15
+ ingestion/orchestrator.py,sha256=ghycXlZ866pml-u6lGwJrxwznjc7ta5Y2ow0VdmVZdo,38927
16
+ ingestion/parser.py,sha256=DXbwLHDdYGMAEhsfdUIRN3hyBrTD9qep1qQGn-Fikls,42703
17
+ ingestion/summarizer.py,sha256=u7JQHZlMQXT5AEd6_9GmifG0vjy9SQeGtJk-qe-dmyY,38365
18
+ interface/__init__.py,sha256=JJfzzJ4rny-irT8WWFR3PVre8vp0D_LzyyCNbfoF-0k,518
19
+ interface/action_hooks.py,sha256=hDLWFPI-IlDKbFPdtaxr2Uf-KoPb0A4c1ZOq9y-ul7o,9358
20
+ interface/cli.py,sha256=3_EgVPnvlC63ijfZ3EAwYYd9s0HmeGRAiShsbbFnb_s,13773
21
+ interface/mcp_server.py,sha256=li85mieI6nmEgqo-s-9dYe9Myv5b2IAMgcB7lKkwozk,68239
22
+ scripts/bootstrap_core_memory.py,sha256=WWpLRWW-hshG5CycFW8sewAyKB7NJSCua9hx48cRWUE,3078
23
+ services/__init__.py,sha256=Wv1zgdLcI952L0peXz9GXDIj0twQzddA9J8S22fjG68,291
24
+ services/janitor.py,sha256=Ni_3VgYzlB8hme0eAkSPq4Au6a6PDLn0H3Bs5xply6I,32372
25
+ storage/__init__.py,sha256=R-27e_wVEdrgfep-wNR76Mm6urrjtFP8RdTAkXG-YPg,1147
26
+ storage/base_backend.py,sha256=cMBnseCEYekmJx1r5p8aF1H42JPN_iJrezPLrR_KIqk,7728
27
+ storage/connection.py,sha256=bKYLJAxAHTTtKStDgsatB4s7l7EolakYqNKZhJeor3o,11876
28
+ storage/logic.py,sha256=awPrK5bPvMHKLVFJGdFeTwZ7ji4jPLgsa6GVFinBfb4,26052
29
+ storage/schema.py,sha256=Su5ao27a0OUrDDqmsE9pHAW3NRZJ_788mRqDftMVxSI,16625
30
+ storage/semantic_logic.py,sha256=_NxWts8CGFjwjfavFmSPjuvs2yg--dFZ3DTEBSZW6SI,4502
31
+ storage/store.py,sha256=eKvkVSLQPDMR1MleLwswozIEcIwETRNx7DYckvy8p9g,35425
32
+ storage/vector_store.py,sha256=LrGsMsrO-JaNBxftg1QgBkfnTxcDzWCUzNDhhXvh4OY,28338
33
+ concierge_graph-3.8.2.dist-info/METADATA,sha256=uiIvZpW7KlJS8P8ZqwoqFstqJ9x1HFqCI6GbQro5maU,13481
34
+ concierge_graph-3.8.2.dist-info/WHEEL,sha256=K260EYznzXsJYBQGqmI8VTxEdiZYNvDZwW9cBh9-_MA,91
35
+ concierge_graph-3.8.2.dist-info/entry_points.txt,sha256=vWr7eJ-whTZPUezGLbT7bjoSQqb9wUJEE6nTCKD94P0,75
36
+ concierge_graph-3.8.2.dist-info/top_level.txt,sha256=FT9rVGklAMOPrsCbIav9diYmtAaNjPUXg5CrSQTV_O8,62
37
+ concierge_graph-3.8.2.dist-info/RECORD,,
@@ -0,0 +1,5 @@
1
+ Wheel-Version: 1.0
2
+ Generator: setuptools (83.0.0)
3
+ Root-Is-Purelib: true
4
+ Tag: py3-none-any
5
+
@@ -0,0 +1,3 @@
1
+ [console_scripts]
2
+ concierge = interface.cli:main
3
+ concierge-mcp = main:main
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 LuisinTheLegend / Grafo Concierge Team
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,8 @@
1
+ agents
2
+ core
3
+ ingestion
4
+ interface
5
+ main
6
+ scripts
7
+ services
8
+ storage
core/__init__.py ADDED
@@ -0,0 +1,23 @@
1
+ """
2
+ core/__init__.py — Grafo Concierge v3.8.0 (Absolute Solidity)
3
+
4
+ core/ package — Agent Brain.
5
+
6
+ Exports the central Facade (GrafoConcierge) and intelligence submodules:
7
+ - GrafoConcierge → Unified facade for memory operations
8
+ - ConciergeConfig → Centralized constants and parameters
9
+ - ProjectIndex → Knowledge GPS / Wing Categorization
10
+ - HybridSearchEngine → Hybrid Search Engine v4
11
+ """
12
+
13
+ from core.config import ConciergeConfig
14
+ from core.project_index import ProjectIndex
15
+ from core.hybrid_search import HybridSearchEngine
16
+ from core.middleware import GrafoConcierge
17
+
18
+ __all__ = [
19
+ "ConciergeConfig",
20
+ "ProjectIndex",
21
+ "HybridSearchEngine",
22
+ "GrafoConcierge",
23
+ ]
core/config.py ADDED
@@ -0,0 +1,192 @@
1
+ """
2
+ core/config.py — Grafo Concierge v3.8.0 (Absolute Solidity)
3
+
4
+ Centralization of all constants, weights, and system parameters.
5
+
6
+ This module is the SINGLE source of truth for magic values.
7
+ No other module should define duplicate constants.
8
+ The values here reflect exactly what was specified in
9
+ Architecture v3.8 and validated in stress tests.
10
+
11
+ Sections:
12
+ 1. Hybrid Search v4 — Tri-signal weights
13
+ 2. Recency — Exponential decay
14
+ 3. Centrality — In-degree normalization
15
+ 4. FTS5 — BM25 parameters
16
+ 5. Wings — Keywords for automatic categorization
17
+ 6. Ingestion — Limits and ignored directories
18
+ 7. Summarization — Tokens per Zoom Gear level
19
+ 8. MCP Server — Runtime configurations
20
+ """
21
+
22
+ from __future__ import annotations
23
+
24
+ import math
25
+ from dataclasses import dataclass, field
26
+ from typing import Optional
27
+
28
+
29
+ @dataclass(frozen=True)
30
+ class ConciergeConfig:
31
+ """Centralized configurations of Grafo Concierge.
32
+
33
+ frozen=True guarantees immutability. To override values,
34
+ create a new instance passing the modified fields.
35
+
36
+ Example:
37
+ config = ConciergeConfig(vector_backend="qdrant")
38
+ """
39
+
40
+ # =================================================================
41
+ # 1. HYBRID SEARCH v4 — Tri-signal weights
42
+ # =================================================================
43
+ # score = (weight_vector × vector)
44
+ # + (weight_fts5 × normalized_bm25)
45
+ # + (weight_recency_centrality × max(recency, centrality))
46
+ weight_vector: float = 0.50
47
+ weight_fts5: float = 0.25
48
+ weight_recency_centrality: float = 0.25
49
+
50
+ # =================================================================
51
+ # 2. RECENCY — Exponential decay
52
+ # =================================================================
53
+ # Half-life of 7 days: score drops to 0.50 after 7 days without commit.
54
+ # Formula: max(e^(-λ × t), recency_min_score)
55
+ # λ = ln(2) / half_life_days ≈ 0.09902
56
+ recency_half_life_days: float = 7.0
57
+ recency_lambda: float = field(default=0.0, init=False)
58
+ recency_min_score: float = 0.01
59
+
60
+ # =================================================================
61
+ # 3. CENTRALITY — In-degree normalization
62
+ # =================================================================
63
+ # min(in_degree / centrality_max_in_degree, 1.0)
64
+ # A node with 10+ dependents is a "Super-Node" (score = 1.0).
65
+ centrality_max_in_degree: int = 10
66
+
67
+ # =================================================================
68
+ # 4. FTS5 — BM25 Parameters
69
+ # =================================================================
70
+ bm25_k1: float = 1.5
71
+ bm25_b: float = 0.75
72
+ bm25_fields: tuple[str, ...] = ("label", "tags", "summary")
73
+
74
+ # =================================================================
75
+ # 5. WINGS — Keywords for automatic categorization
76
+ # =================================================================
77
+ wing_keywords: dict[str, list[str]] = field(default_factory=lambda: {
78
+ "marketing/vendas": [
79
+ "marketing", "venda", "copy", "cta", "conversão", "landing",
80
+ "funil", "lead", "promo", "anúncio", "tráfego",
81
+ ],
82
+ "finanças/quant": [
83
+ "finança", "quant", "trade", "ação", "crypto", "investimento",
84
+ "bolsa", "daytrade", "renda", "mercado", "carteira",
85
+ ],
86
+ "gestão/saas": [
87
+ "saas", "dashboard", "gestão", "erp", "admin", "painel",
88
+ "plataforma", "multi-tenant", "subscription",
89
+ ],
90
+ "automação/rh": [
91
+ "automação", "excel", "planilha", "rh", "workflow",
92
+ "zapier", "n8n", "integração", "bot",
93
+ ],
94
+ "estatística": [
95
+ "estatística", "análise", "dados", "média", "probabilidade",
96
+ "regressão", "machine learning", "dataset",
97
+ ],
98
+ })
99
+
100
+ # Default wing when no keyword is detected.
101
+ default_wing: str = "geral"
102
+
103
+ # Recommended limit of wings — warns user if exceeded.
104
+ max_wings: int = 12
105
+
106
+ # =================================================================
107
+ # 6. INGESTION — Limits and filters
108
+ # =================================================================
109
+ ignore_dirs: tuple[str, ...] = (
110
+ ".git", "node_modules", ".next", "dist", "build",
111
+ "__pycache__", ".mypy_cache", ".pytest_cache", "venv",
112
+ ".venv", "env", ".env", ".tox", "eggs", "*.egg-info",
113
+ )
114
+
115
+ # Supported file extensions for ingestion.
116
+ supported_extensions: tuple[str, ...] = (
117
+ ".py", ".js", ".ts", ".jsx", ".tsx", ".java", ".go",
118
+ ".rs", ".rb", ".php", ".cs", ".cpp", ".c", ".h",
119
+ ".md", ".txt", ".rst", ".yaml", ".yml", ".toml",
120
+ ".json", ".xml", ".html", ".css", ".scss", ".sql",
121
+ )
122
+
123
+ # Maximum file size for ingestion (in bytes). Default: 1MB.
124
+ max_file_size_bytes: int = 1_048_576
125
+
126
+ # =================================================================
127
+ # 7. SUMMARIZATION — Tokens per level (Zoom Gear)
128
+ # =================================================================
129
+ max_l0_tokens: int = 150 # Individual chunk
130
+ max_l1_tokens: int = 300 # Cluster / Folder
131
+ max_l2_tokens: int = 300 # Project Compass
132
+ l2_relevance_threshold: float = 0.15 # Selective Amnesia
133
+
134
+ # =================================================================
135
+ # 8. MCP SERVER — Runtime configurations
136
+ # =================================================================
137
+ vector_backend: str = "chroma"
138
+ embedding_model: str = "all-MiniLM-L6-v2"
139
+ embedding_dimensions: int = 384
140
+ default_scope: str = "primary_wing"
141
+
142
+ # Lightweight mode (saves RAM by disabling vector search and using FTS5)
143
+ lightweight_mode: bool = False
144
+
145
+ # Result limits for searches.
146
+ search_top_k: int = 10
147
+ fts_limit: int = 20
148
+
149
+ # Resume: token limits in the Compass.
150
+ max_resume_tokens: int = 300
151
+ max_commit_tokens: int = 100
152
+
153
+ # Critical Revisor: maximum loops of auditing.
154
+ max_revisor_loops: int = 3
155
+
156
+ # Security & VPS authentication
157
+ api_key: Optional[str] = None
158
+ cors_origins: tuple[str, ...] = ("*",)
159
+
160
+ def __post_init__(self) -> None:
161
+ """Calculates derived fields after initialization."""
162
+ # frozen=True requires object.__setattr__ for calculated fields.
163
+ object.__setattr__(
164
+ self, "recency_lambda",
165
+ math.log(2) / self.recency_half_life_days
166
+ )
167
+
168
+ import os
169
+ if not self.lightweight_mode:
170
+ env_val = os.environ.get("GRAFO_LIGHTWEIGHT_MODE", "false").lower() == "true"
171
+ if env_val:
172
+ object.__setattr__(self, "lightweight_mode", True)
173
+
174
+ if self.api_key is None:
175
+ env_key = os.environ.get("GRAFO_API_KEY")
176
+ if env_key:
177
+ object.__setattr__(self, "api_key", env_key)
178
+
179
+ env_cors = os.environ.get("GRAFO_CORS_ORIGINS")
180
+ if env_cors:
181
+ origins = tuple(o.strip() for o in env_cors.split(",") if o.strip())
182
+ if origins:
183
+ object.__setattr__(self, "cors_origins", origins)
184
+
185
+
186
+
187
+ # ---------------------------------------------------------------------------
188
+ # Default global instance — import directly when customizing values is
189
+ # not necessary.
190
+ # ---------------------------------------------------------------------------
191
+
192
+ DEFAULT_CONFIG = ConciergeConfig()