[PR #2448] [MERGED] fix(targets): retain unsupported PE machine in diagnostics #5236

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

📋 Pull Request Information

Original PR: https://github.com/morluto/rea/pull/2448
Author: @Aurantium-47
Created: 10/13/2026
Status: ✅ Merged
Merged: 10/13/2026
Merged by: @morluto

Base: main ← Head: fix/pe-machine-diagnostics


📝 Commits (1)

  • 04e6a4c fix(targets): retain unsupported PE machine in diagnostics

📊 Changes

2 files changed (+32 additions, -2 deletions)

View changed files

📝 src/domain/binaryTarget.ts (+6 -2)
📝 tests/boundary/filesystem/targetDiagnostics.test.ts (+26 -0)

📄 Description

Summary

Include the original COFF Machine value when target admission rejects an unsupported PE architecture. For the SH4 case reported in #2410, the diagnostic now reads unsupported PE architecture (COFF machine 0x01a6) instead of losing the machine identity.

Refs #2410. This addresses the diagnostic fallback requested there; the broader SuperH provider-support request remains open.

Problem and expected behavior

parsePeRecord reads the two-byte COFF Machine field, but discards its value when decodePeMachine cannot map it to a supported architecture. Callers then cannot distinguish SH4 from another unsupported or unknown machine without separately inspecting the file.

Change and scope

Retain that value at the existing parser boundary and include its four-digit hexadecimal representation in the refusal reason. Existing CLI, MCP, and filesystem error projection propagate it without their own parsing or lookup tables. Supported architectures and the separate native-OS-override rejection retain their behavior.

This is an ordinary diagnostic correction within existing target-admission scope; advance maintainer scope approval is not applicable.

Contract and boundary impact

  • Semantic owner: PE header parsing before provider selection.
  • CLI/MCP: refusal message and details.reason gain the observed machine code; error code, category, schemas, and supported targets remain unchanged.
  • Evidence and identity: the original file and its recorded field are preserved; no provider result is inferred.
  • Target effects: existing local bytes are read. No target execution, mutation, network access, provider, package, or generated-metadata change.

Evidence and regression coverage

  • Three filesystem-boundary cases cover SH4 (0x01a6), zero (0x0000), and an unknown maximum field value (0xffff). All three fail on the base revision because the message and reason omit the machine code.
  • Existing parser coverage retains successful supported-machine handling, malformed-header refusals, managed ReadyToRun support, and native OS-override rejection.
  • Actual compiled CLI inspect and stdio MCP open_binary calls against all three files return target_unavailable with the same precise reason. For SH4: Cannot open artifact: unsupported PE architecture (COFF machine 0x01a6).

Validation performed

  • Relevant parser and filesystem diagnostics suites: 56 passed, 1 existing POSIX permission case skipped automatically on Windows.
  • Actual compiled public entrypoints: 3 CLI and 3 stdio MCP cases passed.
  • npm run check — all six tasks executed successfully, followed by architecture guards; no lint errors.
  • npm run verify:test-discovery — all 1,004 files discovered exactly once.
  • git diff --check — passed.

These checks cover target admission and error delivery on Windows. No Ghidra/Hopper/IDA analysis capability or SuperH execution is claimed.

Before merge

  • Concrete issue-backed diagnostic improvement with failing-before coverage.
  • One focused outcome; original admission and authority boundaries preserved.
  • Public CLI/MCP output verified.
  • No schema, generated metadata, package, or migration changes required.
  • Final diff checked for unrelated changes and credentials.

AI assistance: OpenAI GPT-6 assisted with implementation and verification.


🔄 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/2448 **Author:** [@Aurantium-47](https://github.com/Aurantium-47) **Created:** 10/13/2026 **Status:** ✅ Merged **Merged:** 10/13/2026 **Merged by:** [@morluto](https://github.com/morluto) **Base:** `main` ← **Head:** `fix/pe-machine-diagnostics` --- ### 📝 Commits (1) - [`04e6a4c`](https://github.com/morluto/rea/commit/04e6a4c3aaab24f5ead95ed78d456f56e5fb9960) fix(targets): retain unsupported PE machine in diagnostics ### 📊 Changes **2 files changed** (+32 additions, -2 deletions) <details> <summary>View changed files</summary> 📝 `src/domain/binaryTarget.ts` (+6 -2) 📝 `tests/boundary/filesystem/targetDiagnostics.test.ts` (+26 -0) </details> ### 📄 Description ## Summary Include the original COFF Machine value when target admission rejects an unsupported PE architecture. For the SH4 case reported in #2410, the diagnostic now reads `unsupported PE architecture (COFF machine 0x01a6)` instead of losing the machine identity. Refs #2410. This addresses the diagnostic fallback requested there; the broader SuperH provider-support request remains open. ## Problem and expected behavior `parsePeRecord` reads the [two-byte COFF Machine field](https://learn.microsoft.com/en-us/windows/win32/debug/pe-format#coff-file-header-object-and-image), but discards its value when `decodePeMachine` cannot map it to a supported architecture. Callers then cannot distinguish SH4 from another unsupported or unknown machine without separately inspecting the file. ## Change and scope Retain that value at the existing parser boundary and include its four-digit hexadecimal representation in the refusal reason. Existing CLI, MCP, and filesystem error projection propagate it without their own parsing or lookup tables. Supported architectures and the separate native-OS-override rejection retain their behavior. This is an ordinary diagnostic correction within existing target-admission scope; advance maintainer scope approval is not applicable. ## Contract and boundary impact - Semantic owner: PE header parsing before provider selection. - CLI/MCP: refusal message and `details.reason` gain the observed machine code; error code, category, schemas, and supported targets remain unchanged. - Evidence and identity: the original file and its recorded field are preserved; no provider result is inferred. - Target effects: existing local bytes are read. No target execution, mutation, network access, provider, package, or generated-metadata change. ## Evidence and regression coverage - Three filesystem-boundary cases cover SH4 (`0x01a6`), zero (`0x0000`), and an unknown maximum field value (`0xffff`). All three fail on the base revision because the message and reason omit the machine code. - Existing parser coverage retains successful supported-machine handling, malformed-header refusals, managed ReadyToRun support, and native OS-override rejection. - Actual compiled CLI `inspect` and stdio MCP `open_binary` calls against all three files return `target_unavailable` with the same precise reason. For SH4: `Cannot open artifact: unsupported PE architecture (COFF machine 0x01a6).` ## Validation performed - Relevant parser and filesystem diagnostics suites: 56 passed, 1 existing POSIX permission case skipped automatically on Windows. - Actual compiled public entrypoints: 3 CLI and 3 stdio MCP cases passed. - `npm run check` — all six tasks executed successfully, followed by architecture guards; no lint errors. - `npm run verify:test-discovery` — all 1,004 files discovered exactly once. - `git diff --check` — passed. These checks cover target admission and error delivery on Windows. No Ghidra/Hopper/IDA analysis capability or SuperH execution is claimed. ## Before merge - [x] Concrete issue-backed diagnostic improvement with failing-before coverage. - [x] One focused outcome; original admission and authority boundaries preserved. - [x] Public CLI/MCP output verified. - [x] No schema, generated metadata, package, or migration changes required. - [x] Final diff checked for unrelated changes and credentials. AI assistance: OpenAI GPT-6 assisted with implementation and verification. --- <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:03 +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#5236
No description provided.