Skip to content

fix(coverage): honor repository coverage source instead of excluding tools #2010

Description

@seonghobae

Defect

ContextualWisdomLab/newsdom-api declares its owned Python coverage boundary in pyproject.toml as:

[tool.coverage.run]
source = ["src/newsdom_api", "tools"]
branch = true

[tool.coverage.report]
fail_under = 100

but the live repository test workflow invokes:

uv run pytest --cov=src/newsdom_api --cov-branch --cov-report=term-missing --cov-fail-under=100

The explicit --cov=src/newsdom_api narrows coverage.py's source selection and excludes production tools/*.py, even though the project-level authority includes tools and fleet quality policy requires owned production statement/branch coverage 100%.

Exact evidence

Consumer canary: ContextualWisdomLab/newsdom-api#820@d1424fdd05b6fc8a7acffbfe9593f67971e2b376, tests run 34112404701, pytest job 101711385647.

The job collected 492 tests and tests/test_tools_export_jsonl.py passed all 9 tests, but the coverage table contained only src/newsdom_api/* and reported 829 statements / 254 branches at 100%. No tools/export_jsonl.py row was measured. The run ultimately failed for unrelated CHANGELOG regressions; those were repaired by normal descendant 28d63d699abb2d777f988e56fac5d32486dc9f97, whose tests run 34112582990 is terminal SUCCESS. That success still uses the same narrowed workflow command, so it is not evidence of 100% statement/branch coverage for the exporter.

Current workflow path in consumer: .github/workflows/tests.yml; current command is the explicit --cov=src/newsdom_api invocation above. The consumer should not add # pragma: no cover, reduce thresholds, or maintain an ad-hoc second coverage contract to compensate.

Owner boundary

CI/review/security/release is the organization .github foundation responsibility. Keep the consumer feature PR focused on its domain behavior. Repair this through the canonical reusable workflow/thin-caller or organization CI contract rather than proliferating per-repository coverage semantics.

RED

A deterministic contract should prove that when a repository declares more than one production coverage source, an explicit workflow --cov=<subset> can still produce a nominal 100% report while an owned source tree is unmeasured. newsdom-api provides the concrete canary: tools/export_jsonl.py executes in tests but is absent from the coverage report.

GREEN acceptance

  • Central/reusable Python coverage execution honors the repository's declared [tool.coverage.run].source, or otherwise consumes an immutable trusted source list without narrowing it in a leaf caller.
  • On unchanged newsdom-api#820 exact head, the coverage report includes both src/newsdom_api and tools, with production statement coverage 100% and branch coverage 100%.
  • Missing/unmeasured production source is fail-closed, not treated as 100%.
  • Existing 100% threshold, warning-as-error behavior, test execution and branch protection remain intact.
  • No coverage exclusion marker, test deletion, source-neutral retrigger, self-approval, or gate weakening.
  • The repaired central workflow is exact-SHA validated, documented, and released/versioned if consumed cross-repository; the consumer then bumps to that immutable release and re-proves exact-head GREEN.

This issue is evidence/acceptance only from the fleet loop; no .github source/docs/refs/PR-state was mutated.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingpriority: highHigh-priority or P1 work

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions