Commit Graph

21 Commits

Author SHA1 Message Date
xiaowei f6f4c832fb F1-F4: 端到端管道修复 + 蒸馏激活 + 治理基础
修复内容:
- F1: Hermes 插件 commit/recall 加 agent_id/namespace,201 状态码兼容,namespace 推导
- F2: 存储后端确认在 LanceDB,graph API match 格式兼容,recall/debug 诊断端点
- F3: LLM 端点 URL 修复(缺 /chat/completions),API Key 前缀修复,中文实体提取启发式
- F4: 冲突检测加载实际记忆,图谱 API match 搜索,PassiveValidator 修正
- REPAIR-FULL.md + IMPLEMENTATION.md: G1-G9 全量修复计划
2026-05-30 02:01:11 +08:00
xiaowei da9694a264 fix: add pagerank column to graph_nodes schema
Root cause: CREATE TABLE graph_nodes in Go migration (graph_sqlite.go)
was missing 'pagerank REAL DEFAULT 1.0' per DESIGN.md spec.

Fix:
- Go: add pagerank to CREATE TABLE + migrateAddColumn() for existing DBs
- Rust: replace .ok() hack with ensure_column() that checks pragma_table_info
  before ALTER TABLE, making it properly idempotent with explicit error handling
- Rust: warn+skip if column still missing (rather than silent continue)
2026-05-29 23:29:30 +08:00
xiaowei 2e8ca614fd feat: add static file bypass auth + graph.html API_BASE fix
- Add /static/* route bypass in auth middleware
- Localize d3.min.js (was CDN blocked)
- Fix graph.html API_BASE to server IP for remote access
- Add error logging in graph load function
- Deploy binary at /usr/local/bin/zhiyid (13.5MB, correct cmd/zhiyid path)
2026-05-29 21:59:41 +08:00
xiaowei b78ec335e8 feat: graph navigation + Obsidian notes integration
- ObsidianSyncer.SearchNotesByEntities: scan vault by entity names
- GET /api/v1/graph/notes: navigate graph + search Obsidian in one call
- Hermes zhiyi plugin: prefetch now includes Obsidian notes via graph
- system_prompt_block updated to reflect knowledge graph capability

Fix: move obsidian init before route handlers (Go compile order)
2026-05-29 16:27:23 +08:00
xiaowei fab49fdd9b feat: knowledge graph visualization
- Add GetGraph method to GraphStore interface
- Implement SQLiteGraphStore.GetGraph for full graph export
- Add GET /api/v1/graph/export endpoint with namespace filter
- Add static file serving (/static/ path)
- Create D3.js force-directed graph visualization:
  - Namespace switcher (all/hermes-main/openclaw-main/shared)
  - Node colors by type, size by weight
  - Edge labels on hover, node detail popup on click
  - Dark theme, zoom/pan, force simulation
2026-05-29 15:42:07 +08:00
xiaowei 455833a041 feat: reranker优化 + namespace隔离修复 + graph_auto扩展
- reranker: 本地vLLM cosine rerank 作为模力方舟API的后备
- 修复 namespace 过滤问题,确保 hermes-main/openclaw-main 隔离
- graph_auto: 扩展图谱实体抽取逻辑
- lancedb_ipc: 增强 IPC 错误处理
2026-05-29 15:19:25 +08:00
xiaowei 1c0b45c038 feat: L3 世界模型 bootstrap — ℰ/ℐ/C 三元组完整填充
ℰ: Deepin 25, RTX 3050 4GB, 16GB RAM, 192.168.123.12, Hermes 0.13.0
ℐ: 6个服务拓扑(new-api/Redis/织忆/ComfyUI/Hermes/OpenClaw)+端口+依赖
C: 4硬约束 + 7软规则(牧尘偏好/opencode优先/系统审批)
新增 ServiceInfo 结构体, 硬约束独立字段
2026-05-29 08:09:54 +08:00
xiaowei 1b0e1a549c fix: 蒸馏引擎 + 命名空间隔离 + PassiveValidator + ephemeral清理
- 蒸馏引擎: LLM调用需LLM_API_KEY(不再复用API_KEY), 新增flush日志
- namespace三层: shared/hermes-main/openclaw-main 隔离, Rust IPC client-side过滤
- PassiveValidator: 蒸馏完成回调中加载已有记忆进行P1/P2/P3匹配
- ephemeral清理: currentUnixMS修复, AgentInfo.LastSeen, 定时扫描
- Go代理: goproxy.cn配置
- 图谱: 孤儿边自动补节点, namespace兼容, 多跳导航前缀修复
- 召回管道: shared namespace联合搜索, recall_count跟踪
2026-05-29 08:04:57 +08:00
xiaowei 648e469dc9 feat: Prometheus 监控集成 — /metrics 端点 + 14 指标 + 8 告警规则
- 新增 internal/metrics/metrics.go: 14 个 Prometheus 指标
- server.go: /metrics 替换为 promhttp, 15s 后台同步
- go.mod: 新增 client_golang v1.23.2
- deploy/prometheus.yml: 抓取配置 (zhiyid:7821)
- deploy/prometheus-alerts.yml: 8 条告警规则
- deploy/prometheus.service: systemd unit
2026-05-29 02:51:46 +08:00
xiaowei 08848607fd v3.8 完整代码: Go API + Rust sidecar + ONNX BGE + Client SDK
- 4 大修复: 缺口分类向量化 + Schema 23字段 + Consolidation走Rust IPC + Client SDK
- BGE ONNX: deploy/bge_embed_server.py + systemd unit,1024维本地推理
- Rust sidecar: 8模块完整,DBSCAN/衰减/修剪/质量回溯/整合报告
- Go: zhiyid 7821端口,37个API端点,多Agent架构
2026-05-29 01:07:05 +08:00
xiaowei bedbe55ad5 fix: 6项设计差距补全 — 逐节对照50项→0差距
G1 Recall图谱+预取 (2.6 Step 5-6):
  - RecallPipeline: SetGraphExpander + SetPrefetchPusher
  - GraphExpander接口: 结果<5条时BFS扩展1跳
  - PrefetchBridge: CO_OCCURS权重>0.6→WS推送prefetch.push
  - graph_expander.go: InMemoryGraph实现接口

G2 RateLimit (2.7):
  - auth.go: 滑动窗口限流, 429带Retry-After/X-RateLimit-Reset
  - 120 req/min per agent

G3 WS事件 (2.8):
  - ws_events.go: prefetch.push/gap.filled/memory.updated/quality.drop
  - gap关闭时自动推送gap.filled

G4 自动蒸馏 (3.1):
  - auto_distill.go: commit后→硬规则过滤→蒸馏→图谱更新→冲突→验证
  - 降级蒸馏: 关键词提取 (无需LLM)

G5 version_history (3.3.3):
  - CausalTracker.Entries() 暴露版本历史
  - feedback/correct 路由层自动调用FillVersionHistory+因果链通知

G6 ephemeral命名空间 (1.3):
  - /api/v1/admin/ephemeral/clean 端点
  - 10分钟定时清理循环

go build: 0 errors, go test: 60 passed
2026-05-28 19:01:23 +08:00
xiaowei a2cda57f6b feat: M10 对照设计补齐 — 24项缺失功能全部实现
🔴 结构缺失 → 已实现:
- PassiveValidator: P1/P2/P3 三层匹配 (validator.go)
- 5条自动化流程: commit/gap/correct/consolidate 串联 (pipeline.go)
- Consolidation 流水线 Step 1-4 完整实现 (consolidation_pipe.go)
- V值反向传播: 决策链路追踪+时间衰减 (vprop.go)
- 触发器执行器: 8类自动循环检查+冷却 (executor.go)
- Go Client SDK: ZhiYiClient 完整API (client.go)
- Unix Socket IPC: 帧协议 Go→Rust (ipc.go)

🟡 简化实现 → 完整版:
- 知识图谱自动更新: 蒸馏→实体→节点/边/冲突边 (graph_auto.go)
- 缺口自动修复: Type B同义词映射, Type C阈值重试 (gap_repair.go)
- Skill贝叶斯: Beta-Bernoulli α/β后验+active/probation/retired (skill_bayes.go)
- Obsidian Carriers: 9类模板+自动append+mtime冲突检测 (obsidian_carrier.go)

 未集成 → 已挂载:
- Prometheus /metrics 端点注册
- 搜索缓存: SHA256 key + LRU + 1h TTL (searchcache.go)
- 后台引擎自动启动: Flow+Executor

总计: 49 Go文件, 7920行, 60 tests, 0 build errors
2026-05-28 18:53:00 +08:00
xiaowei ffb13f830a perf: 34 benchmarks + 性能报告 — i5-11260H
基准覆盖 (4 files):
- storage: cosine similarity (254ns), MMR rerank (847μs), memory alloc (6.3μs)
- governance: conflict scan 100 (2.2μs), graph navigate 2000 (485μs), prune (135μs)
- selfoptimize: dashboard metrics (187ns), gap detect (39ns), causal chain (74μs), prefetch (181ns)
- distributed: CRDT merge (325ns), rate limiter (79ns), event bus (304ns)

综合评估: 所有纯 CPU 操作纳秒/微秒级,远超设计目标。
瓶颈在外部 I/O(LanceDB + Embedding 推理)。

报告: BENCHMARK.md
2026-05-28 18:41:11 +08:00
xiaowei cda13e7d17 test: 60 tests — governance/selfoptimize/routes/integration/edge
测试覆盖 (4 files, 1233 lines):
- governance_test.go: 15 tests — 冲突检测/遗忘策略/图谱导航/CRDT
- selfoptimize_test.go: 18 tests — 仪表盘/缺口检测/因果追踪/预取/并发
- routes_test.go: 18 tests — HTTP handler 状态码/JSON/Agent 注册/验证
- integration_test.go: 9 tests — 全链路/边界/空输入/大 payload/无认证

go test ./... → 60 passed, 12 packages, 0 failures
2026-05-28 18:35:19 +08:00
xiaowei ef2ef5069c feat: M9 功能补全 — 30+ 新端点 + 自调参闭环
新增路由层 (10 files):
- graph.go: GET /graph/stats, POST /graph/query, POST /graph/navigate
- feedback.go: POST /feedback/useful|not-useful|deprecate|correct
- gaps.go: GET /gaps, POST /gaps/detect, POST /gaps/close
- conflicts.go: GET /conflicts, POST /conflicts/resolve
- agent.go: POST /agents/register, GET /agents
- admin.go: DELETE /distilled, GET /memory/versions, POST /admin/forget|backup, GET /admin/audit
- l3.go: GET|POST /l3/worldmodel
- triggers.go: GET /triggers, POST /triggers/fire, GET /skills, POST /skills/trial
- eval.go: POST /eval/run, GET /eval/history, POST /eval/generate
- tuning.go: GET /tuning/status, POST /tuning/run, POST /tuning/analytics
- obsidian.go: POST /obsidian/push|pull, GET /obsidian/status

引擎增强:
- governance: InMemoryGraph (零外部依赖) + ListActive/Resolve/DB
- selfoptimize: RecordDeprecation/Correction/GapClosed/ConflictResolved
- storage: IncrementUseful/NotUseful, UpdateMemoryContent, GetVersionHistory,
  GetCandidatesForForgetting, Backup, GetAuditLog

总计: 17 files, 1915+ lines, 35 endpoints, go build 0 errors
2026-05-28 18:25:43 +08:00
xiaowei 02eef1024d feat(Rust): zhiyi-consolidate 整合引擎 — DBSCAN + 衰减回归 + 质量回溯
Rust sidecar (232行): 纯 std + serde + clap,无 async
- DBSCAN 聚类: cosine_sim + 邻居扩展 (20簇/132噪点)
- 衰减回归: 按类别线性拟合,clamp(0.005, 0.05)
- 质量回溯: 信息密度检测
- 输出: stdout JSON,stderr 日志

Go consolidate 客户端: exec Rust 二进制,提取 JSON
server.go: 注册 /api/v1/admin/consolidate

验证:
- Go→Rust consolidate?mode=full → 200 OK 
- 923 distilled, 535 vectors, 20 clusters, 132 noise
2026-05-28 18:08:06 +08:00
xiaowei 8fb688a5c6 feat(M7): 分布式部署——CRDT + 事件传播 + 速率限制 + Prometheus
distributed/distributed.go (239行):
- EventBus: HTTP事件传播(替代Redis Streams),多peer广播
- CRDTMerge: 时间戳优先+来源优先级(牧尘修正>时间戳)
- RateLimiter: 令牌桶算法,per-agent限流(10/s + burst 20)
- HealthChecker: 对等体心跳+服务启动时间
- MetricsHandler: Prometheus /metrics端点,7项指标

全部零外部依赖,100%标准库实现
2026-05-28 17:44:27 +08:00
xiaowei bf105f0fd9 feat(M3-M6): 核心API + 蒸馏 + 治理 + 自优化引擎
M3 核心 API (core.go 173行):/api/v1/commit /recall /bootstrap /stats /batch-commit
M3 SSE推送 (ws.go 117行):零外部依赖,Server-Sent Events
M3 server.go:注册全部7条路由

M4 蒸馏引擎 (distill/engine.go 150行):
- Layer1硬规则过滤 + Layer2 LLM蒸馏
- 每日50次限额 + 降级策略(LLM不可用→规则提取)
- /api/v1/feedback/useful /not-useful

M5 治理 (governance/governance.go 222行):
- 冲突检测:entity/fact/decision三种 + 否定词启发式
- 遗忘策略:线性衰减 + core记忆保护
- 知识图谱:SQLite + 双向BFS多跳导航 + 修剪

M6 自优化 (selfoptimize/selfoptimize.go 272行):
- 自优化仪表盘:7项指标 + 告警阈值
- 知识缺口检测:连续3次miss→typeA/B/C/D自动分类
- 因果追踪:版本链 + 依赖链 + 来源信任度
- 记忆预取:共访关系图谱 >60%概率推送

M2修复:lancedb.go 补充 InsertEpisode/GetTopByQuality/InsertMemory/LanceDB别名
全部零外部依赖,100%标准库实现
2026-05-28 17:42:47 +08:00
xiaowei ad671bda34 feat(M2): 存储层完成 2026-05-28 17:35:25 +08:00
xiaowei 6667d42e14 feat(M1): Go API 服务器骨架 + Auth 中间件 + /health 端点
M1.3: Go HTTP 服务器 (net/http, /health, Auth middleware)
M1.4: Protobuf IPC 定义 (Go↔Rust Consolidation 服务)

验收:
- /health → 200 {"status":"ok","service":"zhiyid","version":"0.1.0"}
- 无 X-API-Key → 401
- 正确 Key → 200
- 错误 Key → 401

文件:
- go/cmd/zhiyid/main.go (127 行, 优雅关闭)
- go/internal/api/server.go (31 行, 路由注册)
- go/internal/api/middleware/auth.go (38 行, X-API-Key)
- go/internal/api/routes/health.go (24 行)
- go/proto/consolidate.proto (72 行, 4 RPC)
2026-05-28 17:16:52 +08:00
xiaowei cfb52518e4 feat: 织忆 MemoryWeave 项目初始化
- Go 项目骨架 (zhiyid daemon, port 7821)
- Rust 项目骨架 (zhiyi-consolidate sidecar)
- 完整设计文档 v3.8 (DESIGN.md)
- 实施计划 8 个里程碑 (IMPLEMENTATION.md)
- systemd 部署文件
- Makefile 构建系统
2026-05-28 17:03:54 +08:00