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(protocols): align ProtocolBase.__registry__ handling and entry layout with the other registry maps #2773
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_registry is a MappingProxyType(dict(...)) snapshot, built the same way as the Extraction/TraceFlow_shipped_* maps, and used for the same restore.
register_protocol raises the same RegistryError type checks as register, the wrapper also validates (as registry-protocol.rst has both sides do), and both return None.
The clash warning is a RegistryWarning in the same shape.
Restore path:_release_name (foundation.registry.protocols) writes lease.displaced straight into the map instead of going through register_protocol.
Descriptors:register_protocol takes a class only, where register/register_option also take a ModuleDescriptor. 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.
Layer grouping: no registry dict in the tree uses layer comments; only protocols/__init__.py's __all__ does. protocol-member-order.rst orders maps "alphabetically by key where there is no enum". The guard does not check __registry__ (it skips string-keyed dunder maps).
(a) Keep _release_name's direct write, which restores exactly what was displaced.
(b) Route it through register_protocol.
Rec: (a), with a one-line comment saying why.
Grouping by layer:
(A) Keep sorting by key: it follows the page, and each entry's module path already shows its layer.
(B) Group by layer (# Link Layer, …, # Miscellaneous for Frame/Header/IP_Pseudo/NoPayload), alphabetical within each group, and amend the page in one sentence.
(C) Group without any order rule.
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.
Restore follows the other maps._release_name restores 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.
(B): entries grouped by layer.__registry__'s built-in entries get layer comments (# Link Layer, # Internet Layer, # Transport Layer, # Application Layer, # Miscellaneous), alphabetical within each group. protocol-member-order.rst gets a one-sentence amendment.
Yes: the guard checks string-keyed maps. That covers the alphabetical rule, and for __registry__ it is applied group by group.
Items 2–4 go in one PR together with #2772, because both edit protocol-member-order.rst and 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.
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_lock now that the shared import_lock guards first resolution.
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.