Skip to content

fix(corekit): BitField packs every bit its namespace does not name as zero (shared root of the per-protocol reserved-bit issues) #1288

Closed

Description

@JarryShaw

Describe the bug
BitField.pre_process starts from an all-zero buffer (pcapkit/corekit/fields/strings.py:232) and only writes named subfields, so any uncovered bit is lost on pack. This is the shared root of #1199, #1207, #1211, #1212, #1221, #1235 and #1246. Counting BitFields in pcapkit/protocols/schema whose namespace leaves bits uncovered gives 70 (mh 28, tcp 14, hip 5, httpv2 4, hopopt 4, ipv6_opts 4, ipv4 3, sctp 3, pcapng 2, ipv6_frag 1, ipv6_route 1, l2tp 1).

To Reproduce

f = BitField(length=1, namespace={"x": (0, 1), "y": (7, 1)})
v = f.post_process(bytes.fromhex("ff"), {})   # {"x": 1, "y": 1}
f.pre_process(v, {}).hex()                    # "81", not "ff"

Expected behavior
Either post_process keeps the uncovered bits under a hidden key that pre_process ORs back, or each site names them as reserved. A fix at the field fixes all the per-protocol reports at once.

Found by the corekit round-trip audit (#1202). The repro was re-checked by an independent verifier, and I re-ran it on main at 11ae68ebf.

Activity

  1. added
    fixPull requests that fix a defect (fix: subject prefix)
    pendingAccepted and unstarted - nobody is on it and nothing blocks it
    on Oct 7, 2026
  2. JarryShaw commented on Oct 7, 2026

    @JarryShaw
    OwnerAuthor

    Blocked until the per-protocol reserved-bit PRs land (#1226, #1253, #1254 and the IPv6 and HTTP/2 wave PRs). This issue then closes with an invariant test that every BitField namespace covers all of its bits.

  3. added
    blockedDeferred pending another issue or decision; see the last comment for what unblocks it
    and removed
    pendingAccepted and unstarted - nobody is on it and nothing blocks it
    on Oct 7, 2026
  4. moved this from Pending to Blocked in PyPCAPKiton Oct 7, 2026
  5. JarryShaw commented on Oct 8, 2026

    @JarryShaw
    OwnerAuthor

    #1226, #1253 and #1254 have merged. Still blocked until #1235 closes: its remaining HOPOPT/IPv6-Opts reserved-bit sites (MPL, IP_DFF, Quick-Start) have a worker on them now.

  6. JarryShaw commented on Oct 8, 2026

    @JarryShaw
    OwnerAuthor

    Unblocked: #1235 is closed (every site already round-trips on ec2ba13a4). A worker is on the invariant test now.

  7. added
    wipWork in flight - a covering PR is open or an agent is actively on it
    and removed
    blockedDeferred pending another issue or decision; see the last comment for what unblocks it
    on Oct 8, 2026
  8. JarryShaw commented on Oct 8, 2026

    @JarryShaw
    OwnerAuthor

    #1416 adds the invariant test. Its KNOWN_GAPS allowlist holds the 27 sites still unfixed: HIP 3 (#1417) and MH 24 (#1418), both now being worked. This issue closes once that allowlist is empty.

  9. removed
    wipWork in flight - a covering PR is open or an agent is actively on it
    on Oct 8, 2026
  10. JarryShaw commented on Oct 8, 2026

    @JarryShaw
    OwnerAuthor

    Done: #1416's KNOWN_GAPS allowlist is now empty on main (949b0a900, test-only). #1419 (HIP) and #1421 (MH) merged after #1416, so the exact-match assertion was failing on 02ee60a71. With the empty allowlist it passes (3 tests OK), and re-adding a single entry makes it fail again.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    fixPull requests that fix a defect (fix: subject prefix)

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions