mempalace-code 1.0.0__tar.gz
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.
- mempalace_code-1.0.0/.github/ISSUE_TEMPLATE/bug_report.md +20 -0
- mempalace_code-1.0.0/.github/ISSUE_TEMPLATE/feature_request.md +11 -0
- mempalace_code-1.0.0/.github/PULL_REQUEST_TEMPLATE.md +8 -0
- mempalace_code-1.0.0/.github/workflows/ci.yml +43 -0
- mempalace_code-1.0.0/.github/workflows/publish.yml +36 -0
- mempalace_code-1.0.0/.gitignore +47 -0
- mempalace_code-1.0.0/.pre-commit-config.yaml +7 -0
- mempalace_code-1.0.0/CHANGELOG.md +74 -0
- mempalace_code-1.0.0/CLAUDE.md +130 -0
- mempalace_code-1.0.0/CONTRIBUTING.md +92 -0
- mempalace_code-1.0.0/LICENSE +192 -0
- mempalace_code-1.0.0/NOTICE +17 -0
- mempalace_code-1.0.0/PKG-INFO +489 -0
- mempalace_code-1.0.0/README.md +450 -0
- mempalace_code-1.0.0/assets/mempalace_banner.jpg +0 -0
- mempalace_code-1.0.0/benchmarks/BENCHMARKS.md +768 -0
- mempalace_code-1.0.0/benchmarks/HYBRID_MODE.md +551 -0
- mempalace_code-1.0.0/benchmarks/README.md +124 -0
- mempalace_code-1.0.0/benchmarks/convomem_bench.py +346 -0
- mempalace_code-1.0.0/benchmarks/embed_ab_bench.py +576 -0
- mempalace_code-1.0.0/benchmarks/locomo_bench.py +1069 -0
- mempalace_code-1.0.0/benchmarks/longmemeval_bench.py +3406 -0
- mempalace_code-1.0.0/benchmarks/membench_bench.py +470 -0
- mempalace_code-1.0.0/benchmarks/results_embed_ab_2026-04-09.json +1078 -0
- mempalace_code-1.0.0/benchmarks/results_token_delta_mempalace.json +608 -0
- mempalace_code-1.0.0/benchmarks/token_delta_bench.py +633 -0
- mempalace_code-1.0.0/docs/AGENT_INSTALL.md +689 -0
- mempalace_code-1.0.0/docs/BACKLOG.yaml +732 -0
- mempalace_code-1.0.0/docs/BACKUP_RESTORE.md +151 -0
- mempalace_code-1.0.0/docs/BENCH_TOKEN_DELTA.md +102 -0
- mempalace_code-1.0.0/docs/COMPARISON_GRAPHIFY.md +206 -0
- mempalace_code-1.0.0/docs/HOW_SEARCH_WORKS.md +86 -0
- mempalace_code-1.0.0/docs/OFFLINE_USAGE.md +136 -0
- mempalace_code-1.0.0/docs/UPSTREAM_HARDENING.md +136 -0
- mempalace_code-1.0.0/docs/WHY_THIS_FORK.md +97 -0
- mempalace_code-1.0.0/examples/HOOKS_TUTORIAL.md +28 -0
- mempalace_code-1.0.0/examples/basic_mining.py +12 -0
- mempalace_code-1.0.0/examples/convo_import.py +11 -0
- mempalace_code-1.0.0/examples/gemini_cli_setup.md +95 -0
- mempalace_code-1.0.0/examples/mcp_setup.md +27 -0
- mempalace_code-1.0.0/hooks/README.md +138 -0
- mempalace_code-1.0.0/hooks/mempal_precompact_hook.sh +77 -0
- mempalace_code-1.0.0/hooks/mempal_save_hook.sh +147 -0
- mempalace_code-1.0.0/mempalace/README.md +40 -0
- mempalace_code-1.0.0/mempalace/__init__.py +6 -0
- mempalace_code-1.0.0/mempalace/__main__.py +5 -0
- mempalace_code-1.0.0/mempalace/cli.py +811 -0
- mempalace_code-1.0.0/mempalace/config.py +149 -0
- mempalace_code-1.0.0/mempalace/convo_miner.py +415 -0
- mempalace_code-1.0.0/mempalace/dialect.py +1075 -0
- mempalace_code-1.0.0/mempalace/entity_detector.py +853 -0
- mempalace_code-1.0.0/mempalace/entity_registry.py +639 -0
- mempalace_code-1.0.0/mempalace/export.py +378 -0
- mempalace_code-1.0.0/mempalace/general_extractor.py +521 -0
- mempalace_code-1.0.0/mempalace/knowledge_graph.py +410 -0
- mempalace_code-1.0.0/mempalace/layers.py +515 -0
- mempalace_code-1.0.0/mempalace/mcp_server.py +873 -0
- mempalace_code-1.0.0/mempalace/migrate.py +153 -0
- mempalace_code-1.0.0/mempalace/miner.py +1285 -0
- mempalace_code-1.0.0/mempalace/normalize.py +328 -0
- mempalace_code-1.0.0/mempalace/onboarding.py +489 -0
- mempalace_code-1.0.0/mempalace/palace_graph.py +225 -0
- mempalace_code-1.0.0/mempalace/py.typed +0 -0
- mempalace_code-1.0.0/mempalace/room_detector_local.py +310 -0
- mempalace_code-1.0.0/mempalace/searcher.py +305 -0
- mempalace_code-1.0.0/mempalace/spellcheck.py +269 -0
- mempalace_code-1.0.0/mempalace/split_mega_files.py +309 -0
- mempalace_code-1.0.0/mempalace/storage.py +807 -0
- mempalace_code-1.0.0/mempalace/version.py +3 -0
- mempalace_code-1.0.0/pyproject.toml +86 -0
- mempalace_code-1.0.0/scripts/bootstrap.sh +126 -0
- mempalace_code-1.0.0/scripts/nuke_wing.py +18 -0
- mempalace_code-1.0.0/tests/conftest.py +246 -0
- mempalace_code-1.0.0/tests/test_chunking.py +744 -0
- mempalace_code-1.0.0/tests/test_cli.py +171 -0
- mempalace_code-1.0.0/tests/test_config.py +32 -0
- mempalace_code-1.0.0/tests/test_convo_miner.py +51 -0
- mempalace_code-1.0.0/tests/test_dialect.py +157 -0
- mempalace_code-1.0.0/tests/test_e2e.py +527 -0
- mempalace_code-1.0.0/tests/test_embed_ab_bench.py +44 -0
- mempalace_code-1.0.0/tests/test_export.py +423 -0
- mempalace_code-1.0.0/tests/test_knowledge_graph.py +139 -0
- mempalace_code-1.0.0/tests/test_lang_detect.py +132 -0
- mempalace_code-1.0.0/tests/test_mcp_server.py +682 -0
- mempalace_code-1.0.0/tests/test_migrate.py +160 -0
- mempalace_code-1.0.0/tests/test_miner.py +1085 -0
- mempalace_code-1.0.0/tests/test_normalize.py +31 -0
- mempalace_code-1.0.0/tests/test_offline.py +44 -0
- mempalace_code-1.0.0/tests/test_searcher.py +106 -0
- mempalace_code-1.0.0/tests/test_split_mega_files.py +48 -0
- mempalace_code-1.0.0/tests/test_storage.py +786 -0
- mempalace_code-1.0.0/tests/test_storage_lance.py +647 -0
- mempalace_code-1.0.0/tests/test_symbol_extract.py +379 -0
- mempalace_code-1.0.0/tests/test_version_consistency.py +22 -0
- mempalace_code-1.0.0/uv.lock +3176 -0
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: Bug Report
|
|
3
|
+
about: Something isn't working
|
|
4
|
+
labels: bug
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
**What happened?**
|
|
8
|
+
|
|
9
|
+
**What did you expect?**
|
|
10
|
+
|
|
11
|
+
**How to reproduce:**
|
|
12
|
+
|
|
13
|
+
1.
|
|
14
|
+
2.
|
|
15
|
+
3.
|
|
16
|
+
|
|
17
|
+
**Environment:**
|
|
18
|
+
- OS:
|
|
19
|
+
- Python version:
|
|
20
|
+
- MemPal version: (check `python mempal.py --version` or git SHA)
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
name: Tests
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
push:
|
|
5
|
+
branches: [main]
|
|
6
|
+
pull_request:
|
|
7
|
+
branches: [main]
|
|
8
|
+
|
|
9
|
+
jobs:
|
|
10
|
+
test:
|
|
11
|
+
runs-on: ubuntu-latest
|
|
12
|
+
strategy:
|
|
13
|
+
fail-fast: false
|
|
14
|
+
matrix:
|
|
15
|
+
python-version: ["3.9", "3.11", "3.13"]
|
|
16
|
+
steps:
|
|
17
|
+
- uses: actions/checkout@v4
|
|
18
|
+
- uses: actions/setup-python@v5
|
|
19
|
+
with:
|
|
20
|
+
python-version: ${{ matrix.python-version }}
|
|
21
|
+
- run: pip install -e ".[dev]"
|
|
22
|
+
- run: python3 -m pytest tests/ -v -m "not needs_network"
|
|
23
|
+
|
|
24
|
+
chroma-compat:
|
|
25
|
+
runs-on: ubuntu-latest
|
|
26
|
+
steps:
|
|
27
|
+
- uses: actions/checkout@v4
|
|
28
|
+
- uses: actions/setup-python@v5
|
|
29
|
+
with:
|
|
30
|
+
python-version: "3.11"
|
|
31
|
+
- run: pip install -e ".[dev,chroma]"
|
|
32
|
+
- run: python3 -m pytest tests/ -v -m "not needs_network"
|
|
33
|
+
|
|
34
|
+
lint:
|
|
35
|
+
runs-on: ubuntu-latest
|
|
36
|
+
steps:
|
|
37
|
+
- uses: actions/checkout@v4
|
|
38
|
+
- uses: actions/setup-python@v5
|
|
39
|
+
with:
|
|
40
|
+
python-version: "3.11"
|
|
41
|
+
- run: pip install ruff
|
|
42
|
+
- run: ruff check .
|
|
43
|
+
- run: ruff format --check .
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
name: Publish to PyPI
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
push:
|
|
5
|
+
tags: ["v*"]
|
|
6
|
+
|
|
7
|
+
permissions:
|
|
8
|
+
id-token: write
|
|
9
|
+
|
|
10
|
+
jobs:
|
|
11
|
+
build:
|
|
12
|
+
runs-on: ubuntu-latest
|
|
13
|
+
steps:
|
|
14
|
+
- uses: actions/checkout@v4
|
|
15
|
+
- uses: actions/setup-python@v5
|
|
16
|
+
with:
|
|
17
|
+
python-version: "3.11"
|
|
18
|
+
- run: pip install build
|
|
19
|
+
- run: python -m build
|
|
20
|
+
- uses: actions/upload-artifact@v4
|
|
21
|
+
with:
|
|
22
|
+
name: dist
|
|
23
|
+
path: dist/
|
|
24
|
+
|
|
25
|
+
publish:
|
|
26
|
+
needs: build
|
|
27
|
+
runs-on: ubuntu-latest
|
|
28
|
+
environment: release
|
|
29
|
+
permissions:
|
|
30
|
+
id-token: write
|
|
31
|
+
steps:
|
|
32
|
+
- uses: actions/download-artifact@v4
|
|
33
|
+
with:
|
|
34
|
+
name: dist
|
|
35
|
+
path: dist/
|
|
36
|
+
- uses: pypa/gh-action-pypi-publish@release/v1
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
*.egg-info/
|
|
2
|
+
dist/
|
|
3
|
+
build/
|
|
4
|
+
__pycache__/
|
|
5
|
+
*.pyc
|
|
6
|
+
.pytest_cache/
|
|
7
|
+
mempal.yaml
|
|
8
|
+
mempalace.yaml
|
|
9
|
+
entities.json
|
|
10
|
+
|
|
11
|
+
# Backlog lock files and archives (backlog CLI)
|
|
12
|
+
*.yaml.lock
|
|
13
|
+
*.md.lock
|
|
14
|
+
docs/BACKLOG-archived.md
|
|
15
|
+
|
|
16
|
+
# Palace data (local user data, never commit)
|
|
17
|
+
*.lance/
|
|
18
|
+
lance/
|
|
19
|
+
chroma.sqlite3
|
|
20
|
+
palace/
|
|
21
|
+
|
|
22
|
+
# Environment
|
|
23
|
+
.venv/
|
|
24
|
+
venv/
|
|
25
|
+
.env
|
|
26
|
+
|
|
27
|
+
# IDE
|
|
28
|
+
.idea/
|
|
29
|
+
.vscode/
|
|
30
|
+
*.swp
|
|
31
|
+
*.swo
|
|
32
|
+
|
|
33
|
+
# OS
|
|
34
|
+
.DS_Store
|
|
35
|
+
Thumbs.db
|
|
36
|
+
|
|
37
|
+
# Sentence-transformers model cache
|
|
38
|
+
.cache/
|
|
39
|
+
|
|
40
|
+
# Autopilot artifacts (plans, audits, task reviews)
|
|
41
|
+
docs/plans/
|
|
42
|
+
docs/audits/
|
|
43
|
+
.tasks/
|
|
44
|
+
autopilot.toml
|
|
45
|
+
|
|
46
|
+
# Claude Code session data
|
|
47
|
+
.claude/
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
## v1.0.0 — 2026-04-12
|
|
4
|
+
|
|
5
|
+
First public release of **mempalace-code**, a code-first fork of
|
|
6
|
+
[milla-jovovich/mempalace](https://github.com/milla-jovovich/mempalace).
|
|
7
|
+
|
|
8
|
+
### Storage — LanceDB rewrite
|
|
9
|
+
|
|
10
|
+
- **LanceDB backend** replaces ChromaDB as the default. Crash-safe columnar Arrow storage, no server required.
|
|
11
|
+
- **Automatic schema migration** — palaces created by older versions are upgraded transparently on open. No manual migration commands needed.
|
|
12
|
+
- **NULL-safe migration defaults** — `CAST('' AS string)` prevents null corruption in existing rows during schema evolution.
|
|
13
|
+
- **Table handle reload** after migration — fixes "missing fields" error on multi-drawer writes to migrated palaces.
|
|
14
|
+
- ChromaDB retained as optional `[chroma]` extra (deprecated).
|
|
15
|
+
|
|
16
|
+
### Code mining
|
|
17
|
+
|
|
18
|
+
- **Language-aware structural chunking** — Python, TypeScript/JavaScript, Go, Markdown. Splits at function/class/type boundaries, not arbitrary line counts.
|
|
19
|
+
- **Language detection** — file extension + shebang + content heuristics. 20+ languages recognized.
|
|
20
|
+
- **Symbol metadata extraction** — `symbol_name`, `symbol_type`, `language` on every chunk. Enables code-search filtering.
|
|
21
|
+
- **Incremental re-mining** — content-hash based. Only changed files are re-chunked. `--full` flag forces rebuild.
|
|
22
|
+
- **Batch embedding with upsert** — deduplicates on write, idempotent re-mines. Batched writes reduce LanceDB overhead on large projects.
|
|
23
|
+
|
|
24
|
+
### MCP tools (18 tools)
|
|
25
|
+
|
|
26
|
+
- **`mempalace_code_search`** — filter by language, symbol name/type, file glob. Returns symbol metadata.
|
|
27
|
+
- **`mempalace_add_drawer`** — now writes `chunker_strategy: "manual_v1"` provenance for backup/restore filtering.
|
|
28
|
+
- **`mempalace_delete_wing`** — delete all drawers in a wing.
|
|
29
|
+
- AAAK dialect tool removed from default MCP exposure (code preserved, dormant).
|
|
30
|
+
|
|
31
|
+
### Export / Import
|
|
32
|
+
|
|
33
|
+
- **`mempalace export`** — JSONL dump with `--only-manual` filter (preserves drawers the miner can't regenerate).
|
|
34
|
+
- **`mempalace import`** — restore from JSONL with dedup, dry-run, wing override.
|
|
35
|
+
- Streaming via `iter_all()` — no full-table memory load.
|
|
36
|
+
|
|
37
|
+
### CLI
|
|
38
|
+
|
|
39
|
+
- **`mempalace init`** — downloads embedding model (~80 MB) explicitly during setup.
|
|
40
|
+
- **`mempalace fetch-model`** — pre-download the model for offline use.
|
|
41
|
+
- **`mempalace mine --full`** — force full rebuild instead of incremental.
|
|
42
|
+
- **`mempalace export / import`** — backup and restore commands.
|
|
43
|
+
- **`mempalace diary write / read`** — agent session journals.
|
|
44
|
+
|
|
45
|
+
### Knowledge graph
|
|
46
|
+
|
|
47
|
+
- Temporal entity-relationship triples in local SQLite.
|
|
48
|
+
- `kg_add`, `kg_query`, `kg_invalidate`, `kg_timeline`, `kg_stats` — all via MCP.
|
|
49
|
+
|
|
50
|
+
### Quality
|
|
51
|
+
|
|
52
|
+
- **419 tests** across 15 test files. Every feature acceptance-gated.
|
|
53
|
+
- Schema migration regression tests (multi-write, NULL safety, partial migration).
|
|
54
|
+
- Storage edge-case tests ($in operator, empty IDs, comparison operators).
|
|
55
|
+
- Export/import round-trip tests with dedup verification.
|
|
56
|
+
|
|
57
|
+
### Docs
|
|
58
|
+
|
|
59
|
+
- `docs/AGENT_INSTALL.md` — decision-tree runbook for agent-driven installation.
|
|
60
|
+
- `docs/UPSTREAM_HARDENING.md` — full audit of upstream claims vs fork status.
|
|
61
|
+
- `docs/BACKUP_RESTORE.md` — backup workflow for manual drawers.
|
|
62
|
+
- `docs/OFFLINE_USAGE.md` — offline operation guide.
|
|
63
|
+
- `docs/STORAGE.md` — automatic schema migration documentation.
|
|
64
|
+
- `benchmarks/BENCHMARKS.md` — methodology caveats for upstream benchmark numbers.
|
|
65
|
+
|
|
66
|
+
### Upstream issues addressed
|
|
67
|
+
|
|
68
|
+
- [#469](https://github.com/milla-jovovich/mempalace/issues/469) — ChromaDB version-cliff data deletion → LanceDB, no version-cliff risk.
|
|
69
|
+
- [#524](https://github.com/milla-jovovich/mempalace/issues/524) — Silent ONNX model download → explicit `mempalace init` + `fetch-model`.
|
|
70
|
+
- [#27](https://github.com/milla-jovovich/mempalace/issues/27) — Unverifiable 100% R@5 claim → removed. AAAK "lossless" claim → labeled lossy.
|
|
71
|
+
|
|
72
|
+
### License
|
|
73
|
+
|
|
74
|
+
Changed from MIT to Apache 2.0 for trademark protection and attribution requirements.
|
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
# mempalace — Project Guide for Claude Code
|
|
2
|
+
|
|
3
|
+
## Stack
|
|
4
|
+
|
|
5
|
+
- **Python** 3.9+ (supports 3.9–3.12)
|
|
6
|
+
- **Storage**: LanceDB (core, crash-safe vector DB — no server required)
|
|
7
|
+
- **Embeddings**: sentence-transformers (local, no API key)
|
|
8
|
+
- **Config**: PyYAML
|
|
9
|
+
- **Linting / formatting**: Ruff
|
|
10
|
+
- **Tests**: pytest
|
|
11
|
+
- **Package manager**: uv (preferred) or pip
|
|
12
|
+
|
|
13
|
+
## Dev Setup
|
|
14
|
+
|
|
15
|
+
```bash
|
|
16
|
+
# With uv (preferred)
|
|
17
|
+
uv pip install -e ".[dev]"
|
|
18
|
+
|
|
19
|
+
# With pip
|
|
20
|
+
pip install -e ".[dev]"
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
No Docker required. Everything runs locally in a venv or with pipx.
|
|
24
|
+
|
|
25
|
+
Optional extras:
|
|
26
|
+
- `.[chroma]` — ChromaDB legacy backend (deprecated; use LanceDB)
|
|
27
|
+
- `.[spellcheck]` — autocorrect support for room/wing names
|
|
28
|
+
|
|
29
|
+
## Running Tests
|
|
30
|
+
|
|
31
|
+
**Important**: Use the Python from your mempalace virtualenv (pipx venv, `.venv`, etc.), not the system Python which may lack dev deps.
|
|
32
|
+
|
|
33
|
+
```bash
|
|
34
|
+
# Full suite (stop on first failure)
|
|
35
|
+
python -m pytest tests/ -x -q
|
|
36
|
+
|
|
37
|
+
# Per-module
|
|
38
|
+
python -m pytest tests/test_storage.py -v
|
|
39
|
+
python -m pytest tests/test_mcp_server.py -v
|
|
40
|
+
python -m pytest tests/test_miner.py -v
|
|
41
|
+
python -m pytest tests/test_convo_miner.py -v
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
## Linting / Formatting
|
|
45
|
+
|
|
46
|
+
```bash
|
|
47
|
+
# Check
|
|
48
|
+
ruff check mempalace/ tests/
|
|
49
|
+
|
|
50
|
+
# Format check
|
|
51
|
+
ruff format --check mempalace/ tests/
|
|
52
|
+
|
|
53
|
+
# Auto-fix lint
|
|
54
|
+
ruff check --fix mempalace/ tests/
|
|
55
|
+
|
|
56
|
+
# Auto-fix format
|
|
57
|
+
ruff format mempalace/ tests/
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
Line length: 100. Target: py39. Quote style: double.
|
|
61
|
+
|
|
62
|
+
## Key Modules
|
|
63
|
+
|
|
64
|
+
| Module | Purpose |
|
|
65
|
+
|--------|---------|
|
|
66
|
+
| `storage.py` | LanceDB vector storage — add, search, delete drawers |
|
|
67
|
+
| `miner.py` | Code project miner — walks source files, extracts drawers |
|
|
68
|
+
| `convo_miner.py` | Conversation miner — ingests Claude/ChatGPT/Slack exports |
|
|
69
|
+
| `searcher.py` | Semantic search — query palace with optional wing/room filters |
|
|
70
|
+
| `knowledge_graph.py` | Temporal KG — entity-relationship triples with validity windows |
|
|
71
|
+
| `layers.py` | Tiered context loading — L0/L1/L2/L3 wake-up layers for local models |
|
|
72
|
+
| `palace_graph.py` | Graph traversal and tunnel detection across wings/rooms |
|
|
73
|
+
| `mcp_server.py` | MCP server — exposes palace tools to Claude Code and other MCP clients |
|
|
74
|
+
| `cli.py` | `mempalace` CLI entry point — init, mine, search, wake-up |
|
|
75
|
+
|
|
76
|
+
## Architecture Principles
|
|
77
|
+
|
|
78
|
+
1. **Verbatim-first** — store content exactly as provided; do not summarize or compress drawers.
|
|
79
|
+
2. **Local-first** — no external APIs required; all embeddings run on-device via sentence-transformers.
|
|
80
|
+
3. **Zero-API-by-default** — LanceDB and sentence-transformers work offline; API integrations are opt-in.
|
|
81
|
+
|
|
82
|
+
## Storage Backend
|
|
83
|
+
|
|
84
|
+
- **LanceDB** is the core backend (installed by default via `lancedb>=0.17`).
|
|
85
|
+
- **ChromaDB** is a legacy optional backend: install with `.[chroma]`. It is deprecated and will be removed in a future major version.
|
|
86
|
+
|
|
87
|
+
## Embedding Model Policy
|
|
88
|
+
|
|
89
|
+
- **Current default**: `all-MiniLM-L6-v2` (384d, sentence-transformers).
|
|
90
|
+
- **No-regression rule**: any embedding model change must match or beat MiniLM on LongMemEval R@5 (text retrieval). Text quality is non-negotiable — this is a code-first fork but natural language search (conversations, commits, decisions) must not degrade.
|
|
91
|
+
- **No code-only models**: CodeBERT, UniXcoder, etc. improve code at the expense of prose. Only general-purpose sentence-transformers that handle both are candidates.
|
|
92
|
+
- **Gate**: model upgrades are gated behind A/B benchmark results.
|
|
93
|
+
|
|
94
|
+
### Benchmark Results — 2026-04-09 (BENCH-EMBED-AB)
|
|
95
|
+
|
|
96
|
+
Code retrieval on the mempalace repo (20 known-answer queries, 469 chunks):
|
|
97
|
+
|
|
98
|
+
| Model | R@5 | R@10 | Embed(s) | Query(ms) | Index(MB) |
|
|
99
|
+
|--------------------|-------|-------|----------|-----------|-----------|
|
|
100
|
+
| all-MiniLM-L6-v2 | 0.950 | 1.000 | 15.2 | 15.9 | 17.0 |
|
|
101
|
+
| all-mpnet-base-v2 | 0.900 | 1.000 | 47.5 | 30.5 | 17.7 |
|
|
102
|
+
| nomic-embed-text-v1.5 | 0.950 | 1.000 | 85.4 | 45.8 | 17.7 |
|
|
103
|
+
|
|
104
|
+
Per-category R@5:
|
|
105
|
+
|
|
106
|
+
| Model | architecture | class_lookup | cross_file | function_lookup |
|
|
107
|
+
|--------------------|:---:|:---:|:---:|:---:|
|
|
108
|
+
| all-MiniLM-L6-v2 | 0.800 | 1.000 | 1.000 | 1.000 |
|
|
109
|
+
| all-mpnet-base-v2 | 0.600 | 1.000 | 1.000 | 1.000 |
|
|
110
|
+
| nomic-embed-text-v1.5 | 1.000 | 1.000 | 1.000 | 0.833 |
|
|
111
|
+
|
|
112
|
+
**Recommendation: minilm remains default.**
|
|
113
|
+
|
|
114
|
+
- mpnet regresses on code R@5 (0.900 vs 0.950) while being 3× slower to embed and 2× slower at query. Eliminated.
|
|
115
|
+
- nomic ties minilm on code R@5 (0.950) but is 5.6× slower to embed and 2.9× slower at query, with a 550 MB model vs 80 MB. No net gain.
|
|
116
|
+
- Text-gate (LongMemEval) evidence was not collected — prerequisites missing (`benchmarks/data/longmemeval_s_cleaned.json` not present, `fastembed` not installed). Any future upgrade must pass the text gate before switching.
|
|
117
|
+
- Full results: `benchmarks/results_embed_ab_2026-04-09.json`.
|
|
118
|
+
|
|
119
|
+
## Git Workflow
|
|
120
|
+
|
|
121
|
+
- **Branch naming**: `feat/<slug>`, `fix/<slug>`, `chore/<slug>`, `docs/<slug>`
|
|
122
|
+
- **Conventional commits**:
|
|
123
|
+
- `feat:` — new feature or capability
|
|
124
|
+
- `fix:` — bug fix
|
|
125
|
+
- `docs:` — documentation only
|
|
126
|
+
- `test:` — test additions or changes
|
|
127
|
+
- `bench:` — benchmarks
|
|
128
|
+
- `chore:` — maintenance, deps, tooling
|
|
129
|
+
- **No force-push to `main`**.
|
|
130
|
+
- PR merges go through the `feat/*` → `main` flow; squash if the branch is noisy.
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
# Contributing to MemPalace
|
|
2
|
+
|
|
3
|
+
Thanks for wanting to help. MemPalace is open source and we welcome contributions of all sizes — from typo fixes to new features.
|
|
4
|
+
|
|
5
|
+
## Getting Started
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
git clone https://github.com/rergards/mempalace-code.git
|
|
9
|
+
cd mempalace
|
|
10
|
+
pip install -e ".[dev]" # installs with dev dependencies (pytest, build, twine)
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
## Running Tests
|
|
14
|
+
|
|
15
|
+
```bash
|
|
16
|
+
pytest tests/ -v
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
All tests must pass before submitting a PR. Tests should run without API keys or network access.
|
|
20
|
+
|
|
21
|
+
## Running Benchmarks
|
|
22
|
+
|
|
23
|
+
```bash
|
|
24
|
+
# Quick test (20 questions, ~30 seconds)
|
|
25
|
+
python benchmarks/longmemeval_bench.py /path/to/longmemeval_s_cleaned.json --limit 20
|
|
26
|
+
|
|
27
|
+
# Full benchmark (500 questions, ~5 minutes)
|
|
28
|
+
python benchmarks/longmemeval_bench.py /path/to/longmemeval_s_cleaned.json
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
See [benchmarks/README.md](benchmarks/README.md) for data download instructions and reproduction guide.
|
|
32
|
+
|
|
33
|
+
## Project Structure
|
|
34
|
+
|
|
35
|
+
```
|
|
36
|
+
mempalace/ ← core package (see mempalace/README.md for module guide)
|
|
37
|
+
benchmarks/ ← reproducible benchmark runners
|
|
38
|
+
hooks/ ← Claude Code auto-save hooks
|
|
39
|
+
examples/ ← usage examples
|
|
40
|
+
tests/ ← test suite
|
|
41
|
+
assets/ ← logo + brand
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
## PR Guidelines
|
|
45
|
+
|
|
46
|
+
1. Fork the repo and create a feature branch: `git checkout -b feat/my-thing`
|
|
47
|
+
2. Write your code
|
|
48
|
+
3. Add or update tests if applicable
|
|
49
|
+
4. Run `pytest tests/ -v` — everything must pass
|
|
50
|
+
5. Commit with a clear message following [conventional commits](https://www.conventionalcommits.org/):
|
|
51
|
+
- `feat: add Notion export format`
|
|
52
|
+
- `fix: handle empty transcript files`
|
|
53
|
+
- `docs: update MCP tool descriptions`
|
|
54
|
+
- `bench: add LoCoMo turn-level metrics`
|
|
55
|
+
6. Push to your fork and open a PR against `main`
|
|
56
|
+
|
|
57
|
+
## Code Style
|
|
58
|
+
|
|
59
|
+
- **Formatting**: [Ruff](https://docs.astral.sh/ruff/) with 100-char line limit (configured in `pyproject.toml`)
|
|
60
|
+
- **Naming**: `snake_case` for functions/variables, `PascalCase` for classes
|
|
61
|
+
- **Docstrings**: on all modules and public functions
|
|
62
|
+
- **Type hints**: where they improve readability
|
|
63
|
+
- **Dependencies**: minimize. Core: `lancedb>=0.17` + `sentence-transformers`. ChromaDB is a legacy optional extra (`.[chroma]`). Don't add new deps without discussion.
|
|
64
|
+
|
|
65
|
+
## Good First Issues
|
|
66
|
+
|
|
67
|
+
Check the [Issues](https://github.com/rergards/mempalace-code/issues) tab. Great starting points:
|
|
68
|
+
|
|
69
|
+
- **New chat formats**: Add import support for Cursor, Copilot, or other AI tool exports
|
|
70
|
+
- **Room detection**: Improve pattern matching in `room_detector_local.py`
|
|
71
|
+
- **Tests**: Increase coverage — especially for `knowledge_graph.py` and `palace_graph.py`
|
|
72
|
+
- **Entity detection**: Better name disambiguation in `entity_detector.py`
|
|
73
|
+
- **Docs**: Improve examples, add tutorials
|
|
74
|
+
|
|
75
|
+
## Architecture Decisions
|
|
76
|
+
|
|
77
|
+
If you're planning a significant change, open an issue first to discuss the approach. Key principles:
|
|
78
|
+
|
|
79
|
+
- **Verbatim first**: Never summarize user content. Store exact words.
|
|
80
|
+
- **Local first**: Everything runs on the user's machine. No cloud dependencies.
|
|
81
|
+
- **Zero API by default**: Core features must work without any API key.
|
|
82
|
+
- **Palace structure matters**: Wings, halls, and rooms aren't cosmetic — they drive a 34% retrieval improvement. Respect the hierarchy.
|
|
83
|
+
|
|
84
|
+
## Community
|
|
85
|
+
|
|
86
|
+
- **Discord**: [Join us](https://discord.com/invite/ycTQQCu6kn)
|
|
87
|
+
- **Issues**: Bug reports and feature requests welcome
|
|
88
|
+
- **Discussions**: For questions and ideas
|
|
89
|
+
|
|
90
|
+
## License
|
|
91
|
+
|
|
92
|
+
MIT — your contributions will be released under the same license.
|
|
@@ -0,0 +1,192 @@
|
|
|
1
|
+
|
|
2
|
+
Apache License
|
|
3
|
+
Version 2.0, January 2004
|
|
4
|
+
http://www.apache.org/licenses/
|
|
5
|
+
|
|
6
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
7
|
+
|
|
8
|
+
1. Definitions.
|
|
9
|
+
|
|
10
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
11
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
12
|
+
|
|
13
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
14
|
+
the copyright owner that is granting the License.
|
|
15
|
+
|
|
16
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
17
|
+
other entities that control, are controlled by, or are under common
|
|
18
|
+
control with that entity. For the purposes of this definition,
|
|
19
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
20
|
+
direction or management of such entity, whether by contract or
|
|
21
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
22
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
23
|
+
|
|
24
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
25
|
+
exercising permissions granted by this License.
|
|
26
|
+
|
|
27
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
28
|
+
including but not limited to software source code, documentation
|
|
29
|
+
source, and configuration files.
|
|
30
|
+
|
|
31
|
+
"Object" form shall mean any form resulting from mechanical
|
|
32
|
+
transformation or translation of a Source form, including but
|
|
33
|
+
not limited to compiled object code, generated documentation,
|
|
34
|
+
and conversions to other media types.
|
|
35
|
+
|
|
36
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
37
|
+
Object form, made available under the License, as indicated by a
|
|
38
|
+
copyright notice that is included in or attached to the work
|
|
39
|
+
(an example is provided in the Appendix below).
|
|
40
|
+
|
|
41
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
42
|
+
form, that is based on (or derived from) the Work and for which the
|
|
43
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
44
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
45
|
+
of this License, Derivative Works shall not include works that remain
|
|
46
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
47
|
+
the Work and Derivative Works thereof.
|
|
48
|
+
|
|
49
|
+
"Contribution" shall mean any work of authorship, including
|
|
50
|
+
the original version of the Work and any modifications or additions
|
|
51
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
52
|
+
submitted to the Licensor for inclusion in the Work by the copyright owner
|
|
53
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
54
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
55
|
+
means any form of electronic, verbal, or written communication sent
|
|
56
|
+
to the Licensor or its representatives, including but not limited to
|
|
57
|
+
communication on electronic mailing lists, source code control systems,
|
|
58
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
59
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
60
|
+
excluding communication that is conspicuously marked or otherwise
|
|
61
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
62
|
+
|
|
63
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
64
|
+
on behalf of whom a Contribution has been received by the Licensor and
|
|
65
|
+
subsequently incorporated within the Work.
|
|
66
|
+
|
|
67
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
68
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
69
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
70
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
71
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
72
|
+
Work and such Derivative Works in Source or Object form.
|
|
73
|
+
|
|
74
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
75
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
76
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
77
|
+
(except as stated in this section) patent license to make, have made,
|
|
78
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
79
|
+
where such license applies only to those patent claims licensable
|
|
80
|
+
by such Contributor that are necessarily infringed by their
|
|
81
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
82
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
83
|
+
institute patent litigation against any entity (including a
|
|
84
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
85
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
86
|
+
or contributory patent infringement, then any patent licenses
|
|
87
|
+
granted to You under this License for that Work shall terminate
|
|
88
|
+
as of the date such litigation is filed.
|
|
89
|
+
|
|
90
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
91
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
92
|
+
modifications, and in Source or Object form, provided that You
|
|
93
|
+
meet the following conditions:
|
|
94
|
+
|
|
95
|
+
(a) You must give any other recipients of the Work or
|
|
96
|
+
Derivative Works a copy of this License; and
|
|
97
|
+
|
|
98
|
+
(b) You must cause any modified files to carry prominent notices
|
|
99
|
+
stating that You changed the files; and
|
|
100
|
+
|
|
101
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
102
|
+
that You distribute, all copyright, patent, trademark, and
|
|
103
|
+
attribution notices from the Source form of the Work,
|
|
104
|
+
excluding those notices that do not pertain to any part of
|
|
105
|
+
the Derivative Works; and
|
|
106
|
+
|
|
107
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
108
|
+
distribution, then any Derivative Works that You distribute must
|
|
109
|
+
include a readable copy of the attribution notices contained
|
|
110
|
+
within such NOTICE file, excluding any notices that do not
|
|
111
|
+
pertain to any part of the Derivative Works, in at least one
|
|
112
|
+
of the following places: within a NOTICE text file distributed
|
|
113
|
+
as part of the Derivative Works; within the Source form or
|
|
114
|
+
documentation, if provided along with the Derivative Works; or,
|
|
115
|
+
within a display generated by the Derivative Works, if and
|
|
116
|
+
wherever such third-party notices normally appear. The contents
|
|
117
|
+
of the NOTICE file are for informational purposes only and
|
|
118
|
+
do not modify the License. You may add Your own attribution
|
|
119
|
+
notices within Derivative Works that You distribute, alongside
|
|
120
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
121
|
+
that such additional attribution notices cannot be construed
|
|
122
|
+
as modifying the License.
|
|
123
|
+
|
|
124
|
+
You may add Your own copyright statement to Your modifications and
|
|
125
|
+
may provide additional or different license terms and conditions
|
|
126
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
127
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
128
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
129
|
+
the conditions stated in this License.
|
|
130
|
+
|
|
131
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
132
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
133
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
134
|
+
this License, without any additional terms or conditions.
|
|
135
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
136
|
+
the terms of any separate license agreement you may have executed
|
|
137
|
+
with Licensor regarding such Contributions.
|
|
138
|
+
|
|
139
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
140
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
141
|
+
except as required for reasonable and customary use in describing the
|
|
142
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
143
|
+
|
|
144
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
145
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
146
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
147
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
148
|
+
implied, including, without limitation, any warranties or conditions
|
|
149
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
150
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
151
|
+
appropriateness of using or redistributing the Work and assume any
|
|
152
|
+
risks associated with Your exercise of permissions under this License.
|
|
153
|
+
|
|
154
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
155
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
156
|
+
unless required by applicable law (such as deliberate and grossly
|
|
157
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
158
|
+
liable to You for damages, including any direct, indirect, special,
|
|
159
|
+
incidental, or consequential damages of any character arising as a
|
|
160
|
+
result of this License or out of the use or inability to use the
|
|
161
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
162
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
163
|
+
other commercial damages or losses), even if such Contributor
|
|
164
|
+
has been advised of the possibility of such damages.
|
|
165
|
+
|
|
166
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
167
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
168
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
169
|
+
or other liability obligations and/or rights consistent with this
|
|
170
|
+
License. However, in accepting such obligations, You may act only
|
|
171
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
172
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
173
|
+
defend, and hold each Contributor harmless for any liability
|
|
174
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
175
|
+
of your accepting any such warranty or additional liability.
|
|
176
|
+
|
|
177
|
+
END OF TERMS AND CONDITIONS
|
|
178
|
+
|
|
179
|
+
Copyright 2025 milla-jovovich/mempalace contributors
|
|
180
|
+
Copyright 2026 Aleksandr Markov
|
|
181
|
+
|
|
182
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
183
|
+
you may not use this file except in compliance with the License.
|
|
184
|
+
You may obtain a copy of the License at
|
|
185
|
+
|
|
186
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
187
|
+
|
|
188
|
+
Unless required by applicable law or agreed to in writing, software
|
|
189
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
190
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
191
|
+
See the License for the specific language governing permissions and
|
|
192
|
+
limitations under the License.
|