Skip to content

ci(coverage): make the per-file coverage gates real, add branch gates (#396) - #522

Merged
adityamukho merged 5 commits into
v3from
ci/396-coverage-gates
Oct 10, 2026
Merged

adityamukho merged 5 commits into
v3from
ci/396-coverage-gates

Conversation

@adityamukho

Copy link
Copy Markdown
Collaborator

Part of #396 (stays open: durability label, closes on release).

The gate never gated

On every run, coverage-gates.yml printed WARNING: <file> not found in coverage report for all seven modules and passed:

  • cargo llvm-cov --text … || true failed partway: the docker/NFS lock tests could not find pid_ns_helper under cargo-llvm-cov's target dir, so no report was written.
  • Even with a report, --text is annotated source with no per-file percentages, so the grep found nothing.
  • btree_v6 no longer exists on v3.
  • The comment pointed at a coverage-thresholds.toml that did not exist.

Now

  • The job builds pid_ns_helper the way llvm-cov.yml does, runs the whole suite with --branch on a pinned nightly (nightly-2026-10-01), and fails if any test fails.
  • scripts/coverage_gates.py reads cargo llvm-cov report --json --summary-only and checks each file's line and branch percentage against coverage-thresholds.toml. A file missing from the report, or one without branch data, fails.
  • coverage-thresholds.toml is the single source of truth. It covers the WAL, db.rs, fact_log.rs, log_writer.rs, graph/storage.rs, every src/storage file, and the evaluator, executor and stratification. Each floor is the measured value minus one point (no slack at 100%). The file also lists the paths left uncovered on purpose:
    • INT-049 invariant checks
    • browser-only holds_every_page() == false paths
    • the Windows-only WAL delete retry
    • non-EOF WAL read errors, which the fault plan cannot inject

New tests for uncovered error paths

Module Branches before → after Lines
wal.rs 83.3% → 95.5% 98.5%
packed_pages.rs 85.7% → 100% 98.1%
persistent_facts.rs 82.3% → 87.9% 96.9%
btree.rs 84.7% → 85.5% 96.0%
index.rs 75% (both misses in test code) 100%

test_wal_fact_size_limit was broken: it overwrote bytes inside the fact, not its length, so it never reached MAX_FACT_SIZE. It now targets the length field. The remaining branch misses in btree.rs and persistent_facts.rs are mostly INT-049 invariants and branches inside test helpers, which llvm-cov counts too.

Notes

  • Local measurement gotcha (now in docs/TEST_COVERAGE.md): stale binaries in target/llvm-cov-target from an older toolchain or cargo-llvm-cov get merged into the report and zero out functions with #[cfg(test)] fault sites. CI always starts clean.
  • main has the same vacuous gate. I left it alone: v2.x only takes data-integrity and security fixes.

Docs: CHANGELOG (Tests), ROADMAP, TEST_COVERAGE, CLAUDE.md/README test count (1422).

🤖 Generated with Claude Code

https://claude.ai/code/session_012wXxZguv7PgKQjMMH4yJ5h

adityamukho and others added 4 commits October 10, 2026 21:04
…#396)

The gate never checked anything: the instrumented test run failed (lock
tests could not find pid_ns_helper), the report was empty, and every
module was skipped with a warning. It also parsed `--text` output, which
has no per-file percentages, and named btree_v6, gone on v3.

Run the suite with branch coverage on a pinned nightly, fail on a test
failure, and check line and branch floors per file from
coverage-thresholds.toml with scripts/coverage_gates.py. A file missing
from the report, or without branch data, fails. The thresholds file
lists the paths left uncovered on purpose.

Add tests for the uncovered error paths in wal.rs, packed_pages.rs,
persistent_facts.rs and btree.rs; fix the WAL fact-size test, which
never reached the limit.

Part of #396.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_012wXxZguv7PgKQjMMH4yJ5h
Only a race between two loading threads reached the double-check after
the write lock, so cache.rs branch coverage moved between runs and the
gate failed in CI (73.3% < 75%). A backend that holds both reads at a
barrier makes both threads miss.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_012wXxZguv7PgKQjMMH4yJ5h
The concurrent-miss test's backend stubs count as uncovered lines.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_012wXxZguv7PgKQjMMH4yJ5h
@codecov

codecov Bot commented Oct 10, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_012wXxZguv7PgKQjMMH4yJ5h
@adityamukho
adityamukho merged commit 791e7b2 into v3 Oct 10, 2026
24 checks passed
@adityamukho
adityamukho deleted the ci/396-coverage-gates branch October 10, 2026 16:18
adityamukho added a commit that referenced this pull request Oct 10, 2026
All conflicts resolved to v3's side: v3 has its own coverage gates,
thresholds, tests and docs from #522. src/storage/cache.rs auto-merged a
second copy of the concurrent-miss test; kept v3's.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_012wXxZguv7PgKQjMMH4yJ5h
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