mirror of
https://github.com/morluto/rea.git
synced 2026-12-03 21:46:01 +00:00
* fix(errors)!: derive retryable from the producer's declared retry class `retryable` means the unchanged request may succeed, but it was computed downstream as an OR of a code table and five class rules. Every error classification now declares a retry class (same_call, change_first, never, unknown_outcome); `retryable` is `same_call` after one incomplete-cleanup check, and the RETRYABLE_CODES table is deleted. Producer corrections: - update_unknown revision conflicts are change_first and report details.current_revision; duplicate record_unknown reports details.existing_unknown_id. - close_gdb_session's explicit-disposition refusal is change_first. - Per-call artifact reader limits are change_first (never when the limit cannot rise). - An exited or unreachable Hopper bridge, and a Hopper start that another REA session owns, are change_first. - File-descriptor exhaustion (EMFILE/ENFILE) outside process launch is occupied host capacity (same_call) for private workspaces, model and GPU readers and JavaScript application reads. - apktool JVM native-thread exhaustion follows the shared capacity default. BREAKING CHANGE: these refusals now report `retryable: false` (descriptor pressure now reports `retryable: true` as `resource_constraint`). Callers that repeated them unchanged should follow the remediation first: re-read the unknown and retry with details.current_revision, dispose GDB inferiors, raise the reported reader limit, or restart the Hopper provider. * fix(errors): require producers to name recovery for conforming refusals A refusal whose arguments match the input schema was presented as a schema error whenever its producer left out remediation, and many producers did. AnalysisInputError's options are now a union: a conforming refusal must supply both its outcome (userMessage) and next step (remediationAction), so the compiler lists every producer; only contract violations may fall back to the schema guidance. Producers fixed: unknown Frida session and script, decompile_all output-directory state, the duplicate unknown build computer factory (collapsed), stale Cutter sessions, Mach-O architecture selection, output roots that already exist, selected files the host refuses, Ghidra lookups the bridge could not resolve, YARA path refusals, unresolved native symbol names, apt key files and withheld sign-in state. A missing selected APK is now target_unavailable like every other selected-file reader. The capability fallback "Choose another analysis or target" is deleted; a capability refusal without its own recovery names details.reason and binary_session. Refs #15312 * fix(errors): classify caller selections and target bytes by their real failure Several refusals reported a code that reads as corruption or a crash: - a missing unknown_id and a missing Evidence reference now report invalid_request instead of execution_failure and evidence_integrity_mismatch; - close_binary with snapshot_path in a resource-only session reports invalid_request instead of evidence_integrity_mismatch; - ADB push onto an existing device path and pulls into an occupied output directory are conforming invalid_request refusals naming overwrite or output_directory, not unreadable_output; - damaged APK ZIP, signing-block, signer and central-directory structures are malformed targets, not invalid input; - NuGet and VSIX bytes without a ZIP signature are unrecognized, not malformed; - a historical source graph file whose entries contradict its root commitment is an integrity failure, not invalid input; - a CDP protocol failure states what happened instead of the unclassified fallback message. Refs #15319 * feat(errors): expose the producer's retry class as retry_class Every error projection now carries retry_class (same_call, change_first, never or unknown_outcome) beside retryable, which stays true exactly for same_call. The field is additive: the error schema accepts errors retained by earlier releases without it. Refs #15323 * fix(errors): address review of the folded error-contract PRs Keep a provider's own capability message as its remediation; the binary_session fallback applies only to a bare declared reason. Delete the unused conformingInputRefusal helper. Compose both retry fields for a refused publication whose cleanup is incomplete. Report descriptor exhaustion from a JavaScript directory opendir as occupied capacity. Let an exited Hopper startup attempt without a setup failure code retry unchanged. Declare retry for the Ghidra superseded checkpoint and unknown IDA readiness. Redact ambiguous selector candidates. Give a Ghidra document miss its own recovery. Drop an unchanged-files claim the journal repair cannot make. Name each withheld sign-in refusal's step. Hash the source graph commitment before the cancellation yield. Keep the browser protocol_error message neutral. Add tests for mutation-audit survivors C3, C5, P2, P4, P8, H1, H4 and H5. * fix(errors): keep a missing Evidence reference an integrity failure and state only the observed commitment mismatch * test(desktop): assert the unknown build computer refusal's remediation, not its message The refusal now carries its next step in remediation.action instead of the message, so the closed-computer checks assert the exact code, message and remediation facts. * fix(errors): keep producer retry choices apart from cleanup and fixed ceilings A capture's retryable flag no longer folds in pending cleanup, so the projection applies the cleanup rule once and a transient capture with pending cleanup reports change_first instead of never. A release-fixed artifact allowance reports never, and a stale admitted session identity reports change_first (reopen, then retry); both have catalogue rows. The bare capability-unavailable remediation names binary_session only for a binary-analysis session, so standalone bridges such as Cutter are pointed at their own reason. * test(vsix): expect a non-ZIP selection to be refused as unrecognized This PR reports bytes without a ZIP signature as another format (unrecognized), not a damaged package; the exact-reason assertion added on main still expected malformed. * test(delivery): expect the capacity refusal's retry class in delivered failure facts The exact failure facts asserted on main predate the projection's retry_class; occupied capacity reports same_call. * fix(errors): mark a sent Hopper cancellation unknown and missing Evidence recoverable A cancellation Hopper already received may still apply, so its retry class is unknown_outcome instead of same_call; an unsent cancellation keeps same_call. A missing EvidenceReferenceError is change_first, since importing the referenced records lets the same request succeed; other reference failures stay never. Both have catalogue rows. * fix(hopper): ask for changed launch arguments before retrying an unencodable launch A launcher path or argument that cannot be encoded as an AppleScript literal meets the same pre-launch guard on every attempt, so the start refusal is change_first and its retry_action is unknown; a start failure without a declared reason stays same_call. * fix(errors): keep a one-shot cleanup failure's retry class with its cleanup state A one-shot reply that reports cleanup_incomplete spread the primary or cleanup projection and overrode only retryable, so a timed-out read whose close also failed carried retry_class same_call. The reply now reads its retry class from the typed composed failure, and never offers the same call before cleanup settles. * test(evtx): expect an unreadable selected log to be refused with its own recovery This PR treats a well-formed path the host refused as a regular file as conforming input with its own remediation; the evtx boundary test still expected a schema-recovery refusal. * test(javascript): expect a broken source-graph commitment as an integrity failure This PR reports a well-formed historical source graph whose entries disagree with its root_sha256 as evidence_integrity_mismatch, not an input issue; the exact refusal assertion added on main still expected invalid_request.
475 lines
17 KiB
TypeScript
475 lines
17 KiB
TypeScript
import { carrySessionExecutionProvenance } from "./binary/SessionEvidenceReuse.js";
|
|
import { permitsCapabilityFallback } from "./CapabilityFallback.js";
|
|
import {
|
|
listNamesFact,
|
|
resolveContainingProcedureFact,
|
|
} from "../domain/native/nativeOperationFacts.js";
|
|
import {
|
|
selectNativeSymbol,
|
|
type NativeSymbolCandidate,
|
|
type NativeSymbolMatch,
|
|
} from "../domain/native/nativeSymbolSelector.js";
|
|
import { executeFact } from "./AnalysisOperationFacts.js";
|
|
import type { AnalysisError } from "../domain/analysisErrorBase.js";
|
|
import {
|
|
AnalysisInputError,
|
|
AnalysisOutputError,
|
|
cancelledBy,
|
|
} from "../domain/analysisErrorCore.js";
|
|
import { classifyAnalysisError } from "../domain/analysisErrorClassification.js";
|
|
import type { JsonValue } from "../domain/jsonValue.js";
|
|
import { err, ok, type Result } from "../domain/result.js";
|
|
import type {
|
|
AnalysisExecution,
|
|
AnalysisOperation,
|
|
AnalysisOperationPort,
|
|
ExecutionOptions,
|
|
} from "../ports/AnalysisProvider.js";
|
|
import { resolveProcedureAddress } from "./ProcedureAddressResolution.js";
|
|
|
|
/** Native operations whose name selector this module resolves. */
|
|
export type NativeSymbolOperation =
|
|
| "xrefs"
|
|
| "find_xrefs_to_name"
|
|
| "procedure_callers"
|
|
| "procedure_references";
|
|
|
|
/** One name selector resolved by the shared owner, or the reason it was not. */
|
|
export type NativeSymbolResolution =
|
|
| {
|
|
readonly status: "resolved";
|
|
readonly address: string;
|
|
readonly name: string;
|
|
/** `procedure_lookup`: the provider's own procedure-name lookup matched. */
|
|
readonly match: NativeSymbolMatch | "procedure_lookup";
|
|
}
|
|
| {
|
|
readonly status: "unresolved";
|
|
readonly candidates: readonly NativeSymbolCandidate[];
|
|
};
|
|
|
|
const selectorField = (operation: NativeSymbolOperation) =>
|
|
operation === "find_xrefs_to_name"
|
|
? "name"
|
|
: operation === "xrefs"
|
|
? "address"
|
|
: "procedure";
|
|
|
|
/** A lookup the provider refused as a valid request it could not satisfy. */
|
|
const isLookupMiss = (error: AnalysisError): boolean =>
|
|
!error.cleanupIncomplete &&
|
|
// A selector that matched several candidates was found, not missed.
|
|
!(
|
|
error instanceof AnalysisInputError && error.ambiguousSelector !== undefined
|
|
) &&
|
|
classifyAnalysisError(error).category === "invalid_input";
|
|
|
|
type NativeSymbolExecutionOptions = Pick<
|
|
ExecutionOptions,
|
|
"signal" | "snapshotContext"
|
|
>;
|
|
|
|
const lookupOptions = (
|
|
options?: NativeSymbolExecutionOptions,
|
|
): NativeSymbolExecutionOptions => ({
|
|
...(options?.signal === undefined ? {} : { signal: options.signal }),
|
|
...(options?.snapshotContext === undefined
|
|
? {}
|
|
: { snapshotContext: options.snapshotContext }),
|
|
});
|
|
|
|
/**
|
|
* Resolve a name selector once for every name-taking native operation: an
|
|
* exact observed name, then a provider-reported import by its imported or
|
|
* library-qualified name, then (when `procedureLookup` is set) the provider's
|
|
* own procedure lookup, which also accepts its namespace and thunk spellings.
|
|
* An inventory miss stays unresolved; it does not show the name is absent.
|
|
*/
|
|
export const resolveNativeSymbol = async (
|
|
analysis: AnalysisOperationPort,
|
|
selector: string,
|
|
operation: NativeSymbolOperation,
|
|
signal: AbortSignal | undefined,
|
|
{
|
|
procedureLookup,
|
|
snapshotContext,
|
|
}: {
|
|
readonly procedureLookup: boolean;
|
|
readonly snapshotContext?: ExecutionOptions["snapshotContext"];
|
|
},
|
|
): Promise<Result<NativeSymbolResolution, AnalysisError>> => {
|
|
if (signal?.aborted) return err(cancelledBy(operation, signal));
|
|
const options = lookupOptions({
|
|
...(signal === undefined ? {} : { signal }),
|
|
...(snapshotContext === undefined ? {} : { snapshotContext }),
|
|
});
|
|
const inventory = await executeFact(analysis, listNamesFact, {}, options);
|
|
if (!inventory.ok) {
|
|
if (
|
|
!procedureLookup ||
|
|
!permitsCapabilityFallback(inventory.error) ||
|
|
inventory.error.operation !== "list_names"
|
|
)
|
|
return inventory;
|
|
return procedureLookupResolution(
|
|
analysis,
|
|
selector,
|
|
signal,
|
|
[],
|
|
snapshotContext,
|
|
);
|
|
}
|
|
if (signal?.aborted) return err(cancelledBy(operation, signal));
|
|
const rows = inventory.value.fact;
|
|
for (let index = 0; index < rows.length; index += 1)
|
|
// An empty address cannot be passed back to a provider operation.
|
|
if (rows[index]!.address.length === 0)
|
|
return err(
|
|
new AnalysisOutputError(
|
|
"list_names",
|
|
`Invalid symbol inventory entry at index ${index}`,
|
|
),
|
|
);
|
|
const selection = selectNativeSymbol(rows, selector);
|
|
if (selection.status === "resolved") return ok(selection);
|
|
if (selection.status === "ambiguous")
|
|
return err(
|
|
new AnalysisInputError(
|
|
operation,
|
|
{
|
|
conformsToInputContract: true,
|
|
ambiguousSelector: {
|
|
field: [selectorField(operation)],
|
|
candidates: selection.candidates.map(({ address }) => address),
|
|
},
|
|
remediationAction:
|
|
"Select an exact address from the candidates and retry with that address.",
|
|
},
|
|
[
|
|
{
|
|
path: [selectorField(operation)],
|
|
reason: "invalid_value",
|
|
message: `Analyzed symbol name ${JSON.stringify(selector)} is ambiguous at ${selection.candidates.map(({ address, name }) => (name === selector ? address : `${address} (${name})`)).join(", ")}. Select an exact address.`,
|
|
},
|
|
],
|
|
),
|
|
);
|
|
return procedureLookup
|
|
? procedureLookupResolution(
|
|
analysis,
|
|
selector,
|
|
signal,
|
|
selection.candidates,
|
|
snapshotContext,
|
|
)
|
|
: ok(selection);
|
|
};
|
|
|
|
const procedureLookupResolution = async (
|
|
analysis: AnalysisOperationPort,
|
|
selector: string,
|
|
signal: AbortSignal | undefined,
|
|
candidates: readonly NativeSymbolCandidate[],
|
|
snapshotContext?: ExecutionOptions["snapshotContext"],
|
|
): Promise<Result<NativeSymbolResolution, AnalysisError>> => {
|
|
const resolved = await resolveProcedureAddress(
|
|
async (operation, parameters, signal) => {
|
|
const result = await analysis.execute(
|
|
operation,
|
|
parameters,
|
|
lookupOptions({
|
|
...(signal === undefined ? {} : { signal }),
|
|
...(snapshotContext === undefined ? {} : { snapshotContext }),
|
|
}),
|
|
);
|
|
return result.ok ? ok(result.value.result) : result;
|
|
},
|
|
selector,
|
|
signal,
|
|
);
|
|
if (resolved.ok)
|
|
return ok({
|
|
status: "resolved",
|
|
address: resolved.value,
|
|
name: selector,
|
|
match: "procedure_lookup",
|
|
});
|
|
return isLookupMiss(resolved.error)
|
|
? ok({ status: "unresolved", candidates })
|
|
: resolved;
|
|
};
|
|
|
|
/** Hexadecimal or space-qualified address spellings; providers own their meaning. */
|
|
const ADDRESS_SELECTOR = /^(?:[A-Za-z_][\w.-]*:)?0x[0-9a-f]+$/iu;
|
|
|
|
const unresolvedNameError = (
|
|
operation: NativeSymbolOperation,
|
|
selector: string,
|
|
candidates: readonly NativeSymbolCandidate[],
|
|
): AnalysisInputError =>
|
|
new AnalysisInputError(
|
|
operation,
|
|
{
|
|
conformsToInputContract: true,
|
|
...(candidates.length > 0
|
|
? {}
|
|
: { related: { operations: ["search_procedures", "list_names"] } }),
|
|
userMessage:
|
|
candidates.length > 0
|
|
? `No observed name equals ${JSON.stringify(selector)}.`
|
|
: `No analyzed symbol is named ${JSON.stringify(selector)}.`,
|
|
remediationAction:
|
|
candidates.length > 0
|
|
? `Retry with one of the observed names or addresses: ${candidates.map(({ address, name }) => `${name} at ${address}`).join(", ")}. The provider does not report which library each name is imported from.`
|
|
: "Find an observed name or address with search_procedures or list_names, then retry. An inventory miss leaves the symbol's presence in the artifact unknown.",
|
|
},
|
|
[
|
|
{
|
|
path: [selectorField(operation)],
|
|
reason: "invalid_value",
|
|
message:
|
|
candidates.length > 0
|
|
? `No observed name equals ${JSON.stringify(selector)}; the provider reports the imported name without its library.`
|
|
: `Unknown analyzed symbol name ${JSON.stringify(selector)}. Use an exact analyzed name or a hexadecimal address.`,
|
|
},
|
|
],
|
|
);
|
|
|
|
const refusesAddressFormatOnly = (error: AnalysisError): boolean =>
|
|
error instanceof AnalysisInputError &&
|
|
error.issues.length > 0 &&
|
|
error.issues.every(
|
|
({ path, reason }) =>
|
|
path.length === 1 && path[0] === "address" && reason === "invalid_format",
|
|
);
|
|
|
|
/**
|
|
* Whether the provider's answer at a resolved address keeps the caller's
|
|
* symbol: an address outside every procedure, or a procedure's exact entry
|
|
* (such as an external import function). An address inside a procedure, such
|
|
* as an interior label, would silently select its containing procedure.
|
|
* A provider without containment lookup keeps its own refusal; any other
|
|
* lookup failure is returned with its facts.
|
|
*/
|
|
const answersSymbolByAddress = async (
|
|
analysis: AnalysisOperationPort,
|
|
address: string,
|
|
options: NativeSymbolExecutionOptions | undefined,
|
|
): Promise<Result<boolean, AnalysisError>> => {
|
|
const containing = await executeFact(
|
|
analysis,
|
|
resolveContainingProcedureFact,
|
|
{ address },
|
|
lookupOptions(options),
|
|
);
|
|
if (!containing.ok)
|
|
return permitsCapabilityFallback(containing.error) ? ok(false) : containing;
|
|
const fact = containing.value.fact;
|
|
return ok(
|
|
fact.found
|
|
? fact.procedure.address === address
|
|
: fact.reason === "not_in_procedure",
|
|
);
|
|
};
|
|
|
|
/** A non-address name selector of an operation the shared owner resolves. */
|
|
const nameSelector = (
|
|
operation: AnalysisOperation,
|
|
parameters: Readonly<Record<string, JsonValue>>,
|
|
): { operation: NativeSymbolOperation; selector: string } | undefined => {
|
|
const field =
|
|
operation === "xrefs"
|
|
? "address"
|
|
: operation === "procedure_callers" ||
|
|
// Outgoing references have no meaning for a symbol outside a procedure.
|
|
(operation === "procedure_references" &&
|
|
parameters.direction === "incoming")
|
|
? "procedure"
|
|
: undefined;
|
|
if (field === undefined) return undefined;
|
|
const selector = parameters[field];
|
|
return typeof selector === "string" && !ADDRESS_SELECTOR.test(selector)
|
|
? { operation: operation as NativeSymbolOperation, selector }
|
|
: undefined;
|
|
};
|
|
|
|
const answeredByAddress = (
|
|
analysis: AnalysisOperationPort,
|
|
operation: NativeSymbolOperation,
|
|
parameters: Readonly<Record<string, JsonValue>>,
|
|
answered: Result<AnalysisExecution, AnalysisError>,
|
|
selector: string,
|
|
resolution: Extract<NativeSymbolResolution, { status: "resolved" }>,
|
|
options: NativeSymbolExecutionOptions | undefined,
|
|
): Result<AnalysisExecution, AnalysisError> => {
|
|
if (!answered.ok || resolution.address === selector) return answered;
|
|
const { evidenceId: _resolvedEvidenceId, ...execution } = answered.value;
|
|
const resolvedExecution: AnalysisExecution = carrySessionExecutionProvenance(
|
|
answered.value,
|
|
{
|
|
...execution,
|
|
limitations: [
|
|
`REA resolved ${JSON.stringify(selector)} to ${resolution.name === selector ? "" : `${resolution.name} at `}${resolution.address} (${resolution.match}) and the provider answered by that address.`,
|
|
...execution.limitations,
|
|
],
|
|
},
|
|
);
|
|
return analysis.retainResolvedExecution === undefined
|
|
? ok(resolvedExecution)
|
|
: analysis.retainResolvedExecution(
|
|
operation,
|
|
parameters,
|
|
resolvedExecution,
|
|
options?.snapshotContext === undefined
|
|
? {}
|
|
: { snapshotContext: options.snapshotContext },
|
|
);
|
|
};
|
|
|
|
/**
|
|
* Run one native operation for CLI and MCP alike, resolving a name selector
|
|
* with {@link resolveNativeSymbol} so it means the same symbol in every tool.
|
|
*
|
|
* - `procedure_callers` and incoming `procedure_references` resolve the name
|
|
* first and ask the provider by its address when that address is outside
|
|
* every procedure or a procedure's exact entry. A name the shared owner
|
|
* cannot resolve, or one inside a procedure, goes to the provider's own
|
|
* procedure lookup, which also accepts its alias and thunk spellings.
|
|
* - `xrefs` asks the provider first; a refused name is resolved and asked
|
|
* again by address.
|
|
*
|
|
* The provider's own refusal is kept when resolution adds nothing, so its
|
|
* facts and recovery still reach the caller.
|
|
*/
|
|
export const executeWithNativeSymbolSelection = async (
|
|
analysis: AnalysisOperationPort,
|
|
operation: AnalysisOperation,
|
|
parameters: Readonly<Record<string, JsonValue>>,
|
|
execute: (
|
|
parameters: Readonly<Record<string, JsonValue>>,
|
|
) => Promise<Result<AnalysisExecution, AnalysisError>>,
|
|
options?: NativeSymbolExecutionOptions,
|
|
): Promise<Result<AnalysisExecution, AnalysisError>> => {
|
|
const named = nameSelector(operation, parameters);
|
|
if (named === undefined) return execute(parameters);
|
|
return named.operation === "xrefs"
|
|
? executeXrefs(analysis, parameters, execute, named.selector, options)
|
|
: executeIncoming(analysis, parameters, execute, named, options);
|
|
};
|
|
|
|
const executeIncoming = async (
|
|
analysis: AnalysisOperationPort,
|
|
parameters: Readonly<Record<string, JsonValue>>,
|
|
execute: (
|
|
parameters: Readonly<Record<string, JsonValue>>,
|
|
) => Promise<Result<AnalysisExecution, AnalysisError>>,
|
|
{
|
|
operation,
|
|
selector,
|
|
}: { operation: NativeSymbolOperation; selector: string },
|
|
options: NativeSymbolExecutionOptions | undefined,
|
|
): Promise<Result<AnalysisExecution, AnalysisError>> => {
|
|
if (options?.signal?.aborted)
|
|
return err(cancelledBy(operation, options.signal));
|
|
const cached = analysis.lookupCachedExecution?.(
|
|
operation,
|
|
parameters,
|
|
options?.snapshotContext === undefined
|
|
? {}
|
|
: { snapshotContext: options.snapshotContext },
|
|
);
|
|
if (cached !== undefined) return ok(cached);
|
|
const resolved = await resolveNativeSymbol(
|
|
analysis,
|
|
selector,
|
|
operation,
|
|
options?.signal,
|
|
// The provider's own procedure lookup runs below when the owner misses.
|
|
{
|
|
procedureLookup: false,
|
|
...(options?.snapshotContext === undefined
|
|
? {}
|
|
: { snapshotContext: options.snapshotContext }),
|
|
},
|
|
);
|
|
// Without a name inventory the provider's procedure lookup is the owner.
|
|
if (!resolved.ok)
|
|
return permitsCapabilityFallback(resolved.error)
|
|
? execute(parameters)
|
|
: resolved;
|
|
const resolution = resolved.value;
|
|
if (resolution.status === "resolved") {
|
|
// An address inside a procedure, such as an interior label, would select
|
|
// its containing procedure; the provider decides that name itself.
|
|
const answers = await answersSymbolByAddress(
|
|
analysis,
|
|
resolution.address,
|
|
options,
|
|
);
|
|
if (!answers.ok) return answers;
|
|
if (answers.value)
|
|
return answeredByAddress(
|
|
analysis,
|
|
operation,
|
|
parameters,
|
|
await execute({ ...parameters, procedure: resolution.address }),
|
|
selector,
|
|
resolution,
|
|
options,
|
|
);
|
|
return execute(parameters);
|
|
}
|
|
const provided = await execute(parameters);
|
|
return !provided.ok &&
|
|
resolution.candidates.length > 0 &&
|
|
isLookupMiss(provided.error)
|
|
? err(unresolvedNameError(operation, selector, resolution.candidates))
|
|
: provided;
|
|
};
|
|
|
|
const executeXrefs = async (
|
|
analysis: AnalysisOperationPort,
|
|
parameters: Readonly<Record<string, JsonValue>>,
|
|
execute: (
|
|
parameters: Readonly<Record<string, JsonValue>>,
|
|
) => Promise<Result<AnalysisExecution, AnalysisError>>,
|
|
selector: string,
|
|
options: NativeSymbolExecutionOptions | undefined,
|
|
): Promise<Result<AnalysisExecution, AnalysisError>> => {
|
|
const first = await execute(parameters);
|
|
if (first.ok || !isLookupMiss(first.error)) return first;
|
|
const resolved = await resolveNativeSymbol(
|
|
analysis,
|
|
selector,
|
|
"xrefs",
|
|
options?.signal,
|
|
{
|
|
procedureLookup: true,
|
|
...(options?.snapshotContext === undefined
|
|
? {}
|
|
: { snapshotContext: options.snapshotContext }),
|
|
},
|
|
);
|
|
// Without a name inventory, the provider's own refusal remains the answer.
|
|
if (!resolved.ok)
|
|
return permitsCapabilityFallback(resolved.error) ? first : resolved;
|
|
const resolution = resolved.value;
|
|
// A provider that refused only the address format never looked the name up,
|
|
// so its refusal says nothing about the name; any other refusal stands.
|
|
if (resolution.status === "unresolved")
|
|
return resolution.candidates.length > 0 ||
|
|
refusesAddressFormatOnly(first.error)
|
|
? err(unresolvedNameError("xrefs", selector, resolution.candidates))
|
|
: first;
|
|
if (resolution.address === selector) return first;
|
|
return answeredByAddress(
|
|
analysis,
|
|
"xrefs",
|
|
parameters,
|
|
await execute({ ...parameters, address: resolution.address }),
|
|
selector,
|
|
resolution,
|
|
options,
|
|
);
|
|
};
|