[PR #4862] [MERGED] fix(ida): supervise regex inventory matching #6446

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

📋 Pull Request Information

Original PR: https://github.com/morluto/rea/pull/4862
Author: @jgt87
Created: 10/17/2026
Status: ✅ Merged
Merged: 10/22/2026
Merged by: @morluto

Base: main ← Head: fix/ida-supervised-regex-search


📝 Commits (1)

  • a1010fa fix(ida): supervise regex inventory matching

📊 Changes

3 files changed (+170 additions, -11 deletions)

View changed files

📝 src/ida/IdaOperationRunner.ts (+31 -7)
📝 src/ida/IdaProviderCapabilities.ts (+10 -4)
📝 src/ida/IdaSessionClient.test.ts (+129 -0)

📄 Description

Summary

Fixes #4860. IDA regex searches currently run RegExp.test on REA's service thread, preventing caller cancellation during CPU-bound matching. Reuse the existing supervised regex worker so cancellation and the five-second matching deadline return typed errors while the session stays usable.

Problem and expected behavior

With ^(a+)+$ against "a".repeat(26) + "!", both production-session regression cases return success on the base despite a scheduled 50 ms cancellation. The service thread must remain available to process cancellation; matching must have a bounded lifetime.

Change and scope

Share the IDA inventory filtering path between procedure and string searches. Regex mode uses matchRegexValues with the caller signal and awaited worker termination; literal mode keeps its current matching. Preserve source order and publish the existing regex limitation in search capabilities and successful regex evidence. No new provider, target execution authority, or upstream IDA operation is introduced.

Contract and boundary impact

  • Semantic owner and earliest changed stage: IDA adapter's local inventory filtering, IdaOperationRunner.
  • Contribution scope fit and linked maintainer decision: ordinary fix inside an existing read-only adapter; new-capability scope decision not applicable.
  • CLI and MCP/tool-catalog contract: request schemas unchanged; regex failures can now return typed cancellation/resource errors; search limitations disclose matching supervision.
  • Provider, bridge, target-format, or platform compatibility: common IDA runner covers legacy/modern/native profiles; runtime verification here covers the attached legacy recording fixture only.
  • Evidence, artifact, provenance, or reconstruction contract: raw upstream observations, addresses, values, and result order preserved; regex limitation added.
  • Target selection, authority, upstream behavior, and cleanup details: upstream inventory and target identity checks unchanged; local regex worker is terminated before its result/error returns.
  • Generated metadata, package, or installation impact: no dependency or installation changes; ignored catalogs are not committed.

Expected effects:

  • Read existing files or captured data.
  • Contact network services (existing configured IDA transport; no new endpoint).

Local matching creates a worker thread, with the existing shared heap and time limits. No new target process, injection, or target writes.

Evidence and regression coverage

  • Added five cases: Unicode/case semantics and order for both search operations; cancellation plus same-session recovery for both; deadline failure followed by a successful regex search.
  • Executed base reproduction at d5be402fb3dbfc56ac9854c27b5538df20cc2437 with only the two cancellation cases added: 2 failed, both returned ok: true; test durations 3077 ms and 594 ms. After the fix those cases passed in 69 ms and 57 ms in the first isolated run. These are test durations, not matching-only benchmarks.
  • Final focused run: 11 passed, 55 skipped. The deadline case passed in 5054 ms, including subsequent search and cleanup.
  • User-visible CLI/MCP output: not exercised; tests invoke the production IdaSessionClient.execute boundary with RecordingIdaMcp. They do not establish actual IDA engine behavior.
  • Remaining proof gaps: real IDA, modern/native engine workflows, public CLI/MCP, pinned Node/npm toolchain, and Linux/macOS execution. CPU time, process-family peak memory, and token costs were not measured.

Validation performed

  • node node_modules/vitest/vitest.mjs run src/ida/IdaSessionClient.test.ts -t "cancels CPU-bound" --reporter=verbose — base 2 failed; fixed 2 passed.
  • node node_modules/vitest/vitest.mjs run src/ida/IdaSessionClient.test.ts -t "attached IDA function observations|attached IDA regex supervision|attached IDA function failure handling|attached IDA legacy string inventory" --reporter=default — 11 passed, 55 skipped.
  • npm run check:fast — typecheck and lint passed.
  • git diff --check — passed before commit; commit hook formatting/lint passed.
  • Earlier full npm run test:local -- src/ida/IdaSessionClient.test.ts on the base plus two cancellation tests — 46 failed, 17 passed; includes the two reproduced failures and 44 other failures in unchanged cases. This Windows checkout's broader suite is not verified. No claim that the full suite passes.
  • npm run build:windows-native — unavailable on this host: the artifact build script requires Linux and MinGW-w64. No native binary/build outputs are included.

Compatibility, safety, and release

  • Breaking changes or migration steps: none intended; pathological matching now fails within a bounded lifetime rather than blocking the service thread.
  • Real Hopper/Ghidra, browser, or OS coverage: Windows x64 source/provider-boundary tests only; no real analysis engine.
  • Package or release metadata impact: none.
  • Security, privacy, process, or containment review: caller regex and inventory values cross workerData into the existing constant worker program; no source interpolation or new execution authority. Shared worker resource policy is reused.

Author readiness

Human owner: @jgt87

  • 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.
  • 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/4862 **Author:** [@jgt87](https://github.com/jgt87) **Created:** 10/17/2026 **Status:** ✅ Merged **Merged:** 10/22/2026 **Merged by:** [@morluto](https://github.com/morluto) **Base:** `main` ← **Head:** `fix/ida-supervised-regex-search` --- ### 📝 Commits (1) - [`a1010fa`](https://github.com/morluto/rea/commit/a1010fa160e35e4698b615a4c6392bf906cc708d) fix(ida): supervise regex inventory matching ### 📊 Changes **3 files changed** (+170 additions, -11 deletions) <details> <summary>View changed files</summary> 📝 `src/ida/IdaOperationRunner.ts` (+31 -7) 📝 `src/ida/IdaProviderCapabilities.ts` (+10 -4) 📝 `src/ida/IdaSessionClient.test.ts` (+129 -0) </details> ### 📄 Description ## Summary Fixes #4860. IDA regex searches currently run `RegExp.test` on REA's service thread, preventing caller cancellation during CPU-bound matching. Reuse the existing supervised regex worker so cancellation and the five-second matching deadline return typed errors while the session stays usable. ## Problem and expected behavior With `^(a+)+$` against `"a".repeat(26) + "!"`, both production-session regression cases return success on the base despite a scheduled 50 ms cancellation. The service thread must remain available to process cancellation; matching must have a bounded lifetime. ## Change and scope Share the IDA inventory filtering path between procedure and string searches. Regex mode uses `matchRegexValues` with the caller signal and awaited worker termination; literal mode keeps its current matching. Preserve source order and publish the existing regex limitation in search capabilities and successful regex evidence. No new provider, target execution authority, or upstream IDA operation is introduced. ## Contract and boundary impact - Semantic owner and earliest changed stage: IDA adapter's local inventory filtering, `IdaOperationRunner`. - Contribution scope fit and linked maintainer decision: ordinary fix inside an existing read-only adapter; new-capability scope decision not applicable. - CLI and MCP/tool-catalog contract: request schemas unchanged; regex failures can now return typed cancellation/resource errors; search limitations disclose matching supervision. - Provider, bridge, target-format, or platform compatibility: common IDA runner covers legacy/modern/native profiles; runtime verification here covers the attached legacy recording fixture only. - Evidence, artifact, provenance, or reconstruction contract: raw upstream observations, addresses, values, and result order preserved; regex limitation added. - Target selection, authority, upstream behavior, and cleanup details: upstream inventory and target identity checks unchanged; local regex worker is terminated before its result/error returns. - Generated metadata, package, or installation impact: no dependency or installation changes; ignored catalogs are not committed. Expected effects: - [x] Read existing files or captured data. - [x] Contact network services (existing configured IDA transport; no new endpoint). Local matching creates a worker thread, with the existing shared heap and time limits. No new target process, injection, or target writes. ## Evidence and regression coverage - Added five cases: Unicode/case semantics and order for both search operations; cancellation plus same-session recovery for both; deadline failure followed by a successful regex search. - Executed base reproduction at `d5be402fb3dbfc56ac9854c27b5538df20cc2437` with only the two cancellation cases added: **2 failed**, both returned `ok: true`; test durations 3077 ms and 594 ms. After the fix those cases passed in 69 ms and 57 ms in the first isolated run. These are test durations, not matching-only benchmarks. - Final focused run: **11 passed, 55 skipped**. The deadline case passed in 5054 ms, including subsequent search and cleanup. - User-visible CLI/MCP output: not exercised; tests invoke the production `IdaSessionClient.execute` boundary with `RecordingIdaMcp`. They do not establish actual IDA engine behavior. - Remaining proof gaps: real IDA, modern/native engine workflows, public CLI/MCP, pinned Node/npm toolchain, and Linux/macOS execution. CPU time, process-family peak memory, and token costs were not measured. ## Validation performed - `node node_modules/vitest/vitest.mjs run src/ida/IdaSessionClient.test.ts -t "cancels CPU-bound" --reporter=verbose` — base 2 failed; fixed 2 passed. - `node node_modules/vitest/vitest.mjs run src/ida/IdaSessionClient.test.ts -t "attached IDA function observations|attached IDA regex supervision|attached IDA function failure handling|attached IDA legacy string inventory" --reporter=default` — 11 passed, 55 skipped. - `npm run check:fast` — typecheck and lint passed. - `git diff --check` — passed before commit; commit hook formatting/lint passed. - Earlier full `npm run test:local -- src/ida/IdaSessionClient.test.ts` on the base plus two cancellation tests — 46 failed, 17 passed; includes the two reproduced failures and 44 other failures in unchanged cases. This Windows checkout's broader suite is not verified. No claim that the full suite passes. - `npm run build:windows-native` — unavailable on this host: the artifact build script requires Linux and MinGW-w64. No native binary/build outputs are included. ## Compatibility, safety, and release - Breaking changes or migration steps: none intended; pathological matching now fails within a bounded lifetime rather than blocking the service thread. - Real Hopper/Ghidra, browser, or OS coverage: Windows x64 source/provider-boundary tests only; no real analysis engine. - Package or release metadata impact: none. - Security, privacy, process, or containment review: caller regex and inventory values cross workerData into the existing constant worker program; no source interpolation or new execution authority. Shared worker resource policy is reused. ## Author readiness Human owner: @jgt87 - [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. - [x] Material scope and authority questions are resolved, and any required maintainer scope decision covers the final diff. - [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>
bsakaguchi 2026-10-31 01:14:31 +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#6446
No description provided.