Skip to content

refactor(protocols)!: group each protocol's protocol, schema and data into one package #2534

Open

Description

@JarryShaw

Owner ruling on #2529 (2026-11-01), paraphrased: replace the three parallel trees (protocols/<layer>/<proto>.py, protocols/schema/<layer>/<proto>.py, protocols/data/<layer>/<proto>.py) with one package per protocol, protocols/<layer>/<proto>/{protocol,schema,data}.py.

Settled design:

Pilot: the VLAN family (vlan, c_tag, s_tag), dispatched now as a local experiment, not a PR.

Blocked: the full move waits for the open PRs that touch pcapkit/protocols (#2528 #2527 #2523 #2522 #2521 #2519 #2509 #2483) and the streams in flight. It unblocks when those have merged or closed.

Activity

  1. added
    breakingBreaks public-facing behaviour or API (apply alongside the type label)
    refactorRestructuring for its own sake — neither a fix nor a new capability (refactor: prefix)
    blockedDeferred pending another issue or decision; see the last comment for what unblocks it
    on Nov 1, 2026
  2. JarryShaw commented on Nov 1, 2026

    @JarryShaw
    OwnerAuthor

    Pilot done on the VLAN family (local f52b9808d, not for push). After the codemod and four kinds of hand edit, all 588 modules import cleanly, 36 test modules pass, and a nitpicky docs build adds no warnings. A dry run over the whole tree touches 56 packages, makes 142 file moves, rewrites 699 files and about 10k dotted references. The codemod is kept, ready for the real run. Decisions needed first:

    1. Framework import cycle: protocol.py imports Raw's and NoPayload's schema/data at the top, and in the new layout those cycle back through misc into protocol.py. Options: (a) defer those imports; (b) keep Raw/NoPayload at the top level as framework; (c) make the layer __init__ files lazy. Recommendation: (a), measured in the full run.
    2. The schema=/data= fallback in __init_subclass__ reads the aggregators that are going away. Only L2TP relies on it. Options: look in the class's own package for sibling schema/data modules, or make the keywords mandatory. Recommendation: sibling lookup.
    3. Does a package __init__ export its class, so that protocols.link.vlan.VLAN still resolves? refactor!: remove every surviving re-export of a moved name or module #1744's D3 allows a package __init__ to aggregate its own submodules. Recommendation: yes, which also makes most imports non-breaking.
    4. The shared ipv6_option schema/data, used by HOPOPT and IPv6_Opts, goes into the family base's package: ipv6_ext's schema/data, per your ruling 1. Recommendation: that.
    5. Framework paths: schema/schema.py → protocols/schema.py, data/data.py and data/protocol.py → protocols/data.py, and the layer bases stay at <layer>/<layer>.py. Recommendation: as listed.
    6. Released changelogs: rewrite only ~ cross-reference targets, which leaves the rendered text unchanged and keeps the links resolving. Recommendation: yes.
    7. Docs: keep one page per protocol at its current URL and add the package's .. module::, rather than a directory per package. Recommendation: keep the URLs.
  3. added
    needs: decisionWaiting on the maintainer to decide — not blocked by other work
    on Nov 1, 2026
  4. moved this to Needs decision in PyPCAPKiton Nov 1, 2026
  5. JarryShaw commented on Nov 1, 2026

    @JarryShaw
    OwnerAuthor
    1. A
    2. Sibling lookup but still takes the class constructor arguments
    3. Yes
    4. Yes, that
    5. As listed
    6. Yes
    7. Keep the URLs/docs layout, each protocol page contains first the protocol class then schema and data.
  6. JarryShaw commented on Nov 1, 2026

    @JarryShaw
    OwnerAuthor

    Owner rulings on the pilot, paraphrased:

    1. (a): protocol.py defers its Raw/NoPayload schema and data imports.
    2. Sibling lookup: __init_subclass__ finds schema/data in the class's own package, and an explicit schema=/data= class keyword still overrides it.
    3. Yes: a package __init__ exports its class, so protocols.link.vlan.VLAN still resolves.
    4. Yes: the shared ipv6_option schema and data go into ipv6_ext's package.
    5. As listed: protocols/schema.py and protocols/data.py; layer bases stay at <layer>/<layer>.py.
    6. Yes: released changelogs get only their ~ targets rewritten.
    7. Keep the URLs: one page per protocol, with the protocol class first, then its schema, then its data.
      Back to blocked: the codemod runs once no open PR or in-flight stream touches pcapkit/protocols.
  7. removed
    needs: decisionWaiting on the maintainer to decide — not blocked by other work
    on Nov 1, 2026
  8. moved this from Needs decision to Blocked 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

    blockedDeferred pending another issue or decision; see the last comment for what unblocks itbreakingBreaks public-facing behaviour or API (apply alongside the type label)refactorRestructuring for its own sake — neither a fix nor a new capability (refactor: prefix)

    Projects

    • Status
      Blocked

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions