fix(native): distinguish batch selectors from resolved entries
This commit is contained in:
@@ -254,20 +254,33 @@ export class EnhancedTools {
|
||||
): EnhancedResult {
|
||||
const items = await Promise.all(
|
||||
addresses.map(async (address) => {
|
||||
const resolved = await resolveProcedureAddress(
|
||||
this.#call.bind(this),
|
||||
address,
|
||||
signal,
|
||||
);
|
||||
const procedure = resolved.ok
|
||||
? await this.#batchProcedureIdentity(resolved.value, signal)
|
||||
: {
|
||||
status: "unknown" as const,
|
||||
error: projectAnalysisError(resolved.error),
|
||||
};
|
||||
const result = await this.#call(
|
||||
"procedure_pseudo_code",
|
||||
{ procedure: address },
|
||||
{ procedure: resolved.ok ? resolved.value : address },
|
||||
signal,
|
||||
);
|
||||
if (!result.ok)
|
||||
return {
|
||||
address,
|
||||
procedure,
|
||||
status: "error" as const,
|
||||
error: projectAnalysisError(result.error),
|
||||
};
|
||||
if (typeof result.value !== "string" || result.value.length === 0)
|
||||
return {
|
||||
address,
|
||||
procedure,
|
||||
status: "error" as const,
|
||||
error: projectAnalysisError(
|
||||
new AnalysisOutputError(
|
||||
@@ -276,7 +289,12 @@ export class EnhancedTools {
|
||||
),
|
||||
),
|
||||
};
|
||||
return { address, status: "ok" as const, pseudocode: result.value };
|
||||
return {
|
||||
address,
|
||||
procedure,
|
||||
status: "ok" as const,
|
||||
pseudocode: result.value,
|
||||
};
|
||||
}),
|
||||
);
|
||||
const succeeded = items.filter(({ status }) => status === "ok").length;
|
||||
@@ -288,6 +306,30 @@ export class EnhancedTools {
|
||||
});
|
||||
}
|
||||
|
||||
async #batchProcedureIdentity(address: string, signal?: AbortSignal) {
|
||||
const observed = await this.#call("address_name", { address }, signal);
|
||||
const named =
|
||||
observed.ok &&
|
||||
(typeof observed.value === "string" || observed.value === null);
|
||||
return {
|
||||
status: "resolved" as const,
|
||||
address,
|
||||
name: named ? observed.value : null,
|
||||
...(named
|
||||
? {}
|
||||
: {
|
||||
name_error: projectAnalysisError(
|
||||
observed.ok
|
||||
? new AnalysisOutputError(
|
||||
"address_name",
|
||||
"provider returned an invalid entry label",
|
||||
)
|
||||
: observed.error,
|
||||
),
|
||||
}),
|
||||
};
|
||||
}
|
||||
|
||||
async #callGraph(
|
||||
input: {
|
||||
readonly address: string;
|
||||
|
||||
@@ -18,7 +18,9 @@ export const workflowAnalysisProfile = (
|
||||
): AnalysisProfileCommitment =>
|
||||
createAnalysisProfile(REA_WORKFLOW_PROVIDER, {
|
||||
upstream_analysis_profile: upstream,
|
||||
...(operation === "binary_overview" ? { workflow_revision: 2 } : {}),
|
||||
...(operation === "binary_overview" || operation === "batch_decompile"
|
||||
? { workflow_revision: 2 }
|
||||
: {}),
|
||||
});
|
||||
|
||||
/** Provider identity for deterministic artifact inventories. */
|
||||
|
||||
@@ -10,7 +10,11 @@ import {
|
||||
committedProviderSchema,
|
||||
} from "../domain/analysisProfile.js";
|
||||
import type { BinaryTarget } from "../domain/binaryTarget.js";
|
||||
import { createEvidence, type Evidence } from "../domain/evidence.js";
|
||||
import {
|
||||
createEvidence,
|
||||
type Evidence,
|
||||
type EvidenceLocation,
|
||||
} from "../domain/evidence.js";
|
||||
import type { JsonValue } from "../domain/jsonValue.js";
|
||||
import type { UnknownRegistryPort } from "./investigation/InvestigationRecordPort.js";
|
||||
import { UnknownRegistryError } from "../domain/unknownRegistryError.js";
|
||||
@@ -37,8 +41,36 @@ export const createWorkflowEvidence = (input: {
|
||||
}),
|
||||
confidence: "derived",
|
||||
limitations: ["Derived by an REA composed workflow."],
|
||||
...(input.operation === "batch_decompile"
|
||||
? { locations: batchProcedureLocations(input.result) }
|
||||
: {}),
|
||||
});
|
||||
|
||||
const batchProcedureLocations = (result: JsonValue): EvidenceLocation[] => {
|
||||
if (
|
||||
result === null ||
|
||||
typeof result !== "object" ||
|
||||
Array.isArray(result) ||
|
||||
!Array.isArray(result.items)
|
||||
)
|
||||
return [];
|
||||
const addresses = new Set<string>();
|
||||
for (const item of result.items) {
|
||||
if (item === null || typeof item !== "object" || Array.isArray(item))
|
||||
continue;
|
||||
const procedure = item.procedure;
|
||||
if (
|
||||
procedure !== null &&
|
||||
typeof procedure === "object" &&
|
||||
!Array.isArray(procedure) &&
|
||||
procedure.status === "resolved" &&
|
||||
typeof procedure.address === "string"
|
||||
)
|
||||
addresses.add(procedure.address);
|
||||
}
|
||||
return [...addresses].map((address) => ({ kind: "address", address }));
|
||||
};
|
||||
|
||||
/** Convert workflow Evidence into its exact replay binding, when it has a profile. */
|
||||
export const workflowSnapshotRecord = (
|
||||
evidence: Evidence,
|
||||
|
||||
Reference in New Issue
Block a user