Skip to content

feat(debuggers): name why an owned debugger stop is incomplete - #11517

Merged
morluto merged 2 commits into
mainfrom
feat/gdb-session-close-reasons
Nov 15, 2026
Merged

morluto merged 2 commits into
mainfrom
feat/gdb-session-close-reasons

Conversation

@morluto

@morluto morluto commented Nov 15, 2026 •

Copy link
Copy Markdown
Owner

Summary

Refs #10508 (Phase 6.1). When REA cannot confirm that an owned GDB or Rizin process stopped, the retained failure now names why as details.diagnostics.debugger_cleanup (15 codes), so agents and tests no longer read the reason sentence. GdbSessionManagerCoverage asserts the codes instead of matching "inferior disposition", "multiple inferiors", "durable output sink", "inferior detach", "inferior state" and "did not stop cleanly".

Problem and expected behavior

  • Retained-session command refusals already carry details.diagnostics.session_stop, but an incomplete stop (OwnedDebuggerStopResult incomplete) carried only a sentence. GDB detach refusals were plain Errors whose text was folded into "inferior detach could not be verified: ...", and close-all failures were bare Error(reason).
  • A client could not tell "inferior never detached" from "multiple inferiors" or "debugger did not exit" without parsing prose; GdbSessionManagerCoverage did exactly that.
  • Expected: every incomplete stop names a code; the code reaches the public error and close-all failures.

Change and scope

  • src/domain/debuggerSessionErrors.ts: DEBUGGER_CLEANUP_INCOMPLETE_CODES and DebuggerCleanupIncomplete {code, reason} beside the existing stop codes.
  • src/process/ownedDebuggerSession.ts: each incomplete result names its code (output-unsettled, detach-pending, inferior-disposition-unverified, inferior-identity-unverified, windows-stop-unsafe, detach-unsupported, detach-timeout, detach-unconfirmed, process-did-not-exit; detach errors keep a provider code from OwnedDebuggerDetachFailure, otherwise detach-failed). closeOwnedDebuggerSessions reports OwnedDebuggerStopFailure (with code) per session. retainedDebuggerCleanupFailure takes the incomplete stop and adds diagnostics.debugger_cleanup.
  • OwnedDebuggerSessionRegistry: retainCleanupFailure takes the stop result instead of its reason string; a rejected stop is stop-failed.
  • GdbSessionManager.#detachInferior throws OwnedDebuggerDetachFailure with inferior-state-unknown, multiple-inferiors, no-durable-output-sink, inferior-tty-changed or detach-failed; the two GDB errors that build their own cleanup observation also carry debugger_cleanup beside session_stop.
  • Rizin call sites pass the stop result (no behaviour change beyond the added diagnostic).
  • incompleteStopFacts(stopped, resources) is the one owner of the cleanup observation plus diagnostics.debugger_cleanup; GDB startup, protocol-failure, timeout and cancellation errors use it, and Rizin's composed #finalizeFailure result retains the code at its top level (review round 1).
  • retainedDebuggerDiagnostics adds debugger_cleanup_codes from the close-all failure tree, so rea debug-with-gdb/debug-with-rizin final cleanup failures, MCP server shutdown and the shutdown log carry the codes.
  • Docs: docs/reverse-engineering-tools.md lists the codes and debugger_cleanup_codes.
  • Not included: the close refusal before cleanup starts ("Close requires an explicit inferior disposition" with gdb_console remediation) keeps its existing capability_unavailable shape; LLDB is not on this owner.

Follow the contribution scope.
Unresolved scope, authority, side effects, or required verification block
integration. Link the required maintainer scope decision for new providers or
capabilities involving target execution, injection, mutation, or protection
recovery; ordinary fixes within existing boundaries may state "not applicable".
Draft PRs may leave the scope decision pending and the readiness and merge checklists
unchecked. Maintainers can help resolve open questions.

Contract and boundary impact

  • Semantic owner and earliest changed stage: stopOwnedDebuggerProcess (src/process/ownedDebuggerSession.ts) produces the code; the session registry and retainedDebuggerCleanupFailure project it; GDB's detach owns its refusal codes
  • Contribution scope fit and linked maintainer decision: Phase 6.1 ([Design] Assert structured remediation facts instead of guidance prose #10508); coordinator assigned "structured close/stop reasons on GDB session errors"
  • CLI and MCP/tool-catalog contract: additive: retained debugger cleanup failures gain details.diagnostics.debugger_cleanup; messages and details.cleanup are unchanged
  • Provider, bridge, target-format, or platform compatibility: GDB and Rizin; no provider protocol change
  • Evidence, artifact, provenance, or reconstruction contract: none
  • Target selection, authority, upstream behavior, and cleanup details (if applicable): no lifecycle change: the same paths retain the same sessions and send the same signals; only the failure facts gain a code
  • Generated metadata (docs/public/product-catalog.json), package, or installation impact (CI generates and validates ignored catalogs and skills/; edit authored instructions in .agents/skills/reverse-engineer-anything/ and never commit build outputs): none

Expected effects (check known effects; use documentation-only on its own).
Unchecked items do not establish absence; leave uncertainties visible.

  • 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 updated: GdbSessionManagerCoverage.test.ts (7 prose matches -> debugger_cleanup / errors[].code; two exact diagnostics expectations now include debugger_cleanup), ownedDebuggerSession.test.ts (12 stop results now assert their exact code; close-all failure asserts code), and fake stopProcess fixtures in 11 GDB/Rizin test files name a code (stop-failed).
  • Base reproduction or other evidence: source-derived: base results have no code and errors no debugger_cleanup, so the converted assertions cannot match; not run against base.
  • Remaining proof gaps: real GDB/Rizin not exercised (fake spawners, as the existing suites).

For boundary fixes, identify the applicable boundary regressions
and lifecycle regressions
covered by the evidence above, and explain relevant gaps.

For evidence-bearing changes:

  • Observed, derived, and inferred claims remain distinguishable.
  • Artifact identity, source provenance, and failed attempts remain preserved.
  • Unsupported, incomplete, unavailable, or uncertain outcomes remain visible.

Validation performed

  • npm run test:focused -- GdbSessionManagerCoverage, ownedDebuggerSession, GdbSessionReviewRegressions, gdbStartupCleanupCli, gdbCancellationMcp, rizinStoppedSessionMcp, RizinDebugSessionCoverage.part1/part3, RizinDebugSessionReviewRegressions, RizinInferiorTty, reverseEngineeringCommands, GdbSessionManagers, RizinDebugSessionManagers: 13 files, 388 passed, 21 skipped (after fixing expectations; final rerun of ownedDebuggerSession + GdbSessionManagerCoverage: 249 passed).
  • npm run check:fast (typecheck, lint, architecture guards): passed. Pre-push hook passed.
  • After review fixes (b0acfac): npm run test:focused -- reverseEngineeringCommands, rizinStoppedSessionMcp, RizinDebugSessionCoverage.part3/part1, GdbSessionManagerCoverage, ownedDebuggerSession, GdbSessionReviewRegressions, gdbCancellationMcp, gdbStartupCleanupCli, RizinDebugSessionReviewRegressions: 10 files, 365 passed, 2 skipped. The Rizin composed-failure assertion fails with the retainDiagnostics call removed (1 failed, 25 passed) and passes with it. npm run check:fast and npm run docs:check passed.
  • npm run docs:check, npx oxfmt --check on changed files: passed.

Compatibility, safety, and release

  • Breaking changes or migration steps: none (additive diagnostic). Internal: retainCleanupFailure and retainedDebuggerCleanupFailure take the incomplete stop, and OwnedDebuggerStopResult incomplete requires code.
  • Real Hopper/Ghidra, browser, or OS coverage: not applicable; real GDB/Rizin not run
  • Package or release metadata impact: none
  • Security, privacy, process, or containment review: none (no signal or retention change)

Author readiness

Human owner:

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

@chatgpt-codex-connector

Copy link
Copy Markdown
Codex Review Summary: ❌ Failed

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

Review Status Commit Review trigger
📝 Code Review ❌ Failed 2026-11-15T21:23:31.065896Z
We couldn’t complete this review. Comment @codex review to try again.
cae2b6b PR opened
ℹ️ 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

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.

@greptile-apps

greptile-apps Bot commented Nov 15, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerView in GreptileConfidence Score: 5/5 Tier: plus

[Medium impact] No new blocking issue was established in the reviewed changes.

Summary

Adds structured reasons when REA cannot confirm that an owned GDB or Rizin debugger stopped.

  • Incomplete GDB and Rizin stops now carry a stable reason code.

Diagram

%%{init: {'theme': 'neutral'}}%%
flowchart LR
  Stop["Stop cannot be confirmed"] --> Facts["Cleanup code and reason"]
  Facts --> Session["Retained session errors"]
  Facts --> All["Close-all child errors"]
  All --> Collect["Collect cleanup codes"]
  Collect --> Exit["CLI and shutdown details"]
Loading

Reviews (3) · Last reviewed commit: "fix(debuggers): put the cleanup code on ..." · Reviewed by Greptile

Comment thread src/gdb/GdbSessionManager.ts Resolved
Comment thread src/rizin/RizinDebugSessionManager.ts Resolved
Comment thread src/process/ownedDebuggerSession.ts Resolved
@morluto

morluto commented Nov 15, 2026

Copy link
Copy Markdown
Owner Author

@greptileai review

Owned debugger stop results carry a cleanup code; retained Rizin and GDB
cleanup failures project it as details.diagnostics.debugger_cleanup, close-all
failures carry it, and GDB detach refusals name multiple inferiors, a missing
durable output sink, unknown inferior state or a changed inferior TTY.
GdbSessionManagerCoverage asserts the codes instead of reason prose.
incompleteStopFacts builds the cleanup observation and debugger_cleanup
diagnostic together, so GDB startup, cancellation and timeout failures carry
the code; Rizin's composed cleanup failure retains it at its top level; and
one-shot debug commands report debugger_cleanup_codes from the close-all
failure.
@morluto
morluto force-pushed the feat/gdb-session-close-reasons branch from b0acfac to 8c93485 Compare November 15, 2026 23:12
@morluto
morluto merged commit ff6467c into main Nov 15, 2026
6 checks passed
@morluto
morluto deleted the feat/gdb-session-close-reasons branch November 15, 2026 23:33
@morluto

morluto commented Nov 15, 2026

Copy link
Copy Markdown
Owner Author

Rebased onto main (8c93485). Conflicts: main's errorMessage kernel helper replaced inline cause instanceof Error ? ... (kept with this PR's code fields), and Rizin's composed failure now uses main's analysisErrorWithCleanupDependencies (binding primary and cleanup) with this PR's retainDiagnostics(incompleteStopFacts(...)). check:fast and 6 GDB/Rizin/owned-debugger files (122 passed, 21 skipped) pass.

@greptileai review

@morluto morluto added area: native Native analysis and decompilation, including Ghidra, IDA, and Hopper analysis behavior enhancement New feature or request labels Nov 22, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: native Native analysis and decompilation, including Ghidra, IDA, and Hopper analysis behavior enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant