mindforge-memory 6.4.1__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.
Files changed (136) hide show
  1. mindforge_memory-6.4.1/LICENSE +21 -0
  2. mindforge_memory-6.4.1/MindForge.py +20 -0
  3. mindforge_memory-6.4.1/PKG-INFO +281 -0
  4. mindforge_memory-6.4.1/README.md +251 -0
  5. mindforge_memory-6.4.1/mindforge/__init__.py +111 -0
  6. mindforge_memory-6.4.1/mindforge/adapters/__init__.py +18 -0
  7. mindforge_memory-6.4.1/mindforge/adapters/claude_adapter.py +84 -0
  8. mindforge_memory-6.4.1/mindforge/adapters/crewai_memory.py +76 -0
  9. mindforge_memory-6.4.1/mindforge/adapters/generic_api.py +183 -0
  10. mindforge_memory-6.4.1/mindforge/adapters/langgraph_store.py +463 -0
  11. mindforge_memory-6.4.1/mindforge/adapters/openclaw_adapter.py +91 -0
  12. mindforge_memory-6.4.1/mindforge/api/__init__.py +1 -0
  13. mindforge_memory-6.4.1/mindforge/api/server.py +1567 -0
  14. mindforge_memory-6.4.1/mindforge/cli/__init__.py +1 -0
  15. mindforge_memory-6.4.1/mindforge/cli/main.py +13607 -0
  16. mindforge_memory-6.4.1/mindforge/core/__init__.py +37 -0
  17. mindforge_memory-6.4.1/mindforge/core/embedding.py +847 -0
  18. mindforge_memory-6.4.1/mindforge/core/encryption.py +597 -0
  19. mindforge_memory-6.4.1/mindforge/core/indexer.py +363 -0
  20. mindforge_memory-6.4.1/mindforge/core/mindforge.py +6298 -0
  21. mindforge_memory-6.4.1/mindforge/core/paths.py +43 -0
  22. mindforge_memory-6.4.1/mindforge/core/query.py +501 -0
  23. mindforge_memory-6.4.1/mindforge/core/storage.py +18656 -0
  24. mindforge_memory-6.4.1/mindforge/core/types.py +314 -0
  25. mindforge_memory-6.4.1/mindforge/core/version.py +56 -0
  26. mindforge_memory-6.4.1/mindforge/daemon/__init__.py +0 -0
  27. mindforge_memory-6.4.1/mindforge/daemon/server.py +277 -0
  28. mindforge_memory-6.4.1/mindforge/mcp/__init__.py +4 -0
  29. mindforge_memory-6.4.1/mindforge/mcp/server.py +2559 -0
  30. mindforge_memory-6.4.1/mindforge/modules/__init__.py +138 -0
  31. mindforge_memory-6.4.1/mindforge/modules/categorizer.py +151 -0
  32. mindforge_memory-6.4.1/mindforge/modules/conflict_detector.py +356 -0
  33. mindforge_memory-6.4.1/mindforge/modules/connectors.py +331 -0
  34. mindforge_memory-6.4.1/mindforge/modules/context_window.py +337 -0
  35. mindforge_memory-6.4.1/mindforge/modules/event_bus.py +572 -0
  36. mindforge_memory-6.4.1/mindforge/modules/evolution.py +210 -0
  37. mindforge_memory-6.4.1/mindforge/modules/experience.py +402 -0
  38. mindforge_memory-6.4.1/mindforge/modules/federated.py +722 -0
  39. mindforge_memory-6.4.1/mindforge/modules/federated_acl.py +393 -0
  40. mindforge_memory-6.4.1/mindforge/modules/follow_up.py +315 -0
  41. mindforge_memory-6.4.1/mindforge/modules/hybrid_search.py +565 -0
  42. mindforge_memory-6.4.1/mindforge/modules/importer.py +374 -0
  43. mindforge_memory-6.4.1/mindforge/modules/integrator.py +196 -0
  44. mindforge_memory-6.4.1/mindforge/modules/intent_router.py +359 -0
  45. mindforge_memory-6.4.1/mindforge/modules/knowledge_graph.py +395 -0
  46. mindforge_memory-6.4.1/mindforge/modules/memory_compressor.py +592 -0
  47. mindforge_memory-6.4.1/mindforge/modules/memory_decay.py +474 -0
  48. mindforge_memory-6.4.1/mindforge/modules/memory_passport.py +250 -0
  49. mindforge_memory-6.4.1/mindforge/modules/multi_agent.py +534 -0
  50. mindforge_memory-6.4.1/mindforge/modules/multimodal.py +304 -0
  51. mindforge_memory-6.4.1/mindforge/modules/outcome_learning.py +186 -0
  52. mindforge_memory-6.4.1/mindforge/modules/personality.py +275 -0
  53. mindforge_memory-6.4.1/mindforge/modules/principled_forgetting.py +258 -0
  54. mindforge_memory-6.4.1/mindforge/modules/privacy.py +736 -0
  55. mindforge_memory-6.4.1/mindforge/modules/recall.py +263 -0
  56. mindforge_memory-6.4.1/mindforge/modules/session_focus.py +305 -0
  57. mindforge_memory-6.4.1/mindforge/modules/share_conflict.py +521 -0
  58. mindforge_memory-6.4.1/mindforge/modules/skill_extractor.py +340 -0
  59. mindforge_memory-6.4.1/mindforge/modules/skill_pack.py +205 -0
  60. mindforge_memory-6.4.1/mindforge/modules/timeline_viz.py +206 -0
  61. mindforge_memory-6.4.1/mindforge/modules/v6.py +931 -0
  62. mindforge_memory-6.4.1/mindforge_memory.egg-info/PKG-INFO +281 -0
  63. mindforge_memory-6.4.1/mindforge_memory.egg-info/SOURCES.txt +134 -0
  64. mindforge_memory-6.4.1/mindforge_memory.egg-info/dependency_links.txt +1 -0
  65. mindforge_memory-6.4.1/mindforge_memory.egg-info/entry_points.txt +3 -0
  66. mindforge_memory-6.4.1/mindforge_memory.egg-info/requires.txt +8 -0
  67. mindforge_memory-6.4.1/mindforge_memory.egg-info/top_level.txt +2 -0
  68. mindforge_memory-6.4.1/pyproject.toml +58 -0
  69. mindforge_memory-6.4.1/setup.cfg +4 -0
  70. mindforge_memory-6.4.1/setup.py +10 -0
  71. mindforge_memory-6.4.1/tests/test_core.py +1696 -0
  72. mindforge_memory-6.4.1/tests/test_security_hardening.py +205 -0
  73. mindforge_memory-6.4.1/tests/test_v546_features.py +221 -0
  74. mindforge_memory-6.4.1/tests/test_v547_fixes.py +242 -0
  75. mindforge_memory-6.4.1/tests/test_v548_features.py +291 -0
  76. mindforge_memory-6.4.1/tests/test_v550_features.py +453 -0
  77. mindforge_memory-6.4.1/tests/test_v552_features.py +328 -0
  78. mindforge_memory-6.4.1/tests/test_v554_features.py +391 -0
  79. mindforge_memory-6.4.1/tests/test_v556_features.py +851 -0
  80. mindforge_memory-6.4.1/tests/test_v557_banner_insight_wal.py +162 -0
  81. mindforge_memory-6.4.1/tests/test_v557_security_fixes.py +339 -0
  82. mindforge_memory-6.4.1/tests/test_v557_webhook_sig_export.py +173 -0
  83. mindforge_memory-6.4.1/tests/test_v558_audit_fixes.py +165 -0
  84. mindforge_memory-6.4.1/tests/test_v558_features.py +356 -0
  85. mindforge_memory-6.4.1/tests/test_v560_decay_gc.py +473 -0
  86. mindforge_memory-6.4.1/tests/test_v560_kdf_versioning.py +406 -0
  87. mindforge_memory-6.4.1/tests/test_v560_module_coverage.py +624 -0
  88. mindforge_memory-6.4.1/tests/test_v561_security.py +271 -0
  89. mindforge_memory-6.4.1/tests/test_v562_p2_fixes.py +361 -0
  90. mindforge_memory-6.4.1/tests/test_v563_entry_coverage.py +459 -0
  91. mindforge_memory-6.4.1/tests/test_v563_perf_fixes.py +345 -0
  92. mindforge_memory-6.4.1/tests/test_v565_security.py +517 -0
  93. mindforge_memory-6.4.1/tests/test_v566_encrypted_search.py +215 -0
  94. mindforge_memory-6.4.1/tests/test_v567_security_fixes.py +218 -0
  95. mindforge_memory-6.4.1/tests/test_v568_fixes.py +545 -0
  96. mindforge_memory-6.4.1/tests/test_v569_fts_sync.py +123 -0
  97. mindforge_memory-6.4.1/tests/test_v570_coverage_expansion.py +537 -0
  98. mindforge_memory-6.4.1/tests/test_v570_drama_and_utils.py +549 -0
  99. mindforge_memory-6.4.1/tests/test_v570_encrypted_fallback.py +192 -0
  100. mindforge_memory-6.4.1/tests/test_v571_fixes.py +148 -0
  101. mindforge_memory-6.4.1/tests/test_v572_security.py +82 -0
  102. mindforge_memory-6.4.1/tests/test_v573_encrypted_export.py +239 -0
  103. mindforge_memory-6.4.1/tests/test_v573_security.py +355 -0
  104. mindforge_memory-6.4.1/tests/test_v575_release_consistency.py +208 -0
  105. mindforge_memory-6.4.1/tests/test_v576_bitemporal.py +402 -0
  106. mindforge_memory-6.4.1/tests/test_v576_gdpr.py +176 -0
  107. mindforge_memory-6.4.1/tests/test_v577_agent_governance.py +433 -0
  108. mindforge_memory-6.4.1/tests/test_v578_embedding.py +228 -0
  109. mindforge_memory-6.4.1/tests/test_v579_graph.py +324 -0
  110. mindforge_memory-6.4.1/tests/test_v580_experience.py +308 -0
  111. mindforge_memory-6.4.1/tests/test_v5812_bugfixes.py +241 -0
  112. mindforge_memory-6.4.1/tests/test_v583_security.py +257 -0
  113. mindforge_memory-6.4.1/tests/test_v584_adapters.py +161 -0
  114. mindforge_memory-6.4.1/tests/test_v585_benchmark.py +62 -0
  115. mindforge_memory-6.4.1/tests/test_v586_federated_mcp.py +92 -0
  116. mindforge_memory-6.4.1/tests/test_v590_features.py +225 -0
  117. mindforge_memory-6.4.1/tests/test_v592_features.py +288 -0
  118. mindforge_memory-6.4.1/tests/test_v593_features.py +246 -0
  119. mindforge_memory-6.4.1/tests/test_v595_features.py +85 -0
  120. mindforge_memory-6.4.1/tests/test_v600_forgetting_followup.py +111 -0
  121. mindforge_memory-6.4.1/tests/test_v600_import_timeline.py +157 -0
  122. mindforge_memory-6.4.1/tests/test_v600_multi_agent_formal.py +197 -0
  123. mindforge_memory-6.4.1/tests/test_v600_outcome_passport.py +136 -0
  124. mindforge_memory-6.4.1/tests/test_v600_skillpack_evolution.py +129 -0
  125. mindforge_memory-6.4.1/tests/test_v611_fixes.py +357 -0
  126. mindforge_memory-6.4.1/tests/test_v612_cascade_fixes.py +288 -0
  127. mindforge_memory-6.4.1/tests/test_v612_fixes.py +687 -0
  128. mindforge_memory-6.4.1/tests/test_v613_integrity.py +241 -0
  129. mindforge_memory-6.4.1/tests/test_v620_growth_governance.py +165 -0
  130. mindforge_memory-6.4.1/tests/test_v630_search_explain.py +130 -0
  131. mindforge_memory-6.4.1/tests/test_v631_scrypt.py +395 -0
  132. mindforge_memory-6.4.1/tests/test_v632_explain_interfaces.py +181 -0
  133. mindforge_memory-6.4.1/tests/test_v635_features.py +304 -0
  134. mindforge_memory-6.4.1/tests/test_v635_integration.py +188 -0
  135. mindforge_memory-6.4.1/tests/test_v636_fixes.py +200 -0
  136. mindforge_memory-6.4.1/tests/test_v6_ports.py +307 -0
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 MindForge
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,20 @@
1
+ # -*- coding: utf-8 -*-
2
+ """
3
+ MindForge - AI Agent 终身记忆系统
4
+ =======================================
5
+ 四层记忆架构 · 知识图谱引擎 · 多模态支持 · 人格化记忆 · 联邦网络 · AI短剧记忆
6
+
7
+ 兼容入口(自 v5.8.13 起):全部源码已迁入 `mindforge.*` 命名空间,
8
+ 本文件仅为向后兼容保留,使 `from MindForge import MindForge` 在 pip install
9
+ 后仍然可用。新代码请统一使用 `from mindforge import MindForge`。
10
+ """
11
+
12
+ from mindforge import * # noqa: F401,F403
13
+ from mindforge import ( # noqa: F401
14
+ __version__,
15
+ VERSION_INFO,
16
+ NEXT_MAJOR_TARGET,
17
+ )
18
+
19
+ __author__ = "MindForge Project"
20
+ __license__ = "MIT"
@@ -0,0 +1,281 @@
1
+ Metadata-Version: 2.4
2
+ Name: mindforge-memory
3
+ Version: 6.4.1
4
+ Summary: AI Agent 终身记忆系统 - 四层记忆架构 · 知识图谱 · 多模态支持
5
+ License: MIT
6
+ Project-URL: Homepage, https://github.com/opok-ops/MindForge
7
+ Project-URL: Documentation, https://opok-ops.github.io/MindForge/
8
+ Project-URL: Bug Reports, https://github.com/opok-ops/MindForge/issues
9
+ Project-URL: Source, https://github.com/opok-ops/MindForge
10
+ Keywords: ai,agent,memory,knowledge-graph,llm
11
+ Classifier: Development Status :: 4 - Beta
12
+ Classifier: Intended Audience :: Developers
13
+ Classifier: License :: OSI Approved :: MIT License
14
+ Classifier: Programming Language :: Python :: 3
15
+ Classifier: Programming Language :: Python :: 3.10
16
+ Classifier: Programming Language :: Python :: 3.11
17
+ Classifier: Programming Language :: Python :: 3.12
18
+ Classifier: Programming Language :: Python :: 3.13
19
+ Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
20
+ Requires-Python: >=3.10
21
+ Description-Content-Type: text/markdown
22
+ License-File: LICENSE
23
+ Requires-Dist: cryptography<52,>=50.0.2
24
+ Provides-Extra: dev
25
+ Requires-Dist: pytest; extra == "dev"
26
+ Requires-Dist: pytest-cov; extra == "dev"
27
+ Provides-Extra: embedding
28
+ Requires-Dist: sentence-transformers>=2.7.0; extra == "embedding"
29
+ Dynamic: license-file
30
+
31
+ # MindForge
32
+
33
+ **A local-first, production-grade memory system for AI agents.**
34
+
35
+ > **Maintainer** — **Gu Fengyu (顾冯雨)**, born 2008-01-10 · GitHub: [opok-ops](https://github.com/opok-ops) · 抖音: [shidianduo3116](https://www.douyin.com/user/shidianduo3116) · 小红书: [4406811524](https://xhslink.cn/o/3m71WBRPD17) · Feedback: [2638895480@qq.com](mailto:2638895480@qq.com)
36
+
37
+ MindForge gives AI agents a persistent, structured long-term memory: a four-tier lifecycle model, knowledge graphs, hybrid retrieval, end-to-end encryption, and MCP / CLI / REST interfaces. All data stays on your machine.
38
+
39
+ > **The story** — one developer, seven months, from v1.0 (March 2026) to v6.4.1: no team, no funding, 1,220 passing tests. [Read the journey →](https://opok-ops.github.io/MindForge/#developer)
40
+
41
+ [![Python 3.10+](https://img.shields.io/badge/python-3.10+-blue.svg)](https://www.python.org/downloads/)
42
+ [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](LICENSE)
43
+ [![Version](https://img.shields.io/badge/version-6.4.1-green.svg)](https://github.com/opok-ops/MindForge/releases)
44
+ [![Stars](https://img.shields.io/github/stars/opok-ops/MindForge.svg)](https://github.com/opok-ops/MindForge/stargazers)
45
+ [![Forks](https://img.shields.io/github/forks/opok-ops/MindForge.svg)](https://github.com/opok-ops/MindForge/forks)
46
+ [![Open Issues](https://img.shields.io/github/issues/opok-ops/MindForge.svg)](https://github.com/opok-ops/MindForge/issues)
47
+ [![Last Commit](https://img.shields.io/github/last-commit/opok-ops/MindForge.svg)](https://github.com/opok-ops/MindForge/commits/master)
48
+ [![CI](https://github.com/opok-ops/MindForge/actions/workflows/ci.yml/badge.svg)](https://github.com/opok-ops/MindForge/actions/workflows/ci.yml)
49
+ [![Documentation](https://img.shields.io/badge/docs-pages-blue.svg)](https://opok-ops.github.io/MindForge/)
50
+
51
+ [English](README.md) · [中文文档](README.zh-CN.md) · [Live Demo](https://opok-ops.github.io/MindForge/) · [Documentation](docs/) · [Discussions](https://github.com/opok-ops/MindForge/discussions)
52
+
53
+ ---
54
+
55
+ ## Overview
56
+
57
+ Agent memory solutions that rely on cloud backends introduce latency, cost, and privacy trade-offs. MindForge takes the opposite approach: memory is computed and stored locally, encrypted at rest, and exposed through standard interfaces your existing agents already speak.
58
+
59
+ Key design decisions:
60
+
61
+ - **Local-first.** No cloud dependency. Storage runs on SQLite + FTS5 with WAL, a single file that moves with you.
62
+ - **Structured memory.** Four tiers (sensory, short-term, long-term, permanent) with promotion and decay driven by the Ebbinghaus forgetting curve.
63
+ - **Retrieval quality.** Six complementary retrieval paths fused into one ranked result, instead of a single vector index.
64
+ - **Encryption by default.** AES-256-GCM at rest with PBKDF2 key derivation; encrypted backups you can export and trust.
65
+ - **Open interfaces.** MCP server (87 tools), Python SDK, CLI with shell completion, and a REST API for non-Python consumers.
66
+
67
+ ## Quick Start
68
+
69
+ Install from source, then start writing and reading memories in minutes:
70
+
71
+ ```bash
72
+ git clone https://github.com/opok-ops/MindForge.git
73
+ cd MindForge
74
+ pip install -e . # zero ML deps: 3-path retrieval (TF-IDF + FTS5 + fuzzy)
75
+ pip install -e ".[embedding]" # + vector path → full 6-way hybrid search
76
+ ```
77
+
78
+ > Without the `embedding` extra, MindForge runs in zero-dependency mode — fully functional, but paraphrased queries may go unrecalled (no semantic path). With it, a small sentence-transformers model downloads on first vector search.
79
+
80
+ ```python
81
+ from mindforge import MindForge
82
+
83
+ m = MindForge(db_path="./data/memory.db", encrypted=False)
84
+ m.add("User prefers type-hinted Python code", category="preferences", importance="HIGH")
85
+ result = m.search("coding preferences")
86
+ print(result.chunks[0].content)
87
+ ```
88
+
89
+ CLI:
90
+
91
+ ```bash
92
+ MindForge add "User likes cats" --category preferences --importance HIGH
93
+ MindForge search "what does user like"
94
+ MindForge stats
95
+ ```
96
+
97
+ ## What's New
98
+
99
+ v6.1.3 – v6.4.1 shipped in nine days (2026-11-01 → 11-09), guarded by **1,224 tests** (1219+4 passed, 1 skipped).
100
+
101
+ - **v6.4.1 — million-character millisecond search** (2026-11-09). Scale benchmark (8,000 memories / ~990k chars) exposed a fuzzy-fallback long tail: search p95 881ms. Root causes: SequenceMatcher wasted on mathematically-impossible matches (ratio = 2M/(m+n), M ≤ m, so n ≥ 4m can never pass 0.4) + a ~50μs/entry Python full-scan tax. Fixed with a math-capped prune + SQLite-level candidate pre-filtering: **search p95 881→30.7ms (28×)**, add p50 2.6ms flat at 10k-scale. New `scripts/bench_scale.py` + CI scale guard (3000 memories, millisecond contract) + 4 behavior-level regression tests pin the semantics.
102
+
103
+ - **v6.4.0 — resident daemon & performance guards** (2026-11-08). New `mindforge daemon` subcommand: line-JSON over stdio, engine resident in a long-lived process — per-request p50 2.5ms vs 400–700ms for CLI subprocess spawning (two orders of magnitude; 2026-11-09 quiet-machine re-bench: 2.5ms vs 401ms p50, ~160×). CI now guards latency (engine in-process thresholds) and daemon 13-step E2E alongside the 16-step CLI E2E guard.
104
+ - **v6.3.6 — E2E-verified fixes** (2026-11-07). Found by real-bridge E2E testing of dsh-mindforge v3.0: compression TF-IDF index was never hydrated on real stores (`compress` always reported 0 clusters — now hydrated from storage), four v6.3.5 commands ignored `--json` (fixed), `adaptive_search` leaked `session_id` into privacy access control (INTERNAL memories always rejected — permanently empty results, now separated), and `key_file=""` misdetected as encryption. Tests 1210 → 1219.
105
+ - **v6.3.5 — Memory compression & adaptive context** (2026-11-07). Two new capabilities: MemoryCompressor clusters near-duplicate memories (TF-IDF cosine), replaces them with a searchable summary, and restores originals on `decompress` — compressed sources stop appearing in every retrieval path; STRICT memories never participate. AdaptiveContextEngine tracks per-session query patterns and dynamically adjusts the relevance threshold (exploration mode lowers it, focus mode raises it, always bounded). Facade methods + four new CLI commands (`compress`, `compress-list`, `decompress`, `adaptive-search`). Also fixes a P0-class integration issue in the draft compression write path (raw SQL bypassing FTS/embedding/audit — including a plaintext-into-encrypted-store flaw) and a ZeroDivisionError in keyword search.
106
+ - **v6.3.2 — Explain everywhere** (2026-11-06). Retrieval explainability, previously CLI/Python-only, is now aligned across all three interfaces: MCP `memory_search` gains an `explain` parameter and REST `/api/search` accepts `?explain=1` — per-result score breakdowns (per-path scores, winner, fusion details) everywhere, zero overhead and byte-identical responses when not requested.
107
+ - **v6.3.1 — Encryption upgrade: scrypt KDF** (2026-11-06). The default key-derivation function moves from PBKDF2 to scrypt (N=2^16, r=8, p=1 — a 64 MiB memory wall): GPU/ASIC rigs can no longer parallelize offline brute-force; per-derivation cost ~0.3 s. New key files and encrypted exports use scrypt; every historical key file (PBKDF2 600k / 60k / legacy) still decrypts unchanged, and `rekey` migrates an existing store in one step. Also fixes a P0: facade `rekey()` had been broken since v5.8.13 (dead import path), and bumps cryptography to ≥50.0.2.
108
+ - **v6.3.0 — Retrieval explainability** (`search --explain`). Hybrid search used to be a black box: you saw the ranking, not the reasoning. Every result can now carry its full score breakdown — per-path scores (TF-IDF / FTS5 / fuzzy / vector), the winning path, and text+vector fusion weights when both hit. Debug why a memory ranked first — or why another was never recalled at all. Zero overhead when disabled.
109
+ - **v6.2.0 — Growth governance & reproducible benchmarks.** Audit logs get a brake: search-audit debouncing (one row per unique query per 60 s, compliance events never sampled or pruned), `audit-prune` for trimming, and a 7th doctor check that flags runaway growth. Also ships `benchmarks/repro_benchmark.py` — the methodology that killed the "encrypted writes are faster" benchmark artifact: same-N alternating rounds, P50/P95 latency over 50 samples per query type, 8-thread concurrency runs, orphan-repair verification.
110
+ - **v6.1.3 — Self-healing data integrity.** GDPR erasure now removes derived data too — embeddings, notes, review schedules, evolution history, and graph relations (five tables previously survived "the right to be forgotten"). `doctor` gained orphan detection with one-command repair (`--fix`): dangling graph references, orphaned versions, and stray embeddings left behind by older cascade deletes are found and cleaned, with `dry_run` for impact assessment.
111
+ - **v6.1.1 — Follow-up closed loop.** Memories don't just wait to be queried — they nudge. Follow-up items can now trigger proactive reminders when their time comes (87 MCP tools total).
112
+
113
+ ## Features
114
+
115
+ **v6.0.0 — multi-agent spaces & 6G preview (2026-10-31)**
116
+
117
+ - **Multi-agent memory spaces** — shared spaces with three-tier roles (owner / editor / reader), last-write-wins conflict resolution, and PRIVATE / STRICT privacy guardrails. Promoted from experimental to a supported capability; available through the `multi_agent` facade, CLI `space-*`, MCP `space_*`, and the v6 port registry (status `AVAILABLE`).
118
+ - **6G AI memory preview** — four capabilities on the preview port, each replacing a former stub: parallel Preview Channels (isolated SQLite stores that never touch the stable database), context distillation (`distill_context` ranks memories HIGH / MEDIUM / LOW under a token budget), incremental index statistics (write-time indexing with near-real-time recall metrics), and per-memory timelines (versions, evolutions, and audit trail). Available through CLI `preview-*`, REST `/api/preview/*`, and MCP `preview_*`.
119
+ - **Agent workflow toolkit** — eight features covering the full memory lifecycle: chat-history import for cold start, timeline visualization, shareable skill packs, memory evolution, outcome-based learning, memory passports for cross-model migration, explainable principled forgetting, and follow-up tracking. Each is exposed consistently across CLI, REST, and MCP.
120
+ - **v6 port registry** — `v6_status()` reports capability readiness; `v6_port(capability)` injects a ready-to-use instance (multi-agent adapter or memory preview), so callers can depend on ports instead of concrete modules.
121
+
122
+ **Retrieval**
123
+
124
+ - **Six-way hybrid search** — vector, FTS5, TF-IDF, fuzzy, query expansion, and cross-encoder reranking fused into a single ranked result set.
125
+ - **Knowledge graph** — automatic entity and relation extraction, path finding, and associative recall.
126
+ - **Weighted recall** — multi-factor scoring (coverage, importance, access frequency, time decay) instead of similarity alone.
127
+
128
+ **Memory lifecycle**
129
+
130
+ - **Four-tier memory** — sensory buffer, short-term, long-term, and permanent tiers with Ebbinghaus-based decay and periodic consolidation.
131
+ - **Conflict detection** — antonym pairs, attribute inconsistencies, and timeline conflicts, with automatic decay.
132
+ - **Procedural memory (Cases → Skills)** — `record_experience()` stores agent success cases, `distill_skills()` turns them into reusable skill templates (persisted, restart-safe), `skill_match()`/`skill_render()` reuse them on new tasks with parameterized steps (v5.8.0).
133
+ - **Knowledge-graph pipeline** — `auto_extract_graph` hooks into `add()`; `extract_graph()` draws entities/relations into a persisted graph (survives restarts), `graph_related`/`graph_path` query it, STRICT-privacy memories are never extracted (v5.7.9).
134
+ - **Reproducible embedding eval** — `benchmarks/embedding_eval.py` compares hybrid / vector / FTS5 / TF-IDF on a fixed multilingual set with fixed seeds (Recall@5 / MRR@10 / NDCG@10); deterministic `fake` backend runs without any model for CI baselines (v5.7.8).
135
+ - **Agent memory governance** — `agent_pin` freezes decay and pins key memories, `agent_forget` soft-deletes with a reason, `agent_decay_boost` accelerates forgetting, and `expire_memory` closes a fact's validity window (v5.7.7).
136
+ - **Conflict auto-reconcile** — `reconcile_conflicts` closes the stale side of `keep_newer` / `keep_higher_importance` conflicts (Bi-temporal expiry, never deletes), and routes `merge` / `review_needed` to human review (v5.7.7).
137
+ - **Connector framework** — pluggable `json` / `csv` / `markdown` / `file` / `url` connectors with a registry and SSRF guard; extensible via `register_connector` (v5.7.7).
138
+ - **Bi-temporal facts** — `valid_from` / `valid_to` windows with as-of queries (`valid_at`) and `supersede` fact replacement that expires the old fact instead of deleting it, keeping full version history (v5.7.6).
139
+ - **Skill extraction** — clusters memories into reusable slots, steps, and trigger words.
140
+
141
+ **Privacy and security**
142
+
143
+ - **Privacy engine** — four isolation levels (PUBLIC / INTERNAL / PRIVATE / STRICT) with fine-grained access control.
144
+ - **At-rest encryption** — AES-256-GCM with PBKDF2-SHA256 key derivation.
145
+ - **Encrypted export / import** — `export-json --password` and `import-json --password` produce encrypted backups that remain unreadable even if the file leaks (v5.7.3).
146
+ - **GDPR toolkit** — `gdpr-report` / `gdpr-export-all` / `gdpr-erase` for data portability and the right to be forgotten, with automatic backup before erasure (v5.7.6).
147
+ - **Memory health report** — `memory_report()` aggregates four-tier counts, TTL expirations, trash, conflict events, FTS consistency, database health, and encryption status, without exposing any plaintext memory content (v5.9.0).
148
+ - **Audit export** — `export_audit()` returns machine-readable audit entries (limit / since / actor filters) for GDPR and forensics; exposed as `GET /api/audit` (v5.9.0).
149
+ - **Privacy health check** — `privacy_report()` aggregates privacy-tier distribution, STRICT count, trash, audit events, encryption / key-file state, and the federated sharing surface, without exposing any plaintext memory content (v5.9.2).
150
+ - **Knowledge-graph export** — `export_graph()` exports entities and relations as structured JSON (schema `mindforge-knowledge-graph/1.0`, memory IDs attached, no plaintext) for external visualization, audit, and migration (v5.9.2).
151
+ - **Privacy-filtered graph export** — `export_graph(max_privacy="INTERNAL")` drops edges sourced from STRICT/PRIVATE memories (fail-closed, isolated nodes pruned); CLI `--privacy` and REST `GET /api/meta/graph?max_privacy=` support the same filter (v5.9.3).
152
+ - **Unknown-privacy grouping** — `privacy_report()` buckets unknown/malformed privacy levels into `unknown_privacy_count` instead of leaking raw level names into the distribution (v5.9.3).
153
+
154
+ **Integration**
155
+
156
+ - **MCP server** — 87 tools, drop into Claude Code, OpenClaw, or any MCP client.
157
+ - **Federated memory** — P2P sharing between agents with trust levels, ACLs, and conflict resolution.
158
+ - **REST API** — standard HTTP endpoints for non-Python applications.
159
+ - **CLI** — 200+ commands with bash / zsh / fish completion.
160
+ - **Embedding backends** — sentence-transformers, OpenAI, Ollama, or a custom HTTP endpoint.
161
+
162
+ ## Architecture
163
+
164
+ ![MindForge Architecture](docs/architecture.png)
165
+
166
+ ```
167
+ ┌──────────────────────────────────────────────────────┐
168
+ │ MindForge v6.4.1 │
169
+ │ Cognitive Layer Personality · KnowledgeGraph │
170
+ │ MemoryEvolution · FederatedMemory │
171
+ ├──────────────────────────────────────────────────────┤
172
+ │ Function Layer RecallEngine · HybridSearch │
173
+ │ IntentRouter · ConflictDetector │
174
+ │ SkillExtractor · SessionFocus │
175
+ ├──────────────────────────────────────────────────────┤
176
+ │ Core Layer Storage (SQLite+FTS5) · Index │
177
+ │ Encryption (AES-256-GCM) · Query │
178
+ ├──────────────────────────────────────────────────────┤
179
+ │ Adapter Layer OpenClaw · Claude Code · MCP │
180
+ │ REST API · CLI · Python SDK │
181
+ └──────────────────────────────────────────────────────┘
182
+ ```
183
+
184
+ ### Four-Tier Memory Model
185
+
186
+ | Tier | Retention | Capacity | Purpose |
187
+ |------|-----------|----------|---------|
188
+ | Sensory | sec ~ min | ~50 | Input buffer, noise filtering |
189
+ | Short-term | hrs ~ days | ~100 | Working memory, active session |
190
+ | Long-term | wks ~ months | unlimited | Consolidated semantic memory |
191
+ | Permanent | forever | unlimited | Core knowledge, preferences, key experience |
192
+
193
+ High-value entries strengthen over time through consolidation; low-value entries decay naturally.
194
+
195
+ ## Performance
196
+
197
+ Benchmarked on i7-12700H / 32GB RAM / NVMe SSD / Python 3.12 / SQLite WAL.
198
+
199
+ | Operation | 1K | 10K | 100K |
200
+ |-----------|-----|------|------|
201
+ | Write (plaintext) | 0.3 ms | 0.5 ms | 0.9 ms |
202
+ | Write (encrypted) | 0.8 ms | 1.2 ms | 2.1 ms |
203
+ | TF-IDF Search P50 | 4 ms | 12 ms | 38 ms |
204
+ | FTS5 Search P50 | 0.4 ms | 0.9 ms | 3.2 ms |
205
+ | Cross-Encoder Rerank P50 | 5 ms | 15 ms | 45 ms |
206
+ | Consolidate (100 entries) | 45 ms | 120 ms | 580 ms |
207
+
208
+ Retrieval quality (500 multi-domain memories, 50 annotated queries):
209
+
210
+ | Metric | TF-IDF | +FTS5+Fuzzy | +Cross-Encoder | +Query Expansion + Vector |
211
+ |--------|--------|-------------|----------------|---------------------------|
212
+ | MRR@10 | 0.62 | 0.71 | **0.82** | **0.85** |
213
+ | NDCG@10 | 0.60 | 0.69 | **0.80** | **0.84** |
214
+ | Recall@10 | 0.70 | 0.80 | **0.88** | **0.92** |
215
+
216
+ ## Integration
217
+
218
+ **Claude Code**
219
+
220
+ ```python
221
+ from adapters import ClaudeCodeAdapter
222
+
223
+ adapter = ClaudeCodeAdapter.from_env()
224
+ adapter.remember("User prefers concise code style", ["preferences"])
225
+ context = adapter.get_context("database optimization")
226
+ ```
227
+
228
+ **MCP Server**
229
+
230
+ ```bash
231
+ MindForge-mcp --db-path ./data/memory.db
232
+ ```
233
+
234
+ **REST API**
235
+
236
+ ```bash
237
+ MindForge serve --api --port 9000
238
+ # GET /api/memories
239
+ # POST /api/memories
240
+ # GET /api/search?q=...
241
+ # GET /api/stats
242
+ ```
243
+
244
+ **OpenClaw**
245
+
246
+ ```yaml
247
+ memory:
248
+ adapter: MindForge
249
+ adapter_config:
250
+ db_path: ~/.MindForge/data/memory.db
251
+ encrypted: true
252
+ auto_consolidate: true
253
+ ```
254
+
255
+ ## Security
256
+
257
+ - **Encrypted databases**: when a key file is present, set `MINDFORGE_PASSWORD` so the process can unlock the store. This is required for the dsh-mindforge bridge and any non-interactive integration (MCP / REST API / scripts) accessing an encrypted store.
258
+ - **API authentication**: if `MINDFORGE_API_KEY` is configured, unauthenticated callers are treated as `anonymous` and can only reach PUBLIC memories. All read/write paths carry actor identity for authorization and audit.
259
+ - **Access logs are sanitized**: search terms and memory IDs are stripped from logs.
260
+ - **Upgrade note**: v5.5.7 removed the experimental HMAC-XOR downgrade path (config flag `EXPERIMENTAL_HMAC_XOR`, the 「降级加密」 experiment). Blobs created under that flag can no longer be decrypted — back up your database before upgrading if you enabled it.
261
+
262
+ See [SECURITY.md](SECURITY.md) for the full security policy.
263
+
264
+ ## Roadmap
265
+
266
+ - [x] **v6.0** — multi-agent memory spaces and the 6G AI memory preview, both promoted from experimental ports to supported capabilities, alongside an eight-feature agent workflow toolkit (released 2026-10-31)
267
+ - [x] **v6.1 – v6.3** — trust & quality: retrieval explainability (`search --explain`), data-integrity self-repair in `doctor`, GDPR-complete erasure, audit-log growth governance, reproducible benchmarks (released 2026-11-05)
268
+ - [ ] Vector database backend (Qdrant / Chroma)
269
+ - [ ] Web UI dashboard
270
+ - [ ] Plugin ecosystem
271
+
272
+ ## Documentation
273
+
274
+ - [Full documentation](docs/)
275
+ - [Changelog](CHANGELOG.md)
276
+ - [Contributing guide](CONTRIBUTING.md)
277
+ - [Security policy](SECURITY.md)
278
+
279
+ ## License
280
+
281
+ [MIT](LICENSE) — Copyright (c) 2026 MindForge Project. If MindForge is useful to you, consider starring it on GitHub — it helps the project stay active and visible.
@@ -0,0 +1,251 @@
1
+ # MindForge
2
+
3
+ **A local-first, production-grade memory system for AI agents.**
4
+
5
+ > **Maintainer** — **Gu Fengyu (顾冯雨)**, born 2008-01-10 · GitHub: [opok-ops](https://github.com/opok-ops) · 抖音: [shidianduo3116](https://www.douyin.com/user/shidianduo3116) · 小红书: [4406811524](https://xhslink.cn/o/3m71WBRPD17) · Feedback: [2638895480@qq.com](mailto:2638895480@qq.com)
6
+
7
+ MindForge gives AI agents a persistent, structured long-term memory: a four-tier lifecycle model, knowledge graphs, hybrid retrieval, end-to-end encryption, and MCP / CLI / REST interfaces. All data stays on your machine.
8
+
9
+ > **The story** — one developer, seven months, from v1.0 (March 2026) to v6.4.1: no team, no funding, 1,220 passing tests. [Read the journey →](https://opok-ops.github.io/MindForge/#developer)
10
+
11
+ [![Python 3.10+](https://img.shields.io/badge/python-3.10+-blue.svg)](https://www.python.org/downloads/)
12
+ [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](LICENSE)
13
+ [![Version](https://img.shields.io/badge/version-6.4.1-green.svg)](https://github.com/opok-ops/MindForge/releases)
14
+ [![Stars](https://img.shields.io/github/stars/opok-ops/MindForge.svg)](https://github.com/opok-ops/MindForge/stargazers)
15
+ [![Forks](https://img.shields.io/github/forks/opok-ops/MindForge.svg)](https://github.com/opok-ops/MindForge/forks)
16
+ [![Open Issues](https://img.shields.io/github/issues/opok-ops/MindForge.svg)](https://github.com/opok-ops/MindForge/issues)
17
+ [![Last Commit](https://img.shields.io/github/last-commit/opok-ops/MindForge.svg)](https://github.com/opok-ops/MindForge/commits/master)
18
+ [![CI](https://github.com/opok-ops/MindForge/actions/workflows/ci.yml/badge.svg)](https://github.com/opok-ops/MindForge/actions/workflows/ci.yml)
19
+ [![Documentation](https://img.shields.io/badge/docs-pages-blue.svg)](https://opok-ops.github.io/MindForge/)
20
+
21
+ [English](README.md) · [中文文档](README.zh-CN.md) · [Live Demo](https://opok-ops.github.io/MindForge/) · [Documentation](docs/) · [Discussions](https://github.com/opok-ops/MindForge/discussions)
22
+
23
+ ---
24
+
25
+ ## Overview
26
+
27
+ Agent memory solutions that rely on cloud backends introduce latency, cost, and privacy trade-offs. MindForge takes the opposite approach: memory is computed and stored locally, encrypted at rest, and exposed through standard interfaces your existing agents already speak.
28
+
29
+ Key design decisions:
30
+
31
+ - **Local-first.** No cloud dependency. Storage runs on SQLite + FTS5 with WAL, a single file that moves with you.
32
+ - **Structured memory.** Four tiers (sensory, short-term, long-term, permanent) with promotion and decay driven by the Ebbinghaus forgetting curve.
33
+ - **Retrieval quality.** Six complementary retrieval paths fused into one ranked result, instead of a single vector index.
34
+ - **Encryption by default.** AES-256-GCM at rest with PBKDF2 key derivation; encrypted backups you can export and trust.
35
+ - **Open interfaces.** MCP server (87 tools), Python SDK, CLI with shell completion, and a REST API for non-Python consumers.
36
+
37
+ ## Quick Start
38
+
39
+ Install from source, then start writing and reading memories in minutes:
40
+
41
+ ```bash
42
+ git clone https://github.com/opok-ops/MindForge.git
43
+ cd MindForge
44
+ pip install -e . # zero ML deps: 3-path retrieval (TF-IDF + FTS5 + fuzzy)
45
+ pip install -e ".[embedding]" # + vector path → full 6-way hybrid search
46
+ ```
47
+
48
+ > Without the `embedding` extra, MindForge runs in zero-dependency mode — fully functional, but paraphrased queries may go unrecalled (no semantic path). With it, a small sentence-transformers model downloads on first vector search.
49
+
50
+ ```python
51
+ from mindforge import MindForge
52
+
53
+ m = MindForge(db_path="./data/memory.db", encrypted=False)
54
+ m.add("User prefers type-hinted Python code", category="preferences", importance="HIGH")
55
+ result = m.search("coding preferences")
56
+ print(result.chunks[0].content)
57
+ ```
58
+
59
+ CLI:
60
+
61
+ ```bash
62
+ MindForge add "User likes cats" --category preferences --importance HIGH
63
+ MindForge search "what does user like"
64
+ MindForge stats
65
+ ```
66
+
67
+ ## What's New
68
+
69
+ v6.1.3 – v6.4.1 shipped in nine days (2026-11-01 → 11-09), guarded by **1,224 tests** (1219+4 passed, 1 skipped).
70
+
71
+ - **v6.4.1 — million-character millisecond search** (2026-11-09). Scale benchmark (8,000 memories / ~990k chars) exposed a fuzzy-fallback long tail: search p95 881ms. Root causes: SequenceMatcher wasted on mathematically-impossible matches (ratio = 2M/(m+n), M ≤ m, so n ≥ 4m can never pass 0.4) + a ~50μs/entry Python full-scan tax. Fixed with a math-capped prune + SQLite-level candidate pre-filtering: **search p95 881→30.7ms (28×)**, add p50 2.6ms flat at 10k-scale. New `scripts/bench_scale.py` + CI scale guard (3000 memories, millisecond contract) + 4 behavior-level regression tests pin the semantics.
72
+
73
+ - **v6.4.0 — resident daemon & performance guards** (2026-11-08). New `mindforge daemon` subcommand: line-JSON over stdio, engine resident in a long-lived process — per-request p50 2.5ms vs 400–700ms for CLI subprocess spawning (two orders of magnitude; 2026-11-09 quiet-machine re-bench: 2.5ms vs 401ms p50, ~160×). CI now guards latency (engine in-process thresholds) and daemon 13-step E2E alongside the 16-step CLI E2E guard.
74
+ - **v6.3.6 — E2E-verified fixes** (2026-11-07). Found by real-bridge E2E testing of dsh-mindforge v3.0: compression TF-IDF index was never hydrated on real stores (`compress` always reported 0 clusters — now hydrated from storage), four v6.3.5 commands ignored `--json` (fixed), `adaptive_search` leaked `session_id` into privacy access control (INTERNAL memories always rejected — permanently empty results, now separated), and `key_file=""` misdetected as encryption. Tests 1210 → 1219.
75
+ - **v6.3.5 — Memory compression & adaptive context** (2026-11-07). Two new capabilities: MemoryCompressor clusters near-duplicate memories (TF-IDF cosine), replaces them with a searchable summary, and restores originals on `decompress` — compressed sources stop appearing in every retrieval path; STRICT memories never participate. AdaptiveContextEngine tracks per-session query patterns and dynamically adjusts the relevance threshold (exploration mode lowers it, focus mode raises it, always bounded). Facade methods + four new CLI commands (`compress`, `compress-list`, `decompress`, `adaptive-search`). Also fixes a P0-class integration issue in the draft compression write path (raw SQL bypassing FTS/embedding/audit — including a plaintext-into-encrypted-store flaw) and a ZeroDivisionError in keyword search.
76
+ - **v6.3.2 — Explain everywhere** (2026-11-06). Retrieval explainability, previously CLI/Python-only, is now aligned across all three interfaces: MCP `memory_search` gains an `explain` parameter and REST `/api/search` accepts `?explain=1` — per-result score breakdowns (per-path scores, winner, fusion details) everywhere, zero overhead and byte-identical responses when not requested.
77
+ - **v6.3.1 — Encryption upgrade: scrypt KDF** (2026-11-06). The default key-derivation function moves from PBKDF2 to scrypt (N=2^16, r=8, p=1 — a 64 MiB memory wall): GPU/ASIC rigs can no longer parallelize offline brute-force; per-derivation cost ~0.3 s. New key files and encrypted exports use scrypt; every historical key file (PBKDF2 600k / 60k / legacy) still decrypts unchanged, and `rekey` migrates an existing store in one step. Also fixes a P0: facade `rekey()` had been broken since v5.8.13 (dead import path), and bumps cryptography to ≥50.0.2.
78
+ - **v6.3.0 — Retrieval explainability** (`search --explain`). Hybrid search used to be a black box: you saw the ranking, not the reasoning. Every result can now carry its full score breakdown — per-path scores (TF-IDF / FTS5 / fuzzy / vector), the winning path, and text+vector fusion weights when both hit. Debug why a memory ranked first — or why another was never recalled at all. Zero overhead when disabled.
79
+ - **v6.2.0 — Growth governance & reproducible benchmarks.** Audit logs get a brake: search-audit debouncing (one row per unique query per 60 s, compliance events never sampled or pruned), `audit-prune` for trimming, and a 7th doctor check that flags runaway growth. Also ships `benchmarks/repro_benchmark.py` — the methodology that killed the "encrypted writes are faster" benchmark artifact: same-N alternating rounds, P50/P95 latency over 50 samples per query type, 8-thread concurrency runs, orphan-repair verification.
80
+ - **v6.1.3 — Self-healing data integrity.** GDPR erasure now removes derived data too — embeddings, notes, review schedules, evolution history, and graph relations (five tables previously survived "the right to be forgotten"). `doctor` gained orphan detection with one-command repair (`--fix`): dangling graph references, orphaned versions, and stray embeddings left behind by older cascade deletes are found and cleaned, with `dry_run` for impact assessment.
81
+ - **v6.1.1 — Follow-up closed loop.** Memories don't just wait to be queried — they nudge. Follow-up items can now trigger proactive reminders when their time comes (87 MCP tools total).
82
+
83
+ ## Features
84
+
85
+ **v6.0.0 — multi-agent spaces & 6G preview (2026-10-31)**
86
+
87
+ - **Multi-agent memory spaces** — shared spaces with three-tier roles (owner / editor / reader), last-write-wins conflict resolution, and PRIVATE / STRICT privacy guardrails. Promoted from experimental to a supported capability; available through the `multi_agent` facade, CLI `space-*`, MCP `space_*`, and the v6 port registry (status `AVAILABLE`).
88
+ - **6G AI memory preview** — four capabilities on the preview port, each replacing a former stub: parallel Preview Channels (isolated SQLite stores that never touch the stable database), context distillation (`distill_context` ranks memories HIGH / MEDIUM / LOW under a token budget), incremental index statistics (write-time indexing with near-real-time recall metrics), and per-memory timelines (versions, evolutions, and audit trail). Available through CLI `preview-*`, REST `/api/preview/*`, and MCP `preview_*`.
89
+ - **Agent workflow toolkit** — eight features covering the full memory lifecycle: chat-history import for cold start, timeline visualization, shareable skill packs, memory evolution, outcome-based learning, memory passports for cross-model migration, explainable principled forgetting, and follow-up tracking. Each is exposed consistently across CLI, REST, and MCP.
90
+ - **v6 port registry** — `v6_status()` reports capability readiness; `v6_port(capability)` injects a ready-to-use instance (multi-agent adapter or memory preview), so callers can depend on ports instead of concrete modules.
91
+
92
+ **Retrieval**
93
+
94
+ - **Six-way hybrid search** — vector, FTS5, TF-IDF, fuzzy, query expansion, and cross-encoder reranking fused into a single ranked result set.
95
+ - **Knowledge graph** — automatic entity and relation extraction, path finding, and associative recall.
96
+ - **Weighted recall** — multi-factor scoring (coverage, importance, access frequency, time decay) instead of similarity alone.
97
+
98
+ **Memory lifecycle**
99
+
100
+ - **Four-tier memory** — sensory buffer, short-term, long-term, and permanent tiers with Ebbinghaus-based decay and periodic consolidation.
101
+ - **Conflict detection** — antonym pairs, attribute inconsistencies, and timeline conflicts, with automatic decay.
102
+ - **Procedural memory (Cases → Skills)** — `record_experience()` stores agent success cases, `distill_skills()` turns them into reusable skill templates (persisted, restart-safe), `skill_match()`/`skill_render()` reuse them on new tasks with parameterized steps (v5.8.0).
103
+ - **Knowledge-graph pipeline** — `auto_extract_graph` hooks into `add()`; `extract_graph()` draws entities/relations into a persisted graph (survives restarts), `graph_related`/`graph_path` query it, STRICT-privacy memories are never extracted (v5.7.9).
104
+ - **Reproducible embedding eval** — `benchmarks/embedding_eval.py` compares hybrid / vector / FTS5 / TF-IDF on a fixed multilingual set with fixed seeds (Recall@5 / MRR@10 / NDCG@10); deterministic `fake` backend runs without any model for CI baselines (v5.7.8).
105
+ - **Agent memory governance** — `agent_pin` freezes decay and pins key memories, `agent_forget` soft-deletes with a reason, `agent_decay_boost` accelerates forgetting, and `expire_memory` closes a fact's validity window (v5.7.7).
106
+ - **Conflict auto-reconcile** — `reconcile_conflicts` closes the stale side of `keep_newer` / `keep_higher_importance` conflicts (Bi-temporal expiry, never deletes), and routes `merge` / `review_needed` to human review (v5.7.7).
107
+ - **Connector framework** — pluggable `json` / `csv` / `markdown` / `file` / `url` connectors with a registry and SSRF guard; extensible via `register_connector` (v5.7.7).
108
+ - **Bi-temporal facts** — `valid_from` / `valid_to` windows with as-of queries (`valid_at`) and `supersede` fact replacement that expires the old fact instead of deleting it, keeping full version history (v5.7.6).
109
+ - **Skill extraction** — clusters memories into reusable slots, steps, and trigger words.
110
+
111
+ **Privacy and security**
112
+
113
+ - **Privacy engine** — four isolation levels (PUBLIC / INTERNAL / PRIVATE / STRICT) with fine-grained access control.
114
+ - **At-rest encryption** — AES-256-GCM with PBKDF2-SHA256 key derivation.
115
+ - **Encrypted export / import** — `export-json --password` and `import-json --password` produce encrypted backups that remain unreadable even if the file leaks (v5.7.3).
116
+ - **GDPR toolkit** — `gdpr-report` / `gdpr-export-all` / `gdpr-erase` for data portability and the right to be forgotten, with automatic backup before erasure (v5.7.6).
117
+ - **Memory health report** — `memory_report()` aggregates four-tier counts, TTL expirations, trash, conflict events, FTS consistency, database health, and encryption status, without exposing any plaintext memory content (v5.9.0).
118
+ - **Audit export** — `export_audit()` returns machine-readable audit entries (limit / since / actor filters) for GDPR and forensics; exposed as `GET /api/audit` (v5.9.0).
119
+ - **Privacy health check** — `privacy_report()` aggregates privacy-tier distribution, STRICT count, trash, audit events, encryption / key-file state, and the federated sharing surface, without exposing any plaintext memory content (v5.9.2).
120
+ - **Knowledge-graph export** — `export_graph()` exports entities and relations as structured JSON (schema `mindforge-knowledge-graph/1.0`, memory IDs attached, no plaintext) for external visualization, audit, and migration (v5.9.2).
121
+ - **Privacy-filtered graph export** — `export_graph(max_privacy="INTERNAL")` drops edges sourced from STRICT/PRIVATE memories (fail-closed, isolated nodes pruned); CLI `--privacy` and REST `GET /api/meta/graph?max_privacy=` support the same filter (v5.9.3).
122
+ - **Unknown-privacy grouping** — `privacy_report()` buckets unknown/malformed privacy levels into `unknown_privacy_count` instead of leaking raw level names into the distribution (v5.9.3).
123
+
124
+ **Integration**
125
+
126
+ - **MCP server** — 87 tools, drop into Claude Code, OpenClaw, or any MCP client.
127
+ - **Federated memory** — P2P sharing between agents with trust levels, ACLs, and conflict resolution.
128
+ - **REST API** — standard HTTP endpoints for non-Python applications.
129
+ - **CLI** — 200+ commands with bash / zsh / fish completion.
130
+ - **Embedding backends** — sentence-transformers, OpenAI, Ollama, or a custom HTTP endpoint.
131
+
132
+ ## Architecture
133
+
134
+ ![MindForge Architecture](docs/architecture.png)
135
+
136
+ ```
137
+ ┌──────────────────────────────────────────────────────┐
138
+ │ MindForge v6.4.1 │
139
+ │ Cognitive Layer Personality · KnowledgeGraph │
140
+ │ MemoryEvolution · FederatedMemory │
141
+ ├──────────────────────────────────────────────────────┤
142
+ │ Function Layer RecallEngine · HybridSearch │
143
+ │ IntentRouter · ConflictDetector │
144
+ │ SkillExtractor · SessionFocus │
145
+ ├──────────────────────────────────────────────────────┤
146
+ │ Core Layer Storage (SQLite+FTS5) · Index │
147
+ │ Encryption (AES-256-GCM) · Query │
148
+ ├──────────────────────────────────────────────────────┤
149
+ │ Adapter Layer OpenClaw · Claude Code · MCP │
150
+ │ REST API · CLI · Python SDK │
151
+ └──────────────────────────────────────────────────────┘
152
+ ```
153
+
154
+ ### Four-Tier Memory Model
155
+
156
+ | Tier | Retention | Capacity | Purpose |
157
+ |------|-----------|----------|---------|
158
+ | Sensory | sec ~ min | ~50 | Input buffer, noise filtering |
159
+ | Short-term | hrs ~ days | ~100 | Working memory, active session |
160
+ | Long-term | wks ~ months | unlimited | Consolidated semantic memory |
161
+ | Permanent | forever | unlimited | Core knowledge, preferences, key experience |
162
+
163
+ High-value entries strengthen over time through consolidation; low-value entries decay naturally.
164
+
165
+ ## Performance
166
+
167
+ Benchmarked on i7-12700H / 32GB RAM / NVMe SSD / Python 3.12 / SQLite WAL.
168
+
169
+ | Operation | 1K | 10K | 100K |
170
+ |-----------|-----|------|------|
171
+ | Write (plaintext) | 0.3 ms | 0.5 ms | 0.9 ms |
172
+ | Write (encrypted) | 0.8 ms | 1.2 ms | 2.1 ms |
173
+ | TF-IDF Search P50 | 4 ms | 12 ms | 38 ms |
174
+ | FTS5 Search P50 | 0.4 ms | 0.9 ms | 3.2 ms |
175
+ | Cross-Encoder Rerank P50 | 5 ms | 15 ms | 45 ms |
176
+ | Consolidate (100 entries) | 45 ms | 120 ms | 580 ms |
177
+
178
+ Retrieval quality (500 multi-domain memories, 50 annotated queries):
179
+
180
+ | Metric | TF-IDF | +FTS5+Fuzzy | +Cross-Encoder | +Query Expansion + Vector |
181
+ |--------|--------|-------------|----------------|---------------------------|
182
+ | MRR@10 | 0.62 | 0.71 | **0.82** | **0.85** |
183
+ | NDCG@10 | 0.60 | 0.69 | **0.80** | **0.84** |
184
+ | Recall@10 | 0.70 | 0.80 | **0.88** | **0.92** |
185
+
186
+ ## Integration
187
+
188
+ **Claude Code**
189
+
190
+ ```python
191
+ from adapters import ClaudeCodeAdapter
192
+
193
+ adapter = ClaudeCodeAdapter.from_env()
194
+ adapter.remember("User prefers concise code style", ["preferences"])
195
+ context = adapter.get_context("database optimization")
196
+ ```
197
+
198
+ **MCP Server**
199
+
200
+ ```bash
201
+ MindForge-mcp --db-path ./data/memory.db
202
+ ```
203
+
204
+ **REST API**
205
+
206
+ ```bash
207
+ MindForge serve --api --port 9000
208
+ # GET /api/memories
209
+ # POST /api/memories
210
+ # GET /api/search?q=...
211
+ # GET /api/stats
212
+ ```
213
+
214
+ **OpenClaw**
215
+
216
+ ```yaml
217
+ memory:
218
+ adapter: MindForge
219
+ adapter_config:
220
+ db_path: ~/.MindForge/data/memory.db
221
+ encrypted: true
222
+ auto_consolidate: true
223
+ ```
224
+
225
+ ## Security
226
+
227
+ - **Encrypted databases**: when a key file is present, set `MINDFORGE_PASSWORD` so the process can unlock the store. This is required for the dsh-mindforge bridge and any non-interactive integration (MCP / REST API / scripts) accessing an encrypted store.
228
+ - **API authentication**: if `MINDFORGE_API_KEY` is configured, unauthenticated callers are treated as `anonymous` and can only reach PUBLIC memories. All read/write paths carry actor identity for authorization and audit.
229
+ - **Access logs are sanitized**: search terms and memory IDs are stripped from logs.
230
+ - **Upgrade note**: v5.5.7 removed the experimental HMAC-XOR downgrade path (config flag `EXPERIMENTAL_HMAC_XOR`, the 「降级加密」 experiment). Blobs created under that flag can no longer be decrypted — back up your database before upgrading if you enabled it.
231
+
232
+ See [SECURITY.md](SECURITY.md) for the full security policy.
233
+
234
+ ## Roadmap
235
+
236
+ - [x] **v6.0** — multi-agent memory spaces and the 6G AI memory preview, both promoted from experimental ports to supported capabilities, alongside an eight-feature agent workflow toolkit (released 2026-10-31)
237
+ - [x] **v6.1 – v6.3** — trust & quality: retrieval explainability (`search --explain`), data-integrity self-repair in `doctor`, GDPR-complete erasure, audit-log growth governance, reproducible benchmarks (released 2026-11-05)
238
+ - [ ] Vector database backend (Qdrant / Chroma)
239
+ - [ ] Web UI dashboard
240
+ - [ ] Plugin ecosystem
241
+
242
+ ## Documentation
243
+
244
+ - [Full documentation](docs/)
245
+ - [Changelog](CHANGELOG.md)
246
+ - [Contributing guide](CONTRIBUTING.md)
247
+ - [Security policy](SECURITY.md)
248
+
249
+ ## License
250
+
251
+ [MIT](LICENSE) — Copyright (c) 2026 MindForge Project. If MindForge is useful to you, consider starring it on GitHub — it helps the project stay active and visible.