You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
refactor: move shared helper functions into utilities or corekit by use case #1519
The owner, in chat, extended #1516: shared helper functions should move to pcapkit.utilities or pcapkit.corekit, depending on what they are used for. Helper and proxy classes are #1516's scope.
Rule of thumb:
utilities: generic, protocol-agnostic code, such as decorators, validation and warnings.
corekit: the library's core data model and I/O primitives.
Scope:
Inventory the module-level helper functions that are duplicated across modules, or defined privately in one module and imported by others. For each, record where it lives, who calls it, and the proposed home.
Move them in slices that avoid in-flight PRs' files. Keep behaviour byte-identical, and update imports and docs.
Add tests that pin each moved helper at its new location.
The #1516 worker is producing the inventory. The moves follow in separate PRs.
9 schema helpers, 3 identical and the rest differing only in the error prefix
schema/internet/hopopt.py and ipv6_opts.py, lines 132–351
a shared IPv6-options schema module
—
_test_start_line (private, imported by http.py)
protocols/application/httpv1.py:85
protocols/application/http.py, the shared base
—
Question for the owner: the last three helpers are shared, but they are engine- or protocol-specific, so neither utilities nor corekit fits them. Is it OK to put each in a shared module inside its own subpackage? I recommend yes, and those three can start right away.
_same_entry, _restore_shipped, _restore_shipped_dumper become public and move into a new module under pcapkit.interface. I checked for an import cycle: with extraction.py importing a new pcapkit.interface submodule at top level, importing pcapkit, pcapkit.foundation.extraction, foundation.traceflow.traceflow and pcapkit.interface all succeed, since pcapkit/__init__.py:96 loads interface first. This slice is queued until refactor(corekit): move the stream proxy classes into corekit.io (#1516) #1521 merges, because both edit extraction.py.
byteorder_callback and the 9 HOPOPT/IPv6-Opts schema helpers are shared, and stay in the pcapkit.protocols.schema package rather than going to a new corekit.schema. The selectors return protocol schema classes, and corekit must not import protocols.
packet2chain and packet2dict stay duplicated, since pcap-ct may diverge.
_test_start_line moves to the http base module.
Workers are starting on the schema helpers and on _test_start_line now.
Recorded: _test_start_line becomes public as test_start_line and moves to the http base module.
Its docstring requires it to accept exactly the start lines the HTTP/1 parser accepts, which is why it currently sits beside _RE_METHOD, _RE_VERSION, _RE_STATUS and _HTTP2_PREFACE_HEADER (httpv1.py:63-82). So those patterns move to http.py with it, and httpv1.py imports them from there.
httpv1.py already imports http.py at top level (:37-38), so this adds no import cycle. It also removes the lazy import at http.py:476-477.
A worker is starting on this now, and another on the schema helpers.
Activity
JarryShaw commentedon Oct 9, 2026
Inventory (functions). Nothing has moved yet.
_same_entry,_restore_shipped,_restore_shipped_dumper(private, imported bytraceflow.py)foundation/extraction.py:98,129,156corekit.modulebyteorder_callback, same role in two placesschema/misc/pcap/frame.py:21,schema/misc/pcapng.py:192corekit.fieldspacket2chainandpacket2dict, identical (AST-checked)toolkit/pypcap.py:59,79=toolkit/pcap_ct.py:60,80schema/internet/hopopt.pyandipv6_opts.py, lines 132–351_test_start_line(private, imported byhttp.py)protocols/application/httpv1.py:85protocols/application/http.py, the shared baseQuestion for the owner: the last three helpers are shared, but they are engine- or protocol-specific, so neither
utilitiesnorcorekitfits them. Is it OK to put each in a shared module inside its own subpackage? I recommend yes, and those three can start right away.JarryShaw commentedon Oct 9, 2026
_same_entry, _restore_shipped, _restore_shipped_dumper - promote to public and move to maybe
interfaceinstead? can create a new module under itbyteorder_callback - yes, maybe these schema helpers can live in
schemamodule still or create acorekit.schemafor thempacket2chain and packet2dict - keep them as is, in case they diverge in the future updates of
pcap-ct9 schema helpers - yes, maybe these schema helpers can live in
schemamodule still or create acorekit.schemafor them_test_start_line - yes, move to
httpbase moduleJarryShaw commentedon Oct 9, 2026
Recorded owner rulings:
_same_entry,_restore_shipped,_restore_shipped_dumperbecome public and move into a new module underpcapkit.interface. I checked for an import cycle: withextraction.pyimporting a newpcapkit.interfacesubmodule at top level, importingpcapkit,pcapkit.foundation.extraction,foundation.traceflow.traceflowandpcapkit.interfaceall succeed, sincepcapkit/__init__.py:96loadsinterfacefirst. This slice is queued until refactor(corekit): move the stream proxy classes into corekit.io (#1516) #1521 merges, because both editextraction.py.byteorder_callbackand the 9 HOPOPT/IPv6-Opts schema helpers are shared, and stay in thepcapkit.protocols.schemapackage rather than going to a newcorekit.schema. The selectors return protocol schema classes, andcorekitmust not importprotocols.packet2chainandpacket2dictstay duplicated, sincepcap-ctmay diverge._test_start_linemoves to thehttpbase module.Workers are starting on the schema helpers and on
_test_start_linenow.JarryShaw commentedon Oct 9, 2026
_test_start_linemaybe becometest_start_lineas well?JarryShaw commentedon Oct 9, 2026
Recorded:
_test_start_linebecomes public astest_start_lineand moves to thehttpbase module.Its docstring requires it to accept exactly the start lines the HTTP/1 parser accepts, which is why it currently sits beside
_RE_METHOD,_RE_VERSION,_RE_STATUSand_HTTP2_PREFACE_HEADER(httpv1.py:63-82). So those patterns move tohttp.pywith it, andhttpv1.pyimports them from there.httpv1.pyalready importshttp.pyat top level (:37-38), so this adds no import cycle. It also removes the lazy import athttp.py:476-477.A worker is starting on this now, and another on the schema helpers.
refactor(schema): share the IPv6-option schema helpers (#1519)
refactor(http): move test_start_line and its patterns into the http b…
refactor(schema): share the IPv6-option schema helpers (#1519)
refactor(schema): share the IPv6-option and byte-order schema helpers (…
refactor(schema): share the IPv6-option and byte-order schema helpers (…
refactor(schema): share the IPv6-option and byte-order schema helpers (…
refactor(interface): make the registry-entry helpers public in pcapki…
refactor(corekit)!: move the byte-order field helpers into corekit (#…
refactor(corekit)!: move the byte-order field helpers into corekit (#…