fix(analysis): resolve procedure identities and preserve literal queries

This commit is contained in:
morluto
2026-10-09 02:42:39 +08:00
parent f2e22e13a6
commit d830cb79b3
9 changed files with 117 additions and 116 deletions
+17 -3
View File
@@ -5,6 +5,7 @@ import { parseRelatedAddresses } from "../domain/hopperValues.js";
import type { JsonValue } from "../domain/jsonValue.js";
import { ok, type Result } from "../domain/result.js";
import type { EnhancedResult } from "./EnhancedToolTypes.js";
import { resolveProcedureAddress } from "./ProcedureAddressResolution.js";
type AnalysisCall = (
name: AnalysisOperation,
@@ -61,7 +62,20 @@ export const traceCallPath = async (
input: CallPathTraceInput,
signal?: AbortSignal,
): EnhancedResult => {
const state = createTraceState(input);
const start = await resolveProcedureAddress(call, input.start, signal);
if (!start.ok) return start;
let goal: string | undefined;
if (input.goal !== undefined) {
const resolved = await resolveProcedureAddress(call, input.goal, signal);
if (!resolved.ok) return resolved;
goal = resolved.value;
}
const resolvedInput = {
start: start.value,
...(goal === undefined ? {} : { goal }),
direction: input.direction,
};
const state = createTraceState(resolvedInput);
while (
state.queueIndex < state.queue.length &&
state.traversalPath.length === 0
@@ -71,7 +85,7 @@ export const traceCallPath = async (
const current = state.visited.get(address);
if (current === undefined) continue;
const found = await expandAddress(call, {
input,
input: resolvedInput,
state,
address,
current,
@@ -79,7 +93,7 @@ export const traceCallPath = async (
});
if (found) break;
}
return ok(projectTrace(input, state));
return ok(projectTrace(resolvedInput, state));
};
const createTraceState = (input: CallPathTraceInput): TraceState => ({