Skip to content

design: is AppType's multi-bit proto necessary, given the enum is already split per transport? #801

Description

@JarryShaw

Is this a bug or a feature request? A design question, raised by the maintainer.

The question, verbatim:

one question tho, should we maintain full transport list in each AppType's enum? like for TCP.http on port 80, the current enum still carries the other transport info like UDP/TSCP/etc. is that necessary? if so, then we dont care. if not, we should then bring back the TransportProtocol retyping.

What it decides. #732's ruling was conditional — "proceed with retyping on TransportProtocol - if we no longer need it to be a Flag. But, if in any case we still prefer using a Flag, then we discard the retyping." This issue is that condition. It exists as its own issue so the reasoning is tracked rather than buried in #732, whose subject is the str-valued/port=-1 shape.

State today. AppType is split into four per-transport registries — TCP 6,147 / UDP 6,143 / SCTP 91 / DCCP 10 = 12,391 members — reached via AppType.__registries__. A member also carries a proto attribute holding a TransportProtocol Flag, which for a service IANA registers on several transports is multi-bit: TCP.http.proto names UDP too. 10,625 of 12,391 rows (85.7%) are multi-bit, so this is most of the enum, not an edge.

Two arguments that the list is redundant:

  1. The split already encodes it. "Which transports bind port 80" is answerable by asking which of the four registries contain it. The multi-bit proto is then a second copy of a fact the structure already carries — and a second copy can drift from the first.
  2. _dispatch already rejects multi-bit. AppType.get(80, TCP|UDP) raises, telling the caller to look one transport up at a time. So the entry point insists on a single transport while the members it returns advertise four.

The one site that decides it is pcapkit/foundation/registry/protocols.py:846, if test not in proto: — the only read known to treat proto as a set rather than a label. Load-bearing if it needs the other bits; decoration if it is only reachable once a registry has been selected.

Being measured now, before any answer — a wrong one costs a 12,391-member migration:

  • Every read of proto across pcapkit/, tests/, docs/: is multi-bit ever the only source of a fact?
  • Derivability: for every port present in more than one registry, does "the set of registries containing it" equal "its proto bit set"? Any disagreement means the two copies have already drifted — a defect independent of this design question.

Findings get appended here as they land. Related: #732, #775, #783.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    breakingBreaks public-facing behaviour or API (apply alongside the type label)designA design or decision issue: a pattern being decided rather than a defect or a requestquestion

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions