test(identify): cover the protobuf structure-scoring branch - #6
Merged
Conversation
The coverage gate named three uncovered lines, none annotated
`// cov:unreachable`: the `Confidence::Medium` arm in `detect_protobuf`
(identify.rs:478) and the two counting arms in `count_structure` (504, 505).
All three are reachable from one input, and no existing test built it. A
protobuf message scores Medium only when its length-delimited fields carry
corroborating structure -- a nested submessage or a string -- and no stronger
reading is competing. Opaque scalars alone stay Low, because a permissive
wire format parses plenty of byte runs by coincidence.
The fixture is hand-assembled so it reads as wire format rather than as an
opaque blob:
0A 05 "hello" field 1, LEN, five text bytes -> a string
12 02 08 01 field 2, LEN, holding `08 01` -> a nested message
The second test feeds the same bytes with `strong_present = true`. The
structure is identical, so the only thing that can change the verdict is the
flag itself -- anything but a downgrade to Low would mean it is not consulted.
Tests only; no production code changes. Verified with CI's exact invocation
(`cargo llvm-cov --all-features` + `scripts/coverage-gate.py`), which now
reports 100% line and function coverage.
h4x0r
marked this pull request as ready for review
August 4, 2026 04:04
h4x0r
added a commit
that referenced
this pull request
Aug 4, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The coverage gate on
mainnamed three uncovered lines, none annotated// cov:unreachable: theConfidence::Mediumarm indetect_protobuf(identify.rs:478) and both counting arms incount_structure(504, 505).All three are reachable from one input that no existing test built — a protobuf message whose length-delimited fields carry corroborating structure (a nested submessage and a string), scored without a stronger competing reading. A companion test feeds the identical bytes with
strong_present = true, so the only thing that can move the verdict is the flag itself.Tests only; no production code changes.
Verification — CI’s exact invocation, not a local approximation:
cargo llvm-cov --all-features --json+scripts/coverage-gate.py→ OK: 100% line + function coveragecargo fmt --all -- --check— cleancargo clippy --workspace --all-targets --all-features -- -D warnings— cleancargo test --workspace --all-features— all suites pass