Skip to content

refactor: dedupe LLM resilience/ingestion retries, type RAG source boundary - #46

Merged
n0nuser merged 1 commit into
mainfrom
feat/code-quality-review-fixes
Jul 8, 2026
Merged

refactor: dedupe LLM resilience/ingestion retries, type RAG source boundary#46
n0nuser merged 1 commit into
mainfrom
feat/code-quality-review-fixes

Conversation

@n0nuser

@n0nuser n0nuser commented Jul 8, 2026

Copy link
Copy Markdown
Owner

Summary

  • Kill 4 type: ignore casts on the RAG→API source boundary via SourceRef(**s) unpacking
  • 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

No 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-principles audit of the whole localrag/ package, then implemented in 3 phases by separate agents on disjoint files.

Test plan

  • ruff check localrag/ tests/ — all checks passed
  • mypy --ignore-missing-imports --no-strict-optional on all touched files — no issues
  • pytest tests/ --ignore=tests/integration — 142 passed
  • Reviewer: confirm 429/404 behavior changes are acceptable (not pure refactor)

https://claude.ai/code/session_01NFJtv7kyDmx4W8u76WW9EC

…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
@n0nuser
n0nuser merged commit 33866e5 into main Jul 8, 2026
8 of 9 checks passed
@n0nuser
n0nuser deleted the feat/code-quality-review-fixes branch July 8, 2026 19:18
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.

1 participant