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
question(registry): should a built-in engine, reassembly or traceflow overridden by name be restorable through the public registrar? #1363
This is a question and needs the owner's ruling; it may be by design.
Describe the behaviour
The public registrars accept an override of a built-in name, but refuse the built-in class when it is offered back, because they check the public Engine / Reassembly / TraceFlow (pcapkit/foundation/extraction.py:469) while the built-ins derive from the *Base classes. #513 and #1016 recorded this on purpose (_register_internal_* is the door for built-ins), so a restore needs the private method or a saved copy of the registry.
To Reproduce register_extractor_engine('dpkt', MyEngine) works (with a RegistryWarning). register_extractor_engine('dpkt', DPKT) then raises RegistryError: engine must be an Engine subclass, not <class 'pcapkit.foundation.engines.dpkt.DPKT'>. The same holds for reassembly ipv4 / ipv6 / tcp and traceflow tcp.
Question
Is "an override of a built-in is permanent for the process" the intended contract? If so, register_engine's docstring could say so; if not, the public registrars could accept a class already registered under another name by the library, or register_* could offer an unregister / restore path.
Found by the round-trip audit of pcapkit/foundation. Run /tmp/rtissues/foundation-repro.py from the repo root (it prints pcapkit.__file__ first).
Found by the foundation round-trip audit (#1202). The repro was re-checked by an independent verifier, and I re-ran it on main at c9676c563.
Decision needed.#513 and #1016 made the public registrars refuse built-ins on purpose: extraction.py:458-469 records it in a comment and the docstring. The consequence is that once register_extractor_engine('dpkt', MyEngine) overrides a built-in, putting DPKT back raises RegistryError: engine must be an Engine subclass. The same holds for reassembly ipv4/ipv6/tcp and traceflow tcp.
Options:
(1) Let the registrar accept the original built-in for a name it shipped with, so an override can be undone. Everything else stays refused.
(2) Add an explicit unregister_*/reset_* that restores the shipped default.
(3) Leave it as designed and document that an override is permanent for the process.
I recommend (1). It is the smallest change, keeps #1016's guarantee for every foreign class, and makes the round trip override→restore exact.
Ruling recorded: option (1), applied to every registrar. A registrar accepts the shipped original for a name it shipped with, so an override can be undone; every other foreign class is still refused as #1016 requires. The rule covers the extraction engine, reassembly, traceflow and dumper registrars, and also the protocol and option registrars.
Sequencing:
Now: the foundation registrars (foundation/extraction.py, foundation/traceflow/, foundation/registry/). No open PR edits them, so they go to a worker this tick.
The foundation half of this ruling has landed in #1376, which has merged. The protocol-registrar half rides on #1362. Blocked until#1362 is fixed, and #1362 itself waits on #1390.
The protocol-registrar half has landed in #1400, which merged: restoring a shipped entry now warns once and is accepted. What remains is the class-storing register in protocols/protocol.py, which is #1364's code. Blocked until#1364 is fixed.
Unblocked: #1364 is fixed by #1415 (merged at 199bfcef8). The class-storing register in protocols/protocol.py now keeps a re-registered stored descriptor, so the protocol-registrar half of this question is settled.
What remains is the question itself, for the owner. It concerns the public register_extractor_engine / _reassembly / _traceflow registrars (foundation/extraction.py). Should offering a built-in class back after an override:
stay refused, making an override permanent for the process (and the docstring would say so), or
Correction first: my comment above was stale. Option 2 is already on main. #1376 (merged 2026-10-08) made the extractor registrars accept the built-in a name shipped with, #1400 did the same for the 14 parser registrars, and #1415 closed the last gap (#1364). Re-measured on 949b0a900:
register_extractor_engine('dpkt', MyEngine), then ('dpkt', DPKT): accepted, and the registry holds the shipped ModuleDescriptor again.
Same for reassembly ipv4 and traceflow tcp.
register_extractor_engine('foo', DPKT) still raises RegistryError. A built-in is only accepted back under the name it shipped with.
One optional nit: restoring warns already registered, overwriting, the same as an override. I'd keep it, because it does replace the override. If you'd rather it say restoring shipped entry, that is a one-line message change.
Closing as answered, per the owner's ruling: the restore behaviour is already on main and both halves stay as they are. A built-in is accepted back under the name it shipped with (#1376, #1400, #1415); under any other name the public door still refuses it (#513, #1016). The already registered, overwriting warning on a restore is kept as-is.
Activity
JarryShaw commentedon Oct 7, 2026
Decision needed. #513 and #1016 made the public registrars refuse built-ins on purpose:
extraction.py:458-469records it in a comment and the docstring. The consequence is that onceregister_extractor_engine('dpkt', MyEngine)overrides a built-in, puttingDPKTback raisesRegistryError: engine must be an Engine subclass. The same holds for reassemblyipv4/ipv6/tcpand traceflowtcp.Options:
unregister_*/reset_*that restores the shipped default.I recommend (1). It is the smallest change, keeps #1016's guarantee for every foreign class, and makes the round trip override→restore exact.
JarryShaw commentedon Oct 7, 2026
okay take (1) then, and this will apply to all registrars.
JarryShaw commentedon Oct 7, 2026
Ruling recorded: option (1), applied to every registrar. A registrar accepts the shipped original for a name it shipped with, so an override can be undone; every other foreign class is still refused as #1016 requires. The rule covers the extraction engine, reassembly, traceflow and dumper registrars, and also the protocol and option registrars.
Sequencing:
foundation/extraction.py,foundation/traceflow/,foundation/registry/). No open PR edits them, so they go to a worker this tick.ipv4.py), fix(mh): keep zero-length PadN, reserved fields and BU/BA flag bits on rebuild #1345 (mh.py), fix(tcp)!: reserved bits, post-EOOL octets and the UTO granularity round-trip (#1211, #1218, #1219) #1348 (tcp.py) and fix(protocol): raw items in a make() list build a packet; str enum names resolve per argument #1352 (protocol.py). They join fix(registry): thirteen code-keyed registrars warn "already registered, overwriting" on re-registering the identical object #1362's sweep once those merge.fix(registry): foundation registrars restore the built-in a name ship…
JarryShaw commentedon Oct 8, 2026
The foundation half of this ruling has landed in #1376, which has merged. The protocol-registrar half rides on #1362. Blocked until #1362 is fixed, and #1362 itself waits on #1390.
fix(protocols): parser registrars warn only when the entry really cha…
JarryShaw commentedon Oct 8, 2026
The protocol-registrar half has landed in #1400, which merged: restoring a shipped entry now warns once and is accepted. What remains is the class-storing
registerinprotocols/protocol.py, which is #1364's code. Blocked until #1364 is fixed.JarryShaw commentedon Oct 8, 2026
Unblocked: #1364 is fixed by #1415 (merged at
199bfcef8). The class-storingregisterinprotocols/protocol.pynow keeps a re-registered stored descriptor, so the protocol-registrar half of this question is settled.What remains is the question itself, for the owner. It concerns the public
register_extractor_engine/_reassembly/_traceflowregistrars (foundation/extraction.py). Should offering a built-in class back after an override:RegistryWarning, the way fix(protocols): parser registrars warn only when the entry really changes (#1362) #1400 now treats protocol registrars?Moved to
needs: decision.JarryShaw commentedon Oct 8, 2026
Your recommendations?
JarryShaw commentedon Oct 8, 2026
Correction first: my comment above was stale. Option 2 is already on
main. #1376 (merged 2026-10-08) made the extractor registrars accept the built-in a name shipped with, #1400 did the same for the 14 parser registrars, and #1415 closed the last gap (#1364). Re-measured on949b0a900:register_extractor_engine('dpkt', MyEngine), then('dpkt', DPKT): accepted, and the registry holds the shippedModuleDescriptoragain.ipv4and traceflowtcp.register_extractor_engine('foo', DPKT)still raisesRegistryError. A built-in is only accepted back under the name it shipped with.tests/foundation/registry/test_restore_builtin_unit.py.Recommendation: close this as answered. Keep both behaviours:
Engine/Reassembly/TraceFlow, which carry the registration hook.One optional nit: restoring warns
already registered, overwriting, the same as an override. I'd keep it, because it does replace the override. If you'd rather it sayrestoring shipped entry, that is a one-line message change.JarryShaw commentedon Oct 8, 2026
all good. close it then.
JarryShaw commentedon Oct 8, 2026
Closing as answered, per the owner's ruling: the restore behaviour is already on
mainand both halves stay as they are. A built-in is accepted back under the name it shipped with (#1376, #1400, #1415); under any other name the public door still refuses it (#513, #1016). Thealready registered, overwritingwarning on a restore is kept as-is.