refactor: dedupe LLM resilience/ingestion retries, type RAG source boundary - #46
Merged
Conversation
…e boundary
- kill 4 type: ignore casts on the RAG->API source boundary via SourceRef(**s)
- collapse ResilientProvider's 4 duplicated breaker/fallback blocks into
_call_with_breaker/_stream_with_breaker
- collapse ingestion's two-pass retry loop into a shared _ingest_batch helper
- type IngestionService.bm25_index as Bm25Index | None instead of Any | None
- add AgentApiError so /agent/query follows the same error-mapping convention
as every other router
- 404 DELETE /collections/{name} on unknown name instead of silently no-oping
- cap concurrent ingest job submission (max_pending_ingest_jobs, default 10),
reject past-cap submissions with 429 instead of unbounded queuing
Claude-Session: https://claude.ai/code/session_01NFJtv7kyDmx4W8u76WW9EC
4 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
type: ignorecasts on the RAG→API source boundary viaSourceRef(**s)unpackingResilientProvider's 4 duplicated breaker/fallback blocks into_call_with_breaker/_stream_with_breaker_ingest_batchhelperIngestionService.bm25_indexasBm25Index | Noneinstead ofAny | NoneAgentApiErrorso/agent/queryfollows the same error-mapping convention as every other routerDELETE /collections/{name}on unknown name instead of silently no-opingmax_pending_ingest_jobs, default 10), reject past-cap submissions with 429No behavior changes except the two explicitly-scoped additions (404 on unknown collection delete, 429 on job-submission cap) — everything else is pure refactor, verified against the existing test suite.
Findings came from a
/thermo-nuclear-code-quality-review+python-anti-patterns+python-code-style+api-design-principlesaudit of the wholelocalrag/package, then implemented in 3 phases by separate agents on disjoint files.Test plan
ruff check localrag/ tests/— all checks passedmypy --ignore-missing-imports --no-strict-optionalon all touched files — no issuespytest tests/ --ignore=tests/integration— 142 passedhttps://claude.ai/code/session_01NFJtv7kyDmx4W8u76WW9EC