Skip to content

refactor(rag): fix N+1 query, extract helpers, simplify router - #48

Merged
Cipher208 merged 2 commits into
masterfrom
refactor/rag-engine
Jul 4, 2026
Merged

Cipher208 merged 2 commits into
masterfrom
refactor/rag-engine

Conversation

@Cipher208

Copy link
Copy Markdown
Owner

Changes

  • N+1 query fix: _search_rrf now batches page lookups with IN clause instead of N individual queries
  • _insert_page helper: Extracted shared FTS insert logic from ingest_file/ingest_text (deduplication)
  • _match_route helper: Flattened nested route matching in router.py

Verification

  • 372 tests pass
  • ruff lint clean
  • Repowise Hotspot: 3.88 → 4.28 (+0.40)

- Fix N+1 query in _search_rrf: batch page lookups with IN clause
- Extract _insert_page helper from ingest_file/ingest_text (dedup FTS insert)
- Extract _match_route helper from route() (flatten nested matching)
@codecov-commenter

Copy link
Copy Markdown

⚠️ Please install the 'codecov app svg image' to ensure uploads and comments are reliably processed by Codecov.

Codecov Report

❌ Patch coverage is 83.67347% with 8 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
rag/engine.py 73.07% 7 Missing ⚠️
rag/router.py 95.65% 1 Missing ⚠️

📢 Thoughts on this report? Let us know!

@Cipher208
Cipher208 merged commit c002365 into master Jul 4, 2026
18 checks passed
@Cipher208
Cipher208 deleted the refactor/rag-engine branch July 4, 2026 02:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants