Motivation
GraphRAG.save(toJSON:) persists the knowledge graph, but a built index (chunk/entity embeddings + the hybrid retriever state) is thrown away between runs, so every process start re-embeds the whole corpus — expensive with a remote embedder. Persisting and reloading a built index makes startup cheap and offline-repeatable.
Scope
- Extend save/load to round-trip chunk embeddings (and entity embeddings if present) so a reloaded graph doesn't need re-embedding.
- Add a
GraphRAG load path that reconstructs a built instance from a saved graph (rebuild the HybridRetriever index from persisted embeddings without calling the embedder).
- Guard against embedder-dimension mismatch on load (re-embed or error clearly) — consistent with the LightRAG dimension guard already in
Searchers.swift.
- Document the save/load lifecycle.
Files (mostly isolated)
Sources/GraphRAG/Graph/KnowledgeGraph.swift (persistence), Sources/GraphRAG/GraphRAG/Engine.swift (load/rebuild), tests. Low overlap with retrieval/community work.
Acceptance criteria
- Save then load reproduces query results without re-invoking the embedder (verifiable with a throwing/failing embedder on the load path).
- Dimension mismatch on load is handled explicitly.
- CI green.
Context: follow-up to PRs #2 / #3.
Motivation
GraphRAG.save(toJSON:)persists the knowledge graph, but a built index (chunk/entity embeddings + the hybrid retriever state) is thrown away between runs, so every process start re-embeds the whole corpus — expensive with a remote embedder. Persisting and reloading a built index makes startup cheap and offline-repeatable.Scope
GraphRAGload path that reconstructs a built instance from a saved graph (rebuild theHybridRetrieverindex from persisted embeddings without calling the embedder).Searchers.swift.Files (mostly isolated)
Sources/GraphRAG/Graph/KnowledgeGraph.swift(persistence),Sources/GraphRAG/GraphRAG/Engine.swift(load/rebuild), tests. Low overlap with retrieval/community work.Acceptance criteria
Context: follow-up to PRs #2 / #3.