Skip to content

test(foundation): reassembly, traceflow, engine and registry round trips (#1202) - #1508

Merged
JarryShaw merged 1 commit into
mainfrom
test/1202-foundation-roundtrips
Oct 9, 2026
Merged

JarryShaw merged 1 commit into
mainfrom
test/1202-foundation-roundtrips

Conversation

@JarryShaw

@JarryShaw JarryShaw commented Oct 9, 2026 •

Copy link
Copy Markdown
Owner

Please follow the guide below

What is the purpose of your pull request?

Tick the commit type your subject line carries.

  • fix — corrects a defect
  • feat — adds a feature
  • perf — changes performance, not behaviour
  • refactor — changes neither behaviour nor performance
  • test — tests only
  • docs — documentation only
  • ci — workflows or build tooling
  • release — bumps the version or rolls up a distribution
  • chore — anything else

Description of your pull request and other information

The foundation slice of #1202, test-only (unit modules feed extract an in-memory io.BytesIO, which #1509 made possible): reassembly recovers the payload, traceflow output re-reads to exactly its frames, every offline engine agrees with default, and override→restore through the 36 public pcapkit.foundation.registry registrars is symmetric (class-level registrars without a wrapper are out of scope). Failures sit in per-module KNOWN_FAILURES, checked in both directions.

Module (tests/foundation/…) Subtests Time RSS
reassembly/test_reassembly_payload_roundtrip_unit.py 432 6.3s 125 MiB
traceflow/test_traceflow_reread_roundtrip_unit.py 100 3.1s 124 MiB
traceflow/test_traceflow_reread_roundtrip_runtime.py 23 3.9s 180 MiB
engines/test_engine_agreement_runtime.py 414 run, 828 skipped (670 run with pyshark + pypcapfile) 17.7s 292 MiB
registry/test_registry_symmetry_unit.py 190 2.4s 124 MiB

Gaps: #1500, #1501, #1520 (dpkt engine drops PCAP-NG SPBs), #1502, #1503, #1504, #1505, #1507 (dpkt/scapy/pypcapfile JSON trace), #1512 (pypcapfile reads no big-endian PCAP), #1513 (pypcapfile drops TCP over IPv6), #1514 (pyshark int('True') on TCP flags), #1515 (pyshark counts a journal export block as a frame). The late duplicate IP fragment is asserted as PARTIAL per the #1507 ruling.

Ran sequentially under a 200 MiB file cap after make_samples.py: the five modules, tests/foundation, tests/project, tests/test_tier_guard.py, tests/test_docstring_contract.py and util/run_unittest_leg.py foundation, all passing; the engine module also passes in a Python 3.11 venv with Scapy, DPKT, PyShark and PyPCAPFile (PyPCAP would not build: no pcap.h).

Refs #1202

@JarryShaw JarryShaw moved this to In review in PyPCAPKit Oct 9, 2026
@JarryShaw JarryShaw added review: running A cross-review is in flight against the current head - no verdict yet test Pull requests that add or correct tests (test: subject prefix) labels Oct 9, 2026
@github-actions

github-actions Bot commented Oct 9, 2026

Copy link
Copy Markdown
Contributor

Coverage: 90.07% (unit tier, Python 3.14, cfed47a6d, Unit Tests run failure)

Package Statements Missed Branches Partial Cover
pcapkit (top level) 104 4 20 4 93.55%
pcapkit/const 18795 843 2356 756 92.08%
pcapkit/corekit 2125 66 686 33 96.19%
pcapkit/dumpkit 242 2 88 2 98.79%
pcapkit/foundation 2648 97 930 41 95.03%
pcapkit/interface 112 7 40 5 92.11%
pcapkit/protocols 17086 238 4628 190 97.98%
pcapkit/toolkit 539 74 168 3 84.58%
pcapkit/utilities 431 4 124 4 98.56%
pcapkit/vendor 4409 2342 1006 157 43.25%

Per-file detail: the coverage-html artifact of this run.

@JarryShaw
JarryShaw force-pushed the test/1202-foundation-roundtrips branch from cfed47a to e781499 Compare October 9, 2026 21:08
@JarryShaw JarryShaw added review: pending No verdict for the current head - never reviewed, or the head moved since the last one and removed review: running A cross-review is in flight against the current head - no verdict yet labels Oct 9, 2026
@JarryShaw
JarryShaw force-pushed the test/1202-foundation-roundtrips branch 2 times, most recently from 7f9c349 to 4775b2c Compare October 9, 2026 21:28
@JarryShaw JarryShaw added review: running A cross-review is in flight against the current head - no verdict yet and removed review: pending No verdict for the current head - never reviewed, or the head moved since the last one labels Oct 9, 2026
@JarryShaw

Copy link
Copy Markdown
Owner Author

Verdict: GOOD TO GO at 4775b2c93. Cross-reviewed on Sonnet; the author ran Opus.

Follow-ups being applied, so this will need one more push:

I corrected the #1515 body: CI hit the harness bug first, so the parity jobs decide that row.

@JarryShaw JarryShaw added review: good-to-go Cross-review at the current head says ready; CI state is separate and removed review: running A cross-review is in flight against the current head - no verdict yet labels Oct 9, 2026
@JarryShaw
JarryShaw force-pushed the test/1202-foundation-roundtrips branch from 4775b2c to 26c370f Compare October 9, 2026 21:53
…ips (#1202)

- reassembly: IPv4, IPv6 and TCP payloads cut, reordered, duplicated and
  overlapped come back as one COMPLETE datagram with the original octets; a
  late duplicate IP fragment surfaces as a second PARTIAL one (#1507)
- traceflow: every flow's PCAP file reads back as exactly its frames, over
  built captures (PCAP and PCAP-NG, both byte orders and resolutions) and
  over every sample capture
- engines: dpkt, scapy, pyshark, pypcap, pcap_ct and pypcapfile agree with
  default field for field; an engine that falls back, or a documented
  refusal, is skipped
- registry: override then restore leaves every public registry as shipped
- failing cases are recorded per root cause in KNOWN_FAILURES, checked in
  both directions: #1500-#1505, #1507, #1512-#1515, #1520

Refs #1202
@JarryShaw
JarryShaw force-pushed the test/1202-foundation-roundtrips branch from 26c370f to f2cb71f Compare October 9, 2026 21:55
@JarryShaw JarryShaw added review: running A cross-review is in flight against the current head - no verdict yet and removed review: good-to-go Cross-review at the current head says ready; CI state is separate labels Oct 9, 2026
@JarryShaw

Copy link
Copy Markdown
Owner Author

Verdict: GOOD TO GO at f2cb71f33. A Sonnet delta review covered the five follow-ups and the rebase onto 5f4da2301 (range-diff =).

Non-blocking:

@JarryShaw JarryShaw removed the review: running A cross-review is in flight against the current head - no verdict yet label Oct 9, 2026
@JarryShaw JarryShaw added the review: good-to-go Cross-review at the current head says ready; CI state is separate label Oct 9, 2026
@JarryShaw
JarryShaw merged commit ffca646 into main Oct 9, 2026
40 checks passed
@JarryShaw
JarryShaw deleted the test/1202-foundation-roundtrips branch October 9, 2026 22:20
@JarryShaw JarryShaw removed the review: good-to-go Cross-review at the current head says ready; CI state is separate label Oct 9, 2026
JarryShaw added a commit that referenced this pull request Oct 9, 2026
- toolkit/dpkt, toolkit/scapy: tcp_traceflow reports a FrameRecord, the
  engine's packet2dict mapping as before, carrying the captured octets and
  the PCAP record header that only the PCAP trace dumper reads.
- engines/dpkt: the PCAP and PCAP-NG readers yield a Timestamp (float) or,
  for a nanosecond PCAP, a DecimalTimestamp: the value dpkt yields, carrying
  the exact timestamp, the resolution and the original length. Under a dpkt
  without the reader internals this relies on, it reads with dpkt's own loop
  and warns.
- engines/scapy: captures are read through PcapReader subclasses that stamp
  each packet with its PCAP or PCAP-NG interface resolution, and close once.
- foundation/traceflow/data: new FrameRecord, a dict with packet and
  frame_info attributes, picklable with every protocol.
- foundation/extraction, interface/misc: dpkt and scapy leave the
  trace_format='pcap' -> JSON fallback; #1508's Gap(1507) keeps pypcapfile.

Traced PCAP files are byte-identical to the default engine's, and JSON,
plist and tree output byte-identical to main's.
JarryShaw added a commit that referenced this pull request Oct 10, 2026
- toolkit/dpkt, toolkit/scapy: tcp_traceflow reports a FrameRecord, the
  engine's packet2dict mapping as before, carrying the captured octets, the
  PCAP record header and the exact time_epoch that only the PCAP trace
  dumper reads.
- engines/dpkt: the PCAP and PCAP-NG readers yield a Timestamp (float) or,
  for a nanosecond PCAP, a DecimalTimestamp: the value dpkt yields, carrying
  the exact timestamp, the resolution and the original length. Under a dpkt
  without the reader internals this relies on, it reads with dpkt's own loop
  and warns.
- engines/scapy: captures are read through PcapReader subclasses that stamp
  each packet with its PCAP or PCAP-NG interface resolution, and close once.
- foundation/traceflow/data: new FrameRecord, a dict with packet, frame_info
  and time_epoch attributes, picklable with every protocol.
- foundation/extraction, interface/misc: dpkt and scapy leave the
  trace_format='pcap' -> JSON fallback; #1508's Gap(1507) keeps pypcapfile.

Traced PCAP files are byte-identical to the default engine's at both trace
resolutions, and JSON, plist and tree output byte-identical to main's.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

test Pull requests that add or correct tests (test: subject prefix)

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

1 participant