[PR #1118] [MERGED] fix(hopper): preserve owned basic-block endpoint instructions #2663

Closed
opened 2026-10-17 21:08:46 +00:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/morluto/rea/pull/1118
Author: @vilmerfrost
Created: 10/8/2026
Status: ✅ Merged
Merged: 10/8/2026
Merged by: @morluto

Base: main ← Head: fix/hopper-block-endpoints


📝 Commits (5)

  • e057c6e fix(hopper): preserve owned basic-block endpoint instructions
  • 0e33f05 chore: merge current main into Hopper endpoint fix
  • 5eb640a test(hopper): share probe runner and restore fixture hashability
  • 10a33f2 fix(hopper): align owned instruction walks with normalized block ranges
  • dd571cd chore: retain contributor Hopper probe improvements

📊 Changes

3 files changed (+328 additions, -12 deletions)

View changed files

📝 bridge/hopper_bridge.py (+32 -12)
➕ tests/boundary/providers/hopper/hopperInstructions.test.ts (+105 -0)
➕ tests/fixtures/hopperInstructionProbe.py (+191 -0)

📄 Description

Summary

Preserve Hopper basic-block endpoint instructions in assembly, fast instruction reads, function dossiers, and reference collection. Related to #343 and #54; this fixes endpoint serialization, not the broader conformance roadmap.

Problem and expected behavior

On Hopper 6.6.0-demo, BasicBlock.getEndingAddress() returns the last instruction's starting address, although its public API documentation describes an exclusive endpoint. Both bridge walkers use < end, dropping terminal b.lt, b.ne, ret, and even ordinary mov instructions. Blindly switching to <= would include adjacent instructions on an exclusive-end build.

Change and scope

Use Procedure.getBasicBlockAtAddress() and native-wrapper equality to confirm block ownership at each candidate instruction. Share one length-aware address walker across consumers, deduplicate addresses, and stop at missing instructions, invalid lengths, or crossed boundaries. Report capability unavailability if ownership cannot be checked.

Contract and boundary impact

  • Semantic owner and earliest changed stage: Python Hopper bridge instruction enumeration, before MCP serialization.
  • CLI and MCP/tool-catalog contract: unchanged schemas; formerly omitted instructions/references are restored.
  • Provider/platform compatibility: ownership handles inclusive/exclusive endpoints without guessing a version-specific convention. Real verification covers macOS ARM64/Hopper 6.6.0-demo; exclusive behavior is covered by adapter tests.
  • Evidence/artifact/provenance contract: unchanged.
  • Process execution, authorization, cleanup: unchanged.
  • Generated metadata/package/installation: none.

Evidence and regression coverage

Eleven new cases cover inclusive/exclusive endpoints, single-instruction return blocks, fresh equal wrappers, duplicate blocks, terminal branch references, adjacent/unowned instructions, missing instructions, invalid lengths, crossed/reversed boundaries, variable instruction lengths, and unavailable ownership APIs.

Initial seven-case regression suite on base d1c904bac7977d44b06bf2f823587baedcc88b9e: five failed, two passed. Final regressions pass.

The preserved stripped fixture was tested inside real Hopper with both unchanged and patched bridge sources at identical addresses:

Entry Before, each of three operations After, each of three operations Independent direct Hopper
0x1000004b0 19 20 20
0x100000500 37 41 41
0x1000005a4 40 41 41

Patched instruction text matches the independent direct result exactly. Fixture: Apple clang 17.0.0, ARM64, -O1 -fno-inline -Wall -Wextra; stripped SHA256 46255fff8c18c7597b4e9e7587f86988e3e156cdbb0f3f367db90e494ddbd66a.

  • Observations, inference, and unsupported behavior remain distinct.
  • Fixture/raw observations and failed attempts are preserved locally; no binaries are committed.
  • Missing ownership capability produces an explicit error.

Validation performed

  • Python syntax compilation of bridge and probe — passed.
  • npx vitest run tests/boundary/providers/hopper/hopperInstructions.test.ts tests/boundary/providers/hopper/hopperBridgeFacade.test.ts tests/boundary/providers/hopper/bridgeSearch.test.ts — 15 passed.
  • Broader Hopper adapter/boundary/conformance suites — 125 passed, 2 skipped, 2 failed in existing native helper/ownership tests. Those two test cases also fail on unchanged upstream code in this environment; assertions can vary. They were not weakened or changed.
  • npm run check — passed (TypeScript, lint, formatting, Knip, metadata).
  • npm run verify:test-discovery — all 630 tests discovered once.
  • npm run verify:hopper with the installed launcher — passed on macOS ARM64, source-built manifest fixtures, target switching, unrelated-process survival, clean shutdown.
  • Preserved ARM64 fixture replay described above — passed.
  • git diff --check — passed.

Compatibility, safety, and release

No schema/migration or release metadata changes. No installed REA/Hopper edits. Linux real-Hopper verification was unavailable on this macOS host. Hopper's separate arithmetic pseudocode defect is outside this fix. Complete function-body range metadata remains unavailable.

Review checklist

  • One focused outcome; conventional title; related issues linked.
  • Regression and failure-path coverage added.
  • Contracts and generated metadata require no authored changes.
  • Final diff checked for unrelated files, secrets, and unsupported claims.

🔄 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/1118 **Author:** [@vilmerfrost](https://github.com/vilmerfrost) **Created:** 10/8/2026 **Status:** ✅ Merged **Merged:** 10/8/2026 **Merged by:** [@morluto](https://github.com/morluto) **Base:** `main` ← **Head:** `fix/hopper-block-endpoints` --- ### 📝 Commits (5) - [`e057c6e`](https://github.com/morluto/rea/commit/e057c6e714ce6d4eb85878600b628f7f59921ead) fix(hopper): preserve owned basic-block endpoint instructions - [`0e33f05`](https://github.com/morluto/rea/commit/0e33f054eb26537c63bfd35d930e6ce1ab24564d) chore: merge current main into Hopper endpoint fix - [`5eb640a`](https://github.com/morluto/rea/commit/5eb640a507998a1e8160a2fcf2c7c0fab0691fee) test(hopper): share probe runner and restore fixture hashability - [`10a33f2`](https://github.com/morluto/rea/commit/10a33f2e6aa9607de54434c0d78f442f0f24fdee) fix(hopper): align owned instruction walks with normalized block ranges - [`dd571cd`](https://github.com/morluto/rea/commit/dd571cd946a8b220d78dc62b94aa672468432143) chore: retain contributor Hopper probe improvements ### 📊 Changes **3 files changed** (+328 additions, -12 deletions) <details> <summary>View changed files</summary> 📝 `bridge/hopper_bridge.py` (+32 -12) ➕ `tests/boundary/providers/hopper/hopperInstructions.test.ts` (+105 -0) ➕ `tests/fixtures/hopperInstructionProbe.py` (+191 -0) </details> ### 📄 Description ## Summary Preserve Hopper basic-block endpoint instructions in assembly, fast instruction reads, function dossiers, and reference collection. Related to #343 and #54; this fixes endpoint serialization, not the broader conformance roadmap. ## Problem and expected behavior On Hopper 6.6.0-demo, `BasicBlock.getEndingAddress()` returns the last instruction's starting address, although its public API documentation describes an exclusive endpoint. Both bridge walkers use `< end`, dropping terminal `b.lt`, `b.ne`, `ret`, and even ordinary `mov` instructions. Blindly switching to `<=` would include adjacent instructions on an exclusive-end build. ## Change and scope Use `Procedure.getBasicBlockAtAddress()` and native-wrapper equality to confirm block ownership at each candidate instruction. Share one length-aware address walker across consumers, deduplicate addresses, and stop at missing instructions, invalid lengths, or crossed boundaries. Report capability unavailability if ownership cannot be checked. ## Contract and boundary impact - Semantic owner and earliest changed stage: Python Hopper bridge instruction enumeration, before MCP serialization. - CLI and MCP/tool-catalog contract: unchanged schemas; formerly omitted instructions/references are restored. - Provider/platform compatibility: ownership handles inclusive/exclusive endpoints without guessing a version-specific convention. Real verification covers macOS ARM64/Hopper 6.6.0-demo; exclusive behavior is covered by adapter tests. - Evidence/artifact/provenance contract: unchanged. - Process execution, authorization, cleanup: unchanged. - Generated metadata/package/installation: none. ## Evidence and regression coverage Eleven new cases cover inclusive/exclusive endpoints, single-instruction return blocks, fresh equal wrappers, duplicate blocks, terminal branch references, adjacent/unowned instructions, missing instructions, invalid lengths, crossed/reversed boundaries, variable instruction lengths, and unavailable ownership APIs. Initial seven-case regression suite on base `d1c904bac7977d44b06bf2f823587baedcc88b9e`: five failed, two passed. Final regressions pass. The preserved stripped fixture was tested inside real Hopper with both unchanged and patched bridge sources at identical addresses: | Entry | Before, each of three operations | After, each of three operations | Independent direct Hopper | | --- | ---: | ---: | ---: | | `0x1000004b0` | 19 | 20 | 20 | | `0x100000500` | 37 | 41 | 41 | | `0x1000005a4` | 40 | 41 | 41 | Patched instruction text matches the independent direct result exactly. Fixture: Apple clang 17.0.0, ARM64, `-O1 -fno-inline -Wall -Wextra`; stripped SHA256 `46255fff8c18c7597b4e9e7587f86988e3e156cdbb0f3f367db90e494ddbd66a`. - [x] Observations, inference, and unsupported behavior remain distinct. - [x] Fixture/raw observations and failed attempts are preserved locally; no binaries are committed. - [x] Missing ownership capability produces an explicit error. ## Validation performed - Python syntax compilation of bridge and probe — passed. - `npx vitest run tests/boundary/providers/hopper/hopperInstructions.test.ts tests/boundary/providers/hopper/hopperBridgeFacade.test.ts tests/boundary/providers/hopper/bridgeSearch.test.ts` — 15 passed. - Broader Hopper adapter/boundary/conformance suites — 125 passed, 2 skipped, 2 failed in existing native helper/ownership tests. Those two test cases also fail on unchanged upstream code in this environment; assertions can vary. They were not weakened or changed. - `npm run check` — passed (TypeScript, lint, formatting, Knip, metadata). - `npm run verify:test-discovery` — all 630 tests discovered once. - `npm run verify:hopper` with the installed launcher — passed on macOS ARM64, source-built manifest fixtures, target switching, unrelated-process survival, clean shutdown. - Preserved ARM64 fixture replay described above — passed. - `git diff --check` — passed. ## Compatibility, safety, and release No schema/migration or release metadata changes. No installed REA/Hopper edits. Linux real-Hopper verification was unavailable on this macOS host. Hopper's separate arithmetic pseudocode defect is outside this fix. Complete function-body range metadata remains unavailable. ## Review checklist - [x] One focused outcome; conventional title; related issues linked. - [x] Regression and failure-path coverage added. - [x] Contracts and generated metadata require no authored changes. - [x] Final diff checked for unrelated files, secrets, and unsupported claims. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-10-17 21:08:46 +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#2663
No description provided.