All notable changes to MATHIR are documented here.
Format follows Keep a Changelog.
v1–v7.6 are historical — kept per project policy ("laisse les deprecated pour qu'ils comprennent que je reviens de loin"). Source code for these versions lives under
_deprecated/. Each version below is summarized in 1–3 lines; see the git history or the_deprecated/folder for the full original entries.
- Codex MCP stdio banner crash —
mathir_mcp/mathir_lib/mathir_mcp_server.py:1490:mcp.run()→mcp.run(show_banner=False). FastMCP 3.4.4 prints a large colored ASCII banner to stdout at startup; MCP-over-stdio uses stdout for JSON-RPC, so the banner corrupted the framing and Codex silently registered zero tools from this server. Full 3-layer failure walk-through inmathir_mcp/docs/troubleshooting/codex-mcp-tools-invisible-three-layers.md. See alsodocs/CODEX_INTEGRATION.mdfor the full Codex↔MATHIR setup guide (config + proxy + hook + autostart).
- Codex integration guide —
docs/CODEX_INTEGRATION.md: how to install, configure~/.codex/config.toml(MCP server +OPENAI_BASE_URLproxy +[shell_environment_policy.set]forwarding), wire the auto-inject hook, survive reboots via the scheduler tasks, and what to do whenmcp__mathir__*tools don't appear.
mathir_mcp package work — full detail in mathir_mcp/CHANGELOG.md.
- An autonomous background maintenance thread now runs memory decay/promotion/dedup/link-building on a timer, config-driven via
mathir.json's new"maintenance"block — previously this lifecycle logic existed but nothing ever triggered it automatically. - Headless, on-demand god-mode workers (
god_mode_start.py/god_mode_stop.py/god_worker_daemon.py) — an orchestrator can now launch a real coding-agent CLI in the background that polls, claims, executes, and reports on a task with no human watching its terminal, closing the gap where the existing notify-only bridge still needed a human to drive execution. - A deterministic (non-LLM) god-mode report tool (
god_mode_report.py) reads results straight from the SQLite DB, after a real incident where an orchestrator's own relay of worker results failed to reach the human. - Atomic task claiming and a new
/api/god/ackroute close a race/staleness bug in god-mode's task-polling protocol.
- A memory decay-eligibility bug that permanently excluded every never-recalled memory from ever decaying.
- Guardrail memories were silently getting reclassified away from the always-injected guardrail tier by the anomaly detector — guardrail saves are now exempt.
- The memory-link-graph similarity threshold was raised (0.7 → 0.88) after the lower value produced an almost-complete, unusable link graph against the real embedding model.
god_bridge.py's env vars renamedMYCERISE_STATE_DIR/MYCERISE_LOG_FILE→MATHIR_STATE_DIR/MATHIR_LOG_FILE(leftover naming from before MATHIR was extracted into its own standalone project — no functional behavior change, defaults still resolve under$XDG_CONFIG_HOME).
mathir_mcp package work — full detail in mathir_mcp/CHANGELOG.md.
- Windows daemon healthcheck watchdog required admin rights and so silently never installed on most machines — a daemon that died mid-session stayed dead until next logon. Now installed by default, no admin required.
- The Claude Code auto-injection hook (
claude_code_hook.py) existed but was never wired into anysettings.json, and had a wrong field name that made it a no-op even when invoked manually. Fixed and wired in automatically by the installer. - A daemon-side prompt-injection sanitizer was a no-op due to a
.strip()bug — confirmed live and exploitable, now fixed and unified with the proxy's (correct) implementation into one shared module. - The universal proxy's default OpenAI-route target had a double-
/v1bug that would 404 every real request.
mathir_proxy.pynow speaks Anthropic's native/v1/messages(previously OpenAI-compatible only) — the endpoint Claude Code itself calls.- Multi-upstream routing (
X-Mathir-Upstreamheader) lets one proxy process serve ~30 allowlisted providers (Anthropic, OpenAI, OpenRouter, Groq, Mistral, DeepSeek, Z.ai, MiniMax, Azure/Bedrock via suffix match, any local model server, ...) instead of one process per provider. mathir-proxy.service(systemd) /com.mathir.proxy.plist(launchd) so the proxy self-heals on Linux/macOS the same way the daemon does; Windows healthcheck now covers both.
mathir_mcp/brain/— a stale, unimported fork superseded bymathir_lib/.
- README + docs reframed away from head-to-head comparisons (Mem0/Zep/Letta/FAISS). The "vs Alternatives" table is replaced with an honest "Positioning (2026)" section acknowledging the current landscape (native memory in Claude/ChatGPT/Gemini, funded agent-memory ecosystem) and stating what MATHIR actually validates: self-maintaining tiered memory, cross-process/cross-provider local-first multi-agent sharing (God Mode).
docs/03_MASTER_QA_GUIDE.md§9/§10/§11 — "VectorDB | MATHIR" scorecards reworded to describe what each layer is for instead of claiming a win.docs/07_MATHIR_VS_VECTORDB_USE_CASES.md— retitled, framing note added; the autonomous-driving section (§4) collapsed into a<details>block, superseded by the new robotics doc.- Dropped inflated "doctoral-level" language across
docs/01_MASTER_RESEARCH_PAPER.md,docs/08_WHY_SAME_RESULTS.md,docs/07_MATHIR_VS_VECTORDB_USE_CASES.md,README.md— this is a master's research project, not a doctoral one. docs/OUTREACH.md— removed an unverifiable "no other memory system does this" claim.
docs/MATHIR_FOR_ROBOTICS.md— seed document for a planned separate MATHIR FOR ROBOTICS track/repo focused on autonomous-driving research (Isaac Sim simulation, then RC car). States the hypothesis (place-based episodic memory as a fallback signal when sensor-fusion confidence collapses), grounds it against the actual literature (sensor-dropout robustness: Grace-BEV/MetaBEV/UniBEV; place memory: Mobileye REM/Tesla fleet learning; LLM-in-the-loop latency: LLM4AD), and is explicit about what is/isn't validated yet.
- Cross-platform autostart hardcoded Python paths —
bin/auto_start.bat(Windows),bin/mathir-daemon.service(systemd),bin/com.mathir.daemon.plist(launchd), andinstall_smart.py's macOS path all previously hardcoded a specific Python interpreter path (Python311,/usr/bin/python3) that silently doesn't exist on Miniconda/Anaconda/Homebrew/pyenv setups. All four now resolve the interpreter dynamically viaPATHat start time. Full detail in mathir_mcp/CHANGELOG.md.
bin/god/god_bridge.py — cross-platform polling daemon for god-mode (worker / orchestrator / observer modes), stdlib-only. Plus god_poll.ps1/.sh one-shot pollers and PROTOCOL.md. Full detail in mathir_mcp/CHANGELOG.md.
Canonical tool count corrected: 26 → 27 — the audit_immunological tool was missing from the v8.9.0 count. All docs, templates, READMEs now consistently say 27 MCP tools (2 auto-injection + 10 basic + 7 lifecycle + 3 advanced + 1 guardrail + 1 immunological + 1 health + 2 god mode). Full detail in mathir_mcp/CHANGELOG.md.
6th memory tier: guardrail. Critical rules that are auto-injected into every context response — the LLM sees them without needing to recall. Push-based, not pull-based.
guardrailtier — 6th tier, always auto-injected into/api/context,memory_session_start, andmemory_contextresponses, before all other memories- Decay immunity — guardrail memories never decay or get archived
- Promotion immunity — guardrails are terminal (like immunological), cannot be promoted
- Priority floor — guardrails enforce minimum priority of 8
- Per-project limit — max 50 guardrails per project to prevent context inflation
memory_list_guardrailsMCP tool — list all active guardrails for the current project/api/memory/guardrailsdaemon route — GET/POST, list guardrails with priority orderinglist_guardrails()/count_guardrails()— VecMemory methods for guardrail queries
LLMs recall at session start but forget mid-task. They repeat mistakes they were corrected on minutes earlier. The guardrail tier solves this by making critical rules always visible — the LLM doesn't choose to see them, they are always there.
Cross-process multi-agent orchestration via MATHIR shared memory. Agents self-identify, orchestrator assigns tasks by strength. Two new MCP tools, two daemon routes, one new module.
mathir_god_agentMCP tool — workers self-identify (name, capabilities, strengths/weaknesses), register, and poll for tasks. No manual configuration needed.mathir_god_orchestreMCP tool — orchestrator discovers workers with full profiles, decomposes directives into tasks, assigns based on worker self-assessments.- Auto-identification flow —
mathir_god_agent()with no args prompts the agent to honestly self-assess. The orchestrator sees all profiles and assigns intelligently. GodProtocol— structured label encoding/decoding (god:{type}:{id}:{target}:{status})TaskGraph— DAG with dependency resolution, cycle detection (DFS), JSON serializationWorkerRegistry— in-memory worker tracking, capability-based lookup, daemon response hydrationWorktreeManager— git worktree lifecycle (create/merge/cleanup/list) for task isolation/api/god/polldaemon route — query pending tasks for a specific worker/api/god/agentsdaemon route — list registered workers with profiles and introductions- Built-in helpers —
mathir_god_agent(name="help")andmathir_god_orchestre(directive="help")return full usage guides
- LIKE wildcard injection prevention in
/api/god/poll(escapes%and_)
- 40 new tests (GodProtocol: 9, TaskGraph: 12, WorkerRegistry: 8, WorktreeManager: 6, DaemonRoutes: 2, Integration: 3)
mathir_mcp/mathir_lib/mathir_god.py— core module (~250 lines)mathir_mcp/tests/test_god.py— test suite (~300 lines)docs/GOD_MODE.md— full documentation
Bug fixes + 3 new MCP tools. Project-aware DB routing, VecMemory mkdir fix, FastMCP k-coerce, incoming_links daemon endpoint.
memory_by_path— Search memories referencing a specific file path (metadata.file_path OR content substring match)memory_recall_quality— Recall with explicit quality signal (high/medium/low/none) + suggestion textmemory_incoming_links— Reverse link graph: memories pointing TO a given memory_idblock_type="auto"inmemory_save— Heuristic auto-classification (how-to/cmd→procedural, TODO/WIP→working_memory, facts→semantic, default→episodic)
get_project_db_path()— Was returning first existing DB in registry instead of matching CWD. Fix: cwd-first, ancestor-match with longest prefix, fallback to most-recently-usedVecMemory._get_conn()— Missingmkdir(parents=True)beforesqlite3.connect. Fix: create.mathir/directory before first connect- FastMCP
mathir_recallprompt —k: intparameter causedValidationErrorwhen clients passed shell-interpolated strings like'$2'. Fix:k: str | intwith coercion - MiMoCode config —
MATHIR_PORTwas set to 7339 instead of 7338
- README.md shortened (~220 → ~90 lines) with documentation index table
- Docs v8.4.1/8.4.2 → v8.5.0 (AGENT.md, DAEMON.md, DIMENSIONS.md)
__main__.pyv8.4.0 → v8.5.0, tool count 17 → 23mathir_dashboard.htmlv8.4.2 → v8.5.0
Major rewrite. v8.5.0 replaces the hand-rolled JSON-RPC MCP server with FastMCP 3.4.2, adds auto-injection of memories into agent system prompts, and unifies the daemon/stats server into a single Flask+Waitress process.
- MCP server rewritten using FastMCP 3.4.2 (20 tools, stdio transport)
- Auto-injection plugin: memories injected into system prompt at session start + during session
memory_session_start+memory_contexttools for explicit session context/api/contextHTTP endpoint for plugin auto-injection- Unified server: single process, single port (7338), Flask + Waitress
- Direct DB access via mathir_vec.py — no HTTP daemon bridge for core operations
- Embedder pre-warmed at startup (25-30s first load, then cached)
- config_template.json: portable paths, no OpenCode hardcodes
- OpenRouter API key purged from git history
- Bun segfault fixed:
"runtime": {"backend": "node"}in opencode.json
- Input length caps: content 100KB, query 5KB, label 200B, agent 100B
- API key purged from all commits (git-filter-repo)
- 0 real keys found in codebase scan
Dev-loop release. v8.4.1 ships two new developer tools (mathir_inject.py, mathir_sync.py), 5 target-specific injection templates, and fixes the install/import path story so the package is reproducible from a clean clone.
mathir_inject.py— Multi-target dynamic injection of the MATHIR block into any.mdfile inagents/,commands/,skills/,skills-global/, ordocs/. Reads the right template from<target_dir>/_MATHIR_INJECT.md(falls back to root oragentstemplate). Idempotent via content-equivalent detection (_normalize()). Flags:--target {agents,commands,skills,skills-global,docs,all},--apply,--check,--file PATH,--list,--explain.mathir_sync.py— Safe source-to-config sync from<repo_root>/mathir_mcp/into~/.config/opencode/. SAFE BY DEFAULT — only copies NEW files, never overwrites existing without--update-existing. Syncsmathir_lib/*.py,brain/*.py,config/*.json,docs/*.md,GLOBAL_INSTRUCTIONS.md, install/scripts, and all 5_MATHIR_INJECT.mdtemplates. Flags:--dry-run,--only,--update-existing,--no-inject,--force,--explain. Auto-runsmathir_inject.py --applyafter a successful--apply.- 5 target templates in
mathir_mcp/opencode/<target>/_MATHIR_INJECT.md(one per target:agents=full,commands=short,skills=minimal,skills-global=minimal,docs=reference — 4 unique templates,skills-globalshares theskillstemplate). Editing the template propagates to all files of that target in one command. --explainmode on both scripts — self-documenting, no external README needed.- Slash commands:
/mathir_inject [check|apply] [target] [name]and/mathir_sync [check|apply] [filter].
| Severity | Issue | Fix |
|---|---|---|
| CRITICAL | Stale .pth file in mathir_lib/mathir_mcp.egg-info/ broke pip install -e . reproducibility |
Cleared egg-info, content re-pinned |
| CRITICAL | Namespace shadow: importing mathir_mcp.X resolved to the package, not the module |
Added mathir_mcp/__init__.py as package marker (exports __version__ + __all__; submodules are reached via mathir_mcp.mathir_lib.*, mathir_mcp.brain.*, mathir_mcp.mathir_dropin.*) |
| HIGH | pyproject.toml entry points pointed at flat paths |
Rewrote as mathir_mcp.mathir_lib.<tool>:main (nested) |
| HIGH | 9 self-referencing imports in __main__.py (from mathir_mcp import X → unbound) |
Rewrote all to from mathir_mcp.mathir_lib.X import Y |
| HIGH | MCP server config pointed at wrong path | Now: bin/mathir_mcp_server.py with PYTHONPATH=bin |
| MEDIUM | Hardcoded repo path in mathir_mcp_server.py:1190 (install-help message) |
Replaced with <repo_root> placeholder + auto-detect |
| MEDIUM | get_embedder() had no way to force ONNX |
Added MATHIR_USE_ONNX=1 env var support |
| LOW | Stale cross-refs in docs/AGENT.md (11) and docs/DASHBOARD_GUIDE.md (12) |
Updated to current paths |
- 173/173 tests pass (unchanged from v8.4.0)
- Swarm verified:
@coder,@refactor,@security,@debugger,@make,@check— all green - Database state: 2 active DBs, 100% embeddings, lifecycle active
- Mycerise project: 368 memories
- MATHIR root project: 137 memories
raspberry_jetson/bumped to v8.4.1 (all files synced)- Install flow:
install.ps1now callsmathir_inject.py --checkon completion
The breakthrough release. MATHIR is no longer a write-only memory disk. It now manages its own memory lifecycle through 5 cognitive phases inspired by hippocampal-cortical consolidation (CLS theory, McClelland, McNaughton & O'Reilly 1995) and Ebbinghaus forgetting curves.
touch_recall(memory_id)— incrementsrecall_count, stampslast_recalled_at, boosts stability (Ebbinghaus)promote(memory_id, force=False)— moves memory up the tier ladder via rules:working_memory→episodic:recall_count >= 3ANDage >= 1depisodic→semantic:recall_count >= 10ANDage >= 7dsemantic→procedural:priority >= 8AND label starts withhow-to:orrecipe:
auto_promote_all()— scans all memories, promotes eligible ones
boost_on_recall(memory_id)—stability += 0.1, capped at 1.0get_decay_candidates(threshold_days=30)— ordered list of stale memoriesdecay_all(threshold_days, archive_floor=0.05)— 5%/30d linear decay, archives whenstability < 0.05- Archived memories keep their
memory_id(soft delete, audit trail)
find_duplicates(threshold=0.95)— pairs with cosine > thresholdconsolidate_pair(id_strong, id_weak)— transactional merge with audit trail inmetadata.merged_from[]consolidate_all(threshold, dry_run=True)— orchestrator with dry-run support
- New table
memory_links(source_id, target_id, weight, created_at)+ indexes add_link(source, target, weight=1.0)— bidirectional graph edgesget_links(memory_id, depth=1, decay=0.5)— BFS with per-hop decay (Collins & Loftus 1975)build_links_all(threshold=0.7)— creates symmetric links for similar pairsfind_related(memory_id, max_hops=2)— vector + graph combined, tags source asvector/link/both
- 7 new MCP tools registered in
mathir_mcp_server.py:memory_promote,memory_auto_promote,memory_decay,memory_consolidatememory_link,memory_get_links,memory_build_links
- 7 new daemon RPC methods in
mathir_daemon.py memory_recallnow auto-callstouch_recall()on every result — stability grows on use- Handlers wired in
_METHOD_HANDLERSdispatch table
- New column
memories.last_recalled_at REAL DEFAULT 0(idempotentALTER TABLEmigration) - New table
memory_links(source_id, target_id, weight, created_at)withidx_links_source+idx_links_target - Both schema branches (new
content-column / legacymodality-BLOB) fully supported
- 26 new pytest tests in
mathir_mcp/dev/test_lifecycle.pyTestPromote(9 tests): force transitions, rule checks, auto-promote, touch_recallTestDecay(6 tests): boost, decay, archive, new-schema skipTestConsolidate(4 tests): find_duplicates, merge, dry-run, real-runTestLinkGraph(7 tests): add_link, get_links BFS with decay, build_links_all, find_related
- 173/173 tests pass (was 147)
docs/assets/logo.png(1024×1024) — neural core with 8 pathwaysdocs/assets/architecture.png(1600×900) — 5-layer system topologydocs/assets/PROMPTS.md— ready-to-paste prompts for AI image generators
mathir_mcp_server.py: Python boolean syntax (True/False, not JSONtrue/false)mathir_mcp_server.py: extra closing brace in TOOLS list (line 484)mathir_vec.py:stats()was querying non-existent columns — now usesjson_extract()on metadata
stats: 29 memories, by_tier={episodic:14, semantic:9, working:6}
promote: episodic → semantic (force=True)
recall: 3 results, touched=3
build_links: 246 links created from 29 memories
consolidate: 3 candidates at threshold 0.9 (dry_run)
- Bug fix:
memory_hybrid_searchreturned 0 results because it used a separate empty_hybrid.dbfile - Root cause: VecMemory was created in the daemon's main thread, then used in handler threads →
ProgrammingError: SQLite objects created in a thread can only be used in that same thread - Fix: Hybrid handler now creates its own SQLite connection with
check_same_thread=False, reads directly from the main vector DB - Schema auto-detection: Handler detects old schema (
modality_text) vs new schema (content) automatically - Performance: ~60ms per hybrid search (was timeout/unusable before)
- Bug fix: 3rd request always timed out (daemon hung after 2 successful requests)
- Root cause:
from mathir_mcp_server import get_embedder_diminside handler methods created a local variable that shadowed the global function →UnboundLocalErroronping→ crash inhandle_clientwhile-True loop - Fix: All
get_project_db_path,get_project_name,get_embeddermoved to top-level imports (line 50) - VecMemory: Added
check_same_thread=Falsetosqlite3.connect()for cross-thread access - Stress test: 50/50 requests (20 saves + 20 pings + 10 recalls), 0 errors
- paraphrase-multilingual-MiniLM-L12-v2 (384d) is now the confirmed production model
- All 4 MATHIR databases migrated from 1024d (bge-large-en-v1.5) to 384d
- 239MB VRAM fp16, 0.929 cosine FR↔EN, 50+ languages
mathir_daemon.py— Hybrid handler uses direct SQLite, global imports,_get_vec_memcachemathir_vec.py—check_same_thread=Falsefor cross-thread SQLite accessmathir_search.py— HybridSearch BM25 + RRF fusion (unchanged, was already correct)
- Proactive memory delivery — daemon pushes relevant memories without explicit recall requests
- Push modes:
--auto: Daemon analyzes context, returns text ready for system prompt injection--json: Returns structured{memories: [...]}with metadata- (default): Returns human-readable
[block/agent] label: contentformat
- Cache system — LRU cache with TTL (300s) prevents redundant embedding computations
- Use cases:
- Auto-inject relevant context before each LLM call
- Proactive memory suggestions during conversations
- Background context enrichment for long sessions
Client → push "context" → Daemon analyzes context → Extracts queries → Searches memory → Returns ranked memories
# Push (proactive memory delivery)
python ~/.config/opencode/mcp/mathir_lib/mathir_client.py push "contexte ici" --auto
python ~/.config/opencode/mcp/mathir_lib/mathir_client.py push "contexte ici" --json
python ~/.config/opencode/mcp/mathir_lib/mathir_client.py push "contexte ici"
# Cache stats (via daemon)
python ~/.config/opencode/mcp/mathir_lib/mathir_client.py push "" --json 2>&1 | head -1README.md— New Daemon Push section with architecture diagramGLOBAL_INSTRUCTIONS.md— Added push commands to MEMORY PROTOCOL and AGENT MEMORY BLOCKS sections
mathir_search.py— New unified vector search class replacingVectorSearch- Auto-scales: numpy brute-force (N < 5000) → USearch HNSW (N ≥ 5000)
- SQLite WAL metadata store always-on (thread-safe, crash-safe)
- USearch HNSW tuned for 1024d:
connectivity=32,expansion_add=256,expansion_search=128 - Auto-persists USearch index to disk (
mathir_indexes/), rebuilds on load - Thread-safe with
RLockon all mutating operations - Agent-filtered search with over-fetch + post-filter
store(),store_batch(),search(),delete(),count(),stats(),save(),close()
usearch— HNSW library with memory-mapped indexes for fast ANN search- Cosine metric, L2-normalized vectors
- Memory-mapped persistence — index survives process restarts
- Auto-builds from SQLite metadata on first load (crash-recovery)
save()persists tomathir_indexes/mathir_{dim}d.usearch
mathir_vec_optimized.py— High-performance sqlite-vec backend- WAL mode + single connection (no pool overhead for sequential access)
- LRU dict cache (512 entries, 120s TTL) for repeated queries
- PRAGMA tuning:
cache_size=-8000,temp_store=MEMORY,mmap_size=256MB store(),store_batch(),search(),delete(),get_all(),stats(),close()
- SciFact (5183 docs, 1109 queries):
| Backend | Latency | Recall@10 | nDCG@10 |
|---|---|---|---|
| Numpy | 0.83ms | 0.8592 | — |
| USearch | 5.33ms | 0.8526 | — |
| sqlite-vec | 37.95ms | 0.8592 | — |
- Numpy backend is fastest at MATHIR scale (< 5000 memories)
- USearch outperforms sqlite-vec for large-scale workloads
- Fixed stale USearch index persistence bug
- Fixed USearch HNSW recall with tuned params
| Severity | Issue | Fix |
|---|---|---|
| CRITICAL | RCE via torch.load |
weights_only=True enforced |
| HIGH | SQL injection in vec0 DDL | Validated dim as int > 0 |
| HIGH | assert-based validation |
Replaced with ValueError |
| MEDIUM | Path traversal on db_path/index_dir |
Path.resolve() canonicalization |
| MEDIUM | Path traversal on torch save/load | Path.resolve() + whitelist |
| MEDIUM | Race condition in USearch search | Lock moved around index access |
| MEDIUM | No thread safety in VecMemory | Added threading.Lock() |
| LOW | Partial locking in _MetadataStore |
Full RLock on all mutations |
| File | Before | After | Reduction |
|---|---|---|---|
mathir_search.py |
559 | 321 | -43% |
mathir_gpu_vec.py |
511 | 275 | -46% |
mathir_vec_optimized.py |
476 | 240 | -50% |
| Total | 1546 | 836 | -46% |
README.md— HybridSearch section, updated performance numbers, architecture diagram, vector search benchmarks03_MASTER_QA_GUIDE.md— Architecture diagram, BEIR benchmarks, deployment options, quick reference04_DEV_INTEGRATION_GUIDE.md— Full HybridSearch chapter with architecture, benchmarks, quick start, advanced usagestress_test/static/changelog.html— Interactive changelog with before/after diffs
benchmark_unified.py— StaleVectorSearchimport →HybridSearchbenchmark_beir.py— Deadrecall_at_kfunction fixedmathir_search.py— DocstringVectorSearch→HybridSearch- Stale
VectorSearchreferences: 0 remaining
- Default model changed:
BAAI/bge-large-en-v1.5(1024d, CUDA) replacesall-MiniLM-L6-v2(384d) - Persistent daemon:
mathir_daemon.pykeeps model loaded in RAM, serves via TCP port 7338 - Fast client:
mathir_client.pyconnects to daemon — no Python startup per call - onnxruntime-gpu 1.26.0: CUDAExecutionProvider + TensorrtExecutionProvider available
- Model saved locally:
~/.config/opencode/models/bge-large-v1.5/
| Model | Dims | Save | Recall | Device |
|---|---|---|---|---|
| bge-large-en-v1.5 | 1024 | 43ms | 25ms | CUDA |
| MiniLM-L6-v2 | 384 | 22ms | 53ms | CUDA |
| nomic-embed-text-v1.5 | 768 | ~21ms | ~20ms | CUDA |
| Octen INT8 (ONNX) | 1024 | ~5000ms | ~2700ms | CPU |
| Octen INT8 (ONNX+CUDA) | 1024 | ~776ms | — | Partial GPU |
- New
mcp/folder with comprehensive integration guides DIMENSIONS.md— Embedding dimension explainedMODEL_COMPARISON.md— All models comparedGPU_SETUP.md— GPU acceleration setupDAEMON.md— Daemon architectureINTEGRATION.md— Platform integration guides
- Removed
backend="onnx"from SentenceTransformer (caused silent CPU fallback, 200x slowdown) - Fixed
EMBEDDING_DIMdefault from 1024 to match actual model dimensions - VecMemory auto-recreates vec0 table on dimension mismatch
mathir_lib/providers/onnx.py— NewONNXProviderusing ONNX Runtime- Supports INT8 quantized models (5.2 MB vs 80 MB for MiniLM)
- L2-normalized output (cosine-ready, unlike HuggingFace)
- Configurable execution provider:
CPUExecutionProviderorDmlExecutionProvider(GPU via DirectML) - Mean pooling + L2 normalize pipeline
- Auto-detects embedding dim from
config.json(default 1024)
mathir_lib/providers/onnx_embedder.py— Standalone embedder wrappermathir_lib/providers/__init__.py— Registeredonnxin factorymathir_lib/config.py— Addedonnxconfig section (model_dir,provider)mcp_server.py— Easy-to-plug MCP server with 4 tools (memory_save,memory_recall,memory_stats,provider_info)
| Provider | Model | Dim | Size | Batch (5q+8d) | Single | Normalized |
|---|---|---|---|---|---|---|
| ONNX (Octen INT8) | Octen-Embedding-0.6B-INT8 |
1024 | 5.2 MB | 203 ms | 18.8 ms | ✅ |
| HuggingFace | all-MiniLM-L6-v2 |
384 | 80 MB | 27 ms | 5.2 ms | ❌ |
| HuggingFace | Qwen/Qwen2.5-7B-Instruct |
3584 | 14 GB | ~30 ms (GPU) | ~10 ms (GPU) | ❌ |
Quality: Octen INT8 produces similarity scores in [0.42, 0.98] (L2-normalized), while MiniLM raw outputs span [-2.53, 34.34] (unnormalized, requires post-processing).
- Updated
README.mdwith provider comparison table and ONNX section benchmark_onnx.py— Reproducible benchmark scriptexamples/onnx_usage.py— Usage examplesmcp_server.py— Drop-in MCP server for Claude/OpenCode
- Full RLock audit — All 8 memory modules in
mathir_lib/memory/now usethreading.RLockon mutating methods (store,forget,reset)working.py,episodic.py,semantic.py,immunological.py— already had RLockensemble_episodic.py,hybrid_episodic.py,raw_episodic.py— added RLock
- mathir_dropin —
store.pyandmemory.pyalready thread-safe (confirmed during audit) - Thread-safe under concurrent stress — stress test runs 5-tier memory + BM25 + cross-encoder concurrently without data races
- CPU metric fixed — Was always 0% due to
psutil.cpu_percent(interval=None)delta-based measurement from sleeping thread. Replaced with manualcpu_times()delta (process.cpu_times().user + .system/time.monotonic()). Process-wide, thread-independent. - GPU metric fixed — Was reporting global VRAM (all processes, 241–328 MB). Now uses
torch.cuda.memory_allocated()for MATHIR-only tensors (36–53 MB). - Clean slate on restart —
start()now deletesstress_memory.db+ WAL/SHM files before reinit. Old data no longer persists between runs. - Start after Stop fixed —
start()now recreatesThreadPoolExecutorafterstop()kills it. Root cause of "Start doesn't work after Stop". - Config deep merge —
start()preserveshealth_thresholdswhen merging frontend config.
- System Health Bar — 3-color bar (green/blue/red) scoring CPU, GPU, Recall, Errors, DB Write. Thresholds server-driven via WebSocket
health_configevent. - REST /api/metrics fixed — Now returns all fields including
cpu_percent,peak_ram_mb,throughput,db_write_latency,uptime. - Frontend error handling —
startTest()handlesalready_runningresponse properly. - Changelog page — Full architecture documentation at
/changelogwith before/after code diffs, benchmarks, file reference. Accessible via "Changelog" button in dashboard header.
- SimpleMemory — New FTS5-only memory class (
mathir_dropin/simple.py), zero external dependencies - get_last(n) — Always include last N memories for context
- search_context() — One-call method for LLM context injection (recall + last, deduplicated)
- DB preservation —
setup_memory()no longer deletes DB on restart - Thread safety — Concurrent access via WAL mode + per-operation connections
- 31/31 audit checks — Architecture, store, recall, edge cases, concurrency
- SVG icons — Replaced all emoji with clean SVG icons
- Chat history — Persisted in localStorage (survives page reload)
- Backend camera — OpenCV via API (not browser getUserMedia)
- 6 views — Chat, Camera, Models, Memory, Accuracy, Settings
- Dark theme — 8px grid, responsive layout
- Fixed 6 broken frontend→backend routes (were returning 404)
/api/system/context+/api/system/info/api/models/switch,/api/models/toggle,/api/models/add-from-hf/api/accuracy/test(was/api/accuracy/run)- Audio via
/api/chatwith audio field
- Reduced from ~1100 tokens to ~126 tokens
- Removed rigid 4-section template forcing
- Model responds naturally instead of following template
- Fixed
localhosthardcoded →127.0.0.1 - Model auto-loads at startup (LFM2.5-VL-1.6B by default)
- Updated README.md for GitHub presentation
- Created AGENT.md (agent guide)
- LaTeX research paper for scientific review (
docs/MATHIR_Research_Paper.tex) - Benchmark methodology documented (dataset, queries, metrics, hardware, sources)
- Added
simple_memory_demo.pyexample (zero deps) - Cleaned workspace (old files archived, temp dirs removed)
- Removed LSTM references from docs (kept as historical citations only)
- Updated docs/28_HOW_TRAINING_WORKS.md (modern training workflow)
- Updated docs/02_MASTER_REFERENCE.md, docs/03_MASTER_QA_GUIDE.md
- Excluded large files from git (GGUF, DLL, binaries)
/api/memory/delete— Delete by ID or clear all memories- Settings view — Create, view, delete memories in MATHIR Memory section
- Playground — Memory panel with delete buttons
- Full conversation storage — Stores complete Q&A (not truncated to 200 chars)
- Skip trivial messages — "hi", "ok", "thanks" not stored
- File markers —
[IMAGE ATTACHED]/[AUDIO ATTACHED]in memory
playground.html— New standalone chat UI at/playground.html- Multi-session — Create new chats, switch between, delete
- Model load modal — See all models, capabilities, switch mid-chat
- Image drag & drop — Attach images directly
- Camera integration — Start/stop backend camera
- Hold-to-talk — Audio recording
- Export chat — Save conversation as .txt
- Status indicator — Green/red dot showing MATHIR connection status
- Memory count — Shows "MATHIR: connected (N memories)"
- Auto-refresh — Status checked every 15 seconds
- Language —
langHTML attribute set fromui_config.json(not hardcodeden) - All routes — Frontend calls match backend endpoints
- All paths — Relative to config files
- Complete web UI in
vision_testing/for testing vision/audio models - Flask backend with 17 API routes
- Web UI with Chat, Camera, Models, Memory, Settings views
- CLI tools:
model_manager.py,setup_binaries.py,download_models.py
- LFM2.5-VL-1.6B-GGUF (vision-language) — 1.2 GB Q4_0
- LFM2.5-Audio-1.5B-GGUF (audio understanding) — 1.0 GB Q4_0
- Add ANY HF GGUF model via UI or CLI
config.json— All model paths (no hardcoded)ui_config.json— UI settings (port, camera, audio)system_context.json— System prompt for models
- Cross-provider recall (OpenAI ↔ Ollama ↔ Cohere)
- Cross-lingual recall (EN ↔ FR ↔ DE ↔ ES ↔ ZH)
- Latin name handling (taxonomic, diacritics, Roman numerals, abbreviations)
- 137/137 tests pass
- 11 mathematical theorems (Broder, Johnson-Lindenstrauss, Wedin, Cormack)
- Dense-only FAISS = SOTA on SciFact (0.7441 nDCG@10)
- ArguAna complete (0.6613 nDCG@10)
- LIRS eviction: 100% recovery after stress
- KL router: 100% tier-routing accuracy
- Immunological: 100% anomaly detection
- LRU result cache (10K entries, 80-85% hit rate)
- 3ms warm path latency (vs 500ms cold)
- Adaptive re-ranking
- ONNX cross-encoder support
- 4 retrieval approaches (A: raw, B: BM25, C: hybrid RRF, D: hybrid+CE)
- 130 new tests, 0 regressions
- Key finding: dense-only = SOTA for scientific retrieval
- 8 new algorithms (Ebbinghaus, SparseCoding, Variational, CrossAttention, Hyperbolic, InfoNCE, NeuralODE, Mahalanobis)
- 6 novel theorems with full proofs
- 9.3× compression (1,088,000 → 116,976 bytes)
- 49/49 unit tests pass
- 100% backward compatible with V6
MATHIRPluginclass — works with any LLM, any embedding dimension- 5-tier memory (Working, Episodic, Semantic, Procedural, Immunological)
- KL-constrained router
- TurboQuant compression
- 12/12 tests pass
- KL-divergence constrained router (prevents collapse)
- Immunological memory (anomaly detection)
- 21 bug fixes (V5.1)
- mHC integration (DeepSeek paper)
- Sinkhorn-Knopp projection
- Lyapunov-based adaptive omega
- CNN + MLP vision encoder
- 3-tier memory (Working, Episodic, Semantic)
- Basic RL training loop