Skip to content

fix(ida): supervise regex inventory matching - #4862

Merged
morluto merged 1 commit into
morluto:mainfrom
jgt87:fix/ida-supervised-regex-search
Oct 22, 2026
Merged

morluto merged 1 commit into
morluto:mainfrom
jgt87:fix/ida-supervised-regex-search

Conversation

@jgt87

@jgt87 jgt87 commented Oct 17, 2026 •

Copy link
Copy Markdown
Contributor

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.

@jgt87
jgt87 marked this pull request as ready for review October 17, 2026 18:32
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 17, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-17T18:38:31.830558Z a1010fa Manual request
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex usage limits have been reached for code reviews. Please check with the admins of this repo to increase the limits by adding credits.
Repo admins can enable using credits for code reviews in their settings.

@jgt87

jgt87 commented Oct 17, 2026

Copy link
Copy Markdown
Contributor Author

@codex review

@greptile-apps

greptile-apps Bot commented Oct 17, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerView in GreptileConfidence Score: 5/5

[Medium impact] The PR appears safe to merge; no actionable defects were found.

Summary

IDA procedure and string searches now share inventory filtering. Regex searches use the existing supervised worker; literal searches keep their current matching.

  • IDA regex searches can stop without blocking later session work.

No actionable issues or security defects were found. Tests were not run during this review. Whether another PR supersedes this one could not be checked because GitHub access required authentication.

Diagram

sequenceDiagram
  participant Caller
  participant Session as IdaSessionClient
  participant Runner as IdaOperationRunner
  participant IDA
  participant Worker as Regex worker
  Caller->>Session: Search with optional signal
  Session->>Runner: Run search
  Runner->>IDA: Read inventory
  IDA-->>Runner: Ordered items
  alt Literal mode
    Runner->>Runner: Filter locally
  else Regex mode
    Runner->>Worker: Pattern and values
    Worker-->>Runner: Matching indices or typed error
    Runner->>Worker: Await termination
  end
  Runner-->>Session: Ordered matches or error
  Session-->>Caller: Result
Loading

Reviews (1) · Last reviewed commit: "fix(ida): supervise regex inventory matc..." · Reviewed by Greptile

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. More of your lovely PRs please.

Reviewed commit: a1010fa160

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@morluto
morluto merged commit db8556e into morluto:main Oct 22, 2026
34 of 36 checks passed
@morluto

morluto commented Oct 25, 2026

Copy link
Copy Markdown
Owner

Thanks, @jgt87, for moving IDA regex searches onto the supervised matcher. Expensive patterns can now be cancelled without blocking the service thread, and the recovery cases cover using the same session afterward. Welcome aboard!

kaoru0822-kitauji added a commit that referenced this pull request Oct 25, 2026
* fix(mcp)!: return a compact binary_session status by default

binary_session {} with no target open returned about 66 KB, most of it
provider rejection diagnostics and candidate capability sets that the
skill's recovery flow re-reads on every retry. 6.8.0 grew it by 21%
because the shared regex capability limitation began repeating setting
bounds and step-by-step recovery for every search operation of every
provider (#6099, #6267, #6301, #7049) and IDA gained that limitation for
its two search operations (#4862).

The regex limitation now states the effective deadline and heap, their
sources and where to change them; the deadline and heap errors keep the
full recovery. binary_session gains detail: summary (default) or
complete. The summary keeps open state, target identity, the binding,
route capabilities, run, activity and health status, each candidate's
availability and target-support status, code and reason, and every
tool's availability, reason, remediation and modes, and lists the
fields it leaves out in omitted_fields. Complete detail returns the
previous shape. The CLI capabilities and providers commands keep
complete provider facts through the same application projection.

BREAKING CHANGE: binary_session {} no longer returns
analysis_provider_candidates[].availability.diagnostics,
target_support.diagnostics or capabilities, or tool_availability group
surface, effects and annotations. Pass {"detail": "complete"} to get
them.

Fixes #7109

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* fix(mcp): key binary_session output fields by detail

The output schema accepted detail: "complete" with summary candidates or
tool groups, and a summary without omitted_fields, so detail did not
tell callers which fields existed. Each session kind is now crossed
with a detail-specific shape: a summary requires omitted_fields and
summary-only candidates and tool groups; complete requires diagnostics,
candidate capabilities and static tool flags and forbids omitted_fields.
Both the canonical schema and the SDK-validated advertised schema reject
mismatched shapes.

The verifier helper accepts summary candidates only for a validated MCP
summary; CLI provider output still requires candidate capabilities.
Regex limitation tests check values, sources and setting names instead
of whole sentences.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

---------

Co-authored-by: Claude Opus 5.5 <[email protected]>
@morluto morluto added bug Something isn't working provider: ida Analysis provider / engine: ida labels Nov 23, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working provider: ida Analysis provider / engine: ida

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug] IDA regex searches block cancellation on the service thread

2 participants