Skip to content

fix(pcap): page retained diagnostics without splitting a surrogate pair - #2874

Closed
Dragolone wants to merge 7 commits into
morluto:mainfrom
Dragolone:fix/pcap-diagnostics-text-page
Closed

Dragolone wants to merge 7 commits into
morluto:mainfrom
Dragolone:fix/pcap-diagnostics-text-page

Conversation

@Dragolone

Copy link
Copy Markdown
Contributor

Summary

The retained pcap view's diagnostics facet pages tshark/capinfos stderr with a raw value.slice(offset, offset + limit). A page can therefore end on the high half of a non-BMP character, and the next page starts with the orphaned low half. An offset inside a surrogate pair is also accepted. Every other retained text view (Android manifest, native pseudocode, WASM, EVM) uses the shared analysisTextPage owner, which backs off to a whole character and rejects a splitting offset.

No issue is linked: I searched issues and PRs for "pcap diagnostics", "pcap surrogate", "surrogate pair", "diagnostics page" and "pcap view" and found no report. pcapCaptureView.ts has only its introducing commit (9581e06), and no open PR touches it.

Problem and expected behavior

Smallest trigger: retained tshark_stderr = "warn 😀 done", view {kind:"pcap", facet:"diagnostics", stream:"tshark", offset:0, limit:6}, then the returned next_offset.

  • Before: page 1 "warn \ud83d" (examined: 6, next_offset: 6), page 2 "\ude00 done".
  • After: page 1 "warn " (examined: 5, next_offset: 5), page 2 starts with the whole emoji. offset: 6 is rejected as invalid view input ("Diagnostics offset splits a UTF-16 surrogate pair."), as the other text views do.

The view already declares that diagnostic page totals count "UTF-16 diagnostic code units"; this keeps that unit while never emitting half a character.

Change and scope

The diagnostics branch calls analysisTextPage(value ?? "", view.offset, view.limit, "Diagnostics") and returns its error or its text and coverage. status (retained / unknown) and the missing-diagnostics unknown are unchanged. For offsets past the end and for absent diagnostics, the coverage is identical to before (pageViewCoverage does not depend on the offset once exhausted).

Not included: other pcap facets, which page rows, not text.

Contribution scope: an ordinary retained-view correctness fix reusing the existing owner; a maintainer scope decision is not applicable.

Contract and boundary impact

  • Semantic owner and earliest changed stage: diagnostics projection in src/domain/analysisView/pcapCaptureView.ts.
  • Contribution scope fit and linked maintainer decision: in scope; not applicable.
  • CLI and MCP/tool-catalog contract: no schema change. Diagnostics pages no longer split a character, and a splitting offset now returns AnalysisInputError instead of a half character.
  • Provider, bridge, target-format, or platform compatibility: none.
  • Evidence, artifact, provenance, or reconstruction contract: concatenated pages now reproduce the retained text exactly.
  • Target selection, authority, upstream behavior, and cleanup details (if applicable): not applicable.
  • Generated metadata (docs/public/product-catalog.json), package, or installation impact: none.

Expected effects (check known effects; use documentation-only on its own).
Unchecked items do not establish absence; leave uncertainties visible.

  • Read existing files or captured data.
  • Launch or attach to a process.
  • Inject instrumentation or run scripts/code.
  • Change process memory, registers, files, or configuration.
  • Contact network services.
  • Recover protected code or work around protections.
  • Documentation or usability only; no target interaction.
  • Not sure yet; investigation or maintainer guidance needed.

Evidence and regression coverage

  • Tests added or updated: new src/domain/analysisView/pcapCaptureView.test.ts — "pages diagnostics without splitting a surrogate pair". It covers three cases: a splitting offset is rejected, a page whose limit would split the pair backs off ("ab", next_offset: 2), and following next_offset with limit 3 reassembles "ab😀cd" exactly. The parent is built with createEvidence, like the web-capture view tests.
  • Base reproduction: on 204a6f3f2 the test fails at the first assertion (the splitting offset returns ok: true).
  • User-visible CLI/MCP output: not captured separately; the existing pcap retained-view boundary test is Linux-only and was skipped on this macOS host.
  • Remaining proof gaps: Linux-only pcap boundary tests not run locally.

For evidence-bearing changes:

  • Observed, derived, and inferred claims remain distinguishable.
  • Artifact identity, source provenance, and failed attempts remain preserved.
  • Unsupported, incomplete, unavailable, or uncertain outcomes remain visible.

Validation performed

macOS (Apple silicon), Node 24.19.0.

  • npx vitest run src/domain/analysisView/pcapCaptureView.test.ts against the base view — fails.
  • npx vitest run src/domain/analysisView/ with the fix — 6 files, 53 tests passed.
  • npm run build:cached && npx vitest run src/pcap tests/boundary/pcap tests/boundary/cli/pcapCli.test.ts tests/boundary/mcp/pcapMcp.test.ts — 34 passed, 21 skipped (Linux-only).
  • npm run verify:test-discovery — all test files discovered exactly once.
  • npm run typecheck — passed.
  • npx oxfmt --check and npx oxlint on both changed files — passed, no errors.
  • npm run verify:module-boundaries — passed.

Compatibility, safety, and release

  • Breaking changes or migration steps: a caller that requested an offset inside a surrogate pair now gets an input error; resuming from the returned next_offset never does that.
  • Real Hopper/Ghidra, browser, or OS coverage: macOS only; Linux pcap boundary tests skipped here.
  • Package or release metadata impact: none.
  • Security, privacy, process, or containment review: none.

Before merge

  • This PR addresses a concrete problem or an agreed enhancement.
  • Material scope and authority questions are resolved, and any required maintainer scope decision covers the final diff.
  • The PR has one focused outcome and the title follows type(scope): outcome.
  • Related issue is linked, or the reason for not linking one is stated above.
  • Tests cover changed observable behavior and meaningful failure paths.
  • Owning docs, contracts, and generated metadata are updated where needed.
  • User-visible CLI/MCP changes include representative output.
  • I checked the final diff for secrets, unrelated cleanup, and unsupported claims.

The diagnostics facet sliced stderr by raw UTF-16 code units, so a page
could end on half of a non-BMP character and an offset inside one was
accepted. Use the shared analysisTextPage owner, as the Android, native,
WASM and EVM text views do: pages back off to a whole character and a
splitting offset is rejected as invalid view input.
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 13, 2026 •

Copy link
Copy Markdown

Codex Review Summary

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

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-13T19:09:56.541308Z e42d3dc New commits
ℹ️ 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.

@greptile-apps

greptile-apps Bot commented Oct 13, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerConfidence Score: 5/5

[Medium impact] The PR appears safe to merge; no blocking issue was found.

Summary

The PR routes retained pcap diagnostics through analysisTextPage instead of raw string slicing.

  • Pcap diagnostic pages keep whole Unicode characters together.

Review notes: The previous and current commits have different merge bases with the target, so this review used the full PR diff. No previous finding threads were supplied. Tests were inspected, not run. Checking whether another PR supersedes this one was blocked by missing GitHub credentials.

Reviews (5) · Last reviewed commit: "Merge branch 'main' into fix/pcap-diagno..." · Reviewed by Greptile

dakjdakd and others added 6 commits October 14, 2026 00:57
* fix(comparison): preserve incomplete function call evidence

Keep missing, unknown, partial and unresolved call relationships unknown in function comparisons and reconstruction claims. Aggregate IDA caller and callee coverage without overwriting uncertainty.

Validate with 144 focused tests, typecheck/lint, docs checks and test discovery. Real providers were not verified; the full headless IDA session suite requires unavailable Windows native controls.

* fix(comparison): recheck historical calls-only changes

---------

Co-authored-by: morluto <76467478+morluto@users.noreply.github.com>
@morluto morluto added area: domain Domain logic, errors, and pure functions bug Something isn't working labels Oct 14, 2026
morluto added a commit that referenced this pull request Oct 14, 2026
Own service-worker CDP registrations and retry failed teardown. Admit redaction and network metadata against remaining capture capacity, retain explicit omission reasons, and preserve source URL, redirect ancestry, caller-selected content, and historical capture values. Forward CLI cancellation through provider cleanup.

Reviewed fixes: #2263, #2637, #2767, #2845, #2859, #2863, #2872, #2874, #2876, #2879, #2955, #2957, #2961, #3033.

Validation: 25 current event/network source tests passed; earlier focused browser lanes passed 201 source tests and 176 boundary tests with two skips, plus 35 Python tests. Real browser/Windows lanes were not rerun. Playwright allocation before admission remains unbounded by these retention limits.
@Dragolone

Copy link
Copy Markdown
Contributor Author

This change landed on main in f690571 (listed under "Reviewed fixes"), so I'm closing this PR. Thanks for reviewing it!

@Dragolone Dragolone closed this Oct 14, 2026
@morluto

morluto commented Oct 15, 2026

Copy link
Copy Markdown
Owner

@Dragolone, thank you for finding the Unicode edge case in paged capture diagnostics. The paging regression now protects surrogate-pair boundaries while checking that complete pages still reconstruct the retained text (main).

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.

3 participants