Skip to content

fix(limits)!: let inspect_pcap_capture take producer_limits for its snapshot and TShark output - #14280

Merged
morluto merged 4 commits into
mainfrom
fix/limits-producer-capture
Nov 24, 2026
Merged

morluto merged 4 commits into
mainfrom
fix/limits-producer-capture

Conversation

@morluto

@morluto morluto commented Nov 24, 2026

Copy link
Copy Markdown
Owner

Summary

Part of #14237. inspect_pcap_capture kept its own hard-coded copies of the producer budgets that inspect_packet_capture already exposes. It refused a capture over 2 GiB, or a TShark JSON pass over 8 MiB, with a fixed ceiling and no override. It now accepts producer_limits (input_bytes, output_bytes), and each refusal reports details.limit for that parameter.

Problem and expected behavior

  • The owned capture snapshot is streamed to disk in 64 KiB chunks, so its 2 GiB bound costs disk, not memory. That makes it a resource limit (class B), and it should be adjustable per call.
  • TShark JSON stdout of 8 MiB is a common size for ordinary captures. It is buffered and parsed in memory, but the parse is already bounded separately by the 128 MiB decoded-JSON estimate.

Change and scope

  • src/domain/pcap/pcapAnalysis.ts owns PCAP_PRODUCER_LIMITS, PCAP_PRODUCER_LIMIT_MAXIMA, pcapProducerLimit and pcapProducerLimitRecovery. The schema, the snapshot, the TShark command and the JSON decoder all use these.
  • output_bytes has a maximum of 128 MiB, the fixed decoded-JSON allowance. Raising it therefore never removes the memory guard; above that, a streaming decoder would be needed.
  • The CLI takes --producer-limits as JSON text, the same as inspect-packet-capture.
  • Registry changes:
    • Removed the snapshot and JSON-decoding pending entries.
    • Reclassified the remaining packet-tool output allowance (capinfos and version or summary probes, 64 KiB fixed-format replies) as protocol.
    • Kept the decoded-JSON expansion and retained-fact allowances fixed, with the streaming reason stated.
  • Pending ceilings: 81 → 78. The prose-only baseline is unchanged at 108; the new refusals bind limit.
  • Not included: the other [Feature] Let fixed producer output and capture allowances use producer_limits #14237 producers (apktool, assetutil, lipo, sigrok, packet-field discovery, SQLite diagnostics, retained command output, native command output, JADX, web-bundle transfer, CDP retention, Kuna, sensitive redaction), which follow in later PRs. Resource limits stay on the existing limit types, out of [Design] One owned target-failure model with derived CLI/MCP projections and a declarative reader conformance registry #14239's TargetFailure.

Contract and boundary impact

  • Semantic owner and earliest changed stage: the pcap domain contract. The provider resolves the limits once and passes them to the snapshot, the commands and the decoders.

  • Contribution scope fit and linked maintainer decision: [Feature] Let fixed producer output and capture allowances use producer_limits #14237, which the owner approved.

  • CLI and MCP/tool-catalog contract: an optional producer_limits field is added; the advertised schema summary is updated.

  • Provider, bridge, target-format, or platform compatibility: none.

  • Evidence, artifact, provenance, or reconstruction contract: none.

  • Read existing files or captured data.

Evidence and regression coverage

  • Tests added or updated:
    • tests/acceptance/pcapProducerLimitsCliMcp.test.ts (Linux; CI): over CLI and MCP, refusals at input_bytes and output_bytes report details.limit with no details.refusal, and the defaults admit the same capture.
    • tests/boundary/mcp/pcapWorkspaceAllocation.test.ts: the sparse 2 GiB + 1 capture now reports details.limit for producer_limits.input_bytes (default 2 GiB) instead of a fixed ceiling. This superseded assertion is replaced, not duplicated.
    • tests/boundary/pcap/pcapSnapshotCancellation.test.ts: the snapshot refuses one byte under the file size with the limit, and admits the file at its size.
    • src/pcap/PcapOutput.test.ts: TShark JSON one byte over output_bytes is refused with the limit, and admitted at its size.
  • Mutation checks:
    • Comparing the snapshot against the default instead of the selected value fails the snapshot test.
    • Dropping the decoder's limit fails the output test.
  • Remaining proof gaps: the CLI/MCP acceptance test runs only on Linux (the capture host profile), so here I ran the MCP boundary test, not the acceptance test. No real Wireshark run was done.

Validation performed

  • npx vitest run src/pcap tests/boundary/pcap tests/boundary/mcp/pcapWorkspaceAllocation.test.ts: passed; the Linux-only tests were skipped on macOS
  • Mutation checks: 2 of 2 caught
  • node scripts/verify/fixed-ceilings.mjs: 96 registered, 78 pending, 108 authored-only
  • node scripts/verify/architecture-guards.mjs: passed
  • npm run build:cached and npm run verify:advertised-schemas -- --update-summary: summary updated
  • Scoped tsc --noEmit on the changed files: clean
  • npx oxfmt --check .: clean
  • npx oxlint on the changed files: no errors

Compatibility, safety, and release

  • Breaking changes or migration steps: refusals at the snapshot or TShark JSON budget report details.limit (producer_limits.input_bytes or producer_limits.output_bytes) and no longer carry a details.refusal fixed_ceiling. Behaviour is unchanged when producer_limits is omitted.
  • Security, privacy, process, or containment review: a larger input_bytes uses more temporary disk. A larger output_bytes stays within the fixed decoded-JSON memory estimate.

…napshot and TShark output

inspect_pcap_capture kept private copies of the producer budgets that
inspect_packet_capture already exposes. It now accepts producer_limits with
input_bytes (the streamed capture snapshot, default 2 GiB) and output_bytes
(each TShark JSON pass, default 8 MiB, at most the fixed 128 MiB decoded-JSON
allowance). Refusals report details.limit for the parameter instead of a
fixed ceiling. The decoded-JSON expansion and retained-fact allowances stay
fixed because raising them needs a streaming decoder; the version and
summary probe capture is reclassified as protocol.

Part of #14237

BREAKING CHANGE: an inspect_pcap_capture refusal at the snapshot or TShark
JSON budget reports details.limit for producer_limits.input_bytes or
producer_limits.output_bytes and no longer carries details.refusal
fixed_ceiling.
@chatgpt-codex-connector

Copy link
Copy Markdown
Codex Review Summary: ❌ Failed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ❌ Failed 2026-11-24T04:51:12.674600Z
We couldn’t complete this review. Comment @codex review to try again.
a4a2155 PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.

@greptile-apps

greptile-apps Bot commented Nov 24, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerView in GreptileConfidence Score: 5/5 Tier: plus

[Medium impact] The reviewed changes appear safe to merge; no new actionable issue was established.

Summary

inspect_pcap_capture now accepts per-call producer_limits through CLI and MCP.

  • Capture inspections let callers choose input and TShark output limits.
  • Partial DNS summaries name the output limit that stopped them.

Diagram

%%{init: {'theme': 'neutral'}}%%
flowchart TD
  A["CLI or MCP request"] --> B["Validate producer_limits"]
  B --> C["Copy snapshot within input_bytes"]
  C --> D["Run TShark within output_bytes"]
  D --> E["Check fixed decoded-JSON allowance"]
  E --> F{"DNS pass needed?"}
  F -->|No| I["Verify snapshot and return Evidence"]
  F -->|Yes| G["Run DNS pass with the same budgets"]
  G -->|Complete| I
  G -->|Output limit| H["Keep partial facts and dns_identity_limit"]
  H --> I
Loading

Reviews (4) · Last reviewed commit: "Merge remote-tracking branch 'origin/mai..." · Reviewed by Greptile

Comment thread src/pcap/PcapProvider.ts Resolved
Comment thread src/pcap/PcapProvider.ts Resolved
… budgets

When only the DNS wire-identity pass exceeds producer_limits.output_bytes,
the partial summary now records dns_identity_limit with the parameter,
effective value, default and range. The pcap output budget is documented as
combined stdout and stderr, as producer_limits.output_bytes is elsewhere.
Acceptance covers TShark output above the old 8 MiB ceiling in both passes.
@morluto
morluto enabled auto-merge (squash) November 24, 2026 14:57
@morluto
morluto merged commit fd09e2b into main Nov 24, 2026
52 checks passed
@morluto
morluto deleted the fix/limits-producer-capture branch November 24, 2026 15:10
@morluto morluto added area: domain Domain logic, errors, and pure functions bug Something isn't working labels Nov 26, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: domain Domain logic, errors, and pure functions bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant