[GH-ISSUE #5101] [Bug] close_frida_session description reverses the implemented detach and resume order #3137

Closed
opened 2026-10-31 00:37:03 +00:00 by bsakaguchi · 2 comments
Owner

Originally created by @coygeek on GitHub (Oct 18, 2026).
Original GitHub issue: https://github.com/morluto/rea/issues/5101

Before submitting

  • I searched the open and closed issues for a related report.
  • I removed credentials, tokens, private paths, and sensitive target data.

Area

MCP or agent integration

Observed behavior

SOURCE-ONLY. The canonical close_frida_session description says a paused spawned process is resumed before detaching. The normal successful close implementation awaits session detach before dispatching resume. MCP registration forwards the canonical description unchanged.

The documentation agrees with the implementation: resume follows instrumentation release through script cleanup or detach. This report concerns the inaccurate ordering sentence; no target-lifecycle failure was reproduced.

Reproduction

Source inspection performed at the revision below:

git rev-parse HEAD
sed -n '248,258p' src/contracts/fridaToolContracts.ts
sed -n '665,713p' src/frida/FridaInstrumentationManager.ts
sed -n '237,258p' src/server/registerFridaTools.ts
sed -n '1,40p' docs/frida-instrumentation.md

The contract says “resume it before detaching.” The manager awaits managed.session.detach() at line 679 and calls managed.device.resume(managed.pid) at line 698. A supported spawn start creates a paused session with no scripts; closing that still-attached session reaches this path. No REA runtime or native provider was executed.

Expected behavior

Describe the actual cleanup order consistently with the Frida guide: release instrumentation, then resume a still-paused spawn when cleanup permits. Remove the claim that resume precedes detach. This expectation requires a wording correction, not a change to the cleanup algorithm.

Impact and scope

The MCP tool description gives callers an incorrect account of cleanup ordering. The sentence is unconditional, while the normal successful close path has the opposite order. Impact is limited to misleading wording on the evidence established here. Consequential target behavior, Evidence loss, or provider incompatibility was not established. The linked guide provides the accurate explanation.

REA version

Source package version 6.7.0; inspected main commit 3537e58c1ab29309f06eabf50bc52adba9817a0c.

Runtime and platform

Inspection host: Node.js v26.12.0, macOS 27.0.1, arm64. NOT_ENOUGH_INFO for REA/Frida runtime behavior: neither was executed.

Target and artifact context

Source-only inspection of a supported paused spawn followed by close. No target binary or process was used.

Interface

MCP

Earliest failure stage

Transport or result projection

Relevant output or evidence

Pinned source references:

These are static observations of REA's dispatch order, not native Frida call traces.

Typed outcome or recovery expected

Correct the advertised description. No typed-result change is needed for this wording defect.

Analysis or suspected cause

Source-derived: the canonical description disagrees with both the manager and the guide. NOT_ENOUGH_INFO about when or why the wording diverged. If detach fails after scripts were released, resume can still be attempted; avoid wording that promises successful detach in every cleanup path.

Additional context

The relevant contract, manager, guide, registration, service, and registration-options files have no differences between rea-agents-6.7.0 and the inspected main commit. Stable packaged-runtime behavior was not tested.

Related #3322 concerns execution-effect annotations. Correcting those annotations would leave the ordering sentence unchanged; this report has a separate wording closure check.

Originally created by @coygeek on GitHub (Oct 18, 2026). Original GitHub issue: https://github.com/morluto/rea/issues/5101 ## Before submitting - [x] I searched the open and closed issues for a related report. - [x] I removed credentials, tokens, private paths, and sensitive target data. ## Area MCP or agent integration ## Observed behavior SOURCE-ONLY. The canonical `close_frida_session` description says a paused spawned process is resumed before detaching. The normal successful close implementation awaits session detach before dispatching resume. MCP registration forwards the canonical description unchanged. The documentation agrees with the implementation: resume follows instrumentation release through script cleanup or detach. This report concerns the inaccurate ordering sentence; no target-lifecycle failure was reproduced. ## Reproduction Source inspection performed at the revision below: ```sh git rev-parse HEAD sed -n '248,258p' src/contracts/fridaToolContracts.ts sed -n '665,713p' src/frida/FridaInstrumentationManager.ts sed -n '237,258p' src/server/registerFridaTools.ts sed -n '1,40p' docs/frida-instrumentation.md ``` The contract says “resume it before detaching.” The manager awaits `managed.session.detach()` at line 679 and calls `managed.device.resume(managed.pid)` at line 698. A supported spawn start creates a paused session with no scripts; closing that still-attached session reaches this path. No REA runtime or native provider was executed. ## Expected behavior Describe the actual cleanup order consistently with the [Frida guide](https://github.com/morluto/rea/blob/3537e58c1ab29309f06eabf50bc52adba9817a0c/docs/frida-instrumentation.md#L7): release instrumentation, then resume a still-paused spawn when cleanup permits. Remove the claim that resume precedes detach. This expectation requires a wording correction, not a change to the cleanup algorithm. ## Impact and scope The MCP tool description gives callers an incorrect account of cleanup ordering. The sentence is unconditional, while the normal successful close path has the opposite order. Impact is limited to misleading wording on the evidence established here. Consequential target behavior, Evidence loss, or provider incompatibility was not established. The linked guide provides the accurate explanation. ## REA version Source package version 6.7.0; inspected main commit `3537e58c1ab29309f06eabf50bc52adba9817a0c`. ## Runtime and platform Inspection host: Node.js v26.12.0, macOS 27.0.1, arm64. NOT_ENOUGH_INFO for REA/Frida runtime behavior: neither was executed. ## Target and artifact context Source-only inspection of a supported paused spawn followed by close. No target binary or process was used. ## Interface MCP ## Earliest failure stage Transport or result projection ## Relevant output or evidence Pinned source references: - [Inaccurate contract description](https://github.com/morluto/rea/blob/3537e58c1ab29309f06eabf50bc52adba9817a0c/src/contracts/fridaToolContracts.ts#L250). - [MCP close registration](https://github.com/morluto/rea/blob/3537e58c1ab29309f06eabf50bc52adba9817a0c/src/server/registerFridaTools.ts#L239) uses [the unchanged contract description](https://github.com/morluto/rea/blob/3537e58c1ab29309f06eabf50bc52adba9817a0c/src/server/toolRegistrationOptions.ts#L30) and calls [the forwarding service](https://github.com/morluto/rea/blob/3537e58c1ab29309f06eabf50bc52adba9817a0c/src/application/frida/FridaInstrumentationService.ts#L356). - [Spawn initialization](https://github.com/morluto/rea/blob/3537e58c1ab29309f06eabf50bc52adba9817a0c/src/frida/FridaInstrumentationManager.ts#L292) establishes the paused session and empty script map. [Close implementation](https://github.com/morluto/rea/blob/3537e58c1ab29309f06eabf50bc52adba9817a0c/src/frida/FridaInstrumentationManager.ts#L665) awaits detach before resume. These are static observations of REA's dispatch order, not native Frida call traces. ## Typed outcome or recovery expected Correct the advertised description. No typed-result change is needed for this wording defect. ## Analysis or suspected cause Source-derived: the canonical description disagrees with both the manager and the guide. NOT_ENOUGH_INFO about when or why the wording diverged. If detach fails after scripts were released, resume can still be attempted; avoid wording that promises successful detach in every cleanup path. ## Additional context The relevant contract, manager, guide, registration, service, and registration-options files have no differences between `rea-agents-6.7.0` and the inspected main commit. Stable packaged-runtime behavior was not tested. Related [#3322](https://github.com/morluto/rea/issues/3322) concerns execution-effect annotations. Correcting those annotations would leave the ordering sentence unchanged; this report has a separate wording closure check.
Author
Owner

@XinwangTao commented on GitHub (Oct 19, 2026):

Confirmed — the close_frida_session description reverses the actual detach/resume order, and since this is the MCP-facing contract, callers will assume the wrong sequencing. Please align the description with the implemented order (detach before resume) rather than changing behavior, so MCP clients get an honest contract; a one-line comment in the close registration would also prevent this from drifting again.

<!-- gh-comment-id:6260290575 --> @XinwangTao commented on GitHub (Oct 19, 2026): Confirmed — the close_frida_session description reverses the actual detach/resume order, and since this is the MCP-facing contract, callers will assume the wrong sequencing. Please align the description with the implemented order (detach before resume) rather than changing behavior, so MCP clients get an honest contract; a one-line comment in the close registration would also prevent this from drifting again.
Author
Owner

@morluto commented on GitHub (Oct 19, 2026):

Fixed on main in 2ec602b191.

Corrected the canonical close description to say scripts are unloaded and detach is attempted before a still-paused spawn is resumed when script cleanup or detach confirms instrumentation release. It reports cleanup failures and preserves the unknown final target state. This matches the existing manager and Frida guide, including the path where script cleanup permits resume despite failed detach. No cleanup algorithm was changed for this wording correction.

Source and affected consumers reviewed;124 focused tests/5 files, check and docs:check passed, with the final registered MCP contract file rerun3/3. No real-provider ordering execution is claimed.

<!-- gh-comment-id:6264957648 --> @morluto commented on GitHub (Oct 19, 2026): Fixed on main in 2ec602b191d3b36dd17733e3e183457c57651c60. Corrected the canonical close description to say scripts are unloaded and detach is attempted before a still-paused spawn is resumed when script cleanup or detach confirms instrumentation release. It reports cleanup failures and preserves the unknown final target state. This matches the existing manager and Frida guide, including the path where script cleanup permits resume despite failed detach. No cleanup algorithm was changed for this wording correction. Source and affected consumers reviewed;124 focused tests/5 files, check and docs:check passed, with the final registered MCP contract file rerun3/3. No real-provider ordering execution is claimed.
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#3137
No description provided.