Skip to content

test: raise coverage to 100%, gate CI at 95% - #19

Merged
man4ish merged 1 commit into
mainfrom
chore/increase-test-coverage
Sep 4, 2026
Merged

test: raise coverage to 100%, gate CI at 95%#19
man4ish merged 1 commit into
mainfrom
chore/increase-test-coverage

Conversation

@man4ish

@man4ish man4ish commented Sep 4, 2026

Copy link
Copy Markdown
Collaborator

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 beyond tmp_path) closing every real gap.

  • 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.
  • rag/engine.py: _load_llm_model's fallback paths, ollama_embed's retry branches, and RAGEngine.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 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.

🤖 Generated with Claude Code

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
@man4ish
man4ish merged commit 4c47af8 into main Sep 4, 2026
3 checks passed
@man4ish
man4ish deleted the chore/increase-test-coverage branch September 4, 2026 02:19
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