Skip to content

test(schema): every BitField namespace covers all of its bits - #1416

Merged
JarryShaw merged 1 commit into
mainfrom
fix/1288-bitfield-coverage
Oct 8, 2026
Merged

JarryShaw merged 1 commit into
mainfrom
fix/1288-bitfield-coverage

Conversation

@JarryShaw

@JarryShaw JarryShaw commented Oct 8, 2026 •

Copy link
Copy Markdown
Owner

What is the purpose of your pull request?

  • test — tests only

Description of your pull request and other information

Refs #1288 (which closes once KNOWN_GAPS is empty; HIP is #1417, MH is #1418). New tests/protocols/schema/test_bitfield_coverage_unit.py walks all 104 BitFields under pcapkit/protocols/schema/ and asserts each namespace covers its width with no gap and no overlap. Discovery is cross-checked against the BitField(...) call count per module (AST).

  • 8 ForwardMatchField-wrapped peeks (Quick-Start in hopopt/ipv6_opts/ipv4, SMF-DPD in hopopt/ipv6_opts, MH CGA, TCP MPTCP, PCAP-NG SHB match) are exempt by construction: they pack no octets.
  • 27 real gaps remain, in an exact-match KNOWN_GAPS allowlist: HIP 3 (HIP.ver bits 4-6, RouteDst/RouteViaParameter.flags bits 2-15) and MH 24. Each fix needs the protocol reader, data model and make(), not just the schema, so they want their own PRs.
  • Sensitivity: dropping 'reserved': (0, 4) from SCTP DATAChunk.flags fails the test with 'transport.sctp.DATAChunk.flags': ((0, 4),).

Tests: new module 3 passed / 105 subtests; run_unittest_leg.py protocols/internet 566 OK; protocols --exclude protocols/internet 1056 OK.

Walk every schema under pcapkit.protocols.schema and assert each BitField
names its full width exactly once. ForwardMatchField-wrapped peeks are
exempt (they pack no octets). Discovery is cross-checked against the
BitField(...) call count per module. The 27 remaining HIP and MH gaps are
an explicit KNOWN_GAPS allowlist, matched exactly so a fixed site must
drop its entry.

Closes #1288
@JarryShaw

Copy link
Copy Markdown
Owner Author

Verdict: GOOD TO GO at 9426e78b3 (Sonnet cross-review; author ran on Opus).

  • Discovery: finds all 104 BitFields, matching a gc count of live instances. Stable across 10 PYTHONHASHSEED values.
  • Exemption: ForwardMatchField.pack returns b'' unconditionally (corekit/fields/misc.py:848-860), so exempting those fields is sound. There are 8 such fields, not 9; the body is corrected.
  • Gaps are real: spot-checked HIP.ver (1f → 11), MH Heartbeat flags (ffff → 0003) and MH NAT Detection flags (ffff → 8000).
  • Sensitivity: removing SCTP DATAChunk reserved fails the test, and so does making an allowlist entry stale (exact match).
  • Leg: protocols --exclude protocols/internet gives 1056 tests, 0 failures.
  • Unverified: a Python 3.10 run (only 3.14 has the dependencies locally). A static read finds no 3.11+ API; CI's 3.10 legs will decide.

@JarryShaw JarryShaw added review: good-to-go Cross-review at the current head says ready; CI state is separate and removed review: running A cross-review is in flight against the current head - no verdict yet labels Oct 8, 2026
@github-actions

github-actions Bot commented Oct 8, 2026

Copy link
Copy Markdown
Contributor

Coverage: 89.43% (unit tier, Python 3.14, 9426e78b3, Unit Tests run success)

Package Statements Missed Branches Partial Cover
pcapkit (top level) 104 4 20 4 93.55%
pcapkit/const 18791 968 2352 869 90.90%
pcapkit/corekit 2038 89 634 25 94.76%
pcapkit/dumpkit 234 2 84 2 98.74%
pcapkit/foundation 2637 98 928 48 94.78%
pcapkit/interface 112 7 40 5 92.11%
pcapkit/protocols 16504 219 4420 183 98.04%
pcapkit/toolkit 539 74 168 3 84.58%
pcapkit/utilities 429 4 122 4 98.55%
pcapkit/vendor 4409 2342 1006 157 43.25%

Per-file detail: the coverage-html artifact of this run.

@JarryShaw
JarryShaw merged commit fb1c6c3 into main Oct 8, 2026
41 checks passed
@JarryShaw
JarryShaw deleted the fix/1288-bitfield-coverage branch October 8, 2026 17:22
@JarryShaw JarryShaw removed the review: good-to-go Cross-review at the current head says ready; CI state is separate label Oct 8, 2026
JarryShaw added a commit that referenced this pull request Oct 8, 2026
#1419 (HIP, #1417) and #1421 (MH, #1418) merged after #1416, so all 27
allowlisted sites now name every bit and the exact-match assertion failed
on main. The allowlist stays, empty, for future filed gaps.
@JarryShaw JarryShaw added this to the PyPCAPKit v1.5 milestone Oct 26, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

test Pull requests that add or correct tests (test: subject prefix)

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

1 participant