← 返回
数据分析 中文

MidOS Memory Cascade

Auto-escalating multi-tier memory search that cascades from in-memory cache through SQLite, grep, and LanceDB vector search to find the best answer with mini...
自动升级的多层内存搜索,从内存缓存逐级串联SQLite、grep及LanceDB向量搜索,以寻找最佳答案。
msruruguay
数据分析 clawhub v1.0.0 1 版本 99861.5 Key: 无需
★ 0
Stars
📥 721
下载
💾 35
安装
1
版本
#latest

概述

MidOS Memory Cascade

A self-tuning, auto-escalating search engine that tries each memory tier from fastest to slowest, stopping as soon as it finds a high-confidence answer.

What It Does

Instead of the agent deciding which storage layer to query, the cascade tries each tier automatically:

TierStorageLatencyStrategy
----------------------------------
T0In-memory session cache<1msExact + fuzzy key match
T1JSON state files<5msFilename + key match
T2SQLite (pipeline_synergy.db)<5msStructured SQL LIKE
T3SQLite FTS5<1msFull-text keyword on 22K rows
T4Grep over 46K chunks~3sBrute-force ripgrep fallback
T5LanceDB keyword (BM25)slow670K vector rows, no embeddings
T5bLanceDB semantic3–30sEmbedding similarity, last resort

Question routing: Queries starting with how/what/why/etc. skip keyword tiers and route directly to semantic search.

Self-learning: The cascade records which tier resolves each query. After enough history, evolve() learns shortcuts (skip directly to the winning tier) and marks consistently-empty tiers for skip.

Usage

Python API

from tools.memory.memory_cascade import recall, store

# Search across all tiers
result = recall("adaptive alpha reranking")
# → {"answer": {...}, "tier": "T5:lancedb", "latency_ms": 340, "confidence": 0.87}

# Write to the right storage automatically
store("pattern", content="...", tags=["ml", "reranking"])

CLI

# Search
python memory_cascade.py recall "query here"

# View tier resolution stats
python memory_cascade.py stats

# Run self-evolution (learn shortcuts + tier skips)
python memory_cascade.py evolve

recall() Options

recall(
    query: str,
    min_confidence: float = 0.5,  # stop escalating at this threshold
    max_tier: int = 6             # 0=T0 only, 6=all tiers
)

Returns:

{
  "answer": { "source": "...", "text": "..." },
  "confidence": 0.87,
  "latency_ms": 340.2,
  "tiers_tried": 3,
  "resolved_at": "T5:lancedb",
  "shortcut": null,
  "question_routed": false,
  "escalation": [...]
}

Requirements

  • Python 3.10+ (stdlib only for core cascade logic)
  • Optional: hive_commons for LanceDB tiers (T5/T5b)
  • Optional: tools.memory.memory_router for store() routing

The cascade degrades gracefully — if LanceDB is unavailable, it stops at grep (T4). All stdlib tiers (T0–T4) work with zero dependencies.

Architecture Notes

  • Thread-safe: Session cache uses threading.Lock; stats writes use separate locks
  • Cross-process safe: JSONL writes use OS-level file locking (msvcrt on Windows, fcntl on Unix)
  • Confidence scoring: Term overlap × score × content richness → normalized 0–1
  • Stats persistence: knowledge/SYSTEM/cascade_stats.json accumulates hit rates per tier

Built with MidOS. 1 of 200+ skills. Full ecosystem at midos.dev/pro

版本历史

共 1 个版本

  • v1.0.0 当前
    2026-03-30 06:15 安全 安全

安全检测

腾讯云安全 (Keen)

安全,无风险
查看报告

腾讯云安全 (Sanbu)

安全,无风险
查看报告

🔗 相关推荐

data-analysis

A股量化 AkShare

mbpz
A股量化数据分析工具,基于AkShare库获取A股行情、财务数据、板块信息等。用于回答关于A股股票查询、行情数据、财务分析、选股等问题。
★ 165 📥 60,086
data-analysis

Excel / XLSX

ivangdavila
创建、检查和编辑 Microsoft Excel 工作簿及 XLSX 文件,支持可靠的公式、日期、类型、格式、重算及模板保留功能。
★ 368 📥 140,582
data-analysis

Data Analysis

ivangdavila
{"answer":"数据分析与可视化。查询数据库、生成报告、自动化电子表格,将原始数据转化为清晰可行的见解。适用于:(1) 您……"}
★ 198 📥 65,167