AI CodeOps

Coverage floor

A coverage floor is the lowest test coverage a change may ship with. How teams set one, its pitfalls, and how minCoveragePct works in the AI CodeOps CI check.

A coverage floor is the minimum test coverage percentage a codebase or change must reach to pass a quality check. If the measured coverage is below the floor, the check fails.

What it is

Coverage tools measure how much of the code the tests executed, usually as a percentage of lines, statements or branches. A floor sets a minimum on that number, for example 80% line coverage, and a CI step fails when the run comes in lower. Some teams apply the floor to the whole project, others only to the lines a change touched.

A floor measures how much code ran during tests, not whether the tests checked anything. A test with no assertions still adds coverage.

Why it matters

Coverage tends to slide when no one watches it, and a floor stops the slide. It's most useful as a ratchet: set it near today's number and raise it as coverage improves. For AI-written changes it's a cheap signal that the session wrote tests along with the code, not instead of them.

In AI CodeOps

The coverage floor is the minCoveragePct option of the release check your CI calls, POST /api/release/check:

{ "pullRequestURL": "https://github.com/acme/checkout/pull/42", "minCoveragePct": 80 }

When a session runs your tests in its sandbox, AI CodeOps parses the coverage figure from the test output when the output carries a summary: a pytest-cov TOTAL line, an Istanbul All files row (Jest, Vitest; the first column, which is statements), or a labelled line such as coverage: 85.3%. It stores the figure with the test run as a whole number, rounded down.

With minCoveragePct set, the most recent test run that reported coverage must meet it. A shortfall denies the release:

{
  "allowed": false,
  "reasons": ["Coverage 71% is below the required 80%"],
  "coverageShortfall": { "coveragePct": 71, "required": 80 }
}

Two details matter:

  • No coverage reported, no coverage gate. If no test run reported coverage, the floor isn't applied and the change isn't denied for it. Make your project's test command print a coverage summary, for example pytest --cov or vitest run --coverage, if you want the floor to bite.
  • CI only. The quality gate in the console blocks failing tests but doesn't check coverage, and the Release gate page has no coverage field. Set the floor in the API call.

Failing tests are a separate check: any recorded test run with a failed test or a non-zero exit code denies the release, whatever the coverage. The full option list is on the API page, and how tests run is on the testing page.

Frequently asked questions

Does AI CodeOps deny a change when no coverage was reported?

No. With minCoveragePct set, the most recent test run that reported coverage must meet it. If none reported coverage, coverage isn't gated.

Is the coverage floor on by default?

No. It applies only when your CI passes minCoveragePct to the release check. The per-session gate in the console doesn't check coverage.

Which coverage number does AI CodeOps use?

Line coverage, read from the test output when it carries a summary, such as a pytest-cov TOTAL line or an Istanbul All files row.