Skip to content

refactor(process): own gdb and rizin debugger sessions in one registry - #10735

Merged
morluto merged 1 commit into
mainfrom
refactor/owned-debugger-registry
Nov 15, 2026
Merged

morluto merged 1 commit into
mainfrom
refactor/owned-debugger-registry

Conversation

@morluto

@morluto morluto commented Nov 15, 2026

Copy link
Copy Markdown
Owner

Summary

GDB and Rizin each kept their own copy of persistent debugger session bookkeeping: the session map, start reservations against the session cap, one shared in-flight stop per session, cleanup failures retained until a stop is confirmed, cleanup retry, and close-all. This moves that bookkeeping into one owner, src/process/OwnedDebuggerSessionRegistry.ts, and both managers use it. Behavior is unchanged.

Workstream W4 (lifecycle) of the structural cleanup plan; no linked issue.

Problem and expected behavior

The two managers had drifted copies of the same lifecycle rules (stopAttempt, cleanupFailures, #sessionReservations, the retry loop and #retainCleanupFailure). A fix in one did not reach the other. One owner should hold these rules, and each debugger should keep only its protocol, detach and stop-reason policy.

Change and scope

  • New OwnedDebuggerSessionRegistry<Session> holds the map, reservations (reserve() returns an idempotent release), stop() (shared attempt; a thrown stop becomes incomplete with the debugger's prefix; a confirmed stop resolves every retained failure), retain / retainCleanupFailure, retryCleanupFailures(keepAddressable) and closeAll().
  • Adapters supply sealSession (GDB cleanupStarted, Rizin closing), which runs on every stop request. Before, retry and close-all reached the stop through the manager's wrapper. Now the registry applies the seal itself, so the separate "seal every session" loops in both closeAll() methods are gone.
  • Removed from both managers: stopAttempt, cleanupFailures, the reservation counter, the #stopProcess field, the duplicated retry loop and #retainCleanupFailure.
  • Not included: LLDB. LldbCallTracer is a serialized one-shot tracer with one pending-cleanup owner, not a pool of addressable sessions. Moving it onto this registry would add an abstraction without removing complexity there.
  • closeOwnedDebuggerSessions stays in ownedDebuggerSession.ts, where its boundary tests live. The registry delegates to it.

Contribution scope: internal refactor within existing boundaries; not applicable.

Contract and boundary impact

  • Semantic owner and earliest changed stage: OwnedDebuggerSessionRegistry now owns persistent debugger session lifecycle bookkeeping. Consumers are GdbSessionManager and RizinDebugSessionManager. The superseded per-manager copies were removed.
  • Contribution scope fit and linked maintainer decision: not applicable (refactor).
  • CLI and MCP/tool-catalog contract: none.
  • Provider, bridge, target-format, or platform compatibility: none. Retained-failure provider ids stay gdb and rizin.
  • Evidence, artifact, provenance, or reconstruction contract: none.
  • Target selection, authority, upstream behavior, and cleanup details: cleanup ordering and retention semantics are unchanged.
  • Generated metadata, package, or installation impact: none.

Evidence and regression coverage

  • Tests added or updated: none. The existing GDB and Rizin lifecycle suites cover the moved rules: cleanup retry, retained sessions after an incomplete stop, close during the serialized queue, admission caps, and close-all.
  • Base reproduction or other evidence: this is a refactor. An intermediate version that used GDB_PROVIDER_IDENTITY.id (gnu.gdb) for retained failures failed 2 tests in GdbSessionManagerCoverage.test.ts, which shows the suites pin the retained-failure contract. It was restored to gdb.
  • Remaining proof gaps: no real GDB or Rizin run; the suites use simulated debugger processes.

Validation performed

  • npm run test:focused -- tests/boundary/providers/GdbSessionManagerCoverage.test.ts tests/boundary/providers/GdbSessionReviewRegressions.test.ts tests/boundary/providers/GdbSessionManagers.test.ts tests/boundary/providers/RizinDebugSessionReviewRegressions.test.ts tests/boundary/providers/RizinDebugSessionAdmission.test.ts tests/boundary/providers/RizinDebugSessionManagers.test.ts tests/boundary/process/ownedDebuggerSession.test.ts tests/boundary/providers/RizinDebugSessionCoverage.part{1..5}.test.ts tests/boundary/providers/RizinTtyCleanup.test.ts tests/boundary/providers/RizinDebugSessionInferiorStdin.test.ts tests/boundary/providers/GdbCommandQueue.test.ts tests/boundary/mcp/gdbCancellationMcp.test.ts tests/boundary/mcp/gdbCloseDisposition.test.ts tests/boundary/cli/gdbStartupCleanupCli.test.ts: 18 files, 403 passed, 10 skipped.
  • npm run check:fast: passed.
  • macOS only.

Compatibility, safety, and release

  • Breaking changes or migration steps: none.
  • Real Hopper/Ghidra, browser, or OS coverage: none.
  • Package or release metadata impact: none.
  • Security, privacy, process, or containment review: process ownership and cleanup retention are unchanged; the shared stop still uses stopOwnedDebuggerProcess.

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.

The session map, start reservations, the shared in-flight stop, retained cleanup failures, cleanup retry and close-all move into OwnedDebuggerSessionRegistry. Each debugger keeps its protocol, detach and stop-reason policy and supplies only its seal and stop hooks.
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 15, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

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

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-15T01:53:59.084413Z 16b6379 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.

@greptile-apps

greptile-apps Bot commented Nov 15, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerView in GreptileConfidence Score: 5/5 Tier: plus

[Low impact] The PR appears safe to merge; no actionable issues were found in the shared lifecycle extraction.

Summary

Moves shared GDB and Rizin session bookkeeping into OwnedDebuggerSessionRegistry.

  • GDB and Rizin now share one owner for session cleanup.

Diagram

%%{init: {'theme': 'neutral'}}%%
flowchart TD
  G[GDB manager] --> R[OwnedDebuggerSessionRegistry]
  Z[Rizin manager] --> R
  R --> A[Reserve slots and own sessions]
  R --> S[Seal session and share stop attempt]
  S --> P[stopOwnedDebuggerProcess]
  P --> C{Cleanup confirmed?}
  C -->|No| K[Keep session and cleanup errors]
  K -->|Retry| S
  C -->|Yes| E[Resolve retained cleanup errors]
  E --> D[Keep published ID or remove session]
Loading

Reviews (2) · Last reviewed commit: "refactor(process): own gdb and rizin deb..." · Reviewed by Greptile

@morluto
morluto merged commit e93dada into main Nov 15, 2026
52 checks passed
@morluto
morluto deleted the refactor/owned-debugger-registry branch November 15, 2026 05:45
@morluto morluto added area: runtime Process capture and runtime observation provider: gdb Analysis provider / engine: gdb provider: rizin Analysis provider / engine: rizin labels Nov 22, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: runtime Process capture and runtime observation provider: gdb Analysis provider / engine: gdb provider: rizin Analysis provider / engine: rizin

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant