Skip to content

fix(native): name numeric Mach-O build-version platforms and tools - #2065

Merged
morluto merged 2 commits into
morluto:mainfrom
TonyWu2333:fix/macho-build-version-names
Oct 13, 2026
Merged

morluto merged 2 commits into
morluto:mainfrom
TonyWu2333:fix/macho-build-version-names

Conversation

@TonyWu2333

Copy link
Copy Markdown
Contributor

Summary

inspect_macho reports build_metadata from otool -h -l. Non-verbose otool prints LC_BUILD_VERSION platform and tool codes as numbers, so a modern Mach-O reports platform: "1" and tool name: "3". LC_VERSION_MIN_* commands in the same field report symbolic platforms ("MACOSX", "IPHONEOS"). Callers have to know <mach-o/loader.h> to read the build platform, and the values from the two command kinds cannot be compared directly.

No linked issue: I found this while running inspect-macho against system binaries on macOS 26.5.1.

Problem and expected behavior

Before, for /bin/ls (arm64e slice):

{"platform":"1","minimum_os":"11.0","sdk":"26.5","tools":[{"name":"3","version":"1267.0"}]}

otool -lv and vtool -show-build print the same command as platform MACOS / tool LD. The normalized result should use the symbolic names too.

Change and scope

parseOtoolLoadCommands maps the platform and tool codes declared in the SDK's <mach-o/loader.h> (PLATFORM_MACOS 1 … PLATFORM_VISIONOS_EXCLAVEKIT 24, TOOL_CLANG … TOOL_METAL_FRAMEWORK) to their names without the prefix. These match otool -lv output, except that otool prints TOOL_METAL for 1024 where this uses METAL.

  • Unknown codes keep their printed value. A newer platform is still reported, not dropped or guessed.
  • Values that otool already printed symbolically pass through unchanged.
  • Raw load_commands[].fields still carry otool's numeric values. Only normalized build_metadata changes.

Contract and boundary impact

  • Semantic owner and earliest changed stage: src/native/parsers/otool.ts (collectBuild, parseBuildTools)
  • CLI and MCP/tool-catalog contract: no schema change. build_metadata[].platform and tools[].name remain strings; their values for known codes change from numeric to symbolic.
  • Provider, bridge, target-format, or platform compatibility: macOS native provider only
  • Evidence, artifact, provenance, or reconstruction contract: raw provenance and load-command fields unchanged
  • Process execution, authorization, cleanup, or containment impact: none
  • Generated metadata, package, or installation impact: none

Evidence and regression coverage

  • Tests added or updated: tests/boundary/providers/native/nativeLoadKinds.golden.test.ts: "names numeric build-version platforms and tools". It covers known and unknown platform codes, known and unknown tool codes, already-symbolic input, and unchanged raw fields.

  • Base reproduction or other evidence: the new test fails on 3bdc873 and passes with this change. I took the name table from the macOS 26.5 SDK loader.h and checked it against otool -lv (cctools-1040) on binaries rewritten with vtool -set-build-version for platforms 1–24 and each declared tool.

  • User-visible CLI/MCP output: rea inspect-macho /bin/ls --format json now reports {"platform":"MACOS","minimum_os":"11.0","sdk":"26.5","tools":[{"name":"LD","version":"1267.0"}]}

  • Remaining proof gaps: none known

  • 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

  • npm run test:focused -- tests/boundary/providers/native/nativeLoadKinds.golden.test.ts tests/boundary/providers/native/nativeMachoHeader.golden.test.ts tests/boundary/providers/native/nativeSelectedArchitecture.test.ts tests/boundary/providers/native/nativeReexport.golden.test.ts: 37 passed
  • The same new test on the base revision: fails as expected
  • npm run check:fast: passed
  • rea inspect-macho on /bin/ls, /usr/bin/ssh, /usr/libexec/sharingd, Calculator.app (macOS 26.5.1, Apple silicon): symbolic build metadata

Compatibility, safety, and release

  • Breaking changes or migration steps: callers that matched the numeric strings ("1", "3") in build_metadata now see "MACOS" / "LD". The raw numeric values remain in load_commands[].fields.
  • Real Hopper/Ghidra, browser, or OS coverage: macOS 26.5.1 native tools. No Hopper or Ghidra involvement.
  • Package or release metadata impact: none
  • Security, privacy, process, or containment review: none

Review checklist

  • This PR addresses a concrete problem or an agreed enhancement.
  • 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.

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 12, 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 ⚠️ Failed 2026-10-12T05:56:17.026005Z 5deaf25 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.

@NIU-123370 NIU-123370 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Local review completed. The numeric-to-symbolic Mach-O mapping preserves unknown values and raw load-command fields. Focused native golden suite passed: 13 tests.

@NIU-123370

Copy link
Copy Markdown
Contributor

Checked the CI failures locally. The failing cases do not fail with this diff applied, so I don't read them as a regression from this PR.

What CI reported (the only run visible for this head 5deaf25 is run 38209672263, whose jobs start at 10:44:49Z; fork PR runs wait for approval before executing, so this is a single CI sample):

  • Test shard (1/4), step npm run test:ci:shard:run -- --shard=1/4: 3 failed tests, all in src/adb/AdbProvider.test.ts (bounded logcat dump returns the output as one unsplit line; case-insensitive package resolution returns []; ENOENT on /tmp/rea-adb-X6BjXw/observed). 3 failed | 2202 passed | 11 skipped.
  • Test shard (2/4): 1 failed test, tests/boundary/cli/cliOptionAliases.test.ts > "register only single-character short flags", with trace-web-module-imports --import-map-path <string> and --import-map-base-url <string> listed as undescribed. 1 failed | 2338 passed | 14 skipped.
  • Test (coverage + timing) failed only at "Require successful test shards" (and an artifact upload), and CI required failed only at "Require every selected lane to pass" — both downstream of those two shards.

This diff is src/native/parsers/otool.ts (+57 −2) and tests/boundary/providers/native/nativeLoadKinds.golden.test.ts (+56). Neither failing file reads otool.ts.

Local reproduction (macOS, Node v22.12.0, dependencies from this repo's lockfile; incur is pinned exactly 0.6.1 in package.json and in the lockfile at both 3bdc873 and fe4b94a66, so the help text parsed by cliOptionAliases is the same version CI used):

  • At trunk fe4b94a66 (the main tip when the run started, 10:44:02Z): src/adb/AdbProvider.test.ts + tests/boundary/cli/cliOptionAliases.test.ts → 2 files passed, 47 tests passed.
  • Merging fe4b94a66 into this head reproduces the CI merge ref; git diff --name-only fe4b94a66 on that tree lists exactly the two files above, nothing else. On that tree those two files plus this PR's golden test → 3 files passed, 0 failed (nativeLoadKinds.golden.test.ts is 13 tests).
  • Reverting only src/native/parsers/otool.ts to this PR's base 3bdc873 and re-running the golden test makes exactly one test fail: names numeric build-version platforms and tools. So the added case does pin the behavior it claims, in both directions.

Where that leaves it: no observed net regression from this change. I can't go further than that — I have no rights to re-run a workflow on this repo, and the failing signature exists only in this one run, so "environment/load" versus "something real" is not settled yet. For reference, the last completed main CI run (38224038323 at 08:31Z, c22111eca) was red on a different case, tests/boundary/mcp/promptCompletion.test.ts, plus the two darwin verify:package lanes, so this repo's CI has several independent live failures today. A re-run of run 38209672263 by someone with access would be the cheapest way to separate those.

Nothing in the change itself needs my review to be different: unknown platform/tool codes keep their printed value, raw load_commands[].fields are untouched, and the already-symbolic LC_VERSION_MIN_* path passes through.

Non-verbose otool prints LC_BUILD_VERSION platform and tool codes as numbers, so inspect_macho build metadata reported platform "1" and tool "3" while LC_VERSION_MIN_* commands report symbolic platforms such as "MACOSX". Name the codes declared in the SDK's <mach-o/loader.h> and keep unknown codes as printed. Raw load-command fields are unchanged.
@TonyWu2333
TonyWu2333 force-pushed the fix/macho-build-version-names branch from 5deaf25 to cdc0ad2 Compare October 13, 2026 02:01
@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

[Medium impact] The PR appears safe to merge; the previous coverage gap is addressed and no new blocking issue was found.

Summary

The PR names known numeric Mach-O build platforms and tools while preserving unknown values and raw fields.

  • Mach-O build metadata uses names for known platform and tool codes.

Reviews (2) · Last reviewed commit: "fix(native): bind Mach-O build names to ..." · Reviewed by Greptile

@morluto

morluto commented Oct 13, 2026

Copy link
Copy Markdown
Owner

Review findings addressed at their producing boundaries and consumers. Latest changes were reviewed from source; tests and provider runs were skipped at the maintainer's request. Findings requiring separate decisions or verification remain open.

  1. thread 1

The producer no longer derives platform codes from array positions: every platform is bound to its explicit numeric code. Added independent table cases for all 24 platforms and all 11 declared tool codes, while retaining the existing unknown-code and already-symbolic cases. This removes the positional brittleness and covers the requested complete mapping; the added tests were not run at the user's request.

Source inspected at 49f7765; git diff --check passed. Tests, builds, source checks and CI reruns were skipped at the user's explicit request. No passing runtime/provider verification is claimed for this update.

@morluto morluto added bug Something isn't working area: native Native analysis and decompilation, including Ghidra, IDA, and Hopper analysis behavior P2: medium Medium priority issue labels Oct 13, 2026
@morluto
morluto merged commit 77e71d5 into morluto:main Oct 13, 2026
34 checks passed
rjvaleo pushed a commit to rjvaleo/rea that referenced this pull request Dec 1, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: native Native analysis and decompilation, including Ghidra, IDA, and Hopper analysis behavior bug Something isn't working P2: medium Medium priority issue

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants