Skip to content

fix(reverse)!: retain cleanup and session ownership for local inspection - #1960

Closed
dandgabr wants to merge 156 commits into
morluto:mainfrom
dandgabr:codex/pr1279-local-inspection
Closed

dandgabr wants to merge 156 commits into
morluto:mainfrom
dandgabr:codex/pr1279-local-inspection

Conversation

@dandgabr

@dandgabr dandgabr commented Oct 11, 2026 •

Copy link
Copy Markdown
Contributor

Problem and outcome

Local inspection commands already exist on main; this PR fixes cleanup ownership, session ordering, provider lookup, and Evidence preservation around them. Incomplete writers remain owned and block replacement work until their actual owner confirms cleanup.

Changes

  • Keep retained process owners through session close and repeated CLI commands; retry cleanup before admitting another command, and reject overlapping CLI runs with retryable capacity guidance.
  • Settle reverse cleanup inside the admitted close transition before deciding writer completion; preserve independent session/snapshot failures, snapshot receipts, and every unresolved session/process/reverse cleanup owner.
  • Resolve Windows executables asynchronously across the complete selected PATH, with cancellation and a startup deadline. Refuse required token sweeps on hosts without an ownership baseline, with actionable guidance.
  • Preserve snapshots when Rizin preparation rejects missing/non-regular input; invalidate immediately before attempted dispatch. Retained writers still invalidate and retire analysis. Fixed analysis sources withhold mutating Rizin because they cannot refresh the binding.
  • Preserve direct ownership-preparation remediation, caller-selected commands, absolute artifact paths, and one authoritative output representation. Keep open/close ordering and their cleanup failures attributable.
  • Select all explicitly owned cancellation checkpoints in the mutation configuration while preserving missing-target and singular-ambiguity failures.

Validation performed

  • Pinned Node 24.18.0 / npm 11.16.0; merged upstream/main at 9af0b6113 while preserving branch history.
  • npm run test:focused -- <17 affected files>: 247 passed, 2 platform skips. Includes CLI lifecycle/demangle budgets, public MCP/session workflows, process supervision, service and lookup regressions, and mutation-configuration validation.
  • Additional retained-client mutation-barrier regression: 12/12 in binarySessionCleanupRetry.test.ts; removing the owner retry guard makes the new test fail, then restoring it passes.
  • npm run check:fast, npm run check, and npm run docs:check: passed.
  • Follow-up 66670714b, 9be820125, and a9db1775a: 104/104 tests passed across seven affected files; check:fast and check passed again. RED/GREEN covers stale cleanup/timeout close refusals, CLI retry advice, mixed owners, and typed cleanup throws/rejections. A synchronous-throw mutation failed on duplicate retry, then passed after restoration. Snapshot receipt/refusal and queued-open ordering controls passed; independent adapter review passed 17 additional owner-combination cases.
  • Real Linux GNU objdump 2.46.1 and Rizin 0.7.4: public CLI and stdio MCP inspections of a self-owned compiled ELF, four successful Evidence results with complete output, raw_result: null, and unchanged pre/post artifact digests; MCP close succeeded.

Not verified: Windows/macOS/Android runtime, real Ghidra, complete coverage/mutation campaigns, or performance/token/CPU/process-family-memory benchmarks. Simulated ownership/probe cases establish boundary behavior, not those host runtimes. CI for the updated head remains separately observable.

Compatibility and scope

Breaking: embedded createServer({ kind: "fixed", analysis }) servers no longer expose execute_rizin_command; use a session-backed source to provide mutation retirement/invalidation. Android/Termux hosts without ownership baselines refuse these one-shot providers rather than silently omit descendant cleanup.

No new execution authority is added. The maintainer scope/authority decision in #3656 remains open and is required before integration; this PR does not establish that approval. GDB, persistent Rizin, and Cutter feature work is outside this correction.

Author readiness

Human owner: @dandgabr

  • 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

  • Material scope and authority questions are resolved, and any required maintainer scope decision covers the final diff.
  • Required checks pass for the final head.

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 11, 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 ⚠️ Failed 2026-10-22T03:52:56.470511Z
We couldn’t complete this review. Comment @codex review to try again.
e6b32e7 New commits
ℹ️ 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 chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: c6bea2e2b0

ℹ️ 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".

Comment thread docs/reverse-engineering-tools.md Resolved

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 64703879f3

ℹ️ 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".

Comment thread src/objdump/ObjdumpCommand.ts Resolved
Comment thread src/server/createServer.ts Resolved

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 92142b74a1

ℹ️ 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".

Comment thread src/contracts/toolEffects.ts Resolved
Comment thread src/domain/reverseEngineering.ts Resolved
Comment thread docs/architecture.mermaid Resolved

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 4b3a6683b8

ℹ️ 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".

Comment thread src/contracts/toolEffects.ts Resolved
Comment thread src/composition/reverseEngineering.ts Resolved
Comment thread docs/reverse-engineering-tools.md Resolved
…pr1279-local-inspection

# Conflicts:
#	src/cliCommandNames.ts
#	src/contracts/toolEffects.ts

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 25c217c9c6

ℹ️ 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".

Comment thread src/server/createServer.ts Resolved

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: b87332435e

ℹ️ 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".

Comment thread src/domain/reverseEngineering.ts Resolved
Comment thread docs/architecture.mermaid Resolved
@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.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 53bfd05ca3

ℹ️ 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".

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 184d9df07f

ℹ️ 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".

Comment thread src/application/binary/BinarySession.ts Resolved

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: a0c7a35a4c

ℹ️ 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".

Comment thread src/application/binary/BinarySession.ts Resolved
Comment thread src/application/binary/BinarySession.ts Resolved
Comment thread src/application/binary/BinarySession.ts Resolved

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 05ff1f0e33

ℹ️ 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".

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 6eb27590c0

ℹ️ 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".

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 50112a803b

ℹ️ 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".

Comment thread src/composition/reverseEngineering.ts Resolved
# Conflicts:
#	src/application/reverse/ReverseEngineeringService.ts
#	src/cli/reverseEngineeringCommands.ts
#	src/contracts/reverseEngineeringToolContracts.ts
#	tests/boundary/cli/doctorCancellation.test.ts
#	tests/boundary/cli/reverseEngineeringCommands.test.ts
#	tests/composition/reverseEngineering.test.ts
@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.

@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.

@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.

@morluto

morluto commented Oct 22, 2026 •

Copy link
Copy Markdown
Owner

Scope decision for #3656 (objdump / Rizin / GDB)

cc @gensokyo-dev (maintainer) @dandgabr (author)

Decision: a hybrid of options 3 and 2 from #3656.

  1. objdump and fixed-operation Rizin ship now (this PR), because they only read artifacts.
  2. Raw provider consoles are off by default. Raw execute_rizin_command (and gdb_console in fix(gdb)!: preserve interrupt and provider cleanup ownership #1961) must be hidden from the tool list and refused unless the operator enables them at server start (e.g. --allow-unrestricted-provider-console). The model must not be able to enable this from inside a session. Record the opt-in in Evidence, and mark raw tools readOnlyHint: false, destructiveHint: true, openWorldHint: true (as disclosure only, not enforcement).
  3. GDB (fix(gdb)!: preserve interrupt and provider cleanup ownership #1961) is held until a Linux containment test shows that shell-spawned children (shell sleep 1000 &, shell setsid sleep 1000) are killed, or reported as retained, after close_gdb_session and after server exit.
  4. Denylists are not the security boundary. GDB reaches the shell through abbreviations (she, pi), $_shell(), make, pipe/|, target remote | cmd, define hooks, eval, source and call system(). Keep the one-shot classifier, but document it as protecting cleanup and detach, not as a sandbox.

What this PR needs before merge

Basis: peer MCP servers follow the same pattern: r2mcp gates raw commands behind -r and has a read-only -R mode, ida-pro-mcp needs --unsafe, BeaCox/gdb-mcp needs --unsafe, and GhidraMCP has no raw tool. The MCP tools spec says a human should be able to deny tool calls, and OWASP LLM06 advises against open-ended shell extensions.

@morluto

morluto commented Oct 25, 2026

Copy link
Copy Markdown
Owner

Source-derived: pinned main implements the reported cleanup and session-ownership behavior across src/application/binary/BinarySession.ts, src/application/reverse/ReverseEngineeringService.ts, and src/composition/resolveWindowsProviderExecutable.ts; lifecycle and CLI boundary coverage exercises retry, partial cleanup outcomes, cancellation, and preservation of session evidence. The PR’s reported lifecycle scope is already present.

@morluto morluto closed this Oct 25, 2026
@morluto morluto added the bug Something isn't working label Nov 23, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: cli CLI adapter and one-shot commands area: domain Domain logic, errors, and pure functions area: server Server layer and tool wiring bug Something isn't working enhancement New feature or request i18n Translations and localization workflow P2: medium Medium priority issue

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants