[PR #2007] [MERGED] fix(target): probe WASM before inferred database routing #4962

Closed
opened 2026-10-31 00:57:27 +00:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/morluto/rea/pull/2007
Author: @SII-YDD
Created: 10/12/2026
Status: ✅ Merged
Merged: 10/13/2026
Merged by: @morluto

Base: main ← Head: fix/wasm-before-inferred-database


📝 Commits (4)

  • 4b59977 fix(target): probe WASM before inferred database routing
  • 79a26b5 test(wasm): execute recovery arguments from native refusal
  • 379c9f5 test(ci): repair fixture alignment and share MCP assertions
  • 4429398 fix(target): reconcile WASM routing with current main

📊 Changes

8 files changed (+261 additions, -151 deletions)

View changed files

📝 docs/wasm-artifacts.md (+5 -0)
📝 src/application/BinaryTargetResolver.ts (+6 -1)
📝 tests/boundary/filesystem/targetDiagnostics.test.ts (+67 -2)
📝 tests/boundary/mcp/analysisViewMcp.test.ts (+4 -9)
📝 tests/boundary/mcp/binaryDiagnosticsMcp.test.ts (+15 -23)
📝 tests/boundary/mcp/evmInterfaceMcp.test.ts (+15 -21)
📝 tests/boundary/mcp/wasmArtifactMcp.test.ts (+97 -95)
➕ tests/fixtures/advertisedMcpTool.ts (+52 -0)

📄 Description

Summary

Follow up on #1872's remaining .hop admission review; refs #1852 (already closed). Recognized WASM v1 bytes renamed to .hop now receive the existing static-inspection refusal. The recovery test executes the actual tool name and JSON arguments printed in that refusal.

Problem and expected behavior

An eight-byte empty WASM header with an inferred .hop interpretation previously returned as a native database before content detection. It should receive wasm_requires_static_inspection. Explicit database/raw-binary/DOS COM choices and non-WASM .hop routing retain their meaning.

Change and scope

Reuse the existing detector before inferred database routing, skipping it for an explicit database choice. Non-WASM artifact dispatch still occurs after the database return. Identical valid ZIP bytes provide positive .zip and .hop/.HOP compatibility controls.

Reuse the existing owned application MCP harness and schema helper. Parameterize the native-refusal case for bin/hop; parse the printed recovery tool name and arguments, check the advertised schema and exact escaped path, then invoke that continuation. Preserve missing-WABT diagnostics, same-connection ping, unchanged source bytes and no native provider startup. Remove only the redundant canonical-input schema check.

Rebased onto 9cf49c7a784ace9b79e4b4c1022c9fbf2b3f77e1. The final diff also includes the test-only CI corrections described below. An independently prepared six-file Ghidra fixture correction was found identical to upstream 18d56f5 and dropped during rebase; it is not an additional contribution in this PR.

Contract and boundary impact

  • Semantic owner and earliest changed stage: filesystem admission in parseBinaryTarget.
  • Contribution scope fit and linked maintainer decision: ordinary correction within existing read-only admission semantics; no new execution capability, so advance scope decision is not applicable.
  • CLI and MCP/tool-catalog contract: existing refusal and inspect_wasm_artifact continuation now reach .hop WASM; schemas unchanged.
  • Provider, bridge, target-format, or platform compatibility: explicit interpretations and ordinary database routing preserved; no provider implementation change.
  • Evidence, artifact, provenance, or reconstruction contract: source bytes and existing identity/cleanup rules preserved.
  • Target selection, authority, upstream behavior and cleanup: no target execution, mutation, implicit provider fallback or installation; owned harness/fixtures reused.
  • Generated metadata, package or installation impact: none.

Expected effects: read existing files; no added target-process launch, injection, mutation, network access or protection recovery.

Evidence and regression coverage

  • Unchanged earlier admission producer: the selected WASM regression fails both filesystem/MCP .hop cases (2 failed / 33 passed).

  • Deliberately mutating the printed tool name to an unavailable tool makes both bin/hop continuation tests fail (2 failed / 7 passed). Production source restored afterward.

  • Final four-file focused run: 92 passed. Latest-base Linux run before the final continuation-test strengthening: 273 passed / 4 platform skips across 19 files, covering all 11 previously failing CI files, every shared Ghidra MCP harness consumer, public JavaScript CLI/MCP, reopen, Java-launch and WASM paths.

  • Final compiled stdio MCP smoke read actual advertised input/output schemas, parsed the refusal's exact arguments including a quoted path, invoked the static tool, observed independent missing-WABT capability_unavailable, then pinged the same connection. Source bytes were unchanged; client/transport/fixture cleanup completed.

  • Representative public result: native open reports target_unavailable / unsupported_target / wasm_requires_static_inspection; unconfigured static WABT lane reports capability_unavailable.

  • Observed, derived and inferred claims remain distinguishable.

  • Artifact identity, source provenance and failed attempts remain preserved.

  • Unsupported, incomplete, unavailable or uncertain outcomes remain visible.

Validation performed

Pinned Node 24.18.0 / npm 11.16.0; isolated dependency/workspace environments without GitHub credentials passed to project processes.

  • macOS: npm run test:focused -- tests/boundary/mcp/wasmArtifactMcp.test.ts tests/boundary/filesystem/targetDiagnostics.test.ts tests/boundary/filesystem/binaryTarget.test.ts tests/boundary/filesystem/rawBinaryTarget.test.ts — 92 passed after final test strengthening.
  • Linux arm64 official Node container with git/procps: 19-file npm run test:focused -- PATH... — 273 passed / 4 platform skips on latest base before final strengthening. Includes src/ghidra/{GhidraDoctor,GhidraInstallation,GhidraSnapshotCache}.test.ts, applicationWorkflowCli, filesystem binaryTarget/ghidraPspExtension/rawBinaryTarget/targetDiagnostics, MCP analysisView/ghidraCompactReferences/ghidraEvidence/ghidraFailureDiagnostics/ghidraInventory/ghidraNativeApi/ghidraReopen/ghidraRouting/inlineEvidenceComposition/wasmArtifact, and ghidraJavaLaunch tests.
  • npm run check, npm run check:fast, npm run docs:check — passed on Linux and repeated on the final macOS tree; architecture guards across 1,297 source files, README consistency 2 passed.
  • npm run verify:test-discovery — 1,036 files exactly once.
  • Linux npm run test:focused -- tests/boundary/mcp/wasmArtifactMcp.test.ts repeated after final strengthening — 9 passed.
  • git diff --check and independent read-only AI review — passed; review found no actionable issue.
  • Final compiled stdio MCP smoke — passed as described above.

CI repair included in this revision

The previous final-head run had two root failures; coverage/timing and required-CI failed as downstream aggregates.

  • The IDA large universal fixture declared alignment14 for offset4096. Its layout now allows an explicit alignment, with12 only for that entry and14 retained for all other entries. Original offsets, selected-slice lengths, byte comparisons, digests and cleanup assertions remain intact; no production parser or provider change.
  • Repeated schema and inline Evidence assertions are now shared by WASM, binary-layout, EVM and analysis-view tests through tests/fixtures/advertisedMcpTool.ts. The helper preserves actual advertised schemas, response success, canonical output parsing, Evidence confidence/digest/normalized result/session retention. Negative-input, malformed-provider, cancellation, retained-reference and cleanup scenarios remain in their existing workflows. Duplication threshold and exclusions are unchanged.

On main ded199a, duplication fell from1,481clones/15,816lines/3.010175% to1,473clones/15,744lines/2.996620%. All42 original tests across the five affected files pass on macOS and Linux, including all7IDA and14analysis-view cases. The exact npm run check:ci gate passed, including duplication and TODO scanning; check, check:fast, docs:check, discovery and compiled MCP smoke also passed. Latest-base post-rebase verification is recorded below.

An independently prepared Ghidra fixture correction was already fixed upstream18d56f5 and remains dropped, attributed to its upstream author.

macOS process-dependent CLI tests remain SDK-blocked: an independent Foundation control also reproduces duplicate SwiftBridging definitions. Host SDK was not modified; those paths were verified in the earlier Linux19-file run. No local Windows or real WABT/Hopper/Ghidra/IDA success run; simulated native bridge/Java evidence does not establish real-engine success. Fresh full upstream CI38367170302 completed successfully on head379c9f5. All six shards, static checks, coverage/timing and required CI passed; PR checks show20success/15conditional skips/0failures. The PR remains open and unmerged.

Compatibility, safety, and release

  • Breaking change or migration: none; recognized WASM follows its existing contract.
  • Real-provider/platform coverage: admission, public CLI/MCP and fixture paths as listed; real engine and macOS SDK gaps explicit above.
  • Package/release metadata: none.
  • Security/privacy/process containment: source bytes and resource ownership preserved; no new target execution.

Implementation, testing and independent review were assisted by OpenAI Codex.

Before merge

  • Concrete problem, focused outcome and Conventional Commit title.
  • Existing scope/authority preserved; related issue/review linked.
  • Observable behavior, recovery, failure, compatibility and cleanup covered.
  • Owning docs and representative output updated where applicable.
  • Final diff checked for secrets, unrelated cleanup and unsupported claims.
  • Latest full upstream CI completed successfully (run38367170302).

Latest-base verification (9cf49c7a784ace9b79e4b4c1022c9fbf2b3f77e1, head 379c9f54b8d38f0b33c3f24b8face33574996b2f):42 focused cases passed; check:ci, check, check:fast, docs:check all passed;1,038 test files discovered exactly once; compiled stdio MCP smoke passed. Exact duplicate percentage:2.990427% with1472clones/15726duplicated lines, below the unchanged3%threshold.


🔄 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/2007 **Author:** [@SII-YDD](https://github.com/SII-YDD) **Created:** 10/12/2026 **Status:** ✅ Merged **Merged:** 10/13/2026 **Merged by:** [@morluto](https://github.com/morluto) **Base:** `main` ← **Head:** `fix/wasm-before-inferred-database` --- ### 📝 Commits (4) - [`4b59977`](https://github.com/morluto/rea/commit/4b5997759da9f044c1432adb2ebcac358989d7a9) fix(target): probe WASM before inferred database routing - [`79a26b5`](https://github.com/morluto/rea/commit/79a26b5cef86933f4b4fdc5d8d0028073205cacc) test(wasm): execute recovery arguments from native refusal - [`379c9f5`](https://github.com/morluto/rea/commit/379c9f54b8d38f0b33c3f24b8face33574996b2f) test(ci): repair fixture alignment and share MCP assertions - [`4429398`](https://github.com/morluto/rea/commit/4429398955d4980ddaf3cb8687c774abe19fd06c) fix(target): reconcile WASM routing with current main ### 📊 Changes **8 files changed** (+261 additions, -151 deletions) <details> <summary>View changed files</summary> 📝 `docs/wasm-artifacts.md` (+5 -0) 📝 `src/application/BinaryTargetResolver.ts` (+6 -1) 📝 `tests/boundary/filesystem/targetDiagnostics.test.ts` (+67 -2) 📝 `tests/boundary/mcp/analysisViewMcp.test.ts` (+4 -9) 📝 `tests/boundary/mcp/binaryDiagnosticsMcp.test.ts` (+15 -23) 📝 `tests/boundary/mcp/evmInterfaceMcp.test.ts` (+15 -21) 📝 `tests/boundary/mcp/wasmArtifactMcp.test.ts` (+97 -95) ➕ `tests/fixtures/advertisedMcpTool.ts` (+52 -0) </details> ### 📄 Description ## Summary Follow up on #1872's remaining `.hop` admission review; refs #1852 (already closed). Recognized WASM v1 bytes renamed to `.hop` now receive the existing static-inspection refusal. The recovery test executes the actual tool name and JSON arguments printed in that refusal. ## Problem and expected behavior An eight-byte empty WASM header with an inferred `.hop` interpretation previously returned as a native database before content detection. It should receive `wasm_requires_static_inspection`. Explicit database/raw-binary/DOS COM choices and non-WASM `.hop` routing retain their meaning. ## Change and scope Reuse the existing detector before inferred database routing, skipping it for an explicit database choice. Non-WASM artifact dispatch still occurs after the database return. Identical valid ZIP bytes provide positive `.zip` and `.hop`/`.HOP` compatibility controls. Reuse the existing owned application MCP harness and schema helper. Parameterize the native-refusal case for `bin`/`hop`; parse the printed recovery tool name and arguments, check the advertised schema and exact escaped path, then invoke that continuation. Preserve missing-WABT diagnostics, same-connection ping, unchanged source bytes and no native provider startup. Remove only the redundant canonical-input schema check. Rebased onto `9cf49c7a784ace9b79e4b4c1022c9fbf2b3f77e1`. The final diff also includes the test-only CI corrections described below. An independently prepared six-file Ghidra fixture correction was found identical to upstream [18d56f5](https://github.com/morluto/rea/commit/18d56f5321c3c5d5be40c19bcb0a0f2b25c2d459) and dropped during rebase; it is not an additional contribution in this PR. ## Contract and boundary impact - Semantic owner and earliest changed stage: filesystem admission in `parseBinaryTarget`. - Contribution scope fit and linked maintainer decision: ordinary correction within existing read-only admission semantics; no new execution capability, so advance scope decision is not applicable. - CLI and MCP/tool-catalog contract: existing refusal and `inspect_wasm_artifact` continuation now reach `.hop` WASM; schemas unchanged. - Provider, bridge, target-format, or platform compatibility: explicit interpretations and ordinary database routing preserved; no provider implementation change. - Evidence, artifact, provenance, or reconstruction contract: source bytes and existing identity/cleanup rules preserved. - Target selection, authority, upstream behavior and cleanup: no target execution, mutation, implicit provider fallback or installation; owned harness/fixtures reused. - Generated metadata, package or installation impact: none. Expected effects: read existing files; no added target-process launch, injection, mutation, network access or protection recovery. ## Evidence and regression coverage - Unchanged earlier admission producer: the selected WASM regression fails both filesystem/MCP `.hop` cases (2 failed / 33 passed). - Deliberately mutating the printed tool name to an unavailable tool makes both `bin`/`hop` continuation tests fail (2 failed / 7 passed). Production source restored afterward. - Final four-file focused run: **92 passed**. Latest-base Linux run before the final continuation-test strengthening: **273 passed / 4 platform skips across 19 files**, covering all 11 previously failing CI files, every shared Ghidra MCP harness consumer, public JavaScript CLI/MCP, reopen, Java-launch and WASM paths. - Final compiled stdio MCP smoke read actual advertised input/output schemas, parsed the refusal's exact arguments including a quoted path, invoked the static tool, observed independent missing-WABT `capability_unavailable`, then pinged the same connection. Source bytes were unchanged; client/transport/fixture cleanup completed. - Representative public result: native open reports `target_unavailable` / `unsupported_target` / `wasm_requires_static_inspection`; unconfigured static WABT lane reports `capability_unavailable`. - [x] Observed, derived and inferred claims remain distinguishable. - [x] Artifact identity, source provenance and failed attempts remain preserved. - [x] Unsupported, incomplete, unavailable or uncertain outcomes remain visible. ## Validation performed Pinned Node 24.18.0 / npm 11.16.0; isolated dependency/workspace environments without GitHub credentials passed to project processes. - macOS: `npm run test:focused -- tests/boundary/mcp/wasmArtifactMcp.test.ts tests/boundary/filesystem/targetDiagnostics.test.ts tests/boundary/filesystem/binaryTarget.test.ts tests/boundary/filesystem/rawBinaryTarget.test.ts` — **92 passed** after final test strengthening. - Linux arm64 official Node container with git/procps: 19-file `npm run test:focused -- PATH...` — **273 passed / 4 platform skips** on latest base before final strengthening. Includes `src/ghidra/{GhidraDoctor,GhidraInstallation,GhidraSnapshotCache}.test.ts`, `applicationWorkflowCli`, filesystem `binaryTarget/ghidraPspExtension/rawBinaryTarget/targetDiagnostics`, MCP `analysisView/ghidraCompactReferences/ghidraEvidence/ghidraFailureDiagnostics/ghidraInventory/ghidraNativeApi/ghidraReopen/ghidraRouting/inlineEvidenceComposition/wasmArtifact`, and `ghidraJavaLaunch` tests. - `npm run check`, `npm run check:fast`, `npm run docs:check` — passed on Linux and repeated on the final macOS tree; architecture guards across **1,297** source files, README consistency **2 passed**. - `npm run verify:test-discovery` — **1,036 files exactly once**. - Linux `npm run test:focused -- tests/boundary/mcp/wasmArtifactMcp.test.ts` repeated after final strengthening — **9 passed**. - `git diff --check` and independent read-only AI review — passed; review found no actionable issue. - Final compiled stdio MCP smoke — passed as described above. ## CI repair included in this revision The [previous final-head run](https://github.com/morluto/rea/actions/runs/38363262390) had two root failures; coverage/timing and required-CI failed as downstream aggregates. - The IDA large universal fixture declared alignment14 for offset4096. Its layout now allows an explicit alignment, with12 only for that entry and14 retained for all other entries. Original offsets, selected-slice lengths, byte comparisons, digests and cleanup assertions remain intact; no production parser or provider change. - Repeated schema and inline Evidence assertions are now shared by WASM, binary-layout, EVM and analysis-view tests through `tests/fixtures/advertisedMcpTool.ts`. The helper preserves actual advertised schemas, response success, canonical output parsing, Evidence confidence/digest/normalized result/session retention. Negative-input, malformed-provider, cancellation, retained-reference and cleanup scenarios remain in their existing workflows. Duplication threshold and exclusions are unchanged. On main ded199a, duplication fell from1,481clones/15,816lines/3.010175% to1,473clones/15,744lines/2.996620%. All42 original tests across the five affected files pass on macOS and Linux, including all7IDA and14analysis-view cases. The exact `npm run check:ci` gate passed, including duplication and TODO scanning; `check`, `check:fast`, `docs:check`, discovery and compiled MCP smoke also passed. Latest-base post-rebase verification is recorded below. An independently prepared Ghidra fixture correction was already fixed upstream18d56f5 and remains dropped, attributed to its upstream author. macOS process-dependent CLI tests remain SDK-blocked: an independent Foundation control also reproduces duplicate SwiftBridging definitions. Host SDK was not modified; those paths were verified in the earlier Linux19-file run. No local Windows or real WABT/Hopper/Ghidra/IDA success run; simulated native bridge/Java evidence does not establish real-engine success. Fresh full upstream [CI38367170302](https://github.com/morluto/rea/actions/runs/38367170302) completed successfully on head379c9f5. All six shards, static checks, coverage/timing and required CI passed; PR checks show20success/15conditional skips/0failures. The PR remains open and unmerged. ## Compatibility, safety, and release - Breaking change or migration: none; recognized WASM follows its existing contract. - Real-provider/platform coverage: admission, public CLI/MCP and fixture paths as listed; real engine and macOS SDK gaps explicit above. - Package/release metadata: none. - Security/privacy/process containment: source bytes and resource ownership preserved; no new target execution. Implementation, testing and independent review were assisted by OpenAI Codex. ## Before merge - [x] Concrete problem, focused outcome and Conventional Commit title. - [x] Existing scope/authority preserved; related issue/review linked. - [x] Observable behavior, recovery, failure, compatibility and cleanup covered. - [x] Owning docs and representative output updated where applicable. - [x] Final diff checked for secrets, unrelated cleanup and unsupported claims. - [x] Latest full upstream CI completed successfully (run38367170302). Latest-base verification (`9cf49c7a784ace9b79e4b4c1022c9fbf2b3f77e1`, head `379c9f54b8d38f0b33c3f24b8face33574996b2f`):42 focused cases passed; `check:ci`, `check`, `check:fast`, `docs:check` all passed;1,038 test files discovered exactly once; compiled stdio MCP smoke passed. Exact duplicate percentage:2.990427% with1472clones/15726duplicated lines, below the unchanged3%threshold. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-10-31 00:57:27 +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#4962
No description provided.