Skip to content

fix(learning): read the index each knowledge base's provider publishes - #2898

Merged
ZQR1101 merged 1 commit into
HKUDS:devfrom
AyhamJo7:fix/2895-mastery-ready-index
Nov 28, 2026
Merged

ZQR1101 merged 1 commit into
HKUDS:devfrom
AyhamJo7:fix/2895-mastery-ready-index

Conversation

@AyhamJo7

Copy link
Copy Markdown

Description

Mastery Path preparation (scope_snapshot in deeptutor/learning/lesson_evidence.py) looked up each selected knowledge base's index with resolve_storage_dir_for_read(directory, signature_from_embedding_config()), which matches the global embedding signature. Two kinds of ready index never match it:

  • PageIndex, GraphRAG and LightRAG versions are written with a provider signature ("signature": "lightrag" etc.; LightRAG keeps the embedding hash in embedding_signature). provider_uses_embedding_versions() documents that only LlamaIndex keys versions by embedding, and the GraphRAG/PageIndex pipelines read with signature=None.
  • A LlamaIndex knowledge base bound to a different embedding than the global default is read with that binding, as KnowledgeBaseManager.get_rag_storage_path does with entry_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, and latest_ready_provider_version(kb_dir, provider) (the provider probe) for the others. The provider and binding come from resolve_kb_metadata, after resolve_for_rag has 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

  • tests
  • Other: deeptutor/learning

Checklist

  • This PR targets dev.
  • I have read and followed the contribution guidelines.
  • My code follows the project's coding standards.
  • I have run pre-commit run --all-files (I ran ruff check and ruff format --check on the two changed files: clean).
  • I have added relevant tests for my changes.
  • I have updated the documentation (not needed).
  • My changes do not introduce any new security vulnerabilities.

Additional Notes

test_ready_index_of_a_provider_signed_version_is_not_rejected (PageIndex and LightRAG) runs the real scope_snapshot with the real version resolver, a global signature that matches nothing, and a provider version whose readiness comes from the provider probe. Both cases fail on dev with 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.py was not run here (no fastapi in my environment). No live LightRAG or PageIndex knowledge base was used.

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.
@pancacake pancacake added bug Something isn't working backend Python runtime, capabilities, tools, API & CLI labels Nov 27, 2026
@ZQR1101 ZQR1101 self-assigned this Nov 28, 2026

@ZQR1101 ZQR1101 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@ZQR1101
ZQR1101 merged commit 88f38c0 into HKUDS:dev Nov 28, 2026
23 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backend Python runtime, capabilities, tools, API & CLI bug Something isn't working

Projects

Status: No status

Development

Successfully merging this pull request may close these issues.

3 participants