Choosing Between utilities and corekit¶
Which of the two support packages a module belongs in. Settled by the owner on #1712, over two alternatives that sorted modules by packet knowledge or by who uses them. This rule can be checked from the import graph alone, and it needed the fewest moves: one.
pcapkit.utilities is for cross-cutting services: exceptions, warnings,
logging, the compatibility layer, configuration, and wrappers around third-party
libraries such as chardet. The question to ask of a module
is could any code use this service, and does it import nothing from pcapkit
outside utilities? Both halves have to hold, and nothing covers a top-level
import, one inside a function and one under TYPE_CHECKING alike.
tests/project/test_utilities_import_boundary_1735_unit.py checks every module
under pcapkit/utilities/ for it.
pcapkit.corekit is for the types the packet model is built from: what
pcapkit.protocols, pcapkit.const and pcapkit.foundation
subclass, instantiate or decorate with. The question is is this part of what a
protocol or its schema is made of? A support module that fails the utilities
question belongs here instead. pcapkit.corekit.decorators is the worked example: it acts on a
protocol’s file and falls back to protocol classes, so it moved out of utilities
on #1735. corekit may import utilities; the reverse is what the rule
forbids.