[PR #3283] [MERGED] fix(artifacts): inventory universal slices REA cannot structurally index #5696

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

📋 Pull Request Information

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

Base: main ← Head: fix/macho-slices-unsupported-structure


📝 Commits (2)

  • c11bcb9 fix(artifacts): inventory universal slices REA cannot structurally index
  • 51bd696 fix(artifacts): validate every FAT slice past an unsupported one

📊 Changes

4 files changed (+206 additions, -8 deletions)

View changed files

📝 src/artifacts/MachOSliceArtifactReader.test.ts (+125 -0)
📝 src/artifacts/MachOSliceArtifactReader.ts (+14 -3)
📝 src/artifacts/apple/MachoLoadCommandReader.ts (+20 -5)
📝 tests/boundary/providers/native/machoSliceReader.test.ts (+47 -0)

📄 Description

Problem

inspect_artifact and extract_artifact refused a valid universal Mach-O whenever one slice fell outside REA's structural index. On this Mac, /Applications/XLD.app/Contents/MacOS/XLD (an installed, ad-hoc signed app with x86_64, i386, ppc and arm64 slices) failed entirely:

code: artifact_operation_failed, category: execution_failure
message: Artifact is invalid or has changed. Get a fresh copy and try again.
detail: Mach-O structural slice index is unsupported: big-endian Mach-O slices are not supported

The artifact is fine. Only the big-endian PowerPC slice is unsupported, and the "fresh copy" advice is wrong.

Fix

MachOSliceArtifactReader already inventories slices from lipo's ranges, with a limitation, when structural Mach-O facts are unavailable (not-mach-o). An unsupported structural result now takes the same path when lipo reported every slice's offset and size. Each slice carries the limitation Structural Mach-O facts were unsupported (<reason>); slice range is based on lipo output. The existing bounds check against the file size still applies.

When lipo omits a range (for example a thin big-endian file), the reader still fails. It now uses the unavailable reason, which reports missing support for the target, instead of format, which reports a corrupt artifact.

Validation

Real data:

  • rea inspect-artifact /Applications/XLD.app/Contents/MacOS/XLD: before, the error above; after, 4 slices in 1.15 s. Each slice's size and SHA-256 equals the byte range from XLD's FAT table (checked independently in Python).
  • rea extract-artifact on the same binary: before, the same error; after, it succeeds.

Tests:

  • A new darwin case in tests/boundary/providers/native/machoSliceReader.test.ts runs the real lipo on a FAT file with a little-endian arm64 slice and a big-endian ppc slice. It fails on main and passes with this change.
  • npm run test:focused on the slice-reader tests (5 files, 23 tests) passes.
  • npm run check:fast passes.

🤖 Generated with Claude Code


🔄 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/3283 **Author:** [@kaoru0822-kitauji](https://github.com/kaoru0822-kitauji) **Created:** 10/14/2026 **Status:** ✅ Merged **Merged:** 10/14/2026 **Merged by:** [@kaoru0822-kitauji](https://github.com/kaoru0822-kitauji) **Base:** `main` ← **Head:** `fix/macho-slices-unsupported-structure` --- ### 📝 Commits (2) - [`c11bcb9`](https://github.com/morluto/rea/commit/c11bcb97e0bb14946cf65c2123c2ba92049d31a1) fix(artifacts): inventory universal slices REA cannot structurally index - [`51bd696`](https://github.com/morluto/rea/commit/51bd6963c9b0a4830819bd2a006a0582fccacc70) fix(artifacts): validate every FAT slice past an unsupported one ### 📊 Changes **4 files changed** (+206 additions, -8 deletions) <details> <summary>View changed files</summary> 📝 `src/artifacts/MachOSliceArtifactReader.test.ts` (+125 -0) 📝 `src/artifacts/MachOSliceArtifactReader.ts` (+14 -3) 📝 `src/artifacts/apple/MachoLoadCommandReader.ts` (+20 -5) 📝 `tests/boundary/providers/native/machoSliceReader.test.ts` (+47 -0) </details> ### 📄 Description ## Problem `inspect_artifact` and `extract_artifact` refused a valid universal Mach-O whenever one slice fell outside REA's structural index. On this Mac, `/Applications/XLD.app/Contents/MacOS/XLD` (an installed, ad-hoc signed app with x86_64, i386, ppc and arm64 slices) failed entirely: ``` code: artifact_operation_failed, category: execution_failure message: Artifact is invalid or has changed. Get a fresh copy and try again. detail: Mach-O structural slice index is unsupported: big-endian Mach-O slices are not supported ``` The artifact is fine. Only the big-endian PowerPC slice is unsupported, and the "fresh copy" advice is wrong. ## Fix `MachOSliceArtifactReader` already inventories slices from `lipo`'s ranges, with a limitation, when structural Mach-O facts are unavailable (`not-mach-o`). An `unsupported` structural result now takes the same path when `lipo` reported every slice's offset and size. Each slice carries the limitation `Structural Mach-O facts were unsupported (<reason>); slice range is based on lipo output.` The existing bounds check against the file size still applies. When `lipo` omits a range (for example a thin big-endian file), the reader still fails. It now uses the `unavailable` reason, which reports missing support for the target, instead of `format`, which reports a corrupt artifact. ## Validation Real data: - `rea inspect-artifact /Applications/XLD.app/Contents/MacOS/XLD`: before, the error above; after, 4 slices in 1.15 s. Each slice's size and SHA-256 equals the byte range from XLD's FAT table (checked independently in Python). - `rea extract-artifact` on the same binary: before, the same error; after, it succeeds. Tests: - A new darwin case in `tests/boundary/providers/native/machoSliceReader.test.ts` runs the real `lipo` on a FAT file with a little-endian arm64 slice and a big-endian ppc slice. It fails on main and passes with this change. - `npm run test:focused` on the slice-reader tests (5 files, 23 tests) passes. - `npm run check:fast` passes. 🤖 Generated with [Claude Code](https://claude.com/claude-code) --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-10-31 01:08:43 +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#5696
No description provided.