Skip to content

fix(errors): name rea doctor only for providers it can check - #10565

Merged
morluto merged 11 commits into
mainfrom
fix/doctor-advice-scope
Nov 15, 2026
Merged

morluto merged 11 commits into
mainfrom
fix/doctor-advice-scope

Conversation

@morluto

@morluto morluto commented Nov 14, 2026 •

Copy link
Copy Markdown
Owner

Summary

Recovery advice told callers to "Run rea doctor" for any provider failure REA did not classify, for any unreadable result, and in the final presentation fallback. rea doctor --provider can check only hopper, ghidra, ida, jadx, kuna and desktop_build. This PR names doctor only for those providers; every other unclassified failure says plainly that REA did not classify it and where the provider's reason is reported.

Refs #10482 (the doctor advice is removed for a jadx-reported per-method failure; the method-scoped body_status result the issue asks for is not part of this change).

Problem and expected behavior

  • new ProviderAdapterError("firmware", op) (and 113 other sites with no message or remediation) projected "Analysis could not complete. Run \rea doctor` and review the reported details; ...". doctor rejects --provider firmware`, so the advice cannot be followed.
  • AnalysisOutputError / AnalysisProtocolError ("unreadable result") also named doctor, though doctor does not inspect a provider's reply.
  • Some producers carried the actionable reason only in details.diagnostics.reason. For example, GhidraProviderClient.ts said "reopen the target to resolve a new profile" in diagnostics while the message said to run doctor and that repeating would not succeed.

Expected: doctor appears only where doctor can check the provider. Otherwise the message states that the failure is unclassified, and recovery names the real next step when the producer knows it.

Change and scope

  • DOCTOR_PROVIDER_IDS moves from src/application/DoctorProviderIds.ts to src/domain/doctorProviderIds.ts with an isDoctorProviderId predicate. Doctor, setup and the CLI import it from there, so presentation (domain) and doctor share one list.
  • analysisErrorPresentation.ts:
    • An unclassified ProviderAdapterError gets the message "The {provider} provider could not complete {operation}, and REA did not classify the failure. Any reason the provider reported is in details.diagnostics."
    • Its recovery is rea doctor --provider {id} for doctor-checkable providers. For other providers it states that no specific recovery is known.
    • An authored userMessage without remediation keeps today's behavior: the message is the recovery.
    • The unreadable-output, process-capture and final fallbacks drop doctor.
    • Removes the timeout, start-failure and adapter tag sets, which were unreachable because earlier branches handle every tag in them.
  • Producers that hid the reason in details:
    • Ghidra: the 13 committed-profile/configuration conflicts in createGhidraProviderClient and the installation-version conflict now go through one ghidraProfileConflict owner. It puts the reason in the message and says to reopen the target.
    • Closed analysis clients: three copies in AnalysisClientCreation, DeferredAnalysisClient and CompositeProvider are replaced by closedAnalysisClientError.
    • A jadx-reported request failure (JadxSession) now says jadx answered with an error, so provider readiness checks cannot repair it.
  • Sibling: the deep-analysis profile rejection (AnalysisProviderEvaluation) now names rea doctor --provider ID only for doctor-checkable providers. rizin and other providers get installation guidance without doctor.

Intentionally not included:

Contribution scope: not applicable (ordinary fix within existing boundaries).

Contract and boundary impact

  • Semantic owner and earliest changed stage: the doctor scope list is owned in the domain and consumed by doctor, setup, CLI and error presentation. Presentation owns the generic text. Ghidra profile conflicts and closed-client errors each have one producer helper.

  • Contribution scope fit and linked maintainer decision: not applicable.

  • CLI and MCP/tool-catalog contract: no schema change. The projected code, category, retryable and details are unchanged; only message and remediation.action text changes.

  • Provider, bridge, target-format, or platform compatibility: none.

  • Evidence, artifact, provenance, or reconstruction contract: none. details.diagnostics.reason values are preserved, including client_closed.

  • Target selection, authority, upstream behavior, and cleanup details: not applicable.

  • Generated metadata, package, or installation impact: docs/user-visible-errors.csv rows for ProviderAdapterError and unreadable results are updated.

  • 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 added or updated:

    • src/domain/analysisErrorProjection.test.ts (new "unclassified failures" block). It checks that doctor-checkable providers get rea doctor --provider ID, that firmware/native-macos/rizin/rea-cdp-browser/rea never mention doctor, that an authored message stays the recovery, and that unreadable output names no doctor.
    • tests/boundary/process/jadxIntegration.test.ts: a jadx tool-error reply through the real protocol fixture projects without doctor.
    • src/ghidra/GhidraProvider.behavior.test.ts: the changed-installation refusal puts the reason in the message and says to reopen the target.
    • AnalysisProviderRegistry.test.ts, WakaruReport.test.ts and enhancedTools.callPathsAndBatches.test.ts: updated from the old doctor text.
  • Base reproduction: with only analysisErrorPresentation.ts reverted to origin/main, all 11 new projection cases fail (doctor text is emitted for every provider, and --provider is never named).

  • User-visible output (from the projection test), for ProviderAdapterError("firmware", "inspect"): message "The firmware provider could not complete inspect, and REA did not classify the failure. Any reason the provider reported is in details.diagnostics.", remediation "Review the reported details for the provider's reason; REA has no specific recovery for this unclassified failure. Repeating the unchanged request is not expected to succeed."

  • Remaining proof gaps: no real Ghidra or jadx run. The Ghidra and jadx paths are covered by the existing simulated provider fixtures.

  • 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 check:fast: passed (typecheck + lint).
  • npm run test:focused -- src/domain/analysisErrorProjection.test.ts src/ghidra/GhidraProvider.behavior.test.ts tests/boundary/mcp/enhancedTools.callPathsAndBatches.test.ts tests/boundary/process/jadxIntegration.test.ts src/doctorRuntime.test.ts: 5 files, 506 passed, 1 skipped.
  • npm run test:local -- src/application/binary/CompositeProvider.test.ts src/application/binary/DeferredAnalysisClient.test.ts src/application/binary/LazyAnalysisProvider.test.ts src/application/binary/AnalysisProviderRegistry.test.ts src/providers/AnalysisClientFailure.test.ts src/domain/analysisErrorProjection.test.ts src/main/messages.test.ts: 7 files, 194 passed.
  • npm run test:local -- src/javascript/recovery/WakaruReport.test.ts src/domain/analysisErrorProjection.test.ts src/application/binary/AnalysisProviderRegistry.test.ts: 159 passed.
  • npm run docs:check: passed.
  • Ran the new projection test against base presentation: 11 failed as expected.
  • Review follow-up: replaced the remaining recovery-prose matches with checks that doctor is not offered. npm run test:local -- src/application/binary/AnalysisProviderRegistry.test.ts — 47 passed; npm run test:focused -- tests/boundary/process/jadxIntegration.test.ts — 53 passed. Pre-push npm run check:fast passed.

Compatibility, safety, and release

  • Breaking changes or migration steps: none. Only message and remediation wording changes; error codes, categories, retryability and details are unchanged.
  • Real Hopper/Ghidra, browser, or OS coverage: none; simulated fixtures only.
  • Package or release metadata impact: none.
  • Security, privacy, process, or containment review: no new data in messages beyond reasons already carried in details (Ghidra profile reasons are REA-authored text).

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.

An unclassified ProviderAdapterError, an unreadable result and the final
presentation fallback all told the caller to run rea doctor, although doctor
checks only hopper, ghidra, ida, jadx, kuna and desktop_build. The doctor
scope list moves into the domain so presentation can consult it: covered
providers get `rea doctor --provider ID`, others are told plainly that the
failure is unclassified and where its reason is reported.

Producers whose actionable reason lived only in details.diagnostics now
author it: Ghidra's committed-profile conflicts share one owner that says to
reopen the target, closed analysis clients share one owner, and a jadx-reported
request failure no longer points at provider readiness. The deep-analysis
profile rejection names doctor only for doctor-checkable providers. Dead
presentation branches for tags handled earlier are removed.
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 14, 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-15T09:49:28.413901Z c760dd3 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.

@greptile-apps

greptile-apps Bot commented Nov 14, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerView in GreptileConfidence Score: 5/5 Tier: plus

[Medium impact] The reviewed changes appear safe to merge.

Summary

This PR limits generic rea doctor advice to providers doctor accepts and gives known failures their own recovery.

  • Provider failures now get recovery advice that fits the checks REA can run.
  • Ghidra profile conflicts now show the mismatch and how to resolve it.
  • Jadx request errors now point callers to the provider's reported reason.
  • Closed analysis clients now direct callers to a new target session.

Diagram

%%{init: {'theme': 'neutral'}}%%
flowchart TD
  A[ProviderAdapterError] --> B{Authored recovery?}
  B -- Yes --> C[Keep authored recovery]
  B -- No --> D{Authored message?}
  D -- Yes --> E[Keep message as recovery]
  D -- No --> F{Provider in shared doctor list?}
  F -- Yes --> G[Offer provider-scoped doctor check]
  F -- No --> H[State no specific recovery is known]
Loading

Reviews (11) · Last reviewed commit: "Merge remote-tracking branch 'origin/mai..." · Reviewed by Greptile

Comment thread src/android/JadxSession.ts Resolved
Comment thread src/ghidra/GhidraProviderClient.ts Resolved
@morluto
morluto merged commit 4aefe2d into main Nov 15, 2026
14 checks passed
@morluto
morluto deleted the fix/doctor-advice-scope branch November 15, 2026 10:09
@morluto morluto added area: domain Domain logic, errors, and pure functions 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: domain Domain logic, errors, and pure functions bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant