test: raise coverage to 100%, gate CI at 95% - #19
Merged
Conversation
Baseline was 95.83% (840 stmts, 35 missing across api/main.py, ingestion/doc_loader.py, processing/chunker.py, rag/engine.py). Added targeted unit tests for the real gaps, all mocked -- no live network, Ollama, or filesystem side effects beyond tmp_path: - api/main.py: the "no persisted FAISS index" startup warning (via a scoped importlib.reload with VectorStore.load patched) and /status's repo-name extraction/dedup loop. - ingestion/doc_loader.py: the work/-subtree skip branch and the per-file exception handler that lets one unreadable .md not abort the whole walk. - rag/engine.py: _load_llm_model's missing-file/malformed-YAML/ non-dict fallback paths, ollama_embed's retry-then-succeed and retry-exhausted-then-raise branches, and RAGEngine.stream_llm's entire NDJSON-streaming generator (token yielding, done-break, inline [LLM_ERROR] on failure) -- previously untested altogether. processing/chunker.py's two remaining lines (116, 132) are genuinely unreachable given how `sections` is built and how _split_at_paragraphs behaves on non-empty input -- verified empirically (including with a deliberately negative budget), not just by inspection. Marked `# pragma: no cover` with the reasoning inline rather than left as an unexplained gap. Result: 100.00% (837/837), 212 passed, ruff clean. Also wires coverage into CI for the first time -- ci.yml's test step now runs `pytest --cov`, and .coveragerc gets `fail_under = 95` / `show_missing = true` so this doesn't silently regress. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01VevfQdYwX27LkcGqfRAxQL
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
Baseline was 95.83% (840 stmts, 35 missing) across
api/main.py,ingestion/doc_loader.py,processing/chunker.py,rag/engine.py. Added targeted, fully-mocked unit tests (no live network/Ollama/filesystem side effects beyondtmp_path) closing every real gap.api/main.py: the "no persisted FAISS index" startup warning (via a scopedimportlib.reloadwithVectorStore.loadpatched) and/status's repo-name extraction/dedup loop.ingestion/doc_loader.py: thework/-subtree skip branch and the per-file exception handler.rag/engine.py:_load_llm_model's fallback paths,ollama_embed's retry branches, andRAGEngine.stream_llm's entire NDJSON-streaming generator (previously untested altogether).processing/chunker.py's two remaining lines are genuinely unreachable given the chunker's own invariants — verified empirically (including with a deliberately negative budget), marked# pragma: no coverwith the reasoning inline rather than left as an unexplained gap.Result
100.00% (837/837), 212 passed, ruff clean.
Also wires coverage into CI for the first time —
ci.yml's test step now runspytest --cov, and.coveragercgetsfail_under = 95/show_missing = trueso this doesn't silently regress.🤖 Generated with Claude Code