Files
memoryweave/go/internal/storage/lancedb.go
T
xiaowei 43286dd2d7 G7.1+G7.2: skill persistence + crystallize API
G7.1 — Skill 持久化:
- BetaSkill: prompt_template, linked_memory_ids, linked_entities, created_at
- BayesianSkillManager: EnableRedisPersistence(), loadFromRedis(), persistSkill()
- Redis HASH (zhiyi:skills) 持久化,重启不丢 skills
- Skill CRUD API: POST/GET/DELETE /api/v1/skills/{name}
- auto_distill skill: ETA=0.93, status=active after 12 trials ✓

G7.2 — Skill 结晶:
- GetSkillCandidates(minRecalls, limit): storage.LanceDB 接口扩展
- SQLiteClient: SQL 查询候选(recall_count>=5, quality_score>=0.7)
- RustLanceDBClient/MemLanceClient: stub 实现
- /api/v1/crystallize/candidates: 获取候选记忆
- /api/v1/crystallize/memory/{id}: 对记忆执行 LLM 结晶
- callSkillLLM(): LLM 生成 prompt 模板(带降级)
- RegisterLDBGetter(): routes 包访问 LanceDB 实例
2026-06-02 00:01:59 +08:00

34 lines
1.5 KiB
Go
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
// 织忆 MemoryWeave — LanceDB 接口定义
// 所有存储后端实现此接口,Go → Rust IPC 由 internal/consolidate 负责
package storage
import "github.com/xiaoxue/memoryweave/internal/models"
// VValueProvider 外部注入的 V 值查询函数(由 server.go 设置 → selfoptimize.VProp)
// 用于召回排序时融合用户决策信号
var VValueProvider func(memoryID string) float64
// LanceDB 存储后端统一接口
// 实现者: SQLiteClient (生产), MemLanceClient (开发/降级)
// 未来: Rust lancedb crate 通过 Unix Socket 提供 LanceDB 原生后端
type LanceDB interface {
InsertEpisode(agentID, namespace, content, category string) (string, error)
GetTopByQuality(agentID string, limit int) ([]models.MemoryRecord, error)
Stats() (map[string]interface{}, error)
SoftDelete(id, reason string) error
GetVersionHistory(id string) ([]map[string]interface{}, error)
GetCandidatesForForgetting() ([]map[string]interface{}, error)
// G7.2: 获取适合结晶为 skill 的记忆候选
GetSkillCandidates(minRecalls, limit int) ([]models.MemoryRecord, error)
Backup(path string) error
GetAuditLog(limit int) ([]map[string]interface{}, error)
IncrementUseful(id string)
IncrementNotUseful(id string)
UpdateMemoryContent(id, newContent, source string) error
InsertMemory(m models.MemoryRecord) error
Search(table string, vector []float32, topK int, namespaceFilter string) ([]models.MemoryRecord, error)
Insert(table string, record any) error
Update(table, id string, fields map[string]any) error
}