Skip to content

fix: retain address context cleanup failures - #8417

Merged
morluto merged 1 commit into
mainfrom
codex/context-cleanup-ownership
Nov 1, 2026
Merged

morluto merged 1 commit into
mainfrom
codex/context-cleanup-ownership

Conversation

@morluto

@morluto morluto commented Nov 1, 2026 •

Copy link
Copy Markdown
Owner

Summary

inspect_address_context can return success or plain cancellation while one or more parallel facet failures report incomplete cleanup. Wait for every facet and preserve the first decisive failure and every still-owned cleanup resource, including when cancellation occurs during a late facet.

Fixes #8416. This is a controlled application/MCP boundary reproduction; a real Ghidra or Kuna cleanup failure has not been reproduced.

Change and scope

The shared context workflow records facet completion order and observes its caller's abort while waiting for all five calls. It combines cleanup-bearing failures using the existing cleanup-error and dependency owners, keeps an earlier failure primary when cancellation arrives later, and retains the provider's own cancellation when it reports the same abort signal. It does not claim an owner was cleaned up until its lease reports success. Ordinary unavailable facets remain local; successful context results and output schema do not change.

The abort listener is removed after the facet work settles, and an already-cancelled request with an explicit document does not start facet work. This addresses an existing lifecycle boundary; it does not add provider mutation or process-control authority. #8415 separately tracks typed input diagnostics, and #8364 tracks retention of aggregate partial observations and contributing Evidence.

Evidence and regression coverage

  • On base 6e9ee97a, both new MCP cases failed: two incomplete cleanup outcomes were reduced to a success, and cancellation with those same outcomes returned plain cancelled without their resources. The corrected boundary suite passes.
  • Controlled cleanup leases cover two independent owners, a failed retry, successful retry without re-closing its peer, and dynamic aggregate status after each release. Controlled cancellation tests cover a late cleanup failure, a late success that ignores cancellation, earlier cleanup before a later cancellation, and provider cancellation diagnostics. They do not simulate a real Ghidra/Kuna process cleanup or prove session-owned retry in those providers.
  • Real Ghidra 12.1.4 and Kuna 1.986 MCP controls on an unexecuted source-owned arm64 Mach-O returned exactly the baseline context results for a function, an outside-function address and an unmapped address. The target digest remained unchanged.
  • A detached integration of this commit with draft fix: guide address-context comment recovery #8414 passed the combined MCP and lifecycle tests. The same detached combination also passed the real-Ghidra COM verifier. It remains an exploratory combination: the two PRs touch the same files and require conflict resolution when integrated.

Validation performed

  • npm run test:local -- src/application/AnalysisContextQueries.test.ts — 28 passed; six new cases failed against the base revision.
  • npm run test:focused -- tests/boundary/mcp/addressContextBookmarks.test.ts — 9 passed; both new cleanup cases failed against base.
  • npm run check:fast, git diff --check and changed-file formatting check — passed.
  • Real Ghidra 12.1.4/JDK 21 and Kuna 1.986 success/facet controls — passed on macOS arm64, SDK 2.3.1 full/compact output schemas as applicable; target unchanged and not executed.
  • Combined detached fix: guide address-context comment recovery #8414 plus this change: MCP boundary tests 14 passed, lifecycle source tests 28 passed, and npm run verify:ghidra:com passed with real Ghidra on macOS arm64.

Compatibility, safety, and release

A formerly successful or plain-cancelled response with incomplete cleanup now reports the unresolved cleanup. No schema or migration change. Real-provider cleanup failures, external process termination, CLI-specific behavior, Windows, and aggregate partial-observation persistence were not verified by this 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.

@greptile-apps

greptile-apps Bot commented Nov 1, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerView in GreptileConfidence Score: 5/5

[Medium impact] The reviewed changes appear safe to merge; no actionable defects were established.

Summary

inspectAddressContext now observes cancellation while waiting for all five facets and preserves unresolved cleanup resources.

  • Address context reports every unresolved facet cleanup.

Diagram

%%{init: {'theme': 'neutral'}}%%
flowchart TD
  A[Resolve document] --> B{Already cancelled?}
  B -->|Yes| C[Return cancellation]
  B -->|No| D[Start five facets]
  D --> E[Record facet completions and caller cancellation]
  E --> F[Wait for all facets]
  F --> G{Decisive failure?}
  G -->|No| H[Return address context]
  G -->|Yes| I[Keep first failure and combine cleanup owners]
  I --> J[Return failure with live cleanup resources]
Loading

Reviews (1) · Last reviewed commit: "fix: retain address context cleanup fail..." · Reviewed by Greptile

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 1, 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-11-01T03:56:48.115930Z 40e8713 Draft marked ready
ℹ️ 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.

@morluto
morluto merged commit 7c755f2 into main Nov 1, 2026
49 of 51 checks passed
@morluto
morluto deleted the codex/context-cleanup-ownership branch November 1, 2026 09:24
Entrpi added a commit to Entrpi/rea that referenced this pull request Nov 1, 2026
Take main 7c755f2 (morluto#8432, morluto#8417). There were no text conflicts, but
morluto#8432 replaced snapshotMatchesBinding with snapshotBindingMismatch,
which returns undefined when a snapshot matches and otherwise names
what differs. rawLoadCompatibility.test.ts now asserts the mismatch: a
pre-morluto#7823 Ghidra snapshot differs only in its profile digest, and a
snapshot of a different target names the target.
coyoteXujie pushed a commit to coyoteXujie/rea that referenced this pull request Nov 2, 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

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug] Address context can hide incomplete facet cleanup

1 participant