@@ -987,70 +987,64 @@ since ESP has already laid the groundwork.
987987Deterministic Construction Arguments
988988------------------------------------
989989
990- This is meant to open a broader run of proposals for the construction
991- (``make() ``) workflow in general rather than stand alone -- more will be added
992- under that heading as they get scoped, and the concrete item ready to write
993- down now is making a ``make() `` call's own argument list deterministic.
994-
995- :meth: `~pcapkit.protocols.protocol.Protocol._make_index ` is where that is not
996- currently true. A number of ``make() `` methods accept a plain ``str ``
997- enum-member name for a field and resolve it by frame-introspecting the
998- caller's locals for a conventional four-argument group -- ``X ``,
999- ``X_default ``, ``X_namespace `` and ``X_reversed `` -- looking for the one
1000- argument whose own default is an enum member, and taking that member's class
1001- as the namespace to search. The actual contract of a ``make() `` call is
1002- therefore not fully visible from its own signature: knowing what a bare
1003- string resolves against means knowing the convention and trusting that every
1004- call site followed it exactly, rather than reading it off the call itself.
1005- That gap is exactly how this round's bug family happened. :issue: `2356 ` is
1006- the walk coming up empty because the relevant argument's own default is
1007- ``None ``, leaving nothing to anchor a namespace to; :issue: `2394 ` is the same
1008- inference failing by a different route -- the name is a loop variable over a
1009- *list * parameter rather than a scalar argument, so the walk's
1010- ``isinstance(value, str) `` check can never see it. Both were fixed narrowly,
1011- by naming the correct enum explicitly at each affected call site rather than
1012- touching the inference, so the mechanism is exactly as fragile as it was
1013- before and just as liable to the same shape of defect at the next call site
1014- that does not fit its assumptions precisely.
1015-
1016- The owner's proposed direction -- recorded here, and explicitly **not **
1017- scheduled for 1.5.0 -- removes the inference rather than patching it again.
1018- ``make() `` would require an actual enum value, or an ``int `` where one is
1019- already accepted, for these fields, with no implicit string-to-enum
1020- resolution performed inside ``make() `` itself. In its place, a small public
1021- wrapper would take the same four-argument group explicitly -- name, default,
1022- namespace, reversed -- and *resolve * a string name to its enum member on
1023- request, so a caller holding a bare string calls that helper first and passes
1024- the resolved value into ``make() ``. That mirrors how a finalised
1025- :class: `~pcapkit.corekit.infoclass.Info ` or
1026- :class: `~pcapkit.protocols.schema.schema.Schema ` already settles its
1027- constructor's keyword set once, when
1028- :func: `~pcapkit.corekit.infoclass.info_final ` or
1029- :func: `~pcapkit.protocols.schema.schema.schema_final ` is applied at
1030- class-definition time, rather than inferring it afresh at every call --
990+ This opens a broader run of proposals for the construction (``make() ``)
991+ workflow in general -- more go under this heading as they get scoped -- and
992+ its first item, making a ``make() `` call's own argument list deterministic, is
993+ **done for 1.6.0 ** (:issue: `2594 `).
994+
995+ Before 1.6.0, :meth: `~pcapkit.protocols.protocol.Protocol._make_index ` resolved
996+ a plain ``str `` enum-member name given to a ``make() `` field by inspecting the
997+ caller's frame for a conventional four-argument group -- ``X ``, ``X_default ``,
998+ ``X_namespace `` and ``X_reversed `` -- looking for the one argument whose own
999+ default is an enum member, and taking that member's class as the namespace to
1000+ search. The contract of a ``make() `` call was therefore not visible from its
1001+ own signature: knowing what a bare string resolved against meant knowing the
1002+ convention and trusting that every call site followed it exactly. That gap is
1003+ how a bug family happened. :issue: `2356 ` is the walk coming up empty because
1004+ the argument's own default is ``None ``, leaving nothing to anchor a namespace
1005+ to; :issue: `2394 ` is the same inference failing by a different route -- the
1006+ name is a loop variable over a *list * parameter, so the walk's
1007+ ``isinstance(value, str) `` check can never see it. Both were fixed narrowly, by
1008+ naming the enum at each affected call site, which left the mechanism as
1009+ fragile as before.
1010+
1011+ The owner removed the inference rather than patching it again, ruled in review
1012+ of :pr: `2593 ` (:issue: `2489 `): a field holding an enumeration takes the member
1013+ or an ``int ``, resolved with the enumeration's
1014+ :meth: `~pcapkit.corekit.enum.EnumLookup.get `, and nothing inside ``make() ``
1015+ turns a string into a member. That settles a call's contract at the signature,
1016+ the way :func: `~pcapkit.corekit.infoclass.info_final ` and
1017+ :func: `~pcapkit.protocols.schema.schema.schema_final ` settle a constructor's
1018+ keyword set once at class-definition time, and
10311019:attr: `~pcapkit.protocols.protocol.Protocol.__own_make_keywords__ `
1032- (:issue: `2286 `) settles the same kind of question explicitly rather than
1033- inferring it, though for a different question: which keywords a ``make() ``
1034- override owns, not what the names passed to it resolve against.
1035-
1036- The trade-off is real and worth stating rather than glossed over. Accepting a
1037- bare string for these fields is a pattern used throughout the docs and the
1038- examples, so dropping the inference is a likely-breaking change at every
1039- ``make() `` call site that currently relies on it -- not a one-line fix.
1040- Deciding that scope -- which call sites change, whether string acceptance is
1041- dropped outright or only the silent-inference path behind it, and what the
1042- wrapper is named and where it lives -- is itself design work, which is
1043- exactly why this belongs on this page rather than as a quick issue. Done, it
1044- removes the root cause of the :issue: `2356 `/:issue: `2394 ` family rather than
1045- leaving its next instance to be found and patched the same way.
1046-
1047- **Scoped for 1.6.0. ** The owner took this direction for every ``make() ``, ruled
1048- in review of :pr: `2593 ` (:issue: `2489 `): a field holding an enum takes the member
1049- or an ``int ``, resolved with the enumeration's ``get `` rather than inferred from
1050- the caller's frame. The shipped ``X_default ``, ``X_namespace `` and ``X_reversed ``
1051- keywords go in 1.6.0 with no deprecation period, ruled on :issue: `2594 `, which
1052- carries the change across :file: `pcapkit/protocols/ ` in one pass and leaves the
1053- helper's name and module to it.
1020+ (:issue: `2286 `) which keywords a ``make() `` override owns. The pieces:
1021+
1022+ * :meth: `~pcapkit.protocols.protocol.Protocol._make_index ` takes the value, the
1023+ enumeration and the field's width, and returns the member ``get `` resolves.
1024+ A name, a :obj: `bool ` for a field wider than one bit, and a code the field or
1025+ the enumeration cannot carry raise
1026+ :exc: `~pcapkit.utilities.exceptions.ProtocolError `, so every caller gets the
1027+ range check :issue: `2617 ` asks for, with no masking.
1028+ * The shipped ``X_default ``, ``X_namespace `` and ``X_reversed `` keywords are
1029+ removed in 1.6.0 with no deprecation period and no shim, ruled on
1030+ :issue: `2594 `; each class that shipped them records them under
1031+ ``versionremoved ``.
1032+ * The public wrapper is :meth: `Protocol.resolve_index
1033+ <pcapkit.protocols.protocol.Protocol.resolve_index> `, which takes the old
1034+ group explicitly -- name, default, namespace, reversed -- so a caller holding
1035+ a bare string resolves it first and passes the result to ``make() ``. It is a
1036+ static method every protocol inherits, beside
1037+ :meth: `~pcapkit.protocols.protocol.Protocol.decode ` and
1038+ :meth: `~pcapkit.protocols.protocol.Protocol.unquote `, rather than a module of
1039+ its own, since it serves ``make() `` alone.
1040+
1041+ The trade-off was real: a bare string for these fields was a pattern used
1042+ throughout the docs and the examples, so the change breaks every ``make() ``
1043+ call site that relied on the inference. That is why it landed as one change
1044+ across :file: `pcapkit/protocols/ ` rather than folded into the next defect fix
1045+ on this family, and it removes the root cause of the
1046+ :issue: `2356 `/:issue: `2394 ` family rather than leaving its next instance to be
1047+ found and patched the same way.
10541048
10551049Release Plan — 1.5.0 in Two Steps
10561050---------------------------------
@@ -1383,10 +1377,9 @@ as are IGMP's and GRE's (:issue:`2618`).
13831377the parsing and the constructing path, rather than a back-reference from a
13841378parsed protocol to its parent.
13851379
1386- **Scoped for 1.6.0 — deterministic construction arguments ** (:issue: `2594 `). See
1380+ **Deterministic construction arguments — done ** (:issue: `2594 `). See
13871381`Deterministic Construction Arguments `_ above: every ``make() `` takes an enum
1388- field as the member or an ``int ``, dropping the implicit string-to-enum inference
1389- and the ``X_default ``, ``X_namespace `` and ``X_reversed `` keywords behind it, and
1390- an explicit helper resolves a bare string. That breaks every call site relying on
1391- the inference, so it lands as one change rather than folded into the next defect
1392- fix on this family.
1382+ field as the member or an ``int ``, with no string-to-enum inference and no
1383+ ``X_default ``, ``X_namespace `` and ``X_reversed `` keywords behind it, and
1384+ :meth: `Protocol.resolve_index <pcapkit.protocols.protocol.Protocol.resolve_index> `
1385+ resolves a bare string first.
0 commit comments