fix E4.3: 回退 FileGraph,恢复 SQLiteGraphStore(数据在 graph.db)

切换 FileGraph 导致 9.9MB 历史图谱数据丢失。
恢复 NewSQLiteGraphStore,GetEntityDegree 加到 SQLiteGraphStore。
验证:1720 节点,32983 边。
This commit is contained in:
xiaowei 2026-06-01 01:16:31 +08:00
parent 2d0923a85c
commit 525b5f2bb2
2 changed files with 8 additions and 3 deletions

View File

@ -99,13 +99,13 @@ func NewServer() http.Handler {
graphPath = "/var/lib/memoryweave/graph.db"
}
var graphStore governance.GraphStore
gs, err := governance.NewFileGraph(graphPath)
gs, err := governance.NewSQLiteGraphStore(graphPath)
if err != nil {
log.Printf("[zhiyid] WARN: FileGraph 初始化失败 (%v),降级为 InMemoryGraph", err)
log.Printf("[zhiyid] WARN: SQLite 图谱初始化失败 (%v),降级为 InMemoryGraph", err)
graphStore = governance.NewInMemoryGraph()
} else {
graphStore = gs
log.Printf("[zhiyid] 图谱后端: FileGraph — %s", graphPath)
log.Printf("[zhiyid] 图谱后端: SQLiteGraphStore — %s", graphPath)
}
graphUpdater := governance.NewAutoGraphUpdater(graphStore)
graphAPI := routes.NewGraphAPI(graphStore)

View File

@ -818,6 +818,11 @@ func (gs *SQLiteGraphStore) EvidenceCount(entity string) int {
return sum
}
// GetEntityDegree E4.3: 返回实体的图谱度(入度+出度),度越高越优先保留
func (gs *SQLiteGraphStore) GetEntityDegree(entity string) int {
return gs.EvidenceCount(entity)
}
// ─── CGO 工具 ──────────────────────────────────────────
// UpdatePageRanks 批量更新节点的 pagerank 值§2.5.5