[PR #3773] feat(bridge): discover BYO x64dbg without launching a session #5887

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

📋 Pull Request Information

Original PR: https://github.com/morluto/rea/pull/3773
Author: @Kizuno18
Created: 10/15/2026
Status: 🔄 Open

Base: main ← Head: feat/x64dbg-discovery


📝 Commits (3)

  • 9f6bddd feat(bridge): discover BYO x64dbg without launching a session
  • d5255bd Merge remote-tracking branch 'upstream/main' into feat/x64dbg-discovery
  • 99dab60 fix(x64dbg): async discovery, case-insensitive Windows env, owned tests

📊 Changes

15 files changed (+671 additions, -1 deletions)

View changed files

➕ docs/specs/live-native-debug-x64dbg.md (+66 -0)
📝 scripts/lib/catalog-builders.mjs (+5 -0)
📝 scripts/lib/catalog-core.mjs (+2 -0)
📝 scripts/lib/test-projects.mjs (+1 -1)
📝 src/cli.ts (+2 -0)
➕ src/cli/x64dbgCommands.ts (+24 -0)
📝 src/cliCommandNames.ts (+1 -0)
📝 src/contracts/toolContracts.ts (+2 -0)
📝 src/contracts/toolEffects.test.ts (+2 -0)
📝 src/contracts/toolEffects.ts (+1 -0)
➕ src/contracts/x64dbgToolContracts.ts (+49 -0)
📝 src/server/createServer.ts (+2 -0)
➕ src/server/registerX64dbgTools.ts (+39 -0)
➕ src/x64dbg/X64dbgDiscovery.test.ts (+231 -0)
➕ src/x64dbg/X64dbgDiscovery.ts (+244 -0)

📄 Description

Summary

Relates to #1267. This PR does not claim to fix the issue until maintainers accept the scope.

It adds only the discovery and capability slice for a bring-your-own x64dbg provider, plus a design spec. It does not launch, attach to, inject into, or modify any process. #1267 defers full live debugging, and this PR keeps it deferred.

Problem and expected behavior

REA has no Windows user-mode debugger provider. Before any session work, callers need a way to check whether a BYO x64dbg/x32dbg is present, which architecture it targets, and why it is unavailable. They need this without REA starting the debugger.

Change and scope

  • docs/specs/live-native-debug-x64dbg.md: design spec. It names x64dbg-automate (MIT) as the preferred transport candidate, with a custom plugin bridge as the alternative. It sets out the identity model (debugger PID ≠ inferior PID), the non-goals (no anti-debug bypass, no kernel debugging, no bundling, no remote debugging), and the increments. The first increment is discovery only.
  • src/x64dbg/X64dbgDiscovery.ts: resolves REA_X64DBG_COMMAND. If that is unset, it checks well-known locations under ProgramFiles, ProgramFiles(x86), LOCALAPPDATA\Programs and the system drive. It reads the file size and the PE COFF machine field (x64 or x86) and never executes the binary. x64dbg has no documented non-interactive --help or version flag, so nothing is spawned.
    • On non-Windows hosts it returns unsupported_platform with an explicit reason.
    • If REA_X64DBG_COMMAND names a missing file, it returns configured_path_not_found and does not silently fall back to other locations.
    • Failures come back as statuses and are never thrown, so an absent or broken optional adapter cannot break peer providers.
  • MCP tool discover_x64dbg and CLI command discover-x64dbg: discovery only. The effects audit is all-false, so the tool is read-only.
  • Catalog wiring (scripts/lib/catalog-*.mjs) adds the provider identity x64dbg.byo.

Not included: start/attach/breakpoint/memory/step tools, plugin detection, and PE version-resource parsing.

Maintainer scope decision requested. Under CONTRIBUTING.md (fail-closed integration), any later increment needs its own explicit maintainer scope decision before implementation intended for integration. That covers launching or attaching to a target, breakpoints, and memory or register writes. This draft does not authorize any of them. Please also confirm whether the discovery slice itself fits REA's scope.

Contract and boundary impact

  • Semantic owner and earliest changed stage: new src/x64dbg provider module; discovery stage only.
  • Contribution scope fit and linked maintainer decision: pending, see #1267.
  • CLI and MCP/tool-catalog contract: adds discover_x64dbg / discover-x64dbg (native-provider family).
  • Provider, bridge, target-format, or platform compatibility: Windows only for positive results; every other platform reports unsupported_platform.
  • Evidence, artifact, provenance, or reconstruction contract: none. The tool returns availability, not Evidence.
  • Target selection, authority, upstream behavior, and cleanup details: no target is selected and no process is created.
  • Generated metadata, package, or installation impact: catalog generators include the new contract and provider identity.

Expected effects:

  • Read existing files or captured data.
  • Launch or attach to a process.
  • Inject instrumentation or run scripts/code.
  • Change process memory, registers, files, or configuration.
  • Contact network services.
  • Recover protected code or work around protections.
  • Documentation or usability only; no target interaction.
  • Not sure yet; investigation or maintainer guidance needed.

Evidence and regression coverage

  • Tests added or updated: src/x64dbg/X64dbgDiscovery.test.ts covers:

    • unsupported on Linux, with the filesystem seam asserted not to be called;
    • env path precedence, plus whitespace trimming;
    • no fallback when the configured path is missing;
    • x64 and x32 builds found in well-known paths;
    • not_found with a remediation hint;
    • fail-closed handling when the host seam throws;
    • unrecognized headers and PE parsing edge cases;
    • schema validity against the output schema;
    • the contract's read-only effects.

    toolEffects.test.ts gets a wording exception for the description's "never launches" language.

  • User-visible CLI output on a Linux host:

$ rea discover-x64dbg
provider: x64dbg.byo
host_platform: linux
configured_command: null
launched_process: false
debug_session_capability: not_implemented
status: unsupported_platform
reason: x64dbg is a Windows debugger; discovery is unavailable on linux.
executables: []
  • Remaining proof gaps: not run against a real Windows x64dbg install. Positive results were checked only with injected PE fixtures.

Validation performed

  • tsc --noEmit — pass
  • vitest run tests/conformance src/contracts src/x64dbg src/server — 37 files, 357 passed
  • vitest run --project mcp-boundary --project cli-boundary — 212 files passed, 1202 tests passed
  • npm run mcp-catalog:check, npm run docs:check, oxfmt --check ., knip, oxlint on the changed files — pass

Compatibility, safety, and release

  • Breaking changes or migration steps: none (additive tool).
  • Real OS coverage: Linux only; Windows not exercised.
  • Package or release metadata impact: one new tool in the catalog.
  • Security, privacy, process, or containment review: discovery reads file metadata and up to 4 KiB of the PE header. It spawns nothing.

Author readiness

Human owner: @Kizuno18

  • 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

  • This PR addresses a concrete problem or an agreed enhancement.
  • Material scope and authority questions are resolved, and any required maintainer scope decision covers the final diff. (Not yet: the maintainer scope decision for the discovery slice is pending in #1267, see above.)
  • The PR has one focused outcome and the title follows type(scope): outcome.
  • Related issue is linked, or the reason for not linking one is stated above.
  • Tests cover changed observable behavior and meaningful failure paths.
  • Owning docs, contracts, and generated metadata are updated where needed.
  • User-visible CLI/MCP changes include representative output.
  • I checked the final diff for secrets, unrelated cleanup, 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/3773 **Author:** [@Kizuno18](https://github.com/Kizuno18) **Created:** 10/15/2026 **Status:** 🔄 Open **Base:** `main` ← **Head:** `feat/x64dbg-discovery` --- ### 📝 Commits (3) - [`9f6bddd`](https://github.com/morluto/rea/commit/9f6bddddd550dee74cbc51d6465186163cc6c5f9) feat(bridge): discover BYO x64dbg without launching a session - [`d5255bd`](https://github.com/morluto/rea/commit/d5255bda3ee7922e6e4cdc5a84ebaf25d6ad1a82) Merge remote-tracking branch 'upstream/main' into feat/x64dbg-discovery - [`99dab60`](https://github.com/morluto/rea/commit/99dab60299a3c63202fc9dfeddb4e6b361451347) fix(x64dbg): async discovery, case-insensitive Windows env, owned tests ### 📊 Changes **15 files changed** (+671 additions, -1 deletions) <details> <summary>View changed files</summary> ➕ `docs/specs/live-native-debug-x64dbg.md` (+66 -0) 📝 `scripts/lib/catalog-builders.mjs` (+5 -0) 📝 `scripts/lib/catalog-core.mjs` (+2 -0) 📝 `scripts/lib/test-projects.mjs` (+1 -1) 📝 `src/cli.ts` (+2 -0) ➕ `src/cli/x64dbgCommands.ts` (+24 -0) 📝 `src/cliCommandNames.ts` (+1 -0) 📝 `src/contracts/toolContracts.ts` (+2 -0) 📝 `src/contracts/toolEffects.test.ts` (+2 -0) 📝 `src/contracts/toolEffects.ts` (+1 -0) ➕ `src/contracts/x64dbgToolContracts.ts` (+49 -0) 📝 `src/server/createServer.ts` (+2 -0) ➕ `src/server/registerX64dbgTools.ts` (+39 -0) ➕ `src/x64dbg/X64dbgDiscovery.test.ts` (+231 -0) ➕ `src/x64dbg/X64dbgDiscovery.ts` (+244 -0) </details> ### 📄 Description ## Summary Relates to #1267. This PR does not claim to fix the issue until maintainers accept the scope. It adds only the discovery and capability slice for a bring-your-own x64dbg provider, plus a design spec. It does not launch, attach to, inject into, or modify any process. #1267 defers full live debugging, and this PR keeps it deferred. ## Problem and expected behavior REA has no Windows user-mode debugger provider. Before any session work, callers need a way to check whether a BYO x64dbg/x32dbg is present, which architecture it targets, and why it is unavailable. They need this without REA starting the debugger. ## Change and scope - `docs/specs/live-native-debug-x64dbg.md`: design spec. It names x64dbg-automate (MIT) as the preferred transport candidate, with a custom plugin bridge as the alternative. It sets out the identity model (debugger PID ≠ inferior PID), the non-goals (no anti-debug bypass, no kernel debugging, no bundling, no remote debugging), and the increments. The first increment is discovery only. - `src/x64dbg/X64dbgDiscovery.ts`: resolves `REA_X64DBG_COMMAND`. If that is unset, it checks well-known locations under `ProgramFiles`, `ProgramFiles(x86)`, `LOCALAPPDATA\Programs` and the system drive. It reads the file size and the PE COFF machine field (x64 or x86) and never executes the binary. x64dbg has no documented non-interactive `--help` or version flag, so nothing is spawned. - On non-Windows hosts it returns `unsupported_platform` with an explicit reason. - If `REA_X64DBG_COMMAND` names a missing file, it returns `configured_path_not_found` and does not silently fall back to other locations. - Failures come back as statuses and are never thrown, so an absent or broken optional adapter cannot break peer providers. - MCP tool `discover_x64dbg` and CLI command `discover-x64dbg`: discovery only. The effects audit is all-false, so the tool is read-only. - Catalog wiring (`scripts/lib/catalog-*.mjs`) adds the provider identity `x64dbg.byo`. Not included: start/attach/breakpoint/memory/step tools, plugin detection, and PE version-resource parsing. **Maintainer scope decision requested.** Under CONTRIBUTING.md (fail-closed integration), any later increment needs its own explicit maintainer scope decision before implementation intended for integration. That covers launching or attaching to a target, breakpoints, and memory or register writes. This draft does not authorize any of them. Please also confirm whether the discovery slice itself fits REA's scope. ## Contract and boundary impact - Semantic owner and earliest changed stage: new `src/x64dbg` provider module; discovery stage only. - Contribution scope fit and linked maintainer decision: pending, see #1267. - CLI and MCP/tool-catalog contract: adds `discover_x64dbg` / `discover-x64dbg` (native-provider family). - Provider, bridge, target-format, or platform compatibility: Windows only for positive results; every other platform reports `unsupported_platform`. - Evidence, artifact, provenance, or reconstruction contract: none. The tool returns availability, not Evidence. - Target selection, authority, upstream behavior, and cleanup details: no target is selected and no process is created. - Generated metadata, package, or installation impact: catalog generators include the new contract and provider identity. Expected effects: - [x] Read existing files or captured data. - [ ] Launch or attach to a process. - [ ] Inject instrumentation or run scripts/code. - [ ] Change process memory, registers, files, or configuration. - [ ] Contact network services. - [ ] Recover protected code or work around protections. - [ ] Documentation or usability only; no target interaction. - [ ] Not sure yet; investigation or maintainer guidance needed. ## Evidence and regression coverage - Tests added or updated: `src/x64dbg/X64dbgDiscovery.test.ts` covers: - unsupported on Linux, with the filesystem seam asserted not to be called; - env path precedence, plus whitespace trimming; - no fallback when the configured path is missing; - x64 and x32 builds found in well-known paths; - `not_found` with a remediation hint; - fail-closed handling when the host seam throws; - unrecognized headers and PE parsing edge cases; - schema validity against the output schema; - the contract's read-only effects. `toolEffects.test.ts` gets a wording exception for the description's "never launches" language. - User-visible CLI output on a Linux host: ``` $ rea discover-x64dbg provider: x64dbg.byo host_platform: linux configured_command: null launched_process: false debug_session_capability: not_implemented status: unsupported_platform reason: x64dbg is a Windows debugger; discovery is unavailable on linux. executables: [] ``` - Remaining proof gaps: not run against a real Windows x64dbg install. Positive results were checked only with injected PE fixtures. ## Validation performed - `tsc --noEmit` — pass - `vitest run tests/conformance src/contracts src/x64dbg src/server` — 37 files, 357 passed - `vitest run --project mcp-boundary --project cli-boundary` — 212 files passed, 1202 tests passed - `npm run mcp-catalog:check`, `npm run docs:check`, `oxfmt --check .`, `knip`, `oxlint` on the changed files — pass ## Compatibility, safety, and release - Breaking changes or migration steps: none (additive tool). - Real OS coverage: Linux only; Windows not exercised. - Package or release metadata impact: one new tool in the catalog. - Security, privacy, process, or containment review: discovery reads file metadata and up to 4 KiB of the PE header. It spawns nothing. ## Author readiness Human owner: @Kizuno18 - [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 - [x] This PR addresses a concrete problem or an agreed enhancement. - [ ] Material scope and authority questions are resolved, and any required maintainer scope decision covers the final diff. (Not yet: the maintainer scope decision for the discovery slice is pending in #1267, see above.) - [x] The PR has one focused outcome and the title follows `type(scope): outcome`. - [x] Related issue is linked, or the reason for not linking one is stated above. - [x] Tests cover changed observable behavior and meaningful failure paths. - [x] Owning docs, contracts, and generated metadata are updated where needed. - [x] User-visible CLI/MCP changes include representative output. - [x] I checked the final diff for secrets, unrelated cleanup, and unsupported claims. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
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#5887
No description provided.