[PR #2506] [MERGED] fix(native): name the ownership helper prerequisite in command failures #5283

Closed
opened 2026-10-31 01:05:26 +00:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/morluto/rea/pull/2506
Author: @kaoru0822-kitauji
Created: 10/13/2026
Status: ✅ Merged
Merged: 10/13/2026
Merged by: @kaoru0822-kitauji

Base: main ← Head: fix/native-ownership-helper-detail


📝 Commits (3)

  • 050bac6 fix(native): name the ownership helper prerequisite in command failures
  • f402f78 test(native): cover the provider's ownership helper diagnostics
  • 160ef99 Merge remote-tracking branch 'origin/main' into fix/native-ownership-helper-detail

📊 Changes

6 files changed (+90 additions, -2 deletions)

View changed files

📝 src/artifacts/MachOSliceArtifactReader.ts (+3 -1)
📝 src/native/CommandRunner.ts (+18 -1)
📝 src/native/NativeMacOSProvider.ts (+1 -0)
📝 tests/boundary/providers/native/machoSliceReader.test.ts (+22 -0)
📝 tests/boundary/providers/native/nativeCommandTermination.test.ts (+21 -0)
📝 tests/boundary/providers/native/nativeProvider.test.ts (+25 -0)

📄 Description

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.

🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/morluto/rea/pull/2506 **Author:** [@kaoru0822-kitauji](https://github.com/kaoru0822-kitauji) **Created:** 10/13/2026 **Status:** ✅ Merged **Merged:** 10/13/2026 **Merged by:** [@kaoru0822-kitauji](https://github.com/kaoru0822-kitauji) **Base:** `main` ← **Head:** `fix/native-ownership-helper-detail` --- ### 📝 Commits (3) - [`050bac6`](https://github.com/morluto/rea/commit/050bac62ca25b7c99f8c2f049d822476069a8cbb) fix(native): name the ownership helper prerequisite in command failures - [`f402f78`](https://github.com/morluto/rea/commit/f402f78894b7abed11450419d8cbeb6f364011ff) test(native): cover the provider's ownership helper diagnostics - [`160ef99`](https://github.com/morluto/rea/commit/160ef99fa224f099ca0921dd6c51b8bb04ea64f5) Merge remote-tracking branch 'origin/main' into fix/native-ownership-helper-detail ### 📊 Changes **6 files changed** (+90 additions, -2 deletions) <details> <summary>View changed files</summary> 📝 `src/artifacts/MachOSliceArtifactReader.ts` (+3 -1) 📝 `src/native/CommandRunner.ts` (+18 -1) 📝 `src/native/NativeMacOSProvider.ts` (+1 -0) 📝 `tests/boundary/providers/native/machoSliceReader.test.ts` (+22 -0) 📝 `tests/boundary/providers/native/nativeCommandTermination.test.ts` (+21 -0) 📝 `tests/boundary/providers/native/nativeProvider.test.ts` (+25 -0) </details> ### 📄 Description ## 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: ```console $ 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: ```console $ 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](https://claude.com/claude-code) <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## 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. <!-- end of auto-generated comment: release notes by coderabbit.ai --> --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-10-31 01:05:26 +00:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
morluto/rea#5283
No description provided.