Skip to content

refactor(registry): every class-level registry map gets its foundation.registry wrapper #2511

Closed

Description

@JarryShaw

Owner ruling (this session, 2026-11-01), paraphrased: every registry map gets a matching registration wrapper in pcapkit.foundation.registry that does the same validation as the existing ones. Write that down as a convention, then audit main and the open PRs for gaps and fix them.

The established shape, read from main: a class-level map (Link.__proto__, IPv4.__option__, ICMPv4.__type__, ...) has two parts:

  1. a register / register_<kind> classmethod that is the owning class's own. An inherited one counts only when it is typed and validated for exactly that map's keys (owner, 2026-11-01, option 2 below): TCP/UDP keep Transport.register, while Link.register (EtherType) and Internet.register (TransType) do not cover FRAD, NETLINK, Loopback or IPX;
  2. a public register_<name> function in pcapkit.foundation.registry.protocols, tagged # NOTE: <map path>. It checks the code against its enum with _check_code, checks the target (a protocol class or descriptor, or an existing _read_* parser name), calls the classmethod, logs, and for protocol maps records the name with _register_name.

Candidate gaps on main (to verify): IPX.__proto__, Loopback.__proto__, and SCTP's chunk/parameter/cause maps. The LinuxSLL/FRAD/NETLINK maps are #2510's.

Deliverables: the convention written into docs/source/contributing/conventions/registry-protocol.rst, the missing wrappers on main, and a list of any gaps in open PRs.

Activity

  1. added
    refactorRestructuring for its own sake — neither a fix nor a new capability (refactor: prefix)
    pendingAccepted and unstarted - nobody is on it and nothing blocks it
    on Nov 1, 2026
  2. moved this to Pending in PyPCAPKiton Nov 1, 2026
  3. added
    wipWork in flight - a covering PR is open or an agent is actively on it
    and removed
    pendingAccepted and unstarted - nobody is on it and nothing blocks it
    on Nov 1, 2026
  4. moved this from Pending to WIP in PyPCAPKiton Nov 1, 2026
  5. JarryShaw commented on Nov 1, 2026

    @JarryShaw
    OwnerAuthor

    Owner clarification (2026-11-01), paraphrased: each map's register* classmethod is the owning class's own. On main, five map-owning classes define none and rely on an inherited one:

    Sub-question for the owner: do TCP/UDP need their own override?

    1. Yes, every map-owning class defines its own.
    2. No, an inherited classmethod counts when it is typed and validated for exactly that map's keys.

    Recommendation: 2. Transport.register already matches both maps, and an override would only repeat it. The other four change either way.

  6. added
    needs: decisionWaiting on the maintainer to decide — not blocked by other work
    on Nov 1, 2026
  7. moved this from WIP to Needs decision in PyPCAPKiton Nov 1, 2026
  8. JarryShaw commented on Nov 1, 2026

    @JarryShaw
    OwnerAuthor

    take 2.

  9. JarryShaw commented on Nov 1, 2026

    @JarryShaw
    OwnerAuthor

    Owner chose option 2: an inherited register* classmethod counts when it is typed and validated for exactly that map's keys. So TCP and UDP keep Transport.register. IPX (inherits the TransType-typed Internet.register) and Loopback (inherits the EtherType-typed Link.register) each get their own here, and FRAD/NETLINK get theirs in #2510. The convention text in registry-protocol.rst will state that exception.

  10. removed
    needs: decisionWaiting on the maintainer to decide — not blocked by other work
    on Nov 1, 2026
  11. moved this from Needs decision to WIP in PyPCAPKiton Nov 1, 2026
  12. JarryShaw commented on Nov 1, 2026

    @JarryShaw
    OwnerAuthor

    #2521 merged: it wrote the convention onto registry-protocol.rst and added main's missing wrappers (IPX, Loopback, SCTP's maps). The LinuxSLL, FRAD and NETLINK maps remain, and they are #2510's, landing in #2527. Blocked: this closes when #2527 merges.

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

    @JarryShaw
    OwnerAuthor

    Would like to consider splitting the registry/protocol.py into per layer or per protocol smaller files/submodules. And if splitting, should name the module registry.protocols. to follow protocols module's convention.

  15. JarryShaw commented on Nov 1, 2026

    @JarryShaw
    OwnerAuthor

    Paraphrased: you are considering splitting registry/protocols.py into per-layer or per-protocol submodules named registry.protocols.<submodule>, after pcapkit.protocols. That is a separate deliverable from this issue, so it is #2578, with options and a recommendation: per layer, with the package __init__ aggregating so public paths stay, done after #2527 and #2544. This issue still closes when #2527 merges.

  16. moved this from WIP to Blocked in PyPCAPKiton Nov 1, 2026
  17. JarryShaw commented on Nov 1, 2026

    @JarryShaw
    OwnerAuthor

    #2527 merged, so the LinuxSLL, FRAD and NETLINK maps have their own register and wrappers (register_arphrd, register_frad, register_netlink). With #2521, that completes this issue.

  18. removed
    blockedDeferred pending another issue or decision; see the last comment for what unblocks it
    on Nov 1, 2026
  19. moved this from Blocked to Done in PyPCAPKiton Nov 1, 2026
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

    refactorRestructuring for its own sake — neither a fix nor a new capability (refactor: prefix)

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions