[PR #4352] [MERGED] fix(artifacts): reconcile ARM32 Mach-O slice names by subtype #6194

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

📋 Pull Request Information

Original PR: https://github.com/morluto/rea/pull/4352
Author: @To3akaRin
Created: 10/16/2026
Status: ✅ Merged
Merged: 10/22/2026
Merged by: @morluto

Base: main ← Head: codex/rea-oct16-artifacts


📝 Commits (10+)

  • 1ccb40d fix(artifacts): reconcile ARM32 Mach-O slice names with subtypes
  • 5ee100c chore: merge main into ARM slice artifact fix
  • 116b31d test(snapshot): preserve Evidence-scoped native workflow unknowns
  • 67928e2 Merge commit 'e8da7e1edd' into codex/rea-oct16-artifacts
  • 79a387e test(process): assert owned snapshot cancellation outcomes
  • 0a61191 test(process): preserve snapshot race causes and owned cleanup
  • 0eac8c6 test(cli): scope runtime cleanup provider injection
  • 80df272 test(artifacts): use valid ASAR bytes for signature control
  • ab7daf6 Merge commit 'ba866a26ec' into codex/rea-oct16-artifacts
  • bc8a11a test(mcp): isolate snapshot filesystem fault injection

📊 Changes

6 files changed (+378 additions, -9 deletions)

View changed files

📝 docs/native-investigation.md (+9 -0)
➕ src/artifacts/MachOSliceArchitecture.test.ts (+108 -0)
📝 src/artifacts/MachOSliceArtifactReader.ts (+34 -9)
➕ tests/boundary/cli/artifactArmSlicesCli.test.ts (+58 -0)
➕ tests/boundary/mcp/artifactArmSlicesMcp.test.ts (+64 -0)
➕ tests/fixtures/machoArmSlices.ts (+105 -0)

📄 Description

Summary

Fix inspect_artifact and extract_artifact rejecting valid ARM32 universal Mach-O slices as integrity_mismatch. An armv7 slice is structurally classified as the arm family; comparing those two strings previously rejected otherwise matching bytes.

Problem and expected behavior

A self-owned 16 KiB FAT fixture contains armv7 (CPU 12/subtype 9), armv7s (12/11), and arm64 slices. System lipo -detailed_info accepts all three. On base 42fc6c53, the public CLI fails at armv7 despite matching CPU, offset, length, and alignment. Inspection should preserve each exact slice name and range; extraction should copy the same bytes.

Found during contribution triage; the reproducer and regression tests are included in this PR. Related issue #4280 concerns a distinct ARM64 subtype already handled by the current base. This PR does not claim to fix that issue.

Change and scope

The artifact reader reconciles a bounded set of ARM32 implementation names with their exact raw subtype, using Apple's cctools architecture table. It retains the structural arm family, existing physical identity checks, and exact lipo names in slice paths. Unknown names and mismatched subtypes remain rejected.

  • Semantic owner: MachOSliceArtifactReader, at lipo/FAT identity reconciliation.
  • Scope decision: not applicable; ordinary fix within existing static inventory/extraction capabilities.
  • CLI/MCP schemas, provider admission, target execution authority, generated metadata and installation: unchanged.
  • Evidence: existing range, hash, manifest and read-command provenance retained.
  • Effects: existing local reads and supervised lipo process; only an explicit extraction request writes derived slice files. No target execution, mounting, network access or global configuration changes.

Evidence and regression coverage

  • Portable reader regressions cover 14 ARM32 names, capability bits, incorrect names/subtypes, and conflicting CPU, capability, offset, size and alignment metadata. Before the production change: 15 positive cases failed; 10 rejection controls passed.
  • Real macOS CLI and production MCP server/SDK transport each inspect and extract a mixed armv7/armv7s/arm64 fixture. Assertions verify complete inventory, original ranges, slice-of edges, hashes, unchanged input, exact extracted bytes, and matching inspection/extraction manifests. MCP uses an in-memory transport with the real artifact provider and real system lipo.
  • Representative successful inventory: slices/armv7 at 4096+44, slices/armv7s at 8192+44, and slices/arm64 at 12288+48, all hash_status: verified. The baseline CLI instead returns artifact_operation_failed / integrity_mismatch at the first ARM32 slice.

Current branch validation

The branch was reconciled with current main while preserving this PR's feature-specific patch; unrelated shared CI repairs have been superseded by upstream and are no longer part of the current diff. See the reconciliation and local verification report.

Remote CI required passed on head 627379f0. The PR readiness status also passed at the last readback. Earlier feature checks below remain historical evidence for their stated revisions.

Earlier feature validation

  • npm run test:focused -- src/artifacts/MachOSliceArchitecture.test.ts src/artifacts/MachOSliceArtifactReader.test.ts tests/boundary/cli/artifactArmSlicesCli.test.ts tests/boundary/mcp/artifactArmSlicesMcp.test.ts tests/boundary/providers/native/machoSliceReader.test.ts tests/boundary/providers/native/artifactProvider.machOSlices.test.ts — 51 tests passed across 6 files, 6.35 s observed.
  • npm run test:focused -- tests/boundary/mcp/artifactArmSlicesMcp.test.ts — passed after strengthening the cleanup assertion.
  • npm run check — passed, including typecheck and architecture guards; existing lint warnings remain.
  • npm run docs:check — passed, including 5 README consistency tests.
  • npm run verify:test-discovery — all 1,403 test files discovered exactly once.
  • npm run jscpd — passed: 3.23% duplicated lines, configured threshold 3.5%.
  • git diff --check — passed.

Host: macOS 15.7.7 (24G720), Node 24.18.0, npm 11.16.0. Real lipo: /Library/Developer/CommandLineTools/usr/bin/lipo, SHA-256 1cd322ae54394e71eefceda6a74946ef0ff678924f890de7520341c34133ef84; Command Line Tools package 16.4.0.0.1.1747106510. lipo advertises no version option and retained tool provenance has tool_version: null.

Compatibility, cost, and limits

No schema changes or migration. The fix adds one fixed-size name lookup per candidate comparison, no additional native commands or byte reads. Test duration above is an observed validation cost, not a throughput benchmark; production CPU/RSS and large-file throughput were not measured. Real OS coverage is the synthetic three-slice macOS fixture; other ARM names use portable captured-command boundaries. No Hopper/Ghidra, ARM target execution, Windows/Linux native lipo, or real-world ARM32 application corpus was exercised. The full repository suite was not run for this focused change.

Author readiness

Human owner: @To3akaRin

  • I reviewed the final diff and relevant existing code, understand the change and its edge cases, and take responsibility for the complete PR, including AI-assisted work.
  • I checked the evidence above, confirmed it supports the current change, and recorded meaningful validation gaps.
  • I declare this PR ready for initial maintainer review.

Before merge

  • Human ownership/readiness review and remote CI are complete.

🔄 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/4352 **Author:** [@To3akaRin](https://github.com/To3akaRin) **Created:** 10/16/2026 **Status:** ✅ Merged **Merged:** 10/22/2026 **Merged by:** [@morluto](https://github.com/morluto) **Base:** `main` ← **Head:** `codex/rea-oct16-artifacts` --- ### 📝 Commits (10+) - [`1ccb40d`](https://github.com/morluto/rea/commit/1ccb40d3114bf052988a65696e416d8cacb6e21f) fix(artifacts): reconcile ARM32 Mach-O slice names with subtypes - [`5ee100c`](https://github.com/morluto/rea/commit/5ee100c80ca10b6864d54d53a6458f0503e6f11c) chore: merge main into ARM slice artifact fix - [`116b31d`](https://github.com/morluto/rea/commit/116b31d2b7e593ce7e41901b23104af13e6d1829) test(snapshot): preserve Evidence-scoped native workflow unknowns - [`67928e2`](https://github.com/morluto/rea/commit/67928e235baf9781cad2f600ed2fc2cbe776eb06) Merge commit 'e8da7e1edd075feec0e6beedec93d5645fed8125' into codex/rea-oct16-artifacts - [`79a387e`](https://github.com/morluto/rea/commit/79a387e11a495d16d1fd99f3480bd72759512be1) test(process): assert owned snapshot cancellation outcomes - [`0a61191`](https://github.com/morluto/rea/commit/0a611910104ea00d5cc28fc49cc4a26c2742e272) test(process): preserve snapshot race causes and owned cleanup - [`0eac8c6`](https://github.com/morluto/rea/commit/0eac8c6014de0b33808e7ceb6555b458a7ac2ad4) test(cli): scope runtime cleanup provider injection - [`80df272`](https://github.com/morluto/rea/commit/80df2727d665a85e4aa6ef37849ea4a686ae391c) test(artifacts): use valid ASAR bytes for signature control - [`ab7daf6`](https://github.com/morluto/rea/commit/ab7daf6bebfc329e857e37b0711dd10041fb20e0) Merge commit 'ba866a26ecbe179a717e746cbc0d1605ae616ad5' into codex/rea-oct16-artifacts - [`bc8a11a`](https://github.com/morluto/rea/commit/bc8a11acbedcdaec7f34f3d15240c5e8ae392d12) test(mcp): isolate snapshot filesystem fault injection ### 📊 Changes **6 files changed** (+378 additions, -9 deletions) <details> <summary>View changed files</summary> 📝 `docs/native-investigation.md` (+9 -0) ➕ `src/artifacts/MachOSliceArchitecture.test.ts` (+108 -0) 📝 `src/artifacts/MachOSliceArtifactReader.ts` (+34 -9) ➕ `tests/boundary/cli/artifactArmSlicesCli.test.ts` (+58 -0) ➕ `tests/boundary/mcp/artifactArmSlicesMcp.test.ts` (+64 -0) ➕ `tests/fixtures/machoArmSlices.ts` (+105 -0) </details> ### 📄 Description ## Summary Fix `inspect_artifact` and `extract_artifact` rejecting valid ARM32 universal Mach-O slices as `integrity_mismatch`. An `armv7` slice is structurally classified as the `arm` family; comparing those two strings previously rejected otherwise matching bytes. ## Problem and expected behavior A self-owned 16 KiB FAT fixture contains `armv7` (CPU 12/subtype 9), `armv7s` (12/11), and `arm64` slices. System `lipo -detailed_info` accepts all three. On base `42fc6c53`, the public CLI fails at `armv7` despite matching CPU, offset, length, and alignment. Inspection should preserve each exact slice name and range; extraction should copy the same bytes. Found during contribution triage; the reproducer and regression tests are included in this PR. Related issue #4280 concerns a distinct ARM64 subtype already handled by the current base. This PR does not claim to fix that issue. ## Change and scope The artifact reader reconciles a bounded set of ARM32 implementation names with their exact raw subtype, using [Apple's cctools architecture table](https://github.com/apple-oss-distributions/cctools/blob/main/libstuff/arch.c). It retains the structural `arm` family, existing physical identity checks, and exact lipo names in slice paths. Unknown names and mismatched subtypes remain rejected. - Semantic owner: `MachOSliceArtifactReader`, at lipo/FAT identity reconciliation. - Scope decision: not applicable; ordinary fix within existing static inventory/extraction capabilities. - CLI/MCP schemas, provider admission, target execution authority, generated metadata and installation: unchanged. - Evidence: existing range, hash, manifest and read-command provenance retained. - Effects: existing local reads and supervised lipo process; only an explicit extraction request writes derived slice files. No target execution, mounting, network access or global configuration changes. ## Evidence and regression coverage - Portable reader regressions cover 14 ARM32 names, capability bits, incorrect names/subtypes, and conflicting CPU, capability, offset, size and alignment metadata. Before the production change: 15 positive cases failed; 10 rejection controls passed. - Real macOS CLI and production MCP server/SDK transport each inspect and extract a mixed `armv7`/`armv7s`/`arm64` fixture. Assertions verify complete inventory, original ranges, slice-of edges, hashes, unchanged input, exact extracted bytes, and matching inspection/extraction manifests. MCP uses an in-memory transport with the real artifact provider and real system lipo. - Representative successful inventory: `slices/armv7` at `4096+44`, `slices/armv7s` at `8192+44`, and `slices/arm64` at `12288+48`, all `hash_status: verified`. The baseline CLI instead returns `artifact_operation_failed / integrity_mismatch` at the first ARM32 slice. ## Current branch validation The branch was reconciled with current main while preserving this PR's feature-specific patch; unrelated shared CI repairs have been superseded by upstream and are no longer part of the current diff. See the [reconciliation and local verification report](https://github.com/morluto/rea/pull/4352#issuecomment-6307378221). Remote [CI required](https://github.com/morluto/rea/actions/runs/39539304991/job/119026992948) passed on head `627379f0`. The PR readiness status also passed at the last readback. Earlier feature checks below remain historical evidence for their stated revisions. ## Earlier feature validation - `npm run test:focused -- src/artifacts/MachOSliceArchitecture.test.ts src/artifacts/MachOSliceArtifactReader.test.ts tests/boundary/cli/artifactArmSlicesCli.test.ts tests/boundary/mcp/artifactArmSlicesMcp.test.ts tests/boundary/providers/native/machoSliceReader.test.ts tests/boundary/providers/native/artifactProvider.machOSlices.test.ts` — 51 tests passed across 6 files, 6.35 s observed. - `npm run test:focused -- tests/boundary/mcp/artifactArmSlicesMcp.test.ts` — passed after strengthening the cleanup assertion. - `npm run check` — passed, including typecheck and architecture guards; existing lint warnings remain. - `npm run docs:check` — passed, including 5 README consistency tests. - `npm run verify:test-discovery` — all 1,403 test files discovered exactly once. - `npm run jscpd` — passed: 3.23% duplicated lines, configured threshold 3.5%. - `git diff --check` — passed. Host: macOS 15.7.7 (24G720), Node 24.18.0, npm 11.16.0. Real lipo: `/Library/Developer/CommandLineTools/usr/bin/lipo`, SHA-256 `1cd322ae54394e71eefceda6a74946ef0ff678924f890de7520341c34133ef84`; Command Line Tools package `16.4.0.0.1.1747106510`. lipo advertises no version option and retained tool provenance has `tool_version: null`. ## Compatibility, cost, and limits No schema changes or migration. The fix adds one fixed-size name lookup per candidate comparison, no additional native commands or byte reads. Test duration above is an observed validation cost, not a throughput benchmark; production CPU/RSS and large-file throughput were not measured. Real OS coverage is the synthetic three-slice macOS fixture; other ARM names use portable captured-command boundaries. No Hopper/Ghidra, ARM target execution, Windows/Linux native lipo, or real-world ARM32 application corpus was exercised. The full repository suite was not run for this focused change. ## Author readiness Human owner: @To3akaRin - [x] I reviewed the final diff and relevant existing code, understand the change and its edge cases, and take responsibility for the complete PR, including AI-assisted work. - [x] I checked the evidence above, confirmed it supports the current change, and recorded meaningful validation gaps. - [x] I declare this PR ready for initial maintainer review. ## Before merge - [ ] Human ownership/readiness review and remote CI are complete. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-10-31 01:12:35 +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#6194
No description provided.