Coverage exclusion policy
RAG006 sets two coverage floors on the backend (src/rag_sample/) and the SPA (frontend/src/), each measured on its own and enforced as a CI hard-fail: a 90% aggregate floor and a 70% per-file floor for any non-excluded file, on combined line and branch coverage for the backend and on each of lines, branches, functions and statements for the SPA. This page is the companion exclusion policy. It is intentionally maintained outside the ADR so it can evolve without amending the decision.
Both numbers in RAG006 are floors, not targets. Coverage above the floors is fine; below either floor fails CI.
What is excluded
Section titled “What is excluded”Backend
Section titled “Backend”The following are excluded from coverage measurement through [tool.coverage.run] omit in the app repo’s backend/pyproject.toml:
| Path or pattern | Reason |
|---|---|
src/rag_sample/__init__.py and the package __init__.py files (db, api, api/authorizer, ingestion, providers, tools) | Trivial re-exports; coverage adds no signal |
src/rag_sample/api/__main__.py and src/rag_sample/tools/__main__.py | Module entrypoints run as scripts; not exercised by unit tests |
src/rag_sample/api/lambda_handler.py (the Mangum entrypoint) | One-liner handler = Mangum(app); covered functionally via integration testing only |
The following are excluded from coverage measurement through the Vitest coverage exclude list in frontend/vite.config.ts:
| Path or pattern | Reason |
|---|---|
src/main.tsx | Entrypoint that mounts the app; no logic to unit-test |
src/**/*.d.ts | Type declarations; no runtime code |
src/**/*.test.{ts,tsx} and src/test/** | Test code and test setup, not application code |
Line-level exclusions
Section titled “Line-level exclusions”Code may opt out of coverage at line granularity using # pragma: no cover (backend) or the Vitest v8 comments /* v8 ignore next */ and /* v8 ignore start */ … /* v8 ignore stop */ (SPA). Use these only for branches that cannot meaningfully be tested:
- defensive
if TYPE_CHECKING:blocks - platform-specific code paths that the CI environment does not exercise (rare in this product)
raise NotImplementedErrorplaceholders in unfinished abstract methods, removed once implemented, and their TypeScript equivalent (throw new Error("not implemented"))
Do not use either form to bypass coverage on logic that is testable but inconvenient. If a branch is hard to test, write a test or refactor the code.
How to change the exclusion list
Section titled “How to change the exclusion list”These lists are the policy of record. Add or remove entries here and update the app repo’s backend/pyproject.toml [tool.coverage.run] omit (backend) or the Vitest coverage exclude list in frontend/vite.config.ts (SPA) to match. No ADR amendment is required — RAG006 references this page rather than enumerating the exclusions itself.
Two operational notes:
- Never add an entry just to dodge a failing CI run. Investigate why coverage dropped and fix the underlying gap before considering an exclusion. Exclusions are for code that genuinely cannot be unit-tested, not for code that is hard to unit-test.
- Keep the list short. A growing exclusion list lowers the effective floor. If the list grows beyond a handful of entries, that is a signal to revisit RAG006.
Enforcement
Section titled “Enforcement”The coverage commands and configuration live in the app repo; the backend exclusion list applies through [tool.coverage.run] omit in backend/pyproject.toml.
On the backend, a script over the coverage json report enforces both floors as a CI step after the suite, on coverage.py’s combined line and branch figure, since pytest-cov has no native per-file threshold. On the SPA, Vitest coverage thresholds enforce both floors on each of lines, branches, functions and statements, since Vitest reports no combined figure.
© 2026 Benjamin Arunski