DeepTutor: Lifelong Personalized Tutoring. https://deeptutor.info/.
Python ai-agentsai-tutorclawbotcli-tooldeepresearchinteractive-learninglearningmulti-agent-systemsrag
fix: display the bound LightRAG version in index provenance
NoxsMedia8d2c452ef59c
diff --git a/deeptutor/knowledge/manager.py b/deeptutor/knowledge/manager.pyindex 681e58fc5..a508a0d2a 100644--- a/deeptutor/knowledge/manager.py+++ b/deeptutor/knowledge/manager.py@@ -1462,6 +1462,8 @@ class KnowledgeBaseManager:published_root_for_embedding(kb_dir, binding_signature) if dir_exists else None)indexing_policy = read_published_policy(published_root)+ if published_root is not None:+ metadata["indexed_version"] = published_root.nameif indexing_policy is None:pending = kb_config.get("pending_indexing_policy")indexing_policy = (diff --git a/tests/services/rag/test_embedding_binding.py b/tests/services/rag/test_embedding_binding.pyindex eea42e555..e246eea1f 100644--- a/tests/services/rag/test_embedding_binding.py+++ b/tests/services/rag/test_embedding_binding.py@@ -142,6 +142,7 @@ def test_lightrag_detail_and_reconciliation_keep_recorded_bound_version(catalog,assert metadata["indexed_embedding_model"] == "embed-a"assert metadata["current_embedding_model"] == ("changed-a" if drift else "embed-a")assert metadata["indexing_policy"]["label"] == "a"+ assert metadata["indexed_version"] == "version-1"def test_lightrag_append_uses_policy_of_actual_bound_index(catalog, tmp_path, monkeypatch):diff --git a/web/components/knowledge/KbIndexVersionsSection.tsx b/web/components/knowledge/KbIndexVersionsSection.tsxindex 956e5e476..c08068665 100644--- a/web/components/knowledge/KbIndexVersionsSection.tsx+++ b/web/components/knowledge/KbIndexVersionsSection.tsx@@ -121,7 +121,11 @@ export default function KbIndexVersionsSection({const publishedLightRagVersion = isLightRag? versions.find(- (version) => version.provider === "lightrag" && version.ready,+ (version) =>+ version.provider === "lightrag" &&+ version.ready &&+ (!kb.metadata?.embedding_selection ||+ version.version === kb.metadata.indexed_version),): undefined;const buildingLightRagVersion = isLightRagdiff --git a/web/lib/knowledge-helpers.ts b/web/lib/knowledge-helpers.tsindex 57a77fe42..09d9a57c7 100644--- a/web/lib/knowledge-helpers.ts+++ b/web/lib/knowledge-helpers.ts@@ -173,6 +173,7 @@ export interface KnowledgeBase {embedding_selection?: { profile_id: string; model_id: string };embedding_status?: "ready" | "missing" | "changed" | "unconfigured" | "legacy";embedding_dim?: number;+ indexed_version?: string;embedding_mismatch?: boolean;indexed_embedding_model?: string;indexed_embedding_dim?: number;diff --git a/web/tests/lightrag-embedding-compatibility.spec.tsx b/web/tests/lightrag-embedding-compatibility.spec.tsxindex b2417307d..39fa03ece 100644--- a/web/tests/lightrag-embedding-compatibility.spec.tsx+++ b/web/tests/lightrag-embedding-compatibility.spec.tsx@@ -50,7 +50,9 @@ const kb: KnowledgeBase = {statistics: {rag_provider: "lightrag",raw_documents: 1,- index_versions: [{ version: "version-1", provider: "lightrag", ready: true }],+ index_versions: [+ { version: "version-1", provider: "lightrag", ready: true },+ ],},};@@ -67,8 +69,12 @@ it("omits mismatch warnings from list cards", () => {onSectionChange={vi.fn()}/>,);- expect(screen.queryByText(/Restore the original configuration/)).not.toBeInTheDocument();- expect(screen.queryByText(/Index embedding.*original-model/)).not.toBeInTheDocument();+ expect(+ screen.queryByText(/Restore the original configuration/),+ ).not.toBeInTheDocument();+ expect(+ screen.queryByText(/Index embedding.*original-model/),+ ).not.toBeInTheDocument();});it("shows detail guidance while files and downloads remain accessible", async () => {@@ -87,9 +93,15 @@ it("shows detail guidance while files and downloads remain accessible", async ()onClearHistory={vi.fn()}/>,);- expect(screen.getByText(/Restore the original configuration/)).toBeInTheDocument();- expect(screen.getByText(/Index embedding.*original-model/)).toBeInTheDocument();- expect(screen.getByText(/Current embedding.*current-model/)).toBeInTheDocument();+ expect(+ screen.getByText(/Restore the original configuration/),+ ).toBeInTheDocument();+ expect(+ screen.getByText(/Index embedding.*original-model/),+ ).toBeInTheDocument();+ expect(+ screen.getByText(/Current embedding.*current-model/),+ ).toBeInTheDocument();fireEvent.click(screen.getByRole("button", { name: "Files" }));fireEvent.click(await screen.findByText("paper.txt"));expect(screen.getByRole("link", { name: "Download" })).toHaveAttribute(@@ -99,24 +111,83 @@ it("shows detail guidance while files and downloads remain accessible", async ()});it("keeps version guidance visible alongside a failed rebuild", async () => {- await act(async () => { render(- <KbIndexVersionsSection- kb={{ ...kb, status: "error" }}- onReindex={vi.fn()}- onUpdatePendingIndexingPolicy={vi.fn()}- />,- ); });- expect(screen.getByText(/Restore the original configuration/)).toBeInTheDocument();- expect(screen.getByText(/Index embedding.*original-model/)).toBeInTheDocument();- expect(screen.getByText(/Current embedding.*current-model/)).toBeInTheDocument();+ await act(async () => {+ render(+ <KbIndexVersionsSection+ kb={{ ...kb, status: "error" }}+ onReindex={vi.fn()}+ onUpdatePendingIndexingPolicy={vi.fn()}+ />,+ );+ });+ expect(+ screen.getByText(/Restore the original configuration/),+ ).toBeInTheDocument();+ expect(+ screen.getByText(/Index embedding.*original-model/),+ ).toBeInTheDocument();+ expect(+ screen.getByText(/Current embedding.*current-model/),+ ).toBeInTheDocument();});-it.each(["ready", "error"])("blocks incompatible appends in %s state and restores them", (status) => {- expect(kbCanUploadDocuments({ ...kb, status }, false)).toBe(false);- expect(- kbCanUploadDocuments(- { ...kb, status, metadata: { ...kb.metadata, embedding_mismatch: false } },- false,- ),- ).toBe(true);+it("shows the recorded bound version rather than a newer unbound publication", async () => {+ await act(async () => {+ render(+ <KbIndexVersionsSection+ kb={{+ ...kb,+ metadata: {+ ...kb.metadata,+ embedding_selection: { profile_id: "p", model_id: "a" },+ indexed_version: "version-1",+ },+ statistics: {+ ...kb.statistics,+ index_versions: [+ {+ version: "version-2",+ provider: "lightrag",+ ready: true,+ indexing_policy: {+ policy: "pinned",+ descriptor: { model: "Newer model" },+ },+ },+ {+ version: "version-1",+ provider: "lightrag",+ ready: true,+ indexing_policy: {+ policy: "pinned",+ descriptor: { model: "Bound model" },+ },+ },+ ],+ },+ }}+ onReindex={vi.fn()}+ onUpdatePendingIndexingPolicy={vi.fn()}+ />,+ );+ });+ const source = screen.getByText("Version source").nextElementSibling;+ expect(source).toHaveTextContent("version-1");});++it.each(["ready", "error"])(+ "blocks incompatible appends in %s state and restores them",+ (status) => {+ expect(kbCanUploadDocuments({ ...kb, status }, false)).toBe(false);+ expect(+ kbCanUploadDocuments(+ {+ ...kb,+ status,+ metadata: { ...kb.metadata, embedding_mismatch: false },+ },+ false,+ ),+ ).toBe(true);+ },+);