Skip to content

fix(native): name the ownership helper prerequisite in command failures - #2506

Merged
kaoru0822-kitauji merged 3 commits into
mainfrom
fix/native-ownership-helper-detail
Oct 13, 2026
Merged

kaoru0822-kitauji merged 3 commits into
mainfrom
fix/native-ownership-helper-detail

Conversation

@kaoru0822-kitauji

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

Copy link
Copy Markdown
Collaborator

Problem

Every supervised native command launch on macOS needs the Darwin process-ownership helper. When that helper can't be compiled, XcrunCommandRunner turned the typed DarwinProcessOwnershipInspectionError into a bare io failure and dropped its message. Causes include a relative REA_DARWIN_SWIFTC_PATH, REA_DARWIN_SWIFTC_PATH without an absolute SDKROOT, a missing compiler, or an SDK/compiler mismatch after a toolchain update. Users then saw messages that pointed nowhere near the cause:

$ REA_DARWIN_SWIFTC_PATH=/usr/bin/swiftc rea inspect-artifact /bin/ls --format json
… "code":"artifact_operation_failed", … "detail":"lipo could not enumerate universal Mach-O slices"

$ REA_DARWIN_SWIFTC_PATH=/usr/bin/swiftc rea inspect-macho /bin/ls --format json
… "code":"execution_failure", "message":"… Run `rea doctor` …",
  "diagnostics":{"tool":"file","reason":"io","exit_code":null,…}

rea doctor doesn't report it either. The cause chain was lipo: io → xcrun: io → DarwinProcessOwnershipInspectionError("Direct Darwin helper compilation requires absolute REA_DARWIN_SWIFTC_PATH and SDKROOT …"). The SQLite and web-capture providers already show this message in diagnostics.reason. Only the native path lost it.

Fix

  • CommandRunner classifies the typed inspection error once, at the launch boundary. It stores the message as NativeCommandFailure.detail and carries it through the xcrun --find resolution wrapper.
  • NativeMacOSProvider adds detail to the ProviderAdapterError diagnostics.
  • MachOSliceArtifactReader appends the detail to its "lipo could not enumerate" message.

Failure reasons and categories are unchanged. When the helper is healthy, the output is byte-identical: inspect-artifact /bin/ls returns the same evidence ID before and after.

After:

$ REA_DARWIN_SWIFTC_PATH=/usr/bin/swiftc rea inspect-artifact /bin/ls --format json
… "detail":"lipo could not enumerate universal Mach-O slices: Direct Darwin helper compilation requires absolute REA_DARWIN_SWIFTC_PATH and SDKROOT paths selecting a compatible installed Swift compiler and macOS SDK."

$ REA_DARWIN_SWIFTC_PATH=/nonexistent SDKROOT=/x rea inspect-macho /bin/ls --format json
… "diagnostics":{…,"reason":"io",…,"detail":"macOS process ownership inspection requires the Apple Swift compiler via the selected Swift compiler (REA_DARWIN_SWIFTC_PATH) (compiler result: ENOENT): no compiler diagnostics were captured"}

Validation

  • Two new boundary tests use the existing NativeCommandLauncher seam: one on the runner (nativeCommandTermination.test.ts) and one on the slice reader (machoSliceReader.test.ts). Both fail on main and pass with this change. The production ownership host is a process-wide singleton built from process.env at import time, so it can't be injected per test.
  • npm run test:focused passed for those two files plus nativeProvider.test.ts and MachOSliceArtifactReader.test.ts (45 tests). npm run check:fast and format:check also passed.
  • I ran the real CLI on macOS with Command Line Tools and covered three cases: a relative compiler path, a missing SDKROOT, and a nonexistent compiler.

Remaining

rea doctor still doesn't check whether the ownership helper compiles, so its remediation can't point at this. That needs its own doctor check, which I left out of this PR.

🤖 Generated with Claude Code

Summary by CodeRabbit

  • Bug Fixes
    • Improved diagnostics for Mach-O slice enumeration and native command failures by including relevant system error details when available.
    • Clarified when a required macOS process-inspection helper is unavailable.

Every supervised native command launch needs the Darwin process-ownership
helper. When that helper cannot be compiled (relative REA_DARWIN_SWIFTC_PATH,
missing SDKROOT, a missing compiler, or an SDK/compiler mismatch), the
runner reduced the typed DarwinProcessOwnershipInspectionError to a bare
`io` failure. inspect_macho then reported `execution_failure` with no hint,
and inspect_artifact on any universal Mach-O said only "lipo could not
enumerate universal Mach-O slices".

The runner now keeps the inspection message as the failure's `detail` at
the launch boundary and carries it through xcrun resolution. The native
provider adds it to its diagnostics and the slice reader appends it to its
message, matching what the SQLite and capture providers already report.

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-13T06:47:46.680159Z 160ef99 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.

@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: 25e60514-069f-40f4-b4c6-e128cedc0fb7
📥 Commits

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

📒 Files selected for processing (5)
  • src/artifacts/MachOSliceArtifactReader.ts
  • src/native/CommandRunner.ts
  • src/native/NativeMacOSProvider.ts
  • tests/boundary/providers/native/machoSliceReader.test.ts
  • tests/boundary/providers/native/nativeCommandTermination.test.ts

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

📝 Walkthrough

Native command failures now retain selected host-side error details. Tool-resolution failures preserve those details, and provider diagnostics and Mach-O slice errors include them when present.

Changes: Native command error details

Layer / File(s) Summary
Capture and preserve command failure details
src/native/CommandRunner.ts, tests/boundary/providers/native/nativeCommandTermination.test.ts
NativeCommandFailure stores optional detail. captureProcess sets it for DarwinProcessOwnershipInspectionError, and tool-resolution failures preserve it. The test checks the detail and nested cause.
Surface details in diagnostics and slice errors
src/native/NativeMacOSProvider.ts, src/artifacts/MachOSliceArtifactReader.ts, tests/boundary/providers/native/machoSliceReader.test.ts
Provider diagnostics and Mach-O slice errors include non-null detail. The test checks the slice error reason and message.

Priority: ⬇️ Low

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

Change: Bug fix

Suggested reviewers: morluto

Merge Risk: ⚪ Minimal · up to 050ba

This change makes failures clearer when the macOS ownership helper cannot be compiled, and it does not alter how failures are classified. No merge-blocking risk was found.

Pre-merge checks · Passed 4 · Failed 1

Failed Failed checks (1 warning)

Check name Status Explanation Resolution
Description check Warning The description clearly explains the problem, implementation, validation, and remaining doctor-check gap. However, it does not follow the repository template and omits required sections such as Contra… Rewrite the description using the repository template. Include the required sections, complete applicable contract and scope fields, state compatibility and security impacts, document evidence and regression coverage, list validation comman…
Passed Passed checks (4 passed)
Check name Status Explanation
Title check Passed The title clearly identifies the native command failure fix and the preserved ownership-helper prerequisite message. It follows the required type(scope): outcome format.
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 5…
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 clearly explains the problem, implementation, validation, and remaining doctor-check gap. However, it does not follow the repository template and omits required sections such as Contract and boundary impact, Evidence and regression coverage, Compatibility, safety, and release, and Before merge.

Resolution

Rewrite the description using the repository template. Include the required sections, complete applicable contract and scope fields, state compatibility and security impacts, document evidence and regression coverage, list validation commands with results, and complete the Before merge checklist.

  • 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 checks the command’s trail,
And finds the detail in the tale.
Through xcrun paths the message goes,
To slice errors where it shows.
Then hops away beneath the moon.

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

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

Summary

Native command failures now retain the Darwin ownership helper’s compiler or SDK error message.

  • Native command failures now show why ownership-helper setup stopped them.

Diagram

%%{init: {'theme': 'neutral'}}%%
flowchart TD
  A["Darwin ownership helper fails"] --> B["CommandRunner stores detail"]
  B --> C["xcrun resolution preserves detail"]
  C --> D["Provider diagnostics.detail"]
  C --> E["Mach-O slice failure message"]
Loading

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

Comment thread src/native/NativeMacOSProvider.ts Resolved
@kaoru0822-kitauji
kaoru0822-kitauji merged commit 20f51d7 into main Oct 13, 2026
35 checks passed
@kaoru0822-kitauji
kaoru0822-kitauji deleted the fix/native-ownership-helper-detail branch October 13, 2026 07:11
@morluto morluto mentioned this pull request Oct 13, 2026
3 tasks done
@morluto morluto added bug Something isn't working area: native Native analysis and decompilation, including Ghidra, IDA, and Hopper analysis behavior labels Oct 14, 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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants