mirror of
https://github.com/morluto/rea.git
synced 2026-11-09 08:17:02 +00:00
* fix(discovery): carry provider repair instructions into capability discovery Provider readiness reported only a failure description, so capability discovery copied that description into tool_availability remediation and dropped repairs the owners already had: the JEB discovery-deadline setting, the ADB/Apktool execute-permission repair kept in diagnostics, and the IDA and Kuna configuration recovery. Unavailable ProviderAvailability now requires the owner's remediation next to its reason, and readiness-derived unavailable capability descriptors carry it too. Every producer supplies it (ADB, Apktool, JADX, JEB, Ghidra, Hopper, IDA, Kuna, pcap, owned-process prerequisites, profile rejection); the inventory uses it verbatim, falling back to the reason only for static capability facts that declare no repair. ADB/Apktool configuration failures own remediation as a field instead of diagnostics, and execution refusals project it as remediation.action. JADX doctor reads the availability's remediation instead of re-deriving it. binary_session complete candidate availability and unavailable capability groups expose remediation (CLI capabilities/providers too); summary omits it and lists it in omitted_fields. The superseded IDA configuration_remediation and windows_native_failure.remediation diagnostics are removed. Fixes #8506 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * fix(discovery): keep owner repairs through provider selection and capability maps Address review findings on the readiness-remediation contract: - Provider selection rejections carry the availability owner's remediation, CLI/MCP error details project it, and an explicit selection refused by readiness uses it as remediation.action. IDA's unreadable registration and Ghidra's Windows readiness repair no longer degrade to generic selection advice now that the diagnostics copies are gone. - Ghidra's Windows readiness and existing-project capability maps carry the same repair as the availability. - pcap readiness keeps the limiter owner's repair (now a typed remediationAction) and falls back to Wireshark guidance only when the failure has none. - ADB/Apktool repairs are owner constants that are complete sentences. The execution refusal keeps its previous message-plus-repair recovery, which the compiled CLI contract asserts. - Regression tests compare with the owning formatter or constant and add public MCP and CLI coverage for an explicit IDA selection. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
98 lines
3.5 KiB
TypeScript
98 lines
3.5 KiB
TypeScript
import { AnalysisCapabilityUnavailableError } from "../domain/analysisErrorCore.js";
|
|
import { ProviderAdapterError } from "../domain/providerAdapterError.js";
|
|
import { jsonValueSchema } from "../domain/jsonValue.js";
|
|
import { DarwinProcessOwnershipInspectionError } from "../process/DarwinProcessRunTokenReader.js";
|
|
import { OwnedCommandFailure } from "../process/OwnedCommand.js";
|
|
import { LinuxOwnedProcessPrerequisiteError } from "../process/ProcessOwnershipObservation.js";
|
|
import type { ProviderAvailability } from "./AnalysisProvider.js";
|
|
|
|
const REMEDIATION =
|
|
"Install your distribution's procps or procps-ng package, or put a procps-compatible ps on REA's PATH, then retry.";
|
|
|
|
const DARWIN_REMEDIATION =
|
|
"Check the selected Xcode or Command Line Tools and Swift compiler configuration, then restart REA and retry.";
|
|
|
|
// Provider adapters re-attribute capability errors and keep the original as cause.
|
|
const prerequisiteRefusal = (
|
|
cause: unknown,
|
|
): LinuxOwnedProcessPrerequisiteError | undefined => {
|
|
if (
|
|
!(cause instanceof AnalysisCapabilityUnavailableError) ||
|
|
cause.cleanupIncomplete
|
|
)
|
|
return undefined;
|
|
for (
|
|
let current: unknown = cause;
|
|
current instanceof AnalysisCapabilityUnavailableError;
|
|
current = current.cause
|
|
)
|
|
if (current instanceof LinuxOwnedProcessPrerequisiteError) return current;
|
|
return undefined;
|
|
};
|
|
|
|
// Recognize only failures attributed to owned-process preparation. Cancellation
|
|
// and failed cleanup remain errors so their owner and completion are not lost.
|
|
const darwinPrerequisiteRefusal = (
|
|
cause: unknown,
|
|
): DarwinProcessOwnershipInspectionError | undefined => {
|
|
let current = cause;
|
|
while (current instanceof ProviderAdapterError) {
|
|
if (
|
|
current.cleanupIncomplete ||
|
|
current.diagnostics?.stage !== "ownership_preparation"
|
|
)
|
|
return undefined;
|
|
current = current.cause;
|
|
}
|
|
if (current instanceof OwnedCommandFailure) {
|
|
if (
|
|
current.reason !== "process" ||
|
|
current.cleanupOwner !== undefined ||
|
|
current.cleanupFailure !== null ||
|
|
current.cleanupResult !== undefined ||
|
|
current.cancellation !== undefined
|
|
)
|
|
return undefined;
|
|
current = current.preparationFailure;
|
|
}
|
|
return current instanceof DarwinProcessOwnershipInspectionError &&
|
|
current.cleanupFailure === undefined &&
|
|
current.cleanupOwner === undefined &&
|
|
current.cancellation === undefined
|
|
? current
|
|
: undefined;
|
|
};
|
|
|
|
/** A host prerequisite gap is the probed provider's unavailability, not a probe failure. */
|
|
export const ownedProcessPrerequisiteAvailability = (
|
|
cause: unknown,
|
|
): ProviderAvailability | undefined => {
|
|
const refusal = prerequisiteRefusal(cause);
|
|
if (refusal !== undefined)
|
|
return {
|
|
status: "unavailable",
|
|
code: "runtime_unavailable",
|
|
reason: `${refusal.reason}. ${REMEDIATION}`,
|
|
remediation: REMEDIATION,
|
|
diagnostics: {
|
|
stage: "ownership_preparation",
|
|
prerequisite_provider_id: refusal.providerId,
|
|
prerequisite_operation: refusal.operation,
|
|
},
|
|
};
|
|
const darwin = darwinPrerequisiteRefusal(cause);
|
|
if (darwin === undefined) return undefined;
|
|
return {
|
|
status: "unavailable",
|
|
code: "runtime_unavailable",
|
|
reason: `${darwin.message}. ${DARWIN_REMEDIATION}`,
|
|
remediation: DARWIN_REMEDIATION,
|
|
diagnostics: {
|
|
stage: "ownership_preparation",
|
|
...(darwin.compilerOutcome === undefined
|
|
? {}
|
|
: { compiler_outcome: jsonValueSchema.parse(darwin.compilerOutcome) }),
|
|
},
|
|
};
|
|
};
|