Closed
Labels
refactorRestructuring for its own sake — neither a fix nor a new capability (refactor: prefix)Restructuring for its own sake — neither a fix nor a new capability (refactor: prefix)
Milestone
Description
What
Owner questions after #2770: does ProtocolBase.__registry__ follow the handling the other registry maps use (lock, read-only copy, register_protocol checks)? And should its built-in entries be grouped by layer? Audit at 3c4b30e2b, read-only, with key claims re-checked by me:
- Matches the other maps:
_shipped_registryis aMappingProxyType(dict(...))snapshot, built the same way as theExtraction/TraceFlow_shipped_*maps, and used for the same restore.register_protocolraises the sameRegistryErrortype checks asregister, the wrapper also validates (asregistry-protocol.rsthas both sides do), and both returnNone.- The clash warning is a
RegistryWarningin the same shape. - The docs (
#:,Warns:, the# NOTE:tag) match.
- Differs:
- Lock:
_registry_lockis the first lock on any registry map. It serialises onlyget_protocol's first resolution (refactor(protocols)!: replace the pcapkit.protocols.__proto__ dict with an auto-registering Registry class #2763, an import deadlock).register_protocol, the__init_subclass__setdefaultand_release_nameall write without it, as every other map does. - Restore path:
_release_name(foundation.registry.protocols) writeslease.displacedstraight into the map instead of going throughregister_protocol. - Descriptors:
register_protocoltakes a class only, whereregister/register_optionalso take aModuleDescriptor. This follows from registering a class by its own name. - Keys: keys are upper-case, inherited from the old
__proto__dict, while the other string-keyed maps use lower-case.
- Lock:
- Layer grouping: no registry dict in the tree uses layer comments; only
protocols/__init__.py's__all__does.protocol-member-order.rstorders maps "alphabetically by key where there is no enum". The guard does not check__registry__(it skips string-keyed dunder maps).
Metadata
Metadata
Assignees
Labels
refactorRestructuring for its own sake — neither a fix nor a new capability (refactor: prefix)Restructuring for its own sake — neither a fix nor a new capability (refactor: prefix)
Projects
- StatusShow more project fieldsDone
Activity
JarryShaw commentedon Nov 4, 2026
Decision needed.
Lock scope:
lazy_exports, which removes the deadlock it guards against.Rec: (c) once fix(utilities): concurrent first access to lazy protocol exports deadlocks the import system #2771 lands, otherwise (a). A single lock in the shared lazy-import helper is the established place, and no other map locks.
Restore path:
_release_name's direct write, which restores exactly what was displaced.register_protocol.Rec: (a), with a one-line comment saying why.
Grouping by layer:
# Link Layer, …,# MiscellaneousforFrame/Header/IP_Pseudo/NoPayload), alphabetical within each group, and amend the page in one sentence.Rec: (A). If you prefer (B), it is a comment-only edit plus the page amendment. (C) would drift unguarded.
Guard gap: the member-order guard doesn't check string-keyed maps, so "alphabetically by key" is unenforced. Rec: extend the guard as part of whichever option you choose for 3.
JarryShaw commentedon Nov 4, 2026
JarryShaw commentedon Nov 4, 2026
Reconciled. Every answer is now settled.
_registry_lockand its use inget_protocolare removed in fix(utilities): concurrent first access to lazy protocol exports deadlocks the import system #2771's PR, once its sharedlazy_exportslock is in place._release_namerestores through the same path the other registry maps' restores use, and there is no need to bring back exactly the displaced object. The special-casing goes.__registry__'s built-in entries get layer comments (# Link Layer,# Internet Layer,# Transport Layer,# Application Layer,# Miscellaneous), alphabetical within each group.protocol-member-order.rstgets a one-sentence amendment.__registry__it is applied group by group.Items 2–4 go in one PR together with #2772, because both edit
protocol-member-order.rstand the member-order guard. Item 1 goes in #2771's PR. Each PR is marked "Part of #2773", and this issue closes when both have merged.docs(registry): plain-sentence _release_name docstring; pin the name …
docs(conventions): settle the member-order page wording and align the…
fix(utilities): serialise first resolution of lazy exports and module…
JarryShaw commentedon Nov 4, 2026
Both parts have landed, so this is closed. #2779 covered items 2–4: the restore path, the layer grouping, and the guard for string-keyed maps. #2781 covered item 1, removing
_registry_locknow that the sharedimport_lockguards first resolution.