Skip to content

feat(pcap): add bounded capture summaries through CLI and MCP - #2340

Merged
N0zoM1z0 merged 9 commits into
morluto:mainfrom
3QL:feat/pcap-analysis
Oct 13, 2026
Merged

N0zoM1z0 merged 9 commits into
morluto:mainfrom
3QL:feat/pcap-analysis

Conversation

@3QL

@3QL 3QL commented Oct 12, 2026 •

Copy link
Copy Markdown
Contributor

REA now summarizes saved pcap/pcapng files through the existing local CLI/MCP model, using caller-selected Wireshark 4.x tshark and capinfos. It derives address/protocol counts and same-response DNS associations, preserving recorded SNI/URI values and unresolved attribution. Existing inspect_packet_capture remains the field/filter/decode-as workflow.

The follow-up enforces native memory limits (Linux prlimit with stricter inherited ceilings; Windows owned Job Objects), serial admission and close draining. Commands use an empty private personal profile and owned temporary paths. Both tools read one streamed stable snapshot, hashed again after analysis. Cleanup failure now returns a typed error with completed Evidence where available; resources stay owned for retry. One domain owner creates both successful/partial historical Evidence.

Arbitrary 200/100/50-item truncation was removed. Complete inventories remain bounded by real output/graph/retained-memory budgets. Opt-in detail summary retains complete Evidence once, and kind pcap views page endpoints, DNS questions/addresses, SNI, protocol stacks, URIs, unattributed addresses or diagnostics. Pages preserve source coverage, work after source deletion and run no additional decoder. URI credentials remain excluded; metadata and stderr remain useful retained evidence.

Validation on ae88bdb:

  • Full check, generated docs, duplication gate (2.98%) and test discovery passed; all 1,018 tests were discovered once. 64 focused checks passed with eight explicit platform skips. After current-main conflict resolution, 26 interface/native regression checks passed, including Dart AOT summaries.
  • Production-boundary CLI/stdio SDK tests cover all facets, late DNS/SNI rows, strict schemas, portable views after source deletion, original-source/private-snapshot mutation, cancellation, concurrent admission/close draining and failed cleanup retry/partial Evidence.
  • Real data: independent Scapy raw-frame/IP parsing plus Python aggregation of separately invoked TShark fields matched six PCAP/PCAPNG corpora totaling 13,026 packets. Includes actual curl HTTP traffic (12,023 packets/1,000 distinct URIs), 60 certificate-verified HTTPS requests/SNI names and one actual 132-address DNS response. All source hashes, CLI/MCP Evidence IDs/results, SDK schemas and retained pages passed on the final head.
  • The existing real TShark CI workflow now also exercises this family. Its 17 native verifier cases pass locally, including PCAP summary/retained protocol pages. These CI format fixtures are synthetic and do not establish capture provenance.

Performance: same final binary, three alternating pairs, fresh MCP sessions and warm filesystem. Task: final ten HTTP URIs plus exact packet/URI/endpoint counts from the 12,023-packet/1,000-URI corpus. Complete replies and summary/retained pages returned identical task facts. Estimated o200k task request/result text fell from 20,856 to 2,544 tokens; including the full advertised input catalog, 154,364 to 136,052. Median wall time was 10.228s versus 10.532s; CPU 11.898s versus 11.941s; sampled family peak 917.21 versus 894.64 MiB. Retained pages took 61–82ms without another decoder. This demonstrates smaller returned context, not a general speedup or actual agent billing; host concurrency and source-cache state remain limits of this local comparison.

Scope: offline caller-selected recordings only; no live acquisition, replay, automatic target requests, decrypted-body recovery, process attribution or network-completeness claim. Capture metadata/names are producer observations; aggregation is derived and Evidence has historical-reference authority. Current real proof is Linux/Node 24.18.0/Wireshark 4.0.17. Actual Windows/Bun Wireshark execution is unverified here; macOS capture inspection returns a capability gap until an enforceable native memory boundary is verified. Version probes remain available. Original other-platform reports predate these changes.

All heavy local work used two CPU cores and an 8 GiB family guard; supplementary privileged loopback data acquisition additionally used a 512 MiB native address-space limit. No OOM or guard stop occurred. Captures, certificates, keys, binaries and private benchmark artifacts are not committed.

Original implementation by @3QL; follow-up review, fixes and real-data verification by @N0zoM1z0. CI remains the final merge gate.

REA Contributor and others added 7 commits October 11, 2026 17:37
Add a pcap-provider family with two operations:

- inspect_pcap_client: resolved tshark/capinfos commands, selection
  sources, and versions; reads no capture file.
- inspect_pcap_capture: capinfos metadata (file type, encapsulation,
  packet count, capture timing, snapshot length) plus tshark JSON
  field projection — endpoint inventory with packet counts, DNS queries
  with resolved addresses, TLS Server Name Indication values, protocol
  distribution, and plain-text HTTP request URIs — each bounded with
  partial coverage on truncation.

Both tools are bring-your-own via REA_TSHARK_COMMAND and
REA_CAPINFOS_COMMAND (absolute, or from PATH); REA never installs the
Wireshark suite. The provider follows the owned-snapshot and bounded-read
patterns from the merged families: the capture file is digested before
analysis, tool output is budget-checked, and results carry the exact
producer versions.

19 tests: parser goldens from real capinfos and tshark output, provider
behavior through #!/bin/sh tool stubs (happy path, non-capture refusal,
missing binary, unreadable file, cancellation before spawn), service
admission, CLI schema advertisement, and MCP schema parity with Ajv-
validated examples and inline Evidence.

A verify:pcap lane exercises both operations against a real capture;
verified against tshark/capinfos 4.6.6 (Alpine Docker) on a 50-packet
Linux cooked-mode pcap with DNS, TLS, and HTTP traffic — file type,
encapsulation, packet count, SHA-256 digest agreement, endpoint
inventory (7 addresses), DNS queries, protocol distribution (6), and
CLI/MCP schema parity all green. READMEs carry the new 'Packet captures'
row in every supported language including Italian.
Merge upstream main and address the ten reproduced pcap review defects: schema projection, input identity, DNS attribution, exact packet counts, cancellation, malformed output, IPv6, projection coverage, configuration errors, and required-tool readiness.

Use supervised commands and read-only snapshots, retain failed cleanup ownership, bound JSON and DNS inventories, and exclude HTTP transport credentials while preserving other URI bytes. Strengthen the real verifier with compiled CLI/MCP schema and Evidence parity checks.

Validation: 62 focused tests across parser, provider, CLI/MCP, tool effects, and catalog coverage; npm run check; docs:check; verify:test-discovery. Real tshark/capinfos 4.6.6 verified on Linux with pcap and pcapng, interleaved DNS, IPv6, 51 SNI names, and 20,010 packets. Native macOS and Windows remain unverified.
Prepare native process ownership outside tool execution deadlines and allow a bounded 120-second cold Swift compilation. Reuse the SDK cache in native parser fixtures while preserving cancellation and cleanup coverage.

Use unleased shared verifier parents on Windows, retain leftover resources, handle quoted batch arguments, and declare readiness-probe filesystem effects.

Validation: static/docs gates and focused Linux regressions passed. Native macOS passed 47 pcap tests, 22 process-reader tests, real CLI/MCP captures, and an isolated cold-cache compilation. Windows passed 32 pcap tests (15 POSIX-only skips), real captures and native-control conformance under a non-administrator account. Windows verification used the Ubuntu 24.04-built addon; a separate Debian 13 build exhibited an addon-load failure.
Resolve the Swift helper options conflict by adopting upstream's compiler selection and opt-in module cache while retaining the verified 120-second cold-compilation budget and independent tool deadline.

Validation: 64 focused tests passed with seven Darwin-only skips, static and generated-doc checks passed, and real Linux tshark/capinfos CLI/MCP verification passed after the merge.
@chatgpt-codex-connector

Copy link
Copy Markdown

Codex usage limits have been reached for code reviews. Please check with the admins of this repo to increase the limits by adding credits.
Repo admins can enable using credits for code reviews in their settings.

@N0zoM1z0 N0zoM1z0 self-assigned this Oct 13, 2026
@N0zoM1z0

Copy link
Copy Markdown
Collaborator

Thanks for the capture-summary implementation. I have taken over the follow-up and pushed ae88bdbcf86919be7bba996934b31151649b2c5e, synchronized with current main and its Dart AOT/native resource changes.

The integration scope is offline, caller-selected saved captures using the admitted Wireshark 4.x output profile. Existing inspect_packet_capture remains the field/filter/decode-as workflow. This family derives address/protocol counts and same-response DNS associations without claiming process identity, final DNS resolution, decrypted payloads or complete network observation.

The follow-up adds enforced native memory limits (Linux prlimit with stricter inherited ceilings; Windows owned Job Objects), one admitted inspection at a time and close draining. Private personal configuration and temporary paths are selected explicitly. Both tools consume one stable streamed snapshot, whose bytes are rechecked after analysis. Arbitrary inventory/address-count caps were removed; full facts are retained within the actual resource budget. Capture summaries and retained fact/text pages now return only requested material, without rerunning Wireshark after the source is removed. Known URI credentials remain excluded and stderr diagnostics are retained.

A correctness bug was also fixed: failed snapshot cleanup no longer returns success. It returns a typed cleanup error, retains completed Evidence where available, and keeps the resources owned for retry. Success and partial observations now share one domain Evidence owner. Wireshark version interpretation likewise stays in the configuration parser, rather than reparsing display text downstream.

Validation: full check/docs passed, duplication 2.98%, all 1,018 tests discovered once. 64 focused checks passed with eight explicit platform skips; after syncing current main, 26 intersection checks passed. Production-boundary tests cover all retained facets, late DNS/SNI rows, source deletion, CLI/MCP parity, source/private-snapshot mutation, cancellation, capacity/close draining and cleanup retry. Native tool emulations are not used as real Wireshark proof.

Real verification uses Linux/Node 24.18.0 with Wireshark 4.0.17. Independent Scapy raw-frame/IP parsing and Python reduction of separately invoked TShark fields match six recorded corpora totaling 13,026 packets, including real curl HTTP traffic (12,023 packets/1,000 distinct URIs), 60 TLS certificate-verified HTTPS requests/SNI names, and a 132-address DNS response. The first five corpora already passed built CLI/stdio MCP/schema/provenance/page parity. Final six-corpus verification and the extended real-TShark CI verifier are running on the pushed head, followed by isolated token/timing measurements.

The original proposal's macOS/Windows results precede these resource changes. Current macOS capture inspection therefore returns an explicit capability gap until an enforceable native memory boundary is verified; version probes remain available. Real Windows/Bun Wireshark execution is unverified here, and no new real-platform claim is made. CI is running. Captures, certificates, keys and private verification artifacts are not committed.

@N0zoM1z0
N0zoM1z0 merged commit 9581e06 into morluto:main Oct 13, 2026
39 checks passed
@morluto morluto mentioned this pull request Oct 13, 2026
3 tasks done
@morluto morluto added enhancement New feature or request area: mcp MCP server, transport, and tool registration labels Oct 14, 2026
@morluto morluto added area: cli CLI adapter and one-shot commands provider: pcap Analysis provider / engine: pcap labels Nov 23, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: cli CLI adapter and one-shot commands area: mcp MCP server, transport, and tool registration enhancement New feature or request provider: pcap Analysis provider / engine: pcap

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants