Skip to content

fix(session): guide unsupported provider recovery - #8567

Merged
morluto merged 17 commits into
mainfrom
codex/provider-capability-recovery
Nov 7, 2026
Merged

morluto merged 17 commits into
mainfrom
codex/provider-capability-recovery

Conversation

@morluto

@morluto morluto commented Nov 1, 2026 •

Copy link
Copy Markdown
Owner

Summary

When the selected binary provider does not declare an operation, guide the caller to an available function-entry comment workflow where applicable, or to inspect candidate capabilities and explicitly choose a provider. Previously the error only suggested choosing another analysis or target. Related: #8565 and #6404.

Problem and expected behavior

A Kuna read_bytes or search_bytes request can be unavailable even when a configured Ghidra candidate supports it. The error now names the undeclared operation and gives MCP and CLI discovery paths, while stating that availability does not guarantee target support and that switching may discard provider session edits which retained Evidence does not restore.

Change and scope

Set the user message at the binary session's undeclared-operation boundary. For regular or inline comment writes, offer annotate_native_function only if the bound provider declares it available, and only as a conditional function-entry option; give its MCP and CLI forms. Declared but unavailable capabilities, provider-selection failures, provider-owned error guidance, error codes and explicit selection behavior are unchanged. No automatic provider fallback or address conversion occurs.

Contract and boundary impact

  • Semantic owner: binary session capability routing, before provider dispatch.
  • Contribution scope: existing static workflows and error presentation; no new target authority or maintainer scope decision required.
  • CLI/MCP: undeclared-operation remediation names binary_session complete detail and explicit open_binary selection, or CLI rea providers and --provider, noting that target support is unknown until a target is selected.
  • Providers and evidence: no change to identities, capabilities, selection, evidence or session lifecycle; discovery is not a guarantee of target support.
  • Generated metadata and installation: no authored generated artifacts or installer changes.

Expected effects:

  • 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

  • The provider-selection MCP boundary regression failed on the base because the error did not mention binary_session; it passes with the new guidance and verifies the selected provider was not switched automatically.

  • Real compact stdio MCP with Kuna 1.988 and Ghidra 12.1.4 on macOS arm64: Kuna read_bytes and search_bytes return the new remediation; binary_session complete lists Ghidra's candidate capabilities; explicit reopening with Ghidra succeeds and returns the expected deadbeef bytes. The owned Mach-O target was unchanged and never executed.

  • In a real Ghidra-to-Kuna-to-Ghidra session, a session-only Ghidra name was absent after reopening, while its mutation Evidence remained retained. A separate Kuna-to-Ghidra switch retained the exact original Kuna inventory Evidence ID and provider attribution. Both tests used the same owned target without changing executable bytes. The final recovery text explicitly warns about possible session-edit loss.

  • A real CLI Kuna read-bytes refusal displayed the same discovery guidance. The earlier wording was exercised through MCP; the CLI check preceded the final wording adjustment.

  • After an actual Ghidra metadata edit, close_binary with snapshot_path refused snapshot creation with evidence_integrity_mismatch and left the edited session active. Switching away and reopening then discarded the edit while retaining its Evidence. This verifies why the warning must not imply that an analysis snapshot or Evidence export restores the live annotation.

  • In a detached combination with fix: guide address-context comment recovery #8414 and real Ghidra MCP, an initial version of this change hid the more specific address-context comment recovery. Generic guidance now stays in the user-facing error message rather than claiming provider-authored remediation; the combined real control returned the function-comments-view guidance for both comment facets. This preserves provider-authored remediation precedence.

  • Review follow-up: the binary session now owns the undeclared-operation formatter; the MCP boundary checks delivery against that owner and separately checks the recovery API names and unchanged provider selection. A harmless warning rewrite passed the focused suite; replacing binary_session with a nonexistent name failed at the intended assertion.

  • No autonomous-agent trial or real-provider check on other platforms was performed. Candidate readiness and target compatibility remain separate facts.

  • On prior head 8d1118a49, real Kuna 1.988 stdio MCP controls in full and compact profiles configured a nonexistent Ghidra installation. read_bytes advised checking candidate availability, target support and capabilities, and choosing a provider only if suitable and available. binary_session reported Ghidra unavailable with executable_missing; an explicit Ghidra open failed readiness without replacing the Kuna session, and its inventory Evidence ID remained unchanged. The owned target digest was unchanged. This tests one unavailable configuration on macOS arm64, not every no-alternative or unsupported-target case.

  • A second prior-head real MCP control also set Hopper's launcher to a nonexistent path. In both profiles, Ghidra, Hopper and IDA were unavailable and the selected Kuna did not declare read_bytes; binary_session therefore contained no candidate simultaneously ready, target-supported and declaring that operation. Explicitly attempting unavailable Ghidra left Kuna's existing inventory Evidence ID intact. The target digest was unchanged. The complete structured status response was 70,006 UTF-8 bytes in this configuration; the 24,089-byte default summary omitted per-candidate capability details. These sizes are not token counts or latency measurements. See [Design] Guide recovery from unsupported provider operations #8565 for a possible bounded discovery follow-up.

  • On prior head da62c6aa3, the 13 focused MCP tests passed, as did touched-file oxfmt and git diff --check. A real Kuna CLI read-bytes refusal showed the revised guidance. In the same no-candidate environment, both rea providers --format json and rea capabilities --format json returned target-free status with target_support: unknown; source inspection shows they invoke the same status workflow. The guidance now recommends one command and does not imply it has assessed a specific target.

  • Current-head (b282fece7) real Kuna 1.989 and Ghidra 12.1.4 stdio MCP on macOS arm64: after a Kuna exact-address xref and an unsupported 256-byte signature search, the error directed candidate discovery. Complete session status showed Ghidra available, target-supported, and declaring search_bytes; an explicit switch found the table. An exported bundle retained the original Kuna xref Evidence ID and provider in both schema profiles. The complete status was 69,914 JSON bytes in this configuration, not a token or latency measurement. The fixture contained an AES S-box and two lookup functions, not an AES implementation; SHA-256 db652d426f596d311d91d5e20f1e3d714784f0512faa70dca8a2a788d99b15a7 was unchanged and the target was not executed. This is one caller-driven workflow, not an agent trial.

Review and integration follow-up

The general selected-provider guidance was stored as a specific remediation, so inspect_address_context skipped its more useful same-document comment-facet recovery. Capability failures now retain generic fallback recovery separately from provider-specific remediation; the error projection, re-attribution and explicit-secret redaction preserve that distinction. Non-comment facets and direct CLI/MCP errors still get the fallback. The top-level message now identifies the unavailable operation without duplicating the full action. Entry-comment guidance no longer promises CLI edits always disappear: persistence depends on the provider and selected checkpoint mode.

A public MCP regression against an actually bound provider with undeclared comment operations failed on the previous implementation and passes with both facet-specific recovery and the unrelated generic fallback retained. On macOS arm64, Node 24.22.1, five focused domain, adapter and MCP suites passed 137 tests; npm run check:fast passed typecheck and lint, both uncached; npm run format:check and git diff --check passed. The focused checks ran on a branch including main through f8bb792; the subsequent conflict-free merge included main through 2e2f981, including #9231. Both include #9276's correction to the old Ghidra evidence assertion. No real Ghidra or Kuna workflow was rerun for this follow-up; the earlier real-provider observations below are attributed to their stated heads.

The MCP fixture helper already owns temporary directory cleanup. The review follow-up removes the duplicate file-level deletion while retaining client and server cleanup in afterEach; the focused provider-selection MCP suite passed all 15 tests on Node 24.22.1, and touched-file formatting and git diff --check passed.

Validation performed

  • npm run test:focused -- tests/boundary/mcp/providerSelectionMcp.test.ts — 13 passed on current head b282fece7, including available and unavailable entry-annotation cases; the original undeclared-operation assertion failed on the base revision.
  • npm run check:fast and git diff --check — passed on current head b282fece7; npm run docs:check passed on the prior head.
  • oxfmt --check on touched files — passed on the current head.

CI status

The prior b282fece7 shard failure concerned #8685. The latest pre-follow-up shard 5 failed a stale Ghidra checkpoint limitation assertion; #9276 updates that test on main and is included in this branch. Hosted CI on the updated head is pending. morluto is exempt from the author-readiness declaration under CONTRIBUTING.md.

Compatibility, safety, and release

The error message and remediation for undeclared operations change; code, category and details remain intact. No automatic provider switch, target execution or installation change.

On the prior head, real Ghidra 12.1.4 fresh-import MCP controls in both profiles returned the conditional function-entry guidance for regular and inline comment requests; annotate_native_function then wrote and read back both comments at the known entry. Existing-project read-only controls did not suggest this unavailable mutation. The target remained unchanged. #6404 tracks arbitrary-address comment support; no autonomous-agent behavior is established.

A temporary conflict-resolved combination of #8567 757f2646 and #8581 d1f5b3ea passed 23 MCP boundary tests and real Ghidra 12.1.4 controls in both schema profiles. Fresh sessions offered and successfully followed the regular/inline function-entry handoff; existing-project sessions did not suggest that unavailable edit and retained their specific read-only recovery. The target and original project hashes were unchanged. This validates the stated local resolution, not an automatic merge.

A real Ghidra control used an interior instruction address as the annotate_native_function procedure selector; Ghidra resolved it to its containing function and wrote at the entry, with the entry returned in Evidence. The conditional handoff here says to use it only for an intended exact entry; #8583 tracks the separate pre-mutation selector-contract concern. This PR does not change annotation selector semantics.

  • Additional pointer-slot workflow on head b282fece7 with a local unrelated catalog-description edit, real Kuna 1.990 and Ghidra 12.1.4: in compact and full stdio MCP, the read_bytes refusal directed candidate discovery and warned about discarded session edits; complete status identified Ghidra as available, target-supported, and declaring the operation. Explicitly switching to Ghidra read loader-adjusted bytes, and the exported bundle retained the earlier Kuna xrefs Evidence exactly. Successful outputs validated against the advertised schemas; the owned target hash remained unchanged. This is a scripted positive handoff, not an agent-selection trial or a guarantee for other configurations.

Latest main integration

Head 2b9a5b1c8e merges main a67525cdf1, including the documentation reorganization. The merge completed without textual conflicts; the affected shared contracts and documentation were inspected. On Node 24.22.1, four focused provider-selection MCP, error projection, sensitive-failure and attribution suites passed 129 tests; git diff --check passed. Hosted checks for this head are pending.

Retry guidance review follow-up

Two retry assertions froze presentation wording instead of checking the behavior they protect. The retry projection now checks the owning formatter, while the fallback-precedence check compares the same retryable error with and without generic fallback and checks its retryable flag. The focused projection suite passed 85 tests; a control that incorrectly prioritizes generic fallback failed at the intended assertion. Touched-file formatting and git diff --check passed. Hosted checks on the new head are pending.

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.

@greptile-apps

greptile-apps Bot commented Nov 1, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerView in GreptileConfidence Score: 5/5 Tier: plus

[Medium impact] The PR appears safe to merge, with no outstanding numbered finding or new actionable issue.

Summary

Adds recovery advice when the selected provider does not declare an operation.

  • Undeclared binary operations point callers to explicit provider recovery.

No new actionable issues or security concerns were identified. This review did not run tests or real providers. Whether another PR supersedes this one could not be confirmed because GitHub access was unavailable.

Reviews (11) · Last reviewed commit: "test: avoid freezing retry remediation w..." · Reviewed by Greptile

@morluto
morluto marked this pull request as ready for review November 1, 2026 17:01
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 1, 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-07T18:19:35.645642Z 4f26b37 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.

An operation the provider does not declare still explains the
entry-comment handoff. A declared but unavailable operation keeps that
capability's own message and remediation.
The merged unknown-provider checks stay in the same scenario and pass
the workspace path explicitly.
Merge main and keep comment-facet recovery distinct from generic provider guidance.
@morluto
morluto enabled auto-merge (squash) November 7, 2026 18:18
@morluto
morluto merged commit 197a296 into main Nov 7, 2026
53 of 55 checks passed
@morluto
morluto deleted the codex/provider-capability-recovery branch November 7, 2026 21:14
@morluto morluto added area: providers Provider and capability discovery, including provider proposal triage bug Something isn't working labels Nov 22, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: providers Provider and capability discovery, including provider proposal triage bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants