Skip to content

fix(coverage): make the patch gate visible and correct under a --dir subdirectory#24

Merged
pedromvgomes merged 1 commit into
mainfrom
feature/patch-coverage-alignment
Jul 18, 2026
Merged

fix(coverage): make the patch gate visible and correct under a --dir subdirectory#24
pedromvgomes merged 1 commit into
mainfrom
feature/patch-coverage-alignment

Conversation

@pedromvgomes

Copy link
Copy Markdown
Contributor

Motivated by wardnet/wardnet#957: bulwark posted a green summary (rust aggregate flat at 86.4%) while codecov/patch failed the very same diff at 83.21% — computed from the very same lcov export our pipeline produced. Two defects let that happen, both fixed here.

ChangedLines was repo-root-relative; everything else is --dir-relative. The git diff runs inside --dir, but git emits paths relative to the repository root, so with --dir source every changed file came back as source/daemon/... while the crate/package prefixes (and lcov normalization, and the Go module) all work in --dir-relative terms. Nothing matched, the patch denominator was empty, and the gate silently measured nothing. --relative fixes the paths and also scopes the diff to --dir, which is the gate's remit anyway — changes outside --dir aren't measured, so they can't be gated. Regression test drives a real repo from a subdirectory and asserts the dir-relative key plus exclusion of an outside-dir change.

A skipped patch gate now says so. When a detected language's patch gate is enabled and the diff touches that language's files but no per-line source was resolved (no lcov for the crate, no lcov reporter in a TS package), patchReport used to continue — indistinguishable in the PR comment from "patch coverage passed". It now prints an [UNMEASURED] <lang> patch: ... line (which the action's generic bracketed-tag grep already picks up, no action.yml change needed) plus a stderr warning naming the missing wiring per language. Never a failure on its own, mirroring the aggregate gate's [UNMEASURED] handling. Scoped to detected ecosystems so the default-enabled gates don't produce lines for a stray changed file of a language the repo doesn't use.

Verified end-to-end against a wardnet-shaped fixture (subdirectory --dir, seeded bulwark-state baseline, --tests=skip): with the lcov present the gate now computes and fails an uncovered new line (rust patch: 0.0% (0/1 new lines; baseline 86.4%)); with it missing, the run stays green but reports [UNMEASURED] with the hint. go test -race ./... green; docs updated in AGENTS.md.

The companion wiring on the consumer side is wardnet/wardnet's coverage workflow (restoring the lcov exports and passing rust-lcov-report); a release needs to be cut here for consumers to pick this up, since the action installs the latest release binary.


Generated by Claude Code

…subdirectory

Two fixes to how the patch gate lines up with what Codecov reports for the
same diff (wardnet/wardnet#957 shipped a green bulwark summary next to a red
codecov/patch computed from the very same lcov export):

- ChangedLines now passes --relative: run from a --dir subdirectory it
  emitted repo-root-relative paths, which matched no crate/package prefix,
  so every changed line silently vanished from the patch denominator and
  the gate measured nothing. --relative also scopes the diff to --dir,
  which is the gate's remit anyway.
- A detected language whose files the diff touches but whose per-line
  source is unresolved is now reported as an [UNMEASURED] patch line (plus
  a stderr hint naming the missing wiring) instead of being skipped in
  silence — a gate that didn't run must be distinguishable from a gate
  that passed. Scoped to detected ecosystems so a stray changed file of a
  language the repo doesn't use stays silent, and never a failure on its
  own, mirroring the aggregate gate's [UNMEASURED] handling.
@pedromvgomes
pedromvgomes merged commit b344466 into main Jul 18, 2026
4 checks passed
@pedromvgomes
pedromvgomes deleted the feature/patch-coverage-alignment branch July 18, 2026 17:00
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