docs(foundation): correct the registrar contracts and cut timed context - #1015
Conversation
379ed8e to
35a78a3
Compare
|
NEEDS CHANGES at It found the job half-done, which is fair. The slice corrected Measured while fixing it, and it strengthens the case: no built-in class subclasses the public class at all — 8 engines, 3 reassembly classes, 1 trace-flow class, every one deriving from the base directly. The old prose named a type nothing shipped satisfies. Four cross-references pointed at an attribute the named class does not own. They cited Both optional items taken: the Re-verified at the new head: AST identical to |
- `Extractor.register_engine`, `register_reassembly` and `register_traceflow` said the argument must be an `Engine`, `Reassembly` or `TraceFlow` subclass. The checks are `issubclass(..., EngineBase / ReassemblyBase / TraceFlowBase)` (`extraction.py:452`, `:491`, `:530`), and the shipped classes derive from the base directly, so the prose understated what is accepted. The wrapper in `registry/foundation.py` carried the same error. - `register_protocol` and nine argument descriptions said `Protocol` where the check is `issubclass(protocol, ProtocolBase)`. - All four `Extractor.register_*` methods raise `RegistryError` on a bad class and emit `RegistryWarning` on an overwrite, and documented neither. Added `Raises:` and `Warns:` sections, which is why this slice adds lines rather than cutting. - `Deferred`'s docstring said TCP reassembly builds `packet` eagerly and that deferring it was left for its own change. `reassembly/tcp.py` already passes `packet=Deferred(...)`, so the claim was false. - Cuts timed context per #719 — "currently", "today", "at the time of writing", "yet", and the "used to"/"no longer"/"previously" history in `Completion`, the `conflict` docs, the reassembly comments and the `trace_format` notes. The `no_eof` behaviour-change note and its measurement are kept as a version-bounded note, citation included. - Brings all four registrar docstrings to one phrasing. Two wrappers in `registry/foundation.py` still named `Reassembly`/`TraceFlow`, and the two `extraction.py` siblings still led with the public class, so one contract read three ways. Measured: **no** built-in class subclasses the public class -- 8 engines, 3 reassembly, 1 trace flow all derive from the base directly. - Repoints four `__callback_fn__` cross-references from `Reassembly`/`TraceFlow` to the concrete `IPv4`/`IPv6`/`TCP` classes. The attribute is in `Reassembly.__dict__` but not in `ReassemblyBase`, and each concrete class owns its own copy, so the docs named a different object from the one written to. - Notes that the `Type[Engine]` hint is narrower than the check, and that a non-class argument raises `TypeError` before `RegistryError` is reached. - Adds the four missing `.. autoattribute:: __callback_fn__` entries under `docs/source/pcapkit/foundation/`. Repointing the cross-references above left them dangling: the attribute was autodoc'd only on `Reassembly` and `TraceFlow`, and `autodoc_default_options` sets no `inherited-members`, so the new targets had no inventory entry and rendered as plain text. `nitpicky` is unset, so the build would not have complained. Verified by a Sphinx build: all four anchors now exist and `registry.html` links to them. No code changed: for all 21 files the AST with docstrings stripped is identical to `main`. Citations are frozen — 41 per-file multisets, byte-identical. `tests/project`: 268 passed, 1 skipped, 864 subtests passed. Part of #719.
35a78a3 to
42cc77f
Compare
|
NEEDS CHANGES at
Fixed by documenting rather than reverting: a The reviewer corrected its own earlier count, in the right direction. It had said 6 engines and 7 reassembly/trace-flow classes from hand-listing module names; enumerating via It also advised keeping the repeated parenthetical in all four registrar docstrings rather than shortening it, on the grounds that the surprising half — that no built-in satisfies the public class — is exactly what the old text got wrong, and that a caller reaches these four independently rather than reading them in sequence. Taken. And it measured what I had only described: all four registrars raise |
|
GOOD TO GO at The warning count is provably unchanged. Base and head both give The fix is build-proven, not argued. All four anchors exist in the generated HTML, and It also checked tree provenance rather than assuming it: each build log carries 11 references to its own worktree and exactly 3 to the shared checkout, all three being Leaving the bases undocumented is more clearly right than I put it. One honest limitation it recorded: it did not build the intermediate head Everything from the earlier rounds carries unchanged against the same unmoved base: the three |
make pylint,make mypy,make isort) — N/A, no code changed; proved by AST comparisonmake testpasses, and a test case covers the change — I rantests/project(268 passed, 1 skipped, 864 subtests) andtests/foundation tests/interface, not the full suitedocs/source/changelog/and regeneratedCHANGELOG.md, if the change is user-visible — N/A, docstrings only, no behaviour changeWhat is the purpose of your pull request?
fix— corrects a defectfeat— adds a featureperf— changes performance, not behaviourrefactor— changes neither behaviour nor performancetest— tests onlydocs— documentation onlyci— workflows or build toolingchore— anything elseDescription of your pull request and other information
The
pcapkit/foundation/**slice of #719 — 21 of 32 files, +186/−170. It adds lines on balance, because the dominant finding was undocumented contract rather than verbose prose.No code changed, and that is checked rather than asserted. For all 21 files, the AST with every docstring stripped is byte-identical to
main(ast.dumpequality). The three registrarissubclasschecks sit atextraction.py:452,:491,:530and are untouched.The registrar contracts were documented one class too narrow.
register_engine,register_reassemblyandregister_tracefloweach said the argument must be anEngine/Reassembly/TraceFlowsubclass; the runtime checks are againstEngineBase/ReassemblyBase/TraceFlowBase, and the shipped classes derive from the base directly. Verified at runtime: all three public classes are strict subclasses of their base, so the documented type was strictly narrower than what is accepted.registry/foundation.py's engine wrapper had the same error, andregister_protocolplus nine argument descriptions saidProtocolwhere the check isProtocolBase. This is the same conflation #513 hit from the caller's side.All four
register_*methods documented neither their failure nor their warning. Each raisesRegistryErroron a bad class (:407,:453,:492,:531) and emitsRegistryWarningon an overwrite (:411,:456,:495,:534).Raises:andWarns:sections are added for all four — that accounts for most of the +186.One docstring was simply false.
Deferredsaid TCP reassembly buildspacketeagerly and that deferring it was left for its own change.reassembly/tcp.py:546already passespacket=Deferred(...).Citations are frozen per the ruling on #719: 41 citation occurrences across the subtree — 25
:issue:roles and 16 bare#nnn— with per-file multisets byte-identical. Timed context is cut: "currently" ×6, "today" ×4, "at the time of writing", "yet", and the "used to"/"no longer"/"previously" history inCompletion, theconflictdocs, the reassembly comments and thetrace_formatnotes. Theno_eofbehaviour-change note is kept, measurement and citation included, as version-bounded prose.A code defect found and deliberately not fixed here, because this is a prose PR: the three error messages still read "must be an Engine / Reassembly / TraceFlow subclass" while the checks beside them are against the
*Baseclasses, so the message misnames the accepted type. Theregister_extractor_enginetype hints are alsoType[Engine], narrower than the runtime check. Filed separately rather than smuggled in.Not done: concision proper. The long
extraction.pydocstrings (no_eof,_owns_input) and theregister_apptypeargument prose are untightened, and 11 of the 32 files are untouched. No Sphinx build; cross-reference targets were checked by importing them instead. Onetests/foundationtest fails on a missing generated capture (test.pcap) in a fresh worktree, which is the known fixture gap rather than anything in this diff.