unsloth/studio/backend/core/rag
Daniel Han ab0828b976 Studio: fix RAG correctness bugs
Backend:
- Deterministic SQLite connection cleanup. The RAG code used bare
  `with get_connection() as conn:`, which commits but never closes, leaning
  on GC to release handles (the rest of studio_db closes explicitly). Add a
  closing_connection() context manager that commits/rolls back like sqlite3's
  own manager and always closes, and route all 30 RAG call sites through it.
- filter_by_min_score no longer drops BM25-only and figure-ref hits. min_score
  is a cosine floor, so it now gates only hits that carry a dense_score;
  lexical and figure-ref hits (dense_score is None) pass through instead of
  being silently discarded when the floor is raised.
- Fix two tests that could not pass against the production code: the RRF
  fusion test asserted the wrong winner (c edges out b: 0.032266 vs 0.032258),
  and two tool-handler scope tests stubbed retrieve_hybrid without accepting
  the embedder_model kwarg the handler now passes (TypeError was swallowed,
  leaving captured["scope"] unset).

Frontend:
- Removing an in-flight upload chip now routes through the teardown thunk
  already registered for the aggregate-progress toast (abort, unsubscribe,
  release the index slot, delete the backend doc with the correct kb/thread
  scope key it closed over) and clears the toast entry. Deleting directly
  leaked the concurrency slot and hardcoded the thread scope, mis-targeting
  KB-scoped docs. Applied in both the composer hook and the compare-view
  composer; drop the now-vestigial chip-scope-key tracking and unused
  activeThreadId selectors. Add index-progress-store.remove(id).
2026-05-31 09:56:23 +00:00
..
parsers Studio: tighten RAG code comments 2026-05-31 08:31:08 +00:00
__init__.py Studio: add RAG with hybrid search, reranker, chat integration 2026-05-23 18:46:15 +04:00
authorization.py Studio: fix RAG correctness bugs 2026-05-31 09:56:23 +00:00
bm25.py Studio: trim verbose comments/docstrings across RAG code 2026-05-26 13:51:11 +04:00
captioner.py Studio: tighten RAG code comments 2026-05-31 08:31:08 +00:00
chunking.py Studio: tighten RAG code comments 2026-05-31 08:31:08 +00:00
db.py Studio: trim verbose comments/docstrings across RAG code 2026-05-26 13:51:11 +04:00
embeddings.py Studio: tighten RAG code comments 2026-05-31 08:31:08 +00:00
ingestion.py Studio: fix RAG correctness bugs 2026-05-31 09:56:23 +00:00
locators.py Studio: fix RAG correctness bugs 2026-05-31 09:56:23 +00:00
reranker.py Studio: tighten RAG code comments 2026-05-31 08:31:08 +00:00
retrieval.py Studio: fix RAG correctness bugs 2026-05-31 09:56:23 +00:00
scope.py Studio: fix RAG correctness bugs 2026-05-31 09:56:23 +00:00
tool.py Studio: fix RAG correctness bugs 2026-05-31 09:56:23 +00:00
vector_store.py Studio: WIP — RAG preview UI, locator/auth refactor, tests, fixtures (pre-merge snapshot) 2026-05-28 00:13:43 +03:00