Commit Graph

156 Commits

Author SHA1 Message Date
xiaowei ea4b5a4dfe fix(distill): max_tokens 600→800 — Agnes推理模型JSON不再截断
engine.go: max_tokens 600→800
consolidate.go: max_tokens 300→800
根因: Agnes 2.0-flash是推理模型,max_tokens=600里大量是推理token,
正文只剩~300→JSON截断→parse error→蒸馏退化。
800确保推理+正文都够用。
2026-08-20 00:10:51 +08:00
小唯 38701748d1 feat(distill): P4 AAAK压缩索引 + P5 Markdown导出层
P4: 借鉴 mempalace AAAK dialect — 每条事实生成紧凑索引(实体|关键词|权重|类型)
P5: 借鉴 EverOS md真相层 — /api/v1/memories/export 导出人可读 Markdown
2026-08-12 01:37:27 +08:00
小唯 82c3d25423 feat(distill): P2 离线整合(UPDATE_PROMPT) + P3 双缓冲(token积累) + JSON健壮剥离修复
- P2: consolidate.go 新增 ConsolidateMemory + TextSimilarity,LLM三选一(update/delete/ignore)合并相似记忆
- P2: server.go 新增 POST /api/v1/consolidate/memory 手动触发端点
- P3: engine.go Enqueue 按 token 积累触发 flush(阈值2000),batchTimeout兜底
- fix: LLM JSON 剥离增强(找首个{和最后}截取),修复模型返回markdown/注释导致的parse error
2026-08-11 21:38:10 +08:00
小唯 0734ffaa5a feat(distill): LightMem式逐条事实提取 prompt(P1)— 从整段摘要升级为逐条独立事实,保留全部实体细节+时间区分+推断隐含信息 2026-08-11 17:51:08 +08:00
小唯 11162e2f60 fix: consolidation 风暴 — distill cooldown 60s→15min, cluster_only 跳过 PageRank
- triggers.go: TriggerDistill cooldown time.Minute → 15 * time.Minute
- consolidation_pipe.go: runGraphMaintenance 仅 full 模式执行(cluster_only 高频快速聚类跳过重负载 PageRank)
- 修复 zhiyid CPU 80-90% 风暴、recall API 120s+ 超时

根因:t_distill 每 60s 触发全量 DBSCAN + PageRank(10356 nodes),数据量大时单次 30-60s CPU 堆积
2026-08-10 01:21:57 +08:00
xiaowei 98e541b985 fix: distill LLM 模型切换 gemma-4-31b-it + JSON 解析增强
根因链:
1. gpt-oss-120b 是 reasoning 模型,content=null 答案全在 reasoning 字段,
   代码只读 content/reasoning_content(OpenAI 用 reasoning 字段名)→ parse 失败
   → 永远降级 keyword 提取 (facts=1 entities=0)
2. skill 记载的 m3/m2.7/mistral-large 均已 EOL 或渠道失效 (2026-07-27 后)
3. gemma-4-31b-it 对 '0.X' 占位符输出 0.0 → prompt 改为明确 0-1 浮点说明

修复:
- engine.go: 支持 reasoning 字段 + 剥离 markdown code fence + prompt 评分说明明确化
- zhiyid.service: LLM_MODEL=google/gemma-4-31b-it

验证: LLM entities=2, overall=1.000, facts=3 entities=2, recall 命中 0.765
2026-08-02 23:59:29 +08:00
xiaowei 21bc777430 fix: episodes 持久化到 LanceDB(重启不再清零)
根因: RustLanceDBClient.InsertEpisode 只写进程内存 _local.episodes,
从未持久化;Stats 的 total_episodes 用内存值覆盖 Rust 真实计数。

修复:
- InsertEpisode 增加 IPC 写入 LanceDB episodes 表(24 字段完整 schema)
- Stats 优先用 Rust sidecar 返回的 episodes 计数,缺失才回退内存
- 持久化失败只记日志不阻断请求(保持'总是写入'语义)

验证: 提交测试 episode → stats episodes=1 → 重启 zhiyid → 仍为 1
历史 45 条内存 episodes 已随重启丢失(原始日志,蒸馏结果在 memories 5063 条保留)
2026-08-02 23:41:37 +08:00
小唯 6f9361f4e9 docs: 更新 README — 4个项目关系图 + TencentDB + Soulful 2026-07-20 15:58:54 +08:00
小唯 4e17b8cb98 docs: 说明与 xiaowei-system 的关系和安装顺序
- 明确织忆是底层基础设施,xiaowei-system 是上层应用
- 安装顺序:先织忆,再小唯系统
- 加 API 调用示例
2026-07-20 15:50:07 +08:00
小唯 c4d17df71c fix: Phase D/G/H 编译修复
- governance.go: 加 PendingCount() 方法给 ConflictsPending metrics
- distill/: 删 consolidation.go(死代码,231行无引用)
- scripts/: backup.sh 加7天保留策略 + restore.sh 恢复脚本
2026-07-10 05:10:12 +08:00
小唯 d524fd741b docs: 分身速通卡(rag-skill集成+100%自动化管道说明) 2026-07-08 15:20:47 +08:00
小唯 707903dee7 docs: 织忆v3.9+rag-skill 项目复盘报告(全自动化管道产出) 2026-07-08 12:58:14 +08:00
小唯 1970fb4f06 feat: 织忆+rag-skill深度检索模式 + 07-Wiki全目录索引
Phase 3: Hermes 插件深度检索
- prefetch() 新增 depth='deep' 参数
- depth=deep: 织忆语义搜索后,异步触发本地文件渐进检索
- 结果标记 [rag-skill File — local Wiki evidence]
- 缓存 TTL 60s,支持双轮(第一轮触发,第二轮拿缓存)
- depth='fast' 默认行为完全不变

Phase 4: 07-Wiki 目录索引补全
- docs/07-Wiki-index/: 织忆同步(1039files)、织忆图谱(299files)、经证同步(29files)
- docs/memory-index/: 记忆顶层 + 织忆进度快照
2026-07-08 12:42:17 +08:00
小唯 25a1bb52dc docs: 织忆系统功能用法说明(v3.9全功能速查) 2026-07-08 12:26:49 +08:00
小唯 25151bfda2 fix: three-way-check.sh — add X-API-Key to zhiyid endpoint check, replace *** placeholder 2026-07-08 12:26:28 +08:00
小唯 8ca3ca0497 feat: 织忆系统全面推 Gitea v3.9
新增:
- cli-anything/ — 命令行伴侣
- docs/ — v3.8设计文档、v3.9 rag-skill补充设计、实施计划、进度快照、data_structure.md索引
- skills/ — zhiyi技能(SKILL.md+scripts+references)、rag-progressive-search渐进检索技能
- scripts/ — 更新wiki_curator.py(中文版)、新增three-way-check.sh、verify-gitea-deploy.sh

变更:
- scripts/wiki_curator.py — 更新为中文说明版
- README.md — 已完成(ca37de9)

功能覆盖:
- P0 Recall降级策略 / P1 自动注入 / P2 信任评分
- P3 CREATIVE.md / P4 Ground Truth / P5 Wiki策展
- H1 BM25融合 / H2 LLM策展 / H3自动信任 / H4 diversity / H5三模式 / H6多级存储
- rag-skill渐进式检索集成(分层索引+渐进检索+先学再做)
2026-07-08 12:24:39 +08:00
小唯 ca37de93b6 docs: 重写 README.md — 完整项目说明(架构图/特性清单/API速查表/目录结构) 2026-07-08 12:23:56 +08:00
小唯 51aa9de939 fix: robust auto-start after reboot
- Moved bge_embed_server.py to ~/.hermes/scripts/ (persistent)
- Moved Rust sidecar binary to ~/bin/zhiyi-consolidate (persistent)
- zhiyid.service: After=zhiyi-consolidate bge-embed (start ordering)
- All services: enabled + Linger=yes → auto-start on boot
- ExecStartPre fallback: re-copy from Gitea clone if file missing
2026-07-02 01:05:24 +08:00
小唯 c86f5bc304 fix: NewAPI key strip sk- prefix + LLM wiki graceful fallback 2026-07-02 01:00:23 +08:00
小唯 57ac628b3f fix: H1-H6 gaps all resolved
H1: BM25 keyword scoring in recall pipeline (0.7 vector + 0.3 keyword)
H2: LLM wiki curation mode (--llm flag, graceful heuristic fallback)
H3: Auto trust score update after each recall call
H4: Default diversity=0.3 (was 0 = no diversity)
H5: Three search modes: hybrid(semantic+BM25) / keyword / semantic
H6: Multi-tier fallback already covered by P0 + SQLiteClient

All verified: hybrid(0.962), keyword(1.000), semantic(0.962)
2026-07-02 00:43:46 +08:00
小唯 db3d3d8e85 docs: P3-P5 implementation plans + skill update 2026-07-02 00:30:43 +08:00
小唯 7fabc58bf3 feat: P3 CREATIVE.md isolation + P4 Ground Truth prompt + P5 Wiki curator
P3: Created ~/.hermes/CREATIVE.md for 织忆 working memory.
Updated plugin system_prompt_block() to load CREATIVE.md as [织忆 工作记忆].

P4: Added Ground Truth hierarchy (4 levels), Context injection convention,
and Memory feedback rule to SOUL.md. Injected [织忆] memory now
explicitly takes priority level 2.

P5: Created wiki_curator.py — scans .md files, extracts concepts/entities/
relations via heuristic, writes to 织忆 via /commit + /graph/edge APIs.
Includes dry-run, force, state tracking, skip rules.
2026-07-02 00:29:47 +08:00
小唯 f4313a40ef docs: add implementation plans for P0/P1/P2 features 2026-07-02 00:23:04 +08:00
小唯 5e24646600 feat: P1 auto-injection hook with social close detection
- queue_prefetch now caches next-turn recall results asynchronously
- Social closer detection skips trivial messages (ok, thanks, emoji)
- prefetch uses cached queue results when available (TTL 30s)
- Output header changed to [织忆 Memory] for source clarity
2026-07-02 00:22:43 +08:00
小唯 72cbf73583 feat: P0 recall fallback + P2 trust scoring for graph edges
P0: When bge-embed/IPC recall fails, fall back to graph.db keyword search (FallbackTextSearch) instead of 500 error. Response includes X-Fallback: graph header.

P2: Add trust_score, retrieval_count, helpful_count columns to graph_edges table. New POST /api/v1/graph/edge/feedback endpoint. UpdateEdgeTrustScores batch calculation.
2026-07-02 00:22:28 +08:00
小唯 fa0eb004a8 docs: add Memory-OS 7-layer comparison with source code analysis (2026-07-01) 2026-07-01 23:53:34 +08:00
小唯 dc8d074cf5 fix: 6 Go code quality fixes + 4 plugin bug fixes 2026-06-20 16:51:13 +08:00
小唯 12c4c58c1c fix: re-enable /api/v1/memories list endpoint (via AdminAPI) 2026-06-20 16:24:52 +08:00
小唯 23c6547503 perf: add graph navigate cache (TTL 5min, 500 entries) + cache invalidation + cache stats API
- NewCachedGraphStore: governance.GraphStore wrapper, only Navigate() is cached
- GraphCacheRef: expose InvalidateAll() + Stats() for cache management
- Cache invalidation on graph/edge add, graph/cleanup (non-dry-run)
- New /api/v1/cache/stats endpoint for cache monitoring
- /api/v1/health now registered at /api/v1/health path too
- normalizeEntity: preserve Unicode letters (Chinese chars not stripped)
2026-06-16 18:09:51 +08:00
小唯 d6188a2bd7 fix: health endpoint + graph/edge API + normalizeEntity Chinese + nl_query comparison
1. Add /api/v1/health endpoint (maps to HandleHealth)
2. Add POST /api/v1/graph/edge for adding relation edges
3. Fix normalizeEntity to preserve Chinese characters (0x4e00-0x9fa5)
4. Fix nl_query direct_path comparison to use normalizeEntity on both sides
2026-06-16 16:16:35 +08:00
小唯 bd8008b3fd fix: comment out api.ListMemories (removed from routes) 2026-06-15 18:34:12 +08:00
小唯 a76b6d3afa feat(graph): add graph cleanup + nl_query + navigate grouped format
- Add CleanupNoiseNodes() to GraphStore interface + SQLiteGraphStore impl
- Add /api/v1/graph/cleanup endpoint (dry_run + execute)
- Add /api/v1/graph/nl_query endpoint for natural language graph queries
- Improve /api/v1/graph/navigate: add grouped_by_relation, suggestions, normalized_entity
- Add CleanupNoiseNodes stubs to InMemoryGraph and FileGraph

BREAKING: navigate response now includes grouped_by_relation and suggestions
2026-06-15 18:09:27 +08:00
小唯 79b994ce4b feat: add memory_graph_navigate and memory_graph_stats tools (v1.1.0)
- Add graph_navigate() and graph_stats() to ZhiYiClient
- Add memory_graph_navigate tool: N-hop knowledge graph navigation
- Add memory_graph_stats tool: graph statistics (nodes/edges/density)
- Update system prompt to list all available tools
- Bump version 1.0.0 -> 1.1.0
2026-06-15 17:28:16 +08:00
小唯 b9f9f75c31 fix: IsContradiction typo in bench_test.go 2026-06-15 11:08:13 +08:00
小唯 8ad4a7c794 feat: add freshness field to memory lifecycle
- server.go: set freshness='fresh' when distill creates new memory
- recall.go: set freshness='verified' when memory is recalled
- Freshness values: fresh (new), verified (recalled), stale (decayed)
2026-06-15 10:39:15 +08:00
xiaowei 42a8aeb53c api/server: only record distill_loss when Overall>0, exclude fallback pollution 2026-06-12 11:43:05 +08:00
xiaowei cf31ff5e8e api: add /api/v1/metrics endpoint exposing Dashboard metrics (avg_distill_loss, etc.) 2026-06-12 08:54:00 +08:00
xiaowei 90c43c0717 fix(distill): increase HTTP client timeout 30s→120s for LLM calls 2026-06-11 10:39:07 +08:00
xiaowei c3db6ffe30 feat(backup): add standalone backup script, deprecate Go API route 2026-06-10 10:19:55 +08:00
xiaowei b237cc9aeb fix(backup): add 5min timeout to tar, fix comment 2026-06-10 10:16:49 +08:00
xiaowei 2c96f805f4 fix: consolidate trigger uses full mode instead of cluster_only
Problem: server.go 30s ticker loop called consolPipe.Run() which
defaults to cluster_only mode. The 'consolidation' and 'backtrack'
actions never executed prune/decay/quality steps.

Fix:
- Separate 'distill' action (keeps cluster_only for fast frequent runs)
- 'consolidation' and 'backtrack' now call RunWithMode(full)
- selfoptimize.Flow.Register('consolidate') also uses RunWithMode('full')
- Proper case indentation (4 tabs for labels, 5 for bodies)

Result: prune + decay + quality steps now run when t_consolidation
or t_backtrack fires (48h cooldown protects against over-firing)
2026-06-09 12:45:33 +08:00
xiaowei ffee97032e docs: save DESIGN-v2-llm-optimizer.md (parked, not implementing yet) 2026-06-08 11:16:54 +08:00
xiaowei b669a01e16 feat: add DESIGN-v2-llm-optimizer.md (草稿 v0.3) 2026-06-08 11:09:43 +08:00
xiaowei 1516fe5bc8 fix: add clusters_found/noise_points/quality_score to consolidate API response 2026-06-08 10:35:10 +08:00
xiaowei f286348ad8 fix: gap auto-close + conflict_muchen handler
- GapDetector.RecordHit(topic): recall 命中后自动关闭该 topic 的 open gap
- GapDetector.ClearMisses(topic): 清除 miss 计数,避免重复触发
- SetGlobalGapDetector / GetGlobalGapDetector: 全局实例注册,供 recall 回调使用
- recall handler (core.go): 命中时调用 RecordHit + ClearMisses 实现 gap auto-close
- conflict_muchen handler (server.go): 注册处理器,自动裁决 pending conflict(latest_wins / primary_wins / dismiss)
- fix: server_sqlite_nowindows.go 修复 osGetenv → os.Getenv (pre-existing)
2026-06-08 00:54:40 +08:00
xiaowei 82652ab489 storage/embedder: 支持 MODEL_NAME 环境变量指定 embedding 模型
- Embedder.modelName 替代硬编码的 bge-m3
- 默认值仍是 bge-m3(兼容本机 vLLM)
- Ollama 等第三方服务可通过 MODEL_NAME 覆盖
- encodeRemote 和 fallback 均使用 e.modelName
2026-06-06 18:22:40 +08:00
xiaowei 2d6981d4fb E5.1 织忆插件 v1.1: 记忆展开详情+分类过滤+质量分条+写记忆入口+设置持久化+图谱边标签+实体列表侧边栏 2026-06-03 20:25:53 +08:00
xiaowei 8d62d35ae7 cleanup: 删除废弃数据目录 /home/muc/data(20K,仅 transaction 文件,实际数据在 /var/lib/memoryweave) 2026-06-03 12:49:54 +08:00
xiaowei 3d054e7590 自验证机制:consolidate 聚类下限 + timestamp 前置检查 + 启动数据目录检查 + 修复图谱扩展字段名
1. consolidation_pipe.go:
   - 前置:抽样检查记忆时间戳(< 2024-01-01 视为可疑 epoch-0)
   - 后置:clusters <= 1 时记录 ERROR + patterns 标记异常
2. server.go: runStartupChecks() 启动时检测废弃路径 + socket 可达性
3. graph_expander.go: Navigate 返回字段从 "target"/"source" 修正为 "to"/"from"
2026-06-03 12:44:31 +08:00
xiaowei 612d915eec fix: 移除 episodes 直接写入 recall 结果
问题:commit 时直接 InsertMemory,原始对话未蒸馏就出现在 recall 结果

修复:
- recall.go: Step 2.5 过滤 episodes/对话类别(filterRecallRawCategories)
- recall.go: cache hit 路径同步加 filter,防止旧缓存污染
- core.go: 移除 commit 时的 InsertMemory,蒸馏完成后由 callback 写入 memories
- engine.go: 蒸馏 prompt 改为结构化提取(decisions/conclusions/actions_taken/open_questions)
- engine.go: max_tokens 300→600,truncate 500→1000

验证:recall('牧尘 小唯 obsidian') → 仅 distilled/system_fact/用户偏好,无 episodes
2026-06-03 01:36:45 +08:00