diff --git a/go/internal/api/server.go b/go/internal/api/server.go index eed0e6e..70f0e5e 100644 --- a/go/internal/api/server.go +++ b/go/internal/api/server.go @@ -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) diff --git a/go/internal/governance/graph_sqlite.go b/go/internal/governance/graph_sqlite.go index c92ba32..06049a7 100644 --- a/go/internal/governance/graph_sqlite.go +++ b/go/internal/governance/graph_sqlite.go @@ -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)