Skip to content

refactor(corekit)!: move the byte-order field helpers into corekit (#1711) - #1715

Merged
JarryShaw merged 1 commit into
mainfrom
refactor/1711-byteorder-helpers-to-corekit
Oct 14, 2026
Merged

JarryShaw merged 1 commit into
mainfrom
refactor/1711-byteorder-helpers-to-corekit

Conversation

@JarryShaw

@JarryShaw JarryShaw commented Oct 14, 2026 •

Copy link
Copy Markdown
Owner

Please follow the guide below

What is the purpose of your pull request?

Tick the commit type your subject line carries.

  • fix — corrects a defect
  • feat — adds a feature
  • perf — changes performance, not behaviour
  • refactor — changes neither behaviour nor performance
  • test — tests only
  • docs — documentation only
  • ci — workflows or build tooling
  • release — bumps the version or rolls up a distribution
  • chore — anything else

Description of your pull request and other information

packet_byteorder and byteorder_callback move from pcapkit/protocols/schema/misc/byteorder.py to pcapkit/corekit/fields/byteorder.py. Per the owner's ruling, nothing is re-exported at the old path.

  • Breaking: importing pcapkit.protocols.schema.misc.byteorder now raises ModuleNotFoundError. That module shipped in 1.5.0b9 to b12 with its own docs page and __all__, though never in a stable release. The subject carries !, following the OSPF/RARP precedent (30714cd51).
  • Why corekit/fields/: the callback sets NumberField._byteorder, and packet_byteorder reads the __packet__ key that SchemaField builds. At runtime the module imports only sys and typing, so there is no cycle.
  • Updated references: frame.py, pcapng.py, corekit/fields/misc.py, examples/generators/endian.py and four tests now import from corekit. A git grep of the old dotted and slash paths finds only the new test's OLD_PATH.
  • Docs: the page moves to corekit/fields/byteorder.rst. The old page and its toctree entry are removed, and the Sphinx warning count is unchanged.
  • Tests: tests/corekit/test_fields_byteorder_1519_unit.py asserts that the old path raises ModuleNotFoundError. That test fails on 94bce816b, the head that still had the re-export.
    • tests/protocols/misc: 230 passed.
    • The touched modules pass on 3.8, 3.9, 3.10, 3.11 and 3.14.

Closes #1711

@JarryShaw JarryShaw added refactor Restructuring for its own sake — neither a fix nor a new capability (refactor: prefix) review: good-to-go Cross-review at the current head says ready; CI state is separate labels Oct 14, 2026
@JarryShaw

Copy link
Copy Markdown
Owner Author

Verdict: GOOD TO GO at 94bce816b. A Sonnet cross-review confirmed the following.

  • Moved, not changed: packet_byteorder and byteorder_callback now live in pcapkit/corekit/fields/byteorder.py, and the function bodies are byte-identical to the old module's.
  • Old path still works: pcapkit.protocols.schema.misc.byteorder re-exports the very same objects (is), so the move is not breaking.
  • No import cycle: 9 modules each imported alone in a fresh process, on 3.8, 3.9, 3.10 and 3.14 (36 runs).
  • Same output: 23 sample captures parse to identical per-frame fingerprints, and every PCAP record header rebuilds byte-exact in both byte orders.
  • Tests: tests/protocols/misc/ passes 230 tests. Sphinx shows the same 63 warnings as main.

@JarryShaw JarryShaw added the review: good-to-go Cross-review at the current head says ready; CI state is separate label Oct 14, 2026
@JarryShaw JarryShaw moved this to In review in PyPCAPKit Oct 14, 2026
@github-actions

github-actions Bot commented Oct 14, 2026 •

Copy link
Copy Markdown
Contributor

Coverage: 89.42% (unit tier, Python 3.15, 51d07f7cc, Unit Tests run success)

Package Statements Missed Branches Partial Cover
pcapkit (top level) 104 3 20 3 95.16%
pcapkit/const 18860 954 2368 868 91.06%
pcapkit/corekit 2381 67 764 35 96.50%
pcapkit/dumpkit 275 3 100 3 98.40%
pcapkit/foundation 2887 144 1012 34 94.20%
pcapkit/interface 138 7 52 5 93.68%
pcapkit/protocols 17172 226 4588 190 98.07%
pcapkit/toolkit 1313 280 532 5 75.88%
pcapkit/utilities 500 4 150 4 98.77%
pcapkit/vendor 4417 2342 1010 157 43.38%

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

@JarryShaw

Copy link
Copy Markdown
Owner Author

Do not re-export. Directly update the import paths.

@JarryShaw

Copy link
Copy Markdown
Owner Author

Recorded: no re-export. pcapkit/protocols/schema/misc/byteorder.py goes, and every import site, docs reference and test moves to pcapkit/corekit/fields/byteorder.py. A worker is on it in this branch.

@JarryShaw JarryShaw added review: needs-changes Cross-review at the current head says changes are required; see the verdict comment and removed review: good-to-go Cross-review at the current head says ready; CI state is separate labels Oct 14, 2026
…1711)

packet_byteorder and byteorder_callback act on a NumberField and on the
__packet__ key SchemaField hands a nested schema, but lived under one
protocol family's schema package.

- corekit: git mv pcapkit/protocols/schema/misc/byteorder.py to
  pcapkit/corekit/fields/byteorder.py, next to the NumberField and
  SchemaField it serves. It imports only sys and typing at runtime, so no
  cycle; it is not added to corekit.fields' __all__.
- protocols: the old module is removed with no re-export, so importing
  pcapkit.protocols.schema.misc.byteorder now raises ModuleNotFoundError;
  frame.py and pcapng.py import from corekit.
- docs: the page moves to corekit/fields/byteorder.rst; the old page and
  its toctree entry are removed, and every reference names the new module.
- tests: the #1519 tests move to tests/corekit and run against the new
  path, plus an old-path-is-gone test and a no-upward-import check.

New tests fail on 94bce81 and origin/main; touched suites pass on 3.8,
3.9, 3.10, 3.11 and 3.14; Sphinx warnings unchanged at 45.

Closes #1711
@JarryShaw
JarryShaw force-pushed the refactor/1711-byteorder-helpers-to-corekit branch from 94bce81 to 51d07f7 Compare October 14, 2026 14:23
@JarryShaw JarryShaw changed the title refactor(corekit): move the byte-order field helpers into corekit (#1711) refactor(corekit)!: move the byte-order field helpers into corekit (#1711) Oct 14, 2026
@JarryShaw JarryShaw added review: good-to-go Cross-review at the current head says ready; CI state is separate breaking Breaks public-facing behaviour or API (apply alongside the type label) and removed review: needs-changes Cross-review at the current head says changes are required; see the verdict comment labels Oct 14, 2026
@JarryShaw

Copy link
Copy Markdown
Owner Author

Done: there is no re-export. pcapkit/protocols/schema/misc/byteorder.py and its docs page are removed, and every import site now uses pcapkit/corekit/fields/byteorder.py.

Verdict: GOOD TO GO at 51d07f7cc. A Sonnet cross-review (the author was Opus) checked 0092e6f29. 51d07f7cc differs from it only by the ! in the subject; the tree is identical.

  • Old path gone: git grep/grep -rI for the dotted, slash and backslash forms finds only the new test's OLD_PATH.
  • Imports and docs: fresh interpreters on 3.8 to 3.11 and 3.14 import cleanly with no cycle. Sphinx gives 63 warnings both before and after, nothing links to the removed page, and objects.inv lists only the new module.
  • Fail before: the negative test fails on 94bce816b (ModuleNotFoundError not raised) and passes now.
  • Breaking: the old path shipped in 1.5.0b9 to b12, documented and with its own __all__. That counts as a public-path change under the label rules, so this PR carries breaking and a !.

@JarryShaw JarryShaw added this to the PyPCAPKit v1.5 milestone Oct 26, 2026
JarryShaw added a commit that referenced this pull request Nov 1, 2026
…les (#2529)

- httpv1.HTTP and httpv2.HTTP become HTTPv1 and HTTPv2, and the top-level
  HTTP class of the httpv1/httpv2 schema and data modules follows; their
  sub-structure classes keep their names. id(), alias and the dispatched
  layer (the base HTTP, data key 'http') are unchanged.
- Package __init__ files import the new names directly; imports, mock and
  registrar targets, autoclass targets, cross-references, ext.rst rows and
  the Mermaid click anchors follow.
- versionremoved 1.6.0 on each old path (module docstring and docs page),
  versionchanged 1.6.0 on each renamed class; register_protocol's docstring
  drops the HTTP name collision the rename removes.
- Tests: the #1744 ledger takes a removal version and registers the six
  paths; the collision and symmetry tests build their own class named
  HTTP; new test_http_member_names_2529_unit.py fails before the rename.

BREAKING CHANGE: HTTP in pcapkit.protocols.application.httpv1/httpv2,
pcapkit.protocols.schema.application.httpv1/httpv2 and
pcapkit.protocols.data.application.httpv1/httpv2 is renamed HTTPv1/HTTPv2
with no alias (#1715, #1744), so `from ...httpv1 import HTTP` raises
ImportError. pcapkit.HTTPv1, pcapkit.protocols.HTTPv1 and the schema/data
package names are unchanged. A member built directly reports info_name
'httpv1'/'httpv2' (was 'http'), and register_protocol(HTTPv1/HTTPv2) keeps
the class under its own key instead of displacing HTTP under 'HTTP'.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

breaking Breaks public-facing behaviour or API (apply alongside the type label) refactor Restructuring for its own sake — neither a fix nor a new capability (refactor: prefix)

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

refactor(corekit): move the byte-order field helpers out of protocols.schema.misc into a shared helper module

1 participant