ir.coverage

Corpus-coverage diagnostic — what’s on disk vs. what’s actually indexed.

Retrieval can only return what was indexed, and an ingestion gap is silent: a whole folder of reports can be missing from the index with no error (a non-recursive glob once dropped every doc in a research/ / decisions/ subtree — 29% of the corpus — invisibly). Back-translation evals cannot catch this: their gold is drawn from what is already indexed, so an un-indexed doc can never lower a metric. Coverage therefore needs its own check.

reports_coverage() independently walks the reports doc-trees on disk (the raw */*/docs and */*/misc/docs files, plus pocket repos and root-level _name companions, before any filtering), classifies each file with the same inclusion SSOT the ingestion walk uses (ir.sources.report_exclude_reason()), and diffs the should-be-indexed set against the built corpus’s ledger — surfacing exactly the on-disk-but-absent reports that a search would silently miss. packages_coverage() does the same for the packages corpus (repo directories on disk vs. repos in the index), so “the registry has no such package” can be told apart from “the registry is stale”.

Functions

packages_coverage([name, repo_dirs, ...])

Diff the repo directories on disk against the built name packages corpus.

reports_coverage([name, projects_root, ...])

Diff the reports docs tree on disk against the built name corpus.

Classes

CoverageReport(name, on_disk, indexed, excluded)

Disk-vs-index coverage for a filesystem-backed corpus.

class ir.coverage.CoverageReport(name, on_disk, indexed, excluded, missing=list(), ledgered_no_records=list())[source]

Bases: object

Disk-vs-index coverage for a filesystem-backed corpus.

property coverage_ratio: float

Fraction of should-index files that are actually indexed (1.0 = full).

property should_index: int

On-disk files that pass the inclusion rule (indexed + missing).

ir.coverage.packages_coverage(name='packages', *, repo_dirs=None, indexed_paths=None, exclude=None)[source]

Diff the repo directories on disk against the built name packages corpus.

repo_dirs defaults to what a build would scan (ir.sources.package_repo_dirs(): the manifest, then every fleet repo), minus the excluded patterns (default: the local ir exclude file). indexed_paths (each indexed repo’s directory) is read from the registered corpus by default. A repo listed in missing is on disk but not searchable: a discover that misses it is then a stale index (ir build <name>), not a ranking miss.

Return type:

CoverageReport

ir.coverage.reports_coverage(name='reports', *, projects_root=None, indexed_ids=None, exclude_dirs=frozenset({'.git', '.hg', '.ipynb_checkpoints', '.obsidian', '.svn', '.tox', '.venv', '__pycache__', 'build', 'dist', 'node_modules', 'site-packages', 'venv'}))[source]

Diff the reports docs tree on disk against the built name corpus.

Walks every */*/docs and */*/misc/docs folder recursively (raw, no filtering), classifies each *.md with the shared inclusion SSOT, and reports how many includable reports are indexed vs. silently missing. A coverage_ratio below 1.0 means on-disk reports are absent from the index — rebuild with ir build <name>.

indexed_ids (the built corpus’s artifact ids) is read from the registered name corpus by default; pass it explicitly (with projects_root) to diff an arbitrary tree against an arbitrary index without opening a corpus.

Return type:

CoverageReport