Skip to content

feat(coverage): 100% line coverage on src/root.zig (v0.2.0)#3

Merged
SMC17 merged 5 commits into
mainfrom
coverage
May 18, 2026
Merged

feat(coverage): 100% line coverage on src/root.zig (v0.2.0)#3
SMC17 merged 5 commits into
mainfrom
coverage

Conversation

@SMC17

@SMC17 SMC17 commented May 18, 2026

Copy link
Copy Markdown
Owner

Summary

Adopts the zig-cobs v1.2.0 coverage-driver pattern. Closes the Wave-4 fleet-wide gap "we cite test counts without naming what % of code those tests actually exercise" for zig-frame-protocol.

Measured: 100.00% (48/48) line coverage on src/root.zig via kcov against a dedicated coverage-driver executable.

Changes

  • examples/coverage_driver.zig — single-binary driver covering every public function + every error variant.
  • tools/coverage.sh — wrapper that builds + runs kcov + prints % + fails on <80%.
  • .github/workflows/ci.yml — new line-coverage (kcov) job; HTML uploaded as CI artifact.
  • README.md — evidence vocabulary now names coverage-measured (48/48).
  • CHANGELOG.md — v0.2.0 entry.
  • build.zig — new coverage-driver step.
  • build.zig.zon — version 1.0.0 → 0.2.0 (per the no-premature-production-claims doctrine).

Why a coverage-driver instead of zig test

Zig 0.16 test-runner debug-info layout doesn't surface line-coverage to kcov through the nixpkgs build (no libbfd-dev). Plain exe with standard ELF+DWARF works cleanly.

Test plan

  • zig build test --summary all passes.
  • bash tools/coverage.sh → 100.00%.
  • CI confirms the new job passes.

SMC17 and others added 5 commits May 18, 2026 16:14
Adds `zig build doctest` (backed by tools/doctest.sh) that:
- Diffs the README Quickstart code block against examples/quickstart.zig
  byte-for-byte, so README<->code drift fails the build.
- Runs the compiled quickstart binary and asserts the documented
  `wire: N bytes` output line.
- Verifies the README's documented build steps (test, bench,
  example-echo) actually exist in `zig build --help`.

Vendors the README Quickstart verbatim into examples/quickstart.zig
with a header explaining the contract. README and vendored example
agreed on first run — no drift to report.

First-pass scope: one code block locked in, five checks. Follow-ups
can extend the doc-test surface to the wire-format table, the API
signature blocks, and the bench output schema.

Pattern lifted from zig-cobs (d29a51a).
Prior v1.0 + "production-grade hygiene milestone" framing was a Type-I
error class. Two independent reasons it doesn't fit:

  1. Zig itself is on 0.16, not 1.0. No Zig library can claim API
     stability beyond "stable on Zig 0.16 today" until the language
     itself ships 1.0.
  2. Zero production deployment, soak time, or incident history.
     Hygiene-milestone shipping (LICENSE / SECURITY / CI / CODE_OF_CONDUCT
     / dependabot / CODEOWNERS) is real, but it's NOT sufficient for
     "production-grade."

This commit adds:
  - STATUS.md with per-component proof-vocabulary index covering
    buildPacket/parsePacket, encode/decode, CRC32 trailer, COBS wrap,
    the 6-test fuzz harness (10k+100k+bit-corruption+truncation+
    version-rejection+length-tampering), throughput (compiled-only;
    no committed RESULTS.md yet), README/code drift, and the CI
    matrix; plus 4 explicit gates (G1 hardware-verified throughput +
    a real bench/RESULTS.md, G2 soak time, G3 independent protocol/
    security review, G4 Zig 1.0) all marked NOT YET CLOSED.
  - CHANGELOG Unreleased "Honesty correction 2026-05-15" entry naming
    the prior over-claim and pinning the proof vocabulary going forward.

v1.x git tag is honored for changelog continuity, but every reader
should treat this repo as pre-1.0 in semver spirit until G4 + at least
one of G1/G2/G3 close. Same correction is being applied fleet-wide.
Adopts the zig-cobs v1.2.0 coverage-driver pattern. Closes the
Wave-4 fleet-wide gap "we cite test counts without naming what %
of code those tests actually exercise" for zig-frame-protocol.

Measured: 100.00% (48/48) line coverage on src/root.zig via kcov
against a dedicated `coverage-driver` executable that exercises
every public function (packetLen, maxEncodedLen, buildPacket,
encodePacket, encode, parsePacket, decode) and every public error
variant (PayloadTooLarge, BufferTooSmall, Truncated,
InvalidEncoding, ChecksumMismatch, UnsupportedVersion).

What changes:
- examples/coverage_driver.zig (new) — single-binary driver
- tools/coverage.sh (new) — `bash tools/coverage.sh` wrapper that
  builds, runs kcov, prints %, fails on <80%
- build.zig — new `coverage-driver` step installs the exe
- .github/workflows/ci.yml — new `line-coverage (kcov)` job runs
  on every push and uploads kcov HTML as a CI artifact
- README.md — evidence vocabulary now names `coverage-measured`
  with the 48/48 line count
- CHANGELOG.md — v0.2.0 entry
- build.zig.zon — version 1.0.0 → 0.2.0 (per the honesty correction
  doctrine: drop the premature v1.x tag); paths expanded

Verified locally: `bash tools/coverage.sh` prints
"src/root.zig line coverage: 100.00% (48/48)".
`zig build test --summary all` still green.

Why a coverage-driver instead of `zig test`: the Zig 0.16 test runner's
debug-info layout does not surface line-coverage to kcov through the
nixpkgs kcov build (compiled without libbfd-dev). A plain executable
has standard ELF+DWARF and kcov captures it cleanly.
@SMC17 SMC17 merged commit 67ba929 into main May 18, 2026
8 checks passed
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