Skip to content

fix(pcap): order evidence ties by code point instead of host locale - #2509

Merged
morluto merged 1 commit into
mainfrom
fix/locale-independent-evidence-order
Oct 13, 2026
Merged

morluto merged 1 commit into
mainfrom
fix/locale-independent-evidence-order

Conversation

@kaoru0822-kitauji

@kaoru0822-kitauji kaoru0822-kitauji commented Oct 13, 2026 •

Copy link
Copy Markdown
Collaborator

Problem

inspect_pcap_capture breaks ties between equal-count endpoints and protocol stacks with String#localeCompare. Flutter build inspection sorts APK lib/<abi>/ directory names the same way. localeCompare follows the host's ICU default locale, which comes from LANG. The same capture can therefore produce differently ordered Evidence, with a different digest, depending on which host or shell ran REA:

$ for L in en_US da_DK lt_LT; do LANG=$L.UTF-8 LC_ALL=$L.UTF-8 node -e '…sort((x,y)=>x.localeCompare(y))'; done
en_US ["…:tcp:aarp","…:tcp:zz","…:udp:ssdp","…:udp:syslog","fe80::1","fe80:1::1"]
da_DK ["…:tcp:zz","…:tcp:aarp",…]            # Danish sorts "aa" as å, after z
lt_LT [… ,"…:udp:syslog","…:udp:ssdp", …]     # Lithuanian sorts y with i

Every locale also disagrees with code-point order on IPv6 text: it sorts fe80::1 before fe80:1::1. The other Evidence producers already use the locale-independent compareUnicodeCodePoints (src/domain/unicodeCodePointOrder.ts). These four calls were the only production uses of localeCompare.

Fix

The two pcap sorts and the two Flutter ABI sorts now use compareUnicodeCodePoints. Primary orderings are unchanged: packet count, and Flutter's ABI preference list. The usual Flutter ABIs (arm64-v8a, armeabi-v7a, x86, x86_64) sort the same either way.

Validation

  • New PcapOutput.test.ts case: equal-count fe80::1 and fe80:1::1 endpoints, plus eth:llc:zz and eth:llc:aarp protocols. It fails on main under any locale and passes with this change.
  • npm run test:focused passed for the pcap provider, retained-view, CLI and MCP tests and the Flutter boundary tests, except one pre-existing failure.
    • That failure is pcapProviderCrossPlatform.test.ts > rejects a path that is not a readable file. It fails the same way on clean main on macOS, because hosts without a native bound refuse before reading the path. It's unrelated to this change, and I'm fixing it in a separate PR.
  • npm run check:fast and format:check pass.
  • I didn't run a real TShark; it isn't installed on this macOS host. The change only affects the order of ties in the parsed fields.

🤖 Generated with Claude Code

Summary by CodeRabbit

  • Bug Fixes
    • Flutter ABI selection and network report sorting now use consistent code-point ordering, avoiding differences caused by host locale.
  • Tests
    • Added coverage for consistent ordering of equally ranked endpoints and protocols.

The pcap summary sorted equal-count endpoints and protocol stacks with
String#localeCompare, and Flutter build inspection sorted APK ABI
directory names the same way. localeCompare follows the host's ICU
locale, so the same capture produced differently ordered Evidence on
different hosts: under da_DK "aarp" sorts after "zz", under lt_LT
"syslog" sorts before "ssdp", and every locale puts "fe80::1" before
"fe80:1::1". Use the repository's compareUnicodeCodePoints, as the
other Evidence producers already do.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@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-13T05:12:26.184572Z ad129c4 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.

@coderabbitai

coderabbitai Bot commented Oct 13, 2026 •

Copy link
Copy Markdown

Review in Change Stack →

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration
  • Configuration used: Organization UI
  • Review profile: ASSERTIVE
  • Plan: Advanced
  • Run ID: a4820b12-f3ef-48f2-8893-7dfd99202512
📥 Commits

Reviewing files that changed from the base of the PR and between 8b18171 and ad129c4.

📒 Files selected for processing (3)
  • src/flutter/FlutterBuildProvider.ts
  • src/pcap/PcapOutput.test.ts
  • src/pcap/PcapOutput.ts

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 7 remain after this review.

📝 Walkthrough

Flutter ABI sorting and PCAP endpoint and protocol tie-breaking now use Unicode code-point ordering instead of locale-dependent ordering. A PCAP test checks the ordering of equal-count endpoints and protocols.

Changes: Flutter ABI Ordering

Layer / File(s) Summary
Apply code-point ordering to ABI selection
src/flutter/FlutterBuildProvider.ts
Flutter build identification and Dart AOT inspection sort ABIs by Unicode code point.

PCAP Output Ordering

Layer / File(s) Summary
Apply and test code-point tie-breaking
src/pcap/PcapOutput.ts, src/pcap/PcapOutput.test.ts
Endpoint and protocol ties use Unicode code-point ordering. A test checks the ordering for equal-count results.

Priority: ⬇️ Low

Estimated code review effort: 2 (Simple) | ~10 minutes

Change: Bug fix

Suggested reviewers: 3ql

Merge Risk: ⚪ Minimal · up to ad129

No actionable merge-blocking risk was identified in the reviewed changes.

Pre-merge checks · Passed 4 · Failed 1

Failed Failed checks (1 warning)

Check name Status Explanation Resolution
Description check Warning The description explains the problem, fix, regression coverage, validation results, and unavailable TShark coverage. However, it omits most required template sections, including contract and boundary … Update the description to use the required headings and complete the missing fields. Add Summary; Problem and expected behavior; Change and scope; Contract and boundary impact; Evidence and regression coverage; Validation performed with exa…
Passed Passed checks (4 passed)
Check name Status Explanation
Title check Passed The title clearly and concisely describes the main change: replacing host-locale ordering with code-point ordering for pcap evidence ties.
Docstring Coverage Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check. Docstring coverage is scoped to functions touched by this diff. Analyzed 0 functions across 3…
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Full details: Description check

Explanation

The description explains the problem, fix, regression coverage, validation results, and unavailable TShark coverage. However, it omits most required template sections, including contract and boundary impact, contribution scope, compatibility and release impact, security review, remaining proof gaps, and the before-merge checklist.

Resolution

Update the description to use the required headings and complete the missing fields. Add Summary; Problem and expected behavior; Change and scope; Contract and boundary impact; Evidence and regression coverage; Validation performed with exact commands and results; Compatibility, safety, and release; and Before merge. State the scope decision or mark it not applicable, document the issue link or explain why none exists, record package and metadata impact, and complete the applicable checklist items.

  • Fix all pre-merge checks with AI
✨ Finishing Touches
📝 Generate docstrings
  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Warning

Billing warning: we have not been able to collect payment for this subscription for more than 72 hours. Please update the payment method or pay any pending invoices in Billing to avoid service interruption.

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

A rabbit sorts the letters bright
By code-point paths, not locale’s flight
The endpoints line up in a row
The protocols match their flow
A test confirms the order is right

Comment @coderabbitai help to get the list of available commands.

@morluto

morluto commented Oct 13, 2026

Copy link
Copy Markdown
Owner

@greptileai review

@greptile-apps

greptile-apps Bot commented Oct 13, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerConfidence Score: 5/5 Tier: plus

[Medium impact] The PR appears safe to merge; no actionable issues were found.

Summary

This PR makes pcap evidence and Flutter ABI ordering independent of the host locale by using compareUnicodeCodePoints.

  • Packet evidence ties now sort the same on every host.
  • Flutter ABI results no longer depend on the host locale.

kaoru0822-kitauji reports that the existing pcapProviderCrossPlatform.test.ts readable-file failure also occurs on clean main on macOS and will be fixed separately.

Reviews (1) · Last reviewed commit: "fix(pcap): order evidence ties by code p..." · Reviewed by Greptile

@morluto
morluto merged commit f6556ad into main Oct 13, 2026
37 checks passed
@morluto
morluto deleted the fix/locale-independent-evidence-order branch October 13, 2026 06:44
@morluto morluto mentioned this pull request Oct 13, 2026
3 tasks done
@morluto morluto added bug Something isn't working area: evidence Evidence, artifacts, and reconstruction labels Oct 14, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: evidence Evidence, artifacts, and reconstruction bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants