Skip to content

Statement coverage to >=80%: finish the unwired modules, then hold the floor #196

Description

@cdeust

Why

test_statement_coverage80 is a MUST at OpenSSF silver and is the first of two criteria blocking the badge (project 13836). Measured in the CI coverage job on main (run 30195080156, coverage.py 7.15.2): 74.83% statement coverage — 27,746 of 37,078 statements in mcp_server. The criterion needs ≥80%, i.e. roughly 1,916 more covered statements.

Coverage is a floor, not the goal: the interesting part of this gap is why the uncovered code is uncovered.

What the gap actually is

21 modules sit at 0% coverage (1,510 statements). Four of them have no importer anywhere in the tree:

Module Statements Importers
mcp_server/infrastructure/git_diff.py 147 0
mcp_server/shared/memory_types.py 145 0
mcp_server/core/context_assembly/condensers.py 136 0
mcp_server/hooks/preemptive_context.py 84 0

These are not deletion candidates by default. An unimported module means the call site it was written for was never built — an unfinished implementation, which is the defect to fix (§9 "if it's built, it must be called", and the standing rule that an unused symbol means a missing implementation, not dead code). For each one: find the intended caller, build it, and test it. Deletion is only correct where the behaviour is proven to live elsewhere already, and that proof goes in the PR.

Another cluster is imported but never exercised (e.g. core/context_assembly/stage_detector.py, 107 statements, 6 importers, 0% covered) — there the importing paths are themselves untested.

Largest remaining gaps by uncovered statements: hooks/session_start.py (300), core/concept_emerger.py (151), infrastructure/sqlite_store_search.py (148), core/ast_extractors.py (145), core/wiki_coverage_dashboard.py (138), core/wiki_view_executor.py (137).

Acceptance criteria

  1. Every one of the four zero-importer modules is resolved: the missing call site is implemented and covered by tests, or the PR proves the behaviour already exists elsewhere and removes the module. One of the two, never "left as is".
  2. Statement coverage over mcp_server is ≥80%, measured by the CI coverage job and quoted in the PR.
  3. The tests added are contract tests, not implementation mirrors: each asserts an observable postcondition, and every failure path added asserts the signal it emits.
  4. A coverage floor is enforced in CI (--cov-fail-under, seeded at the achieved number) so the figure cannot silently fall back.
  5. .bestpractices.json flips test_statement_coverage80 to Met with the measured number, and docs/ASSURANCE-CASE.md § "What this assurance case does NOT claim" is updated in the same PR.

Blocks: OpenSSF silver (project 13836). Roadmap item 1.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions