Repository navigation
fix(learning): read the index each knowledge base's provider publishes - #2898
Conversation
Mastery Path preparation looked up a knowledge base's index by the global embedding signature. PageIndex, GraphRAG and LightRAG versions carry a provider signature instead, and a LlamaIndex knowledge base can be bound to another embedding, so a ready index was rejected with 'no compatible completed index'. Preparation now resolves the index the way the provider reads it: the KB's bound embedding for LlamaIndex, the newest provider-ready version otherwise. Fixes HKUDS#2895.
ZQR1101
left a comment
There was a problem hiding this comment.
This is a clean, correctly diagnosed fix for #2895. Mastery Path preparation looked up each selected knowledge base with resolve_storage_dir_for_read(..., signature_from_embedding_config()), so two kinds of already-ready index were rejected with "no compatible completed index": PageIndex / GraphRAG / LightRAG versions, which publish a provider signature rather than an embedding hash, and a LlamaIndex knowledge base bound to a non-default embedding.
ready_index_storage now resolves the index the way the provider itself reads it: entry_signature(entry) for LlamaIndex (same as get_rag_storage_path), and latest_ready_provider_version for the others, after resolve_for_rag has authorized the knowledge base. A knowledge base with no config entry keeps the previous LlamaIndex + global-signature behavior. The new PageIndex / LightRAG test runs the real scope_snapshot against a global signature that matches nothing, and fails on dev as described.
Non-blocking: the new test does not cover GraphRAG, PageIndex OSS, or a LlamaIndex KB bound to a non-global embedding — the last of those is a distinct code path and would be worth locking in. LightRAG / GraphRAG query paths can also prefer a binding-compatible version via bound_graph_storage_root when a republish failed; preparation will take the newest probe-ready version. That only matters when multiple versions exist, and it does not affect the reported bug.
CI is green on the current head, and the touched files have not changed on dev.
Description
Mastery Path preparation (
scope_snapshotindeeptutor/learning/lesson_evidence.py) looked up each selected knowledge base's index withresolve_storage_dir_for_read(directory, signature_from_embedding_config()), which matches the global embedding signature. Two kinds of ready index never match it:"signature": "lightrag"etc.; LightRAG keeps the embedding hash inembedding_signature).provider_uses_embedding_versions()documents that only LlamaIndex keys versions by embedding, and the GraphRAG/PageIndex pipelines read withsignature=None.KnowledgeBaseManager.get_rag_storage_pathdoes withentry_signature(entry).In both cases preparation stopped with "A selected knowledge base has no compatible completed index".
The new
ready_index_storage(kb_ref, kb_dir)resolves the index the way the provider reads it:resolve_storage_dir_for_read(kb_dir, entry_signature(entry))for LlamaIndex, andlatest_ready_provider_version(kb_dir, provider)(the provider probe) for the others. The provider and binding come fromresolve_kb_metadata, afterresolve_for_raghas already authorized the knowledge base. A knowledge base with no config entry keeps the previous behavior (LlamaIndex with the global signature).Related Issues
Module(s) Affected
testsdeeptutor/learningChecklist
dev.pre-commit run --all-files(I ranruff checkandruff format --checkon the two changed files: clean).Additional Notes
test_ready_index_of_a_provider_signed_version_is_not_rejected(PageIndex and LightRAG) runs the realscope_snapshotwith the real version resolver, a global signature that matches nothing, and a provider version whose readiness comes from the provider probe. Both cases fail ondevwith the issue's message and pass with this change, and the fix file restores byte-identical afterwards.pytest tests/services/rag/test_index_probe.py tests/services/rag/test_mastery_source_pages.py tests/agents/chat/test_mastery_source_request_boundary.py: 113 passed.tests/api/test_mastery_path_reviews.pywas not run here (nofastapiin my environment). No live LightRAG or PageIndex knowledge base was used.