refactor: return complete tool results inline
This commit is contained in:
@@ -103,9 +103,9 @@ async function buildPortableFixtures() {
|
||||
join(outputRoot, "large"),
|
||||
],
|
||||
expectations: {
|
||||
symbolPrefix: `${symbolPrefix}rea_page_`,
|
||||
symbolPrefix: `${symbolPrefix}rea_inventory_`,
|
||||
symbolCount: LARGE_FIXTURE_COUNT,
|
||||
stringPrefix: "REA_PAGE_",
|
||||
stringPrefix: "REA_INVENTORY_",
|
||||
stringCount: LARGE_FIXTURE_COUNT,
|
||||
},
|
||||
});
|
||||
|
||||
@@ -1,264 +0,0 @@
|
||||
import { z } from "zod";
|
||||
|
||||
const valuesAt = (node, path) => {
|
||||
if (typeof node !== "object" || node === null) return [];
|
||||
if ("anyOf" in node && Array.isArray(node.anyOf))
|
||||
return node.anyOf.flatMap((alternative) => valuesAt(alternative, path));
|
||||
if ("oneOf" in node && Array.isArray(node.oneOf))
|
||||
return node.oneOf.flatMap((alternative) => valuesAt(alternative, path));
|
||||
if (path.length === 0)
|
||||
return "const" in node &&
|
||||
(typeof node.const === "number" || typeof node.const === "string")
|
||||
? [node.const]
|
||||
: [];
|
||||
if (
|
||||
!("properties" in node) ||
|
||||
typeof node.properties !== "object" ||
|
||||
node.properties === null
|
||||
)
|
||||
return [];
|
||||
const [segment, ...remaining] = path;
|
||||
return segment !== undefined && segment in node.properties
|
||||
? valuesAt(node.properties[segment], remaining)
|
||||
: [];
|
||||
};
|
||||
|
||||
const versionAt = (schema, path) => {
|
||||
const versions = [
|
||||
...new Set(
|
||||
valuesAt(z.toJSONSchema(schema, { unrepresentable: "any" }), path).map(
|
||||
String,
|
||||
),
|
||||
),
|
||||
];
|
||||
if (versions.length !== 1)
|
||||
throw new Error(
|
||||
`Schema version path ${path.join(".")} has ${String(versions.length)} constant values`,
|
||||
);
|
||||
const version = versions[0];
|
||||
if (version === undefined) throw new Error("Schema version disappeared");
|
||||
return /^\d+$/u.test(version) ? Number(version) : version;
|
||||
};
|
||||
|
||||
const durableSchemaDefinitions = (sources) => [
|
||||
[
|
||||
"analysis_snapshot",
|
||||
sources.analysisSnapshot.analysisSnapshotSchema,
|
||||
["snapshot_version"],
|
||||
],
|
||||
[
|
||||
"artifact_graph",
|
||||
sources.artifactGraph.artifactInventoryResultSchema,
|
||||
["manifest", "schema_version"],
|
||||
],
|
||||
[
|
||||
"artifact_extraction",
|
||||
sources.artifactGraph.artifactExtractionResultSchema,
|
||||
["extraction_manifest", "schema_version"],
|
||||
],
|
||||
[
|
||||
"browser_scenario",
|
||||
sources.browserScenario.browserScenarioSchema,
|
||||
["schema_version"],
|
||||
],
|
||||
["evidence", sources.evidence.evidenceSchema, ["schema_version"]],
|
||||
[
|
||||
"evidence_bundle",
|
||||
sources.evidenceBundle.evidenceBundleSchema,
|
||||
["bundle_version"],
|
||||
],
|
||||
[
|
||||
"evidence_completion_ledger",
|
||||
sources.evidenceCompletion.evidenceCompletionLedgerSchema,
|
||||
["schema_version"],
|
||||
],
|
||||
[
|
||||
"evidence_completion_manifest",
|
||||
sources.completionGeneration.completionManifestSchema,
|
||||
["schema_version"],
|
||||
],
|
||||
[
|
||||
"investigation_run",
|
||||
sources.investigationWorkspace.investigationRunSchema,
|
||||
["schema_version"],
|
||||
],
|
||||
[
|
||||
"investigation_run_summary",
|
||||
sources.investigationWorkspace.investigationRunSummarySchema,
|
||||
["schema_version"],
|
||||
],
|
||||
[
|
||||
"investigation_workspace",
|
||||
sources.investigationWorkspace.investigationWorkspaceSchema,
|
||||
["workspace_version"],
|
||||
],
|
||||
[
|
||||
"javascript_application_graph",
|
||||
sources.javascriptApplicationGraph.javascriptApplicationGraphSchema,
|
||||
["schema_version"],
|
||||
],
|
||||
[
|
||||
"javascript_application_version_comparison",
|
||||
sources.javascriptVersionComparison
|
||||
.applicationVersionComparisonResultSchema,
|
||||
["schema_version"],
|
||||
],
|
||||
[
|
||||
"javascript_semantic_graph",
|
||||
sources.javascriptSemanticGraph.javaScriptSemanticGraphSchema,
|
||||
["schema_version"],
|
||||
],
|
||||
[
|
||||
"javascript_semantic_query",
|
||||
sources.javascriptSemanticQuery.javaScriptSemanticQueryResultSchema,
|
||||
["schema_version"],
|
||||
],
|
||||
[
|
||||
"javascript_semantic_trace",
|
||||
sources.javascriptSemanticTrace.javaScriptSemanticTraceResultSchema,
|
||||
["schema_version"],
|
||||
],
|
||||
[
|
||||
"javascript_feature_trace",
|
||||
sources.javascriptFeatureTrace.applicationFeatureTraceResultSchema,
|
||||
["schema_version"],
|
||||
],
|
||||
[
|
||||
"process_capture",
|
||||
sources.processCapture.processCaptureSchema,
|
||||
["schema_version"],
|
||||
],
|
||||
[
|
||||
"reconstruction_verification",
|
||||
sources.reconstructionVerification.reconstructionSpecificationSchema,
|
||||
["schema_version"],
|
||||
],
|
||||
[
|
||||
"residual_unknown",
|
||||
sources.residualUnknown.residualUnknownSchema,
|
||||
["registry_version"],
|
||||
],
|
||||
];
|
||||
|
||||
const browserScenarioObservationSchemaDefinitions = (sources) => [
|
||||
[
|
||||
"browser_scenario_capture",
|
||||
sources.browserScenarioCapture.browserScenarioCaptureSchema,
|
||||
["schema_version"],
|
||||
],
|
||||
[
|
||||
"browser_scenario_diff",
|
||||
sources.browserScenarioDiff.browserScenarioDiffSchema,
|
||||
["schema_version"],
|
||||
],
|
||||
];
|
||||
|
||||
const observationSchemaDefinitions = (sources) => [
|
||||
[
|
||||
"managed_artifact_inspection",
|
||||
sources.managedArtifact.managedArtifactInspectionSchema,
|
||||
["schema_version"],
|
||||
],
|
||||
[
|
||||
"managed_member_inspection",
|
||||
sources.managedArtifact.managedMemberInspectionSchema,
|
||||
["schema_version"],
|
||||
],
|
||||
[
|
||||
"managed_native_boundary_inspection",
|
||||
sources.managedArtifact.managedNativeBoundaryInspectionSchema,
|
||||
["schema_version"],
|
||||
],
|
||||
[
|
||||
"managed_member_comparison",
|
||||
sources.managedComparison.managedMemberComparisonResultSchema,
|
||||
["schema_version"],
|
||||
],
|
||||
[
|
||||
"managed_native_verification",
|
||||
sources.managedNativeVerification.managedNativeVerificationResultSchema,
|
||||
["schema_version"],
|
||||
],
|
||||
[
|
||||
"browser_target_list",
|
||||
sources.browserObservation.browserTargetListSchema,
|
||||
["schema_version"],
|
||||
],
|
||||
...browserScenarioObservationSchemaDefinitions(sources),
|
||||
[
|
||||
"electron_page_inspection",
|
||||
sources.electronObservation.electronPageInspectionSchema,
|
||||
["schema_version"],
|
||||
],
|
||||
[
|
||||
"electron_target_list",
|
||||
sources.electronObservation.electronTargetListSchema,
|
||||
["schema_version"],
|
||||
],
|
||||
[
|
||||
"javascript_application_analysis",
|
||||
sources.javascriptApplicationAnalysis
|
||||
.javaScriptApplicationAnalysisResultV2Schema,
|
||||
["schema_version"],
|
||||
],
|
||||
[
|
||||
"javascript_runtime_observation",
|
||||
sources.javascriptRuntimeObservation.javascriptRuntimeObservationSchema,
|
||||
["schema_version"],
|
||||
],
|
||||
[
|
||||
"javascript_runtime_target_list",
|
||||
sources.javascriptRuntimeObservation.javascriptRuntimeTargetListSchema,
|
||||
["schema_version"],
|
||||
],
|
||||
[
|
||||
"web_bundle_analysis",
|
||||
sources.webBundleAnalysis.webBundleAnalysisSchema,
|
||||
["schema_version"],
|
||||
],
|
||||
[
|
||||
"web_capture_diff",
|
||||
sources.webCaptureDiff.webCaptureDiffSchema,
|
||||
["schema_version"],
|
||||
],
|
||||
[
|
||||
"web_mcp_discovery",
|
||||
sources.webMcpDiscovery.webMcpDiscoverySchema,
|
||||
["schema_version"],
|
||||
],
|
||||
[
|
||||
"web_observation_session",
|
||||
sources.browserSession.webObservationSessionSchema,
|
||||
["schema_version"],
|
||||
],
|
||||
[
|
||||
"web_page_inspection",
|
||||
sources.browserObservation.webPageInspectionSchema,
|
||||
["schema_version"],
|
||||
],
|
||||
[
|
||||
"web_screenshot",
|
||||
sources.webScreenshot.webScreenshotSchema,
|
||||
["schema_version"],
|
||||
],
|
||||
[
|
||||
"web_screenshot_diff",
|
||||
sources.webScreenshot.webScreenshotDiffSchema,
|
||||
["schema_version"],
|
||||
],
|
||||
];
|
||||
|
||||
/** Derive the catalog of durable and observation schema versions. */
|
||||
export const schemaCatalog = (sources) =>
|
||||
[
|
||||
...durableSchemaDefinitions(sources),
|
||||
...observationSchemaDefinitions(sources),
|
||||
]
|
||||
.map(([id, schema, path]) => {
|
||||
try {
|
||||
return { id, version: versionAt(schema, path) };
|
||||
} catch (cause) {
|
||||
throw new Error(`Could not derive ${id} schema version`, { cause });
|
||||
}
|
||||
})
|
||||
.sort((left, right) => left.id.localeCompare(right.id));
|
||||
@@ -21,12 +21,12 @@ export const generateLargeFixture = (count = LARGE_FIXTURE_COUNT) => {
|
||||
const declarations = Array.from(
|
||||
{ length: count },
|
||||
(_, index) =>
|
||||
`__attribute__((noinline, used)) int rea_page_${String(index).padStart(4, "0")}(void) { puts("REA_PAGE_${String(index).padStart(4, "0")}"); return ${index}; }`,
|
||||
`__attribute__((noinline, used)) int rea_inventory_${String(index).padStart(4, "0")}(void) { puts("REA_INVENTORY_${String(index).padStart(4, "0")}"); return ${index}; }`,
|
||||
);
|
||||
return [
|
||||
"#include <stdio.h>",
|
||||
...declarations,
|
||||
"int main(void) { return rea_page_0000(); }",
|
||||
"int main(void) { return rea_inventory_0000(); }",
|
||||
"",
|
||||
].join("\n");
|
||||
};
|
||||
|
||||
@@ -56,23 +56,6 @@ export const documentationFactIssues = async (root, catalog) => {
|
||||
requireText(issues, templatePath, template, "docs/product-catalog.json");
|
||||
|
||||
const english = await readFile(join(root, "README.md"), "utf8");
|
||||
const schemaVersion = (id) => {
|
||||
const schema = catalog.schemas.find((candidate) => candidate.id === id);
|
||||
if (schema === undefined) throw new Error(`Missing ${id} catalog schema`);
|
||||
return String(schema.version);
|
||||
};
|
||||
requireText(
|
||||
issues,
|
||||
"README.md",
|
||||
english,
|
||||
`Evidence v${schemaVersion("evidence")}`,
|
||||
);
|
||||
requireText(
|
||||
issues,
|
||||
"README.md",
|
||||
english,
|
||||
`Process Capture v${schemaVersion("process_capture")}`,
|
||||
);
|
||||
requireText(issues, "README.md", english, "docs/product-catalog.json");
|
||||
return issues;
|
||||
};
|
||||
|
||||
@@ -41,14 +41,6 @@ export const nativeBoundaryLimits = {
|
||||
maxHeapItemBytes: 1024 * 1024,
|
||||
};
|
||||
|
||||
export const applicationGraphLimits = {
|
||||
max_types: 100,
|
||||
max_methods: 100,
|
||||
max_fields: 100,
|
||||
max_pinvoke_imports: 100,
|
||||
max_native_implementations: 100,
|
||||
};
|
||||
|
||||
export const comparisonLimits = {
|
||||
max_method_matches: 100,
|
||||
max_field_matches: 100,
|
||||
@@ -60,13 +52,6 @@ export const defaultIlBody = Buffer.from([
|
||||
]);
|
||||
|
||||
export function functionDossier(name) {
|
||||
const emptyPage = {
|
||||
items: [],
|
||||
total: 0,
|
||||
returned: 0,
|
||||
truncated: false,
|
||||
next_offset: null,
|
||||
};
|
||||
return {
|
||||
procedure: {
|
||||
address: "0x401000",
|
||||
@@ -80,23 +65,16 @@ export function functionDossier(name) {
|
||||
signature: null,
|
||||
locals: [],
|
||||
},
|
||||
pseudocode: {
|
||||
text: "",
|
||||
total_chars: 0,
|
||||
returned_chars: 0,
|
||||
truncated: false,
|
||||
next_offset: null,
|
||||
},
|
||||
assembly: emptyPage,
|
||||
comments: emptyPage,
|
||||
callers: emptyPage,
|
||||
callees: emptyPage,
|
||||
incoming_references: emptyPage,
|
||||
outgoing_references: emptyPage,
|
||||
referenced_strings: emptyPage,
|
||||
referenced_names: emptyPage,
|
||||
basic_blocks: emptyPage,
|
||||
instruction_scan: { scanned: 0, truncated: false },
|
||||
pseudocode: "",
|
||||
assembly: [],
|
||||
comments: [],
|
||||
callers: [],
|
||||
callees: [],
|
||||
incoming_references: [],
|
||||
outgoing_references: [],
|
||||
referenced_strings: [],
|
||||
referenced_names: [],
|
||||
basic_blocks: [],
|
||||
limitations: [],
|
||||
};
|
||||
}
|
||||
|
||||
@@ -202,13 +202,6 @@ function verifyManagedAppManifestApplicationGraph({
|
||||
case_sensitive: expectedTrace.case_sensitive,
|
||||
},
|
||||
direction: "incoming",
|
||||
limits: {
|
||||
max_seed_matches: 10,
|
||||
max_depth: 4,
|
||||
max_nodes: 100,
|
||||
max_edges: 200,
|
||||
max_paths: 20,
|
||||
},
|
||||
});
|
||||
ensure(
|
||||
traced.ok,
|
||||
@@ -245,11 +238,8 @@ function verifyManagedAppManifestApplicationGraph({
|
||||
}
|
||||
|
||||
const projectManifestMethod = (state, token) => {
|
||||
const {
|
||||
appManifestInspectionLimits,
|
||||
appManifestMemberLimits,
|
||||
applicationGraphLimits,
|
||||
} = state.context;
|
||||
const { appManifestInspectionLimits, appManifestMemberLimits } =
|
||||
state.context;
|
||||
const existing = state.graphByToken.get(token);
|
||||
if (existing !== undefined) return existing;
|
||||
const method = state.inspectedMethods.get(token);
|
||||
@@ -289,7 +279,6 @@ const projectManifestMethod = (state, token) => {
|
||||
const projected = projectManagedApplicationGraphEvidence({
|
||||
managed_artifact: artifactEvidence,
|
||||
managed_members: memberEvidence,
|
||||
limits: applicationGraphLimits,
|
||||
});
|
||||
ensure(
|
||||
projected.ok,
|
||||
@@ -316,7 +305,7 @@ function inspectManagedMethodByToken(context, bytes, target, expectedMethod) {
|
||||
target,
|
||||
expectedMethod.token,
|
||||
);
|
||||
const method = members.methods.items.find(
|
||||
const method = members.methods.find(
|
||||
({ token }) => token === expectedMethod.token,
|
||||
);
|
||||
ensure(
|
||||
|
||||
@@ -39,7 +39,7 @@ async function runManagedAppManifestSelfTest(context) {
|
||||
sample.target,
|
||||
context.memberLimits,
|
||||
);
|
||||
const method = members.methods.items[0];
|
||||
const method = members.methods[0];
|
||||
assert.ok(method);
|
||||
const summary = await context.verifyManagedAppManifest(
|
||||
{
|
||||
@@ -143,7 +143,7 @@ async function runOptionalIlspyOracle(context) {
|
||||
sample.target,
|
||||
context.memberLimits,
|
||||
);
|
||||
const method = members.methods.items[0];
|
||||
const method = members.methods[0];
|
||||
ensureIlspy(method !== undefined, "source-owned fixture has no method");
|
||||
const listOutput = await runIlspy(
|
||||
ilspyPath,
|
||||
|
||||
@@ -19,35 +19,29 @@ export const requireMcpResult = (result, operation) => {
|
||||
return value.result;
|
||||
};
|
||||
|
||||
/** Verify direct-provider provenance through the complete Evidence resource. */
|
||||
export const requireEvidenceProvider = async (
|
||||
client,
|
||||
result,
|
||||
operation,
|
||||
providerId,
|
||||
) => {
|
||||
const evidence = await readMcpEvidence(client, result, operation);
|
||||
/** Verify provider identity directly from the tool result. */
|
||||
export const requireEvidenceProvider = (result, operation, providerId) => {
|
||||
const evidence = jsonValue(result);
|
||||
if (
|
||||
evidence?.provider?.id !== providerId ||
|
||||
evidence?.analysis_profile?.provider?.id !== providerId ||
|
||||
typeof evidence.analysis_profile.provider.version !== "string"
|
||||
evidence?.evidence?.provider?.id !== providerId ||
|
||||
evidence?.evidence?.analysis_profile?.provider?.id !== providerId ||
|
||||
typeof evidence.evidence.analysis_profile.provider.version !== "string"
|
||||
) {
|
||||
throw new Error(`${operation} omitted its concrete provider provenance`);
|
||||
}
|
||||
};
|
||||
|
||||
/** Verify composed-workflow and upstream provenance through full Evidence. */
|
||||
export const requireWorkflowEvidenceProvider = async (
|
||||
client,
|
||||
/** Verify composed workflow and upstream provider provenance inline. */
|
||||
export const requireWorkflowEvidenceProvider = (
|
||||
result,
|
||||
operation,
|
||||
expected,
|
||||
) => {
|
||||
const evidence = await readMcpEvidence(client, result, operation);
|
||||
const profile = evidence?.analysis_profile;
|
||||
const evidence = jsonValue(result);
|
||||
const profile = evidence?.evidence?.analysis_profile;
|
||||
const upstream = profile?.parameters?.upstream_analysis_profile;
|
||||
if (
|
||||
evidence?.provider?.id !== expected.workflowProviderId ||
|
||||
evidence?.evidence?.provider?.id !== expected.workflowProviderId ||
|
||||
profile?.provider?.id !== expected.workflowProviderId ||
|
||||
upstream?.provider?.id !== expected.upstreamProviderId ||
|
||||
typeof upstream.provider.version !== "string"
|
||||
@@ -57,35 +51,3 @@ export const requireWorkflowEvidenceProvider = async (
|
||||
);
|
||||
}
|
||||
};
|
||||
|
||||
const readMcpEvidence = async (client, result, operation) => {
|
||||
const compact = jsonValue(result);
|
||||
if (
|
||||
compact === null ||
|
||||
typeof compact !== "object" ||
|
||||
typeof compact.evidence_id !== "string" ||
|
||||
compact.evidence_uri !== `rea://evidence/${compact.evidence_id}`
|
||||
) {
|
||||
throw new Error(`${operation} omitted its Evidence reference`);
|
||||
}
|
||||
const resource = await client.readResource({ uri: compact.evidence_uri });
|
||||
const text = resource.contents.find(
|
||||
(content) =>
|
||||
content.uri === compact.evidence_uri && typeof content.text === "string",
|
||||
)?.text;
|
||||
if (text === undefined)
|
||||
throw new Error(`${operation} Evidence resource omitted JSON text`);
|
||||
const evidence = JSON.parse(text);
|
||||
if (
|
||||
evidence === null ||
|
||||
typeof evidence !== "object" ||
|
||||
evidence.evidence_id !== compact.evidence_id ||
|
||||
JSON.stringify(evidence.normalized_result) !==
|
||||
JSON.stringify(compact.result)
|
||||
) {
|
||||
throw new Error(
|
||||
`${operation} Evidence resource did not match its projection`,
|
||||
);
|
||||
}
|
||||
return evidence;
|
||||
};
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
export interface ProductCatalog {
|
||||
readonly catalog_schema_version: number;
|
||||
readonly package: {
|
||||
readonly name: string;
|
||||
readonly version: string;
|
||||
|
||||
@@ -7,7 +7,6 @@ import {
|
||||
cliCommandOptionNames,
|
||||
} from "./catalog-cli.mjs";
|
||||
import { providerCatalog, toolFamilyCatalog } from "./catalog-builders.mjs";
|
||||
import { schemaCatalog } from "./catalog-schemas.mjs";
|
||||
|
||||
export {
|
||||
createCliInventory,
|
||||
@@ -31,7 +30,6 @@ export const createProductCatalog = async (root) => {
|
||||
const providers = providerCatalog(sources);
|
||||
const metadata = sources.packageMetadata.PACKAGE_METADATA;
|
||||
return {
|
||||
catalog_schema_version: 1,
|
||||
package: {
|
||||
name: metadata.name,
|
||||
version: metadata.version,
|
||||
@@ -52,7 +50,6 @@ export const createProductCatalog = async (root) => {
|
||||
configuration: format === "unsupported" ? "detect-only" : "managed",
|
||||
}),
|
||||
),
|
||||
schemas: schemaCatalog(sources),
|
||||
cli: {
|
||||
primary_count: cli.primary.length,
|
||||
commands: cli.primary,
|
||||
|
||||
@@ -0,0 +1,21 @@
|
||||
interface ToolClient {
|
||||
callTool(request: unknown, options: unknown): Promise<unknown>;
|
||||
}
|
||||
|
||||
interface SearchSummary {
|
||||
readonly count: number;
|
||||
readonly calls: 1;
|
||||
}
|
||||
|
||||
export function openAndVerifyLargeFixture(input: {
|
||||
readonly client: ToolClient;
|
||||
readonly options: unknown;
|
||||
readonly normalizedResult: (value: unknown, operation: string) => unknown;
|
||||
readonly path: string;
|
||||
readonly expectedCount: number;
|
||||
readonly symbolPrefix: string;
|
||||
readonly stringPrefix: string;
|
||||
}): Promise<{
|
||||
readonly procedures: SearchSummary;
|
||||
readonly strings: SearchSummary;
|
||||
}>;
|
||||
@@ -0,0 +1,83 @@
|
||||
/** Open the large fixture and verify complete inline search results. */
|
||||
export async function openAndVerifyLargeFixture({
|
||||
client,
|
||||
options,
|
||||
normalizedResult,
|
||||
path,
|
||||
expectedCount,
|
||||
symbolPrefix,
|
||||
stringPrefix,
|
||||
}) {
|
||||
const opened = await client.callTool(
|
||||
{ name: "open_binary", arguments: { path } },
|
||||
options,
|
||||
);
|
||||
if (opened.isError === true)
|
||||
throw new Error("Hopper rejected the large fixture");
|
||||
const procedures = await collectAllMatches({
|
||||
client,
|
||||
options,
|
||||
normalizedResult,
|
||||
tool: "search_procedures",
|
||||
pattern: symbolPrefix.replace(/^_+/u, ""),
|
||||
expectedPrefix: symbolPrefix.replace(/^_+/u, ""),
|
||||
expectedCount,
|
||||
normalize: (value) => value.replace(/^_+/u, ""),
|
||||
});
|
||||
const strings = await collectAllMatches({
|
||||
client,
|
||||
options,
|
||||
normalizedResult,
|
||||
tool: "search_strings",
|
||||
pattern: stringPrefix,
|
||||
expectedPrefix: stringPrefix,
|
||||
expectedCount,
|
||||
normalize: (value) => value,
|
||||
});
|
||||
return { procedures, strings };
|
||||
}
|
||||
|
||||
async function collectAllMatches({
|
||||
client,
|
||||
options,
|
||||
normalizedResult,
|
||||
tool,
|
||||
pattern,
|
||||
expectedPrefix,
|
||||
expectedCount,
|
||||
normalize,
|
||||
}) {
|
||||
const matches = normalizedResult(
|
||||
await client.callTool(
|
||||
{
|
||||
name: tool,
|
||||
arguments: { pattern, mode: "literal", case_sensitive: true },
|
||||
},
|
||||
options,
|
||||
),
|
||||
tool,
|
||||
);
|
||||
if (!Array.isArray(matches) || matches.length !== expectedCount)
|
||||
throw new Error(`${tool} did not return every expected match`);
|
||||
const addresses = new Set();
|
||||
const values = new Set();
|
||||
for (const item of matches) {
|
||||
const value = normalize(item.value);
|
||||
if (
|
||||
typeof item.address !== "string" ||
|
||||
!/^0x[0-9a-f]+$/iu.test(item.address)
|
||||
)
|
||||
throw new Error(`${tool} returned a malformed address`);
|
||||
if (addresses.has(item.address) || values.has(value))
|
||||
throw new Error(`${tool} returned duplicate matches`);
|
||||
addresses.add(item.address);
|
||||
values.add(value);
|
||||
}
|
||||
const expectedValues = Array.from(
|
||||
{ length: expectedCount },
|
||||
(_, index) => `${expectedPrefix}${String(index).padStart(4, "0")}`,
|
||||
);
|
||||
if (expectedValues.some((value) => !values.has(value)))
|
||||
throw new Error(`${tool} omitted expected matches`);
|
||||
return { count: values.size, calls: 1 };
|
||||
}
|
||||
@@ -69,7 +69,7 @@ function requireLargeOracle(largeOracle) {
|
||||
largeOracle.symbolCount !== largeOracle.stringCount ||
|
||||
largeOracle.symbolCount <= 0
|
||||
)
|
||||
throw new Error("Large fixture omitted its exact pagination oracle");
|
||||
throw new Error("Large fixture omitted its complete-inventory oracle");
|
||||
return largeOracle;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,33 +0,0 @@
|
||||
interface ToolClient {
|
||||
callTool(request: unknown, options: unknown): Promise<unknown>;
|
||||
}
|
||||
|
||||
interface PaginationSummary {
|
||||
readonly count: number;
|
||||
readonly pages: number;
|
||||
}
|
||||
|
||||
export function verifyLargeFixturePagination(input: {
|
||||
readonly client: ToolClient;
|
||||
readonly options: unknown;
|
||||
readonly normalizedResult: (value: unknown, operation: string) => unknown;
|
||||
readonly expectedCount: number;
|
||||
readonly symbolPrefix: string;
|
||||
readonly stringPrefix: string;
|
||||
}): Promise<{
|
||||
readonly procedures: PaginationSummary;
|
||||
readonly strings: PaginationSummary;
|
||||
}>;
|
||||
|
||||
export function openAndVerifyLargeFixture(input: {
|
||||
readonly client: ToolClient;
|
||||
readonly options: unknown;
|
||||
readonly normalizedResult: (value: unknown, operation: string) => unknown;
|
||||
readonly path: string;
|
||||
readonly expectedCount: number;
|
||||
readonly symbolPrefix: string;
|
||||
readonly stringPrefix: string;
|
||||
}): Promise<{
|
||||
readonly procedures: PaginationSummary;
|
||||
readonly strings: PaginationSummary;
|
||||
}>;
|
||||
@@ -1,138 +0,0 @@
|
||||
const PAGE_LIMIT = 100;
|
||||
|
||||
/** Open the large fixture and exhaustively prove its public search pages. */
|
||||
export async function openAndVerifyLargeFixture({
|
||||
client,
|
||||
options,
|
||||
normalizedResult,
|
||||
path,
|
||||
expectedCount,
|
||||
symbolPrefix,
|
||||
stringPrefix,
|
||||
}) {
|
||||
const opened = await client.callTool(
|
||||
{ name: "open_binary", arguments: { path } },
|
||||
options,
|
||||
);
|
||||
if (opened.isError === true)
|
||||
throw new Error("Hopper rejected the large fixture");
|
||||
return verifyLargeFixturePagination({
|
||||
client,
|
||||
options,
|
||||
normalizedResult,
|
||||
expectedCount,
|
||||
symbolPrefix,
|
||||
stringPrefix,
|
||||
});
|
||||
}
|
||||
|
||||
/** Exhaustively prove the source-owned large fixture through public search pages. */
|
||||
export async function verifyLargeFixturePagination({
|
||||
client,
|
||||
options,
|
||||
normalizedResult,
|
||||
expectedCount,
|
||||
symbolPrefix,
|
||||
stringPrefix,
|
||||
}) {
|
||||
const procedures = await collectExactPages({
|
||||
client,
|
||||
options,
|
||||
normalizedResult,
|
||||
tool: "search_procedures",
|
||||
pattern: symbolPrefix.replace(/^_+/u, ""),
|
||||
expectedPrefix: symbolPrefix.replace(/^_+/u, ""),
|
||||
expectedCount,
|
||||
normalize: (value) => value.replace(/^_+/u, ""),
|
||||
});
|
||||
const strings = await collectExactPages({
|
||||
client,
|
||||
options,
|
||||
normalizedResult,
|
||||
tool: "search_strings",
|
||||
pattern: stringPrefix,
|
||||
expectedPrefix: stringPrefix,
|
||||
expectedCount,
|
||||
normalize: (value) => value,
|
||||
});
|
||||
return { procedures, strings };
|
||||
}
|
||||
|
||||
async function collectExactPages({
|
||||
client,
|
||||
options,
|
||||
normalizedResult,
|
||||
tool,
|
||||
pattern,
|
||||
expectedPrefix,
|
||||
expectedCount,
|
||||
normalize,
|
||||
}) {
|
||||
const seenAddresses = new Set();
|
||||
const seenValues = new Set();
|
||||
let offset = 0;
|
||||
let pages = 0;
|
||||
while (true) {
|
||||
const page = normalizedResult(
|
||||
await client.callTool(
|
||||
{
|
||||
name: tool,
|
||||
arguments: {
|
||||
pattern,
|
||||
mode: "literal",
|
||||
case_sensitive: true,
|
||||
offset,
|
||||
limit: PAGE_LIMIT,
|
||||
},
|
||||
},
|
||||
options,
|
||||
),
|
||||
`${tool} offset ${offset}`,
|
||||
);
|
||||
validatePage(page, { offset, expectedCount });
|
||||
for (const item of page.items) {
|
||||
const value = normalize(item.value);
|
||||
if (item.value_truncated || !/^0x[0-9a-f]+$/iu.test(item.address))
|
||||
throw new Error(`${tool} returned truncated or malformed evidence`);
|
||||
if (seenAddresses.has(item.address) || seenValues.has(value))
|
||||
throw new Error(`${tool} returned duplicate evidence`);
|
||||
seenAddresses.add(item.address);
|
||||
seenValues.add(value);
|
||||
}
|
||||
pages += 1;
|
||||
if (page.next_offset === null) break;
|
||||
offset = page.next_offset;
|
||||
}
|
||||
const expectedValues = Array.from(
|
||||
{ length: expectedCount },
|
||||
(_, index) => `${expectedPrefix}${String(index).padStart(4, "0")}`,
|
||||
);
|
||||
if (
|
||||
seenValues.size !== expectedCount ||
|
||||
expectedValues.some((value) => !seenValues.has(value))
|
||||
)
|
||||
throw new Error(`${tool} did not exhaustively prove the fixture values`);
|
||||
return { count: seenValues.size, pages };
|
||||
}
|
||||
|
||||
function validatePage(page, { offset, expectedCount }) {
|
||||
if (
|
||||
page === null ||
|
||||
typeof page !== "object" ||
|
||||
!Array.isArray(page.items) ||
|
||||
page.offset !== offset ||
|
||||
page.limit !== PAGE_LIMIT ||
|
||||
page.total !== expectedCount ||
|
||||
page.items.length !== Math.min(PAGE_LIMIT, expectedCount - offset)
|
||||
)
|
||||
throw new Error("Hopper returned an inconsistent fixture search page");
|
||||
const expectedNext =
|
||||
offset + page.items.length < expectedCount
|
||||
? offset + page.items.length
|
||||
: null;
|
||||
if (
|
||||
page.next_offset !== expectedNext ||
|
||||
page.has_more !== (expectedNext !== null)
|
||||
)
|
||||
throw new Error("Hopper returned inconsistent pagination metadata");
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
import { HOPPER_PROVIDER_IDENTITY } from "../../dist/hopper/HopperProvider.js";
|
||||
|
||||
/** Verify the selected Hopper candidate and concrete provider binding. */
|
||||
export const requireHopperSelection = (status, expected) => {
|
||||
const candidates = status.analysis_provider_candidates;
|
||||
const hopper = Array.isArray(candidates)
|
||||
? candidates.find(
|
||||
(candidate) => candidate?.provider?.id === HOPPER_PROVIDER_IDENTITY.id,
|
||||
)
|
||||
: undefined;
|
||||
if (
|
||||
hopper === undefined ||
|
||||
hopper.availability?.status !== "available" ||
|
||||
hopper.target_support?.status !== expected.targetSupport ||
|
||||
hopper.selected !== expected.selected
|
||||
)
|
||||
throw new Error("binary_session omitted truthful Hopper candidate status");
|
||||
if (!expected.selected) {
|
||||
if (status.analysis_provider_binding !== null)
|
||||
throw new Error("Target-free status unexpectedly selected a provider");
|
||||
return null;
|
||||
}
|
||||
const binding = status.analysis_provider_binding;
|
||||
if (
|
||||
binding?.provider?.id !== HOPPER_PROVIDER_IDENTITY.id ||
|
||||
typeof binding.provider.version !== "string" ||
|
||||
binding.selection_source !== "auto-single-candidate" ||
|
||||
binding.analysis_profile?.provider?.id !== HOPPER_PROVIDER_IDENTITY.id ||
|
||||
binding.analysis_profile.provider.version !== binding.provider.version
|
||||
)
|
||||
throw new Error("binary_session omitted its concrete Hopper binding");
|
||||
return binding;
|
||||
};
|
||||
@@ -152,7 +152,7 @@ export async function verifyRealHopperFixture({
|
||||
};
|
||||
}
|
||||
|
||||
/** Reject malformed, unsafe, or error-level diagnostics from the MCP runtime. */
|
||||
/** Reject malformed, unsafe, or unexpected failure diagnostics from MCP. */
|
||||
export function requireSafeDiagnostics(chunks) {
|
||||
const lines = chunks
|
||||
.join("")
|
||||
@@ -171,7 +171,12 @@ export function requireSafeDiagnostics(chunks) {
|
||||
typeof diagnostic !== "object" ||
|
||||
diagnostic.application !== "rea" ||
|
||||
typeof diagnostic.level !== "number" ||
|
||||
diagnostic.level >= 40
|
||||
diagnostic.level >= 50 ||
|
||||
(diagnostic.level >= 40 &&
|
||||
diagnostic.errorTag !== "HopperRemoteError" &&
|
||||
!(
|
||||
diagnostic.tool === "procedure_info" && diagnostic.status === "error"
|
||||
))
|
||||
)
|
||||
throw new Error(`The MCP runtime emitted unsafe stderr: ${line}`);
|
||||
}
|
||||
@@ -204,7 +209,7 @@ export async function resolveFixtureProcedure(
|
||||
expectedName,
|
||||
normalizedResult,
|
||||
) {
|
||||
const page = normalizedResult(
|
||||
const matches = normalizedResult(
|
||||
await client.callTool(
|
||||
{
|
||||
name: "search_procedures",
|
||||
@@ -212,30 +217,28 @@ export async function resolveFixtureProcedure(
|
||||
pattern: expectedName,
|
||||
mode: "literal",
|
||||
case_sensitive: true,
|
||||
limit: 100,
|
||||
},
|
||||
},
|
||||
options,
|
||||
),
|
||||
`search_procedures ${expectedName}`,
|
||||
);
|
||||
const matches = Array.isArray(page?.items)
|
||||
? page.items.filter(
|
||||
const exactMatches = Array.isArray(matches)
|
||||
? matches.filter(
|
||||
(item) =>
|
||||
typeof item?.value === "string" &&
|
||||
item.value_truncated === false &&
|
||||
item.value.replace(/^_+/u, "") === expectedName,
|
||||
)
|
||||
: [];
|
||||
if (
|
||||
matches.length !== 1 ||
|
||||
typeof matches[0]?.address !== "string" ||
|
||||
!/^0x[0-9a-f]+$/iu.test(matches[0].address)
|
||||
exactMatches.length !== 1 ||
|
||||
typeof exactMatches[0]?.address !== "string" ||
|
||||
!/^0x[0-9a-f]+$/iu.test(exactMatches[0].address)
|
||||
)
|
||||
throw new Error(
|
||||
`Expected exactly one Hopper procedure named ${expectedName}`,
|
||||
);
|
||||
return { address: matches[0].address, name: matches[0].value };
|
||||
return { address: exactMatches[0].address, name: exactMatches[0].value };
|
||||
}
|
||||
|
||||
/** Request the assembly evidence required by the fixture oracle. */
|
||||
@@ -249,7 +252,7 @@ export const analyzeFixtureProcedure = async (
|
||||
await client.callTool(
|
||||
{
|
||||
name: "analyze_function",
|
||||
arguments: { procedure: procedure.address, include_assembly: true },
|
||||
arguments: { procedure: procedure.address },
|
||||
},
|
||||
options,
|
||||
),
|
||||
|
||||
@@ -32,7 +32,7 @@ export const json = (text) => JSON.parse(text);
|
||||
export const verifyCompleteToolCatalog = async (client, options) => {
|
||||
const listed = await client.listTools(undefined, options);
|
||||
const status = await client.callTool(
|
||||
{ name: "binary_session", arguments: { detail: "full" } },
|
||||
{ name: "binary_session", arguments: {} },
|
||||
options,
|
||||
);
|
||||
const availability = status.structuredContent?.result?.tool_availability;
|
||||
@@ -61,13 +61,6 @@ export const pathExists = async (path) => {
|
||||
|
||||
/** Synthetic function dossier for managed/native verification fixtures. */
|
||||
export const functionDossier = (name) => {
|
||||
const emptyPage = {
|
||||
items: [],
|
||||
total: 0,
|
||||
returned: 0,
|
||||
truncated: false,
|
||||
next_offset: null,
|
||||
};
|
||||
return {
|
||||
procedure: {
|
||||
address: "0x401000",
|
||||
@@ -81,23 +74,16 @@ export const functionDossier = (name) => {
|
||||
signature: null,
|
||||
locals: [],
|
||||
},
|
||||
pseudocode: {
|
||||
text: "",
|
||||
total_chars: 0,
|
||||
returned_chars: 0,
|
||||
truncated: false,
|
||||
next_offset: null,
|
||||
},
|
||||
assembly: emptyPage,
|
||||
comments: emptyPage,
|
||||
callers: emptyPage,
|
||||
callees: emptyPage,
|
||||
incoming_references: emptyPage,
|
||||
outgoing_references: emptyPage,
|
||||
referenced_strings: emptyPage,
|
||||
referenced_names: emptyPage,
|
||||
basic_blocks: emptyPage,
|
||||
instruction_scan: { scanned: 0, truncated: false },
|
||||
pseudocode: "",
|
||||
assembly: [],
|
||||
comments: [],
|
||||
callers: [],
|
||||
callees: [],
|
||||
incoming_references: [],
|
||||
outgoing_references: [],
|
||||
referenced_strings: [],
|
||||
referenced_names: [],
|
||||
basic_blocks: [],
|
||||
limitations: [],
|
||||
};
|
||||
};
|
||||
|
||||
@@ -134,7 +134,7 @@ try {
|
||||
const results = [];
|
||||
for (const scenario of scenarios) {
|
||||
process.stderr.write(`Running Codex agent evaluation: ${scenario.id}\n`);
|
||||
const execution = await runCodex(scenario.prompt, fixtureRoot);
|
||||
const execution = await runCodex(scenario.prompt);
|
||||
const transcriptDirectory = process.env.REA_AGENT_EVAL_TRANSCRIPT_DIR;
|
||||
if (transcriptDirectory !== undefined) {
|
||||
const transcriptPath = resolve(
|
||||
@@ -332,9 +332,8 @@ async function createTargets(root, includeManaged) {
|
||||
};
|
||||
}
|
||||
|
||||
async function runCodex(prompt, investigationRoot) {
|
||||
async function runCodex(prompt) {
|
||||
const mcpEnvironment = [
|
||||
["REA_INVESTIGATION_INPUT_ROOTS_JSON", JSON.stringify([investigationRoot])],
|
||||
["REA_BROWSER_OBSERVE_ENABLED", "true"],
|
||||
[
|
||||
"REA_BROWSER_CDP_ENDPOINTS_JSON",
|
||||
@@ -378,7 +377,6 @@ async function runCodex(prompt, investigationRoot) {
|
||||
cwd: evaluationRoot,
|
||||
env: {
|
||||
...process.env,
|
||||
REA_INVESTIGATION_INPUT_ROOTS_JSON: JSON.stringify([investigationRoot]),
|
||||
REA_BROWSER_OBSERVE_ENABLED: "true",
|
||||
REA_BROWSER_CDP_ENDPOINTS_JSON: JSON.stringify(["http://127.0.0.1:9222"]),
|
||||
REA_BROWSER_ALLOWED_ORIGINS_JSON: JSON.stringify([
|
||||
|
||||
@@ -9,11 +9,9 @@ import {
|
||||
compareJavaScriptExportShapesEvidence,
|
||||
traceApplicationFeatureEvidence,
|
||||
} from "../dist/application/JavaScriptApplicationWorkflowService.js";
|
||||
import { PermissionAuthority } from "../dist/application/PermissionAuthority.js";
|
||||
import { applicationVersionComparisonResultSchema } from "../dist/domain/javascriptApplicationVersionComparisonSchemas.js";
|
||||
import { applicationFeatureTraceResultSchema } from "../dist/domain/javascriptFeatureTraceSchemas.js";
|
||||
import { javaScriptExportShapeComparisonResultSchema } from "../dist/domain/javascriptExportShapeComparisonSchemas.js";
|
||||
import { createPermissionPolicy } from "../dist/domain/permissionPolicy.js";
|
||||
import { completeVerifierRun, createVerifierRun } from "./lib/verifier-run.mjs";
|
||||
|
||||
const verifierRun = createVerifierRun();
|
||||
@@ -24,7 +22,6 @@ const options = parseArgs({
|
||||
right: { type: "string" },
|
||||
"seed-kind": { type: "string", default: "module" },
|
||||
"seed-value": { type: "string" },
|
||||
"source-map-read-approved": { type: "boolean", default: false },
|
||||
"left-module-path": { type: "string" },
|
||||
"left-export-name": { type: "string" },
|
||||
"right-module-path": { type: "string" },
|
||||
@@ -44,10 +41,9 @@ const [leftPath, rightPath] = await Promise.all([
|
||||
]);
|
||||
if (leftPath === rightPath)
|
||||
throw new Error("--left and --right must resolve to distinct paths");
|
||||
const authority = permissionAuthority([leftPath, rightPath]);
|
||||
const [left, right] = await Promise.all([
|
||||
analyze(leftPath, authority),
|
||||
analyze(rightPath, authority),
|
||||
analyze(leftPath),
|
||||
analyze(rightPath),
|
||||
]);
|
||||
const comparison = compareApplicationVersionsEvidence({ left, right });
|
||||
if (!comparison.ok) throw comparison.error;
|
||||
@@ -199,37 +195,10 @@ function selectorKey(selector) {
|
||||
return `${selector.modulePath}\0${selector.exportName}`;
|
||||
}
|
||||
|
||||
async function analyze(path, authority) {
|
||||
const result = await analyzeJavaScriptApplication(authority, {
|
||||
async function analyze(path) {
|
||||
const result = await analyzeJavaScriptApplication({
|
||||
input_path: path,
|
||||
approved: true,
|
||||
source_map_read_approved: options["source-map-read-approved"],
|
||||
});
|
||||
if (!result.ok) throw result.error;
|
||||
return result.value;
|
||||
}
|
||||
|
||||
function permissionAuthority(roots) {
|
||||
const scope = {
|
||||
capability: "investigation_input",
|
||||
roots,
|
||||
executables: [],
|
||||
environment_names: [],
|
||||
network: "none",
|
||||
mount: false,
|
||||
};
|
||||
return new PermissionAuthority(
|
||||
createPermissionPolicy(
|
||||
[scope],
|
||||
[
|
||||
{
|
||||
...scope,
|
||||
grant_id: "local-application-workflow-verifier",
|
||||
lifetime: "session",
|
||||
operation_identity: null,
|
||||
expires_at: null,
|
||||
},
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
@@ -4,9 +4,7 @@ import { readFile, realpath } from "node:fs/promises";
|
||||
import { parseArgs } from "node:util";
|
||||
|
||||
import { analyzeJavaScriptApplication } from "../dist/application/JavaScriptApplicationService.js";
|
||||
import { PermissionAuthority } from "../dist/application/PermissionAuthority.js";
|
||||
import { reconcileJavaScriptRuntimeEvidence } from "../dist/application/JavaScriptRuntimeReconciliationService.js";
|
||||
import { createPermissionPolicy } from "../dist/domain/permissionPolicy.js";
|
||||
import { completeVerifierRun, createVerifierRun } from "./lib/verifier-run.mjs";
|
||||
|
||||
const verifierRun = createVerifierRun();
|
||||
@@ -18,7 +16,6 @@ const options = parseArgs({
|
||||
assets: { type: "string", multiple: true, default: [] },
|
||||
"runtime-evidence": { type: "string", multiple: true, default: [] },
|
||||
mapping: { type: "string", multiple: true, default: [] },
|
||||
"source-map-read-approved": { type: "boolean", default: false },
|
||||
},
|
||||
strict: true,
|
||||
allowPositionals: false,
|
||||
@@ -42,14 +39,11 @@ const canonicalLayers = await Promise.all(
|
||||
path: await realpath(layer.path),
|
||||
})),
|
||||
);
|
||||
const authority = permissionAuthority(canonicalLayers.map(({ path }) => path));
|
||||
const staticLayers = [];
|
||||
for (const layer of canonicalLayers) {
|
||||
const analyzed = await analyzeJavaScriptApplication(authority, {
|
||||
const analyzed = await analyzeJavaScriptApplication({
|
||||
input_path: layer.path,
|
||||
format: "auto",
|
||||
approved: true,
|
||||
source_map_read_approved: options["source-map-read-approved"],
|
||||
});
|
||||
if (!analyzed.ok) throw analyzed.error;
|
||||
staticLayers.push({
|
||||
@@ -104,31 +98,6 @@ process.stdout.write(
|
||||
})}\n`,
|
||||
);
|
||||
|
||||
function permissionAuthority(roots) {
|
||||
const scope = {
|
||||
capability: "investigation_input",
|
||||
roots,
|
||||
executables: [],
|
||||
environment_names: [],
|
||||
network: "none",
|
||||
mount: false,
|
||||
};
|
||||
return new PermissionAuthority(
|
||||
createPermissionPolicy(
|
||||
[scope],
|
||||
[
|
||||
{
|
||||
...scope,
|
||||
grant_id: "local-javascript-runtime-verifier",
|
||||
lifetime: "session",
|
||||
operation_identity: null,
|
||||
expires_at: null,
|
||||
},
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
async function readEvidenceFile(path) {
|
||||
const bytes = await readFile(await realpath(path));
|
||||
if (bytes.byteLength > 64 * 1024 * 1024)
|
||||
|
||||
@@ -21,7 +21,6 @@ import {
|
||||
} from "./lib/managed-pe-fixture.mjs";
|
||||
import { createManagedConformanceSupport } from "./lib/managed-conformance-support.mjs";
|
||||
import {
|
||||
applicationGraphLimits,
|
||||
comparisonLimits,
|
||||
defaultIlBody,
|
||||
functionDossier,
|
||||
@@ -45,7 +44,6 @@ const {
|
||||
workspace,
|
||||
inspectionLimits,
|
||||
memberLimits,
|
||||
applicationGraphLimits,
|
||||
defaultIlBody,
|
||||
});
|
||||
|
||||
@@ -66,7 +64,7 @@ try {
|
||||
".NETCoreApp,Version=v8.0",
|
||||
]);
|
||||
assert.equal(
|
||||
modernArtifact.resources.items[0]?.data_sha256,
|
||||
modernArtifact.resources[0]?.data_sha256,
|
||||
sha256(Buffer.from("source-owned managed resource")),
|
||||
);
|
||||
|
||||
@@ -94,17 +92,14 @@ try {
|
||||
framework.target,
|
||||
nativeBoundaryLimits,
|
||||
);
|
||||
assert.equal(frameworkBoundaries.pinvoke_imports.total, 1);
|
||||
assert.equal(frameworkBoundaries.pinvoke_imports.length, 1);
|
||||
assert.equal(
|
||||
frameworkBoundaries.pinvoke_imports.items[0]?.verification,
|
||||
frameworkBoundaries.pinvoke_imports[0]?.verification,
|
||||
"managed-declaration-only",
|
||||
);
|
||||
assert.equal(frameworkBoundaries.pinvoke_imports[0]?.char_set, "unicode");
|
||||
assert.equal(
|
||||
frameworkBoundaries.pinvoke_imports.items[0]?.char_set,
|
||||
"unicode",
|
||||
);
|
||||
assert.equal(
|
||||
frameworkBoundaries.pinvoke_imports.items[0]?.call_convention,
|
||||
frameworkBoundaries.pinvoke_imports[0]?.call_convention,
|
||||
"stdcall",
|
||||
);
|
||||
const frameworkMembers = inspectManagedMembersBytes(
|
||||
@@ -173,10 +168,6 @@ try {
|
||||
const nativeVerification = verifyManagedNativeBoundariesEvidence({
|
||||
managed_boundaries: frameworkBoundaryEvidence,
|
||||
native_observations: [nativeFunctionEvidence],
|
||||
limits: {
|
||||
max_native_observations: 20,
|
||||
max_candidates_per_import: 25,
|
||||
},
|
||||
});
|
||||
assert.equal(nativeVerification.ok, true);
|
||||
assert.equal(nativeVerification.value.normalized_result.summary.verified, 1);
|
||||
@@ -184,13 +175,6 @@ try {
|
||||
managed_artifact: frameworkArtifactEvidence,
|
||||
managed_members: frameworkMemberEvidence,
|
||||
managed_native_boundaries: frameworkBoundaryEvidence,
|
||||
limits: {
|
||||
max_types: 100,
|
||||
max_methods: 100,
|
||||
max_fields: 100,
|
||||
max_pinvoke_imports: 100,
|
||||
max_native_implementations: 100,
|
||||
},
|
||||
});
|
||||
assert.equal(applicationGraph.ok, true);
|
||||
assert.equal(
|
||||
@@ -213,13 +197,6 @@ try {
|
||||
case_sensitive: true,
|
||||
},
|
||||
direction: "incoming",
|
||||
limits: {
|
||||
max_seed_matches: 5,
|
||||
max_depth: 4,
|
||||
max_nodes: 50,
|
||||
max_edges: 100,
|
||||
max_paths: 10,
|
||||
},
|
||||
});
|
||||
assert.equal(applicationTrace.ok, true);
|
||||
assert.equal(
|
||||
@@ -254,12 +231,9 @@ try {
|
||||
nativeBoundaryLimits,
|
||||
);
|
||||
assert.equal(r2rBoundaries.summary.ready_to_run, true);
|
||||
assert.equal(r2rBoundaries.native_implementations[0]?.code_type, "native");
|
||||
assert.equal(
|
||||
r2rBoundaries.native_implementations.items[0]?.code_type,
|
||||
"native",
|
||||
);
|
||||
assert.equal(
|
||||
r2rBoundaries.native_implementations.items[0]?.boundary_kind,
|
||||
r2rBoundaries.native_implementations[0]?.boundary_kind,
|
||||
"native-body",
|
||||
);
|
||||
|
||||
@@ -273,9 +247,9 @@ try {
|
||||
obfuscated.target,
|
||||
memberLimits,
|
||||
);
|
||||
assert.equal(obfuscatedMembers.types.items[0]?.full_name, "Fixture.ꙮType");
|
||||
assert.equal(obfuscatedMembers.methods.items[0]?.name, "λ⛧");
|
||||
assert.equal(obfuscatedMembers.fields.items[0]?.name, "字段");
|
||||
assert.equal(obfuscatedMembers.types[0]?.full_name, "Fixture.ꙮType");
|
||||
assert.equal(obfuscatedMembers.methods[0]?.name, "λ⛧");
|
||||
assert.equal(obfuscatedMembers.fields[0]?.name, "字段");
|
||||
const runtimeExecutable = join(workspace, "dotnet");
|
||||
await writeFile(runtimeExecutable, "#!/bin/sh\n");
|
||||
const runtimeCeiling = {
|
||||
@@ -299,7 +273,7 @@ try {
|
||||
],
|
||||
);
|
||||
assert.equal(runtimeAuthority.ok, true);
|
||||
const runtimeMethod = obfuscatedMembers.methods.items[0];
|
||||
const runtimeMethod = obfuscatedMembers.methods[0];
|
||||
assert.ok(runtimeMethod);
|
||||
const obfuscatedMembersEvidence = createEvidence(
|
||||
undefined,
|
||||
|
||||
@@ -39,7 +39,7 @@ export async function verifyPackageDiscovery({ cli, environment }) {
|
||||
);
|
||||
const doctorExecution = await runWithStatus(
|
||||
cli,
|
||||
["doctor", "--detail", "full", "--json"],
|
||||
["doctor", "--json"],
|
||||
environment,
|
||||
);
|
||||
const summary = json(summaryExecution.stdout);
|
||||
|
||||
@@ -75,7 +75,6 @@ export async function verifyPackageEnvironment({
|
||||
...packageHopperEnvironment(root),
|
||||
REA_NPX_LOG: npxLog,
|
||||
REA_EVIDENCE_ROOTS_JSON: JSON.stringify([evidenceRoot]),
|
||||
REA_INVESTIGATION_INPUT_ROOTS_JSON: JSON.stringify([workspace]),
|
||||
REA_REFERENCE_ROOTS_JSON: JSON.stringify([referenceRoot]),
|
||||
REA_REFERENCE_SECRET_PATTERNS_JSON: JSON.stringify([".env"]),
|
||||
};
|
||||
|
||||
@@ -327,7 +327,7 @@ export async function verifyManaged({ cli, workspace, environment }) {
|
||||
managedPath,
|
||||
environment,
|
||||
});
|
||||
const managedMethod = managedMembers.normalized_result.methods.items[0];
|
||||
const managedMethod = managedMembers.normalized_result.methods[0];
|
||||
await verifyManagedReconstruction({
|
||||
cli,
|
||||
managedMembers,
|
||||
|
||||
@@ -41,7 +41,7 @@ const verifyMcpReplay = async (client, mcpOptions, investigationReplay) => {
|
||||
|
||||
const verifyMcpTargetFree = async (client, mcpOptions) => {
|
||||
const status = await client.callTool(
|
||||
{ name: "binary_session", arguments: { detail: "full" } },
|
||||
{ name: "binary_session", arguments: {} },
|
||||
mcpOptions,
|
||||
);
|
||||
const currentDocument =
|
||||
@@ -89,7 +89,7 @@ const verifyMcpOpenAndBind = async (client, mcpOptions) => {
|
||||
const providerStatusEnvelope = json(
|
||||
prompts.mcpText(
|
||||
await client.callTool(
|
||||
{ name: "binary_session", arguments: { detail: "full" } },
|
||||
{ name: "binary_session", arguments: {} },
|
||||
mcpOptions,
|
||||
),
|
||||
),
|
||||
@@ -204,7 +204,6 @@ export async function verifyPackageMcp({
|
||||
args: ["mcp"],
|
||||
env: {
|
||||
...environment,
|
||||
REA_INVESTIGATION_INPUT_ROOTS_JSON: JSON.stringify([]),
|
||||
},
|
||||
stderr: "pipe",
|
||||
});
|
||||
|
||||
@@ -21,23 +21,11 @@ export async function verifyPackagePlatform({ cli, environment }) {
|
||||
`packaged Hopper-backed analyze CLI failed: ${JSON.stringify(overview)}`,
|
||||
);
|
||||
const inspected = json(
|
||||
await run(
|
||||
cli,
|
||||
[
|
||||
"inspect",
|
||||
process.execPath,
|
||||
"--detail",
|
||||
"detailed",
|
||||
"--limit",
|
||||
"1",
|
||||
"--json",
|
||||
],
|
||||
environment,
|
||||
),
|
||||
await run(cli, ["inspect", process.execPath, "--json"], environment),
|
||||
);
|
||||
if (
|
||||
inspected.operation !== "binary_overview" ||
|
||||
inspected.normalized_result?.detail !== "detailed"
|
||||
inspected.normalized_result?.procedure_count < 1
|
||||
)
|
||||
throw new Error("packaged inspect CLI failed");
|
||||
const functionResult = json(
|
||||
|
||||
@@ -54,7 +54,6 @@ try {
|
||||
args: ["mcp"],
|
||||
environment: {
|
||||
...environmentData.environment,
|
||||
REA_INVESTIGATION_INPUT_ROOTS_JSON: JSON.stringify([]),
|
||||
},
|
||||
policy: MCP_STARTUP_POLICY,
|
||||
});
|
||||
@@ -63,7 +62,6 @@ try {
|
||||
args: ["mcp"],
|
||||
environment: {
|
||||
...environmentData.environment,
|
||||
REA_INVESTIGATION_INPUT_ROOTS_JSON: JSON.stringify([]),
|
||||
},
|
||||
policy: MCP_STARTUP_POLICY,
|
||||
packageName: PRODUCT_IDENTITY.packageName,
|
||||
|
||||
@@ -35,7 +35,7 @@ export async function verifyPackedBridge({
|
||||
const probe = JSON.parse(
|
||||
(
|
||||
await exec("python3", [
|
||||
join(root, "tests/fixtures/bridgeRegexProbe.py"),
|
||||
join(root, "tests/fixtures/bridgeSearchProbe.py"),
|
||||
join(workspace, packedHopperBridge),
|
||||
JSON.stringify({
|
||||
action: "match",
|
||||
|
||||
@@ -408,8 +408,8 @@ async function pageTarget(provider, endpoint, origin) {
|
||||
approved: true,
|
||||
}),
|
||||
);
|
||||
if (listed.ok && listed.value.targets.items[0] !== undefined)
|
||||
return listed.value.targets.items[0].target_id;
|
||||
if (listed.ok && listed.value.targets[0] !== undefined)
|
||||
return listed.value.targets[0].target_id;
|
||||
await delay(25);
|
||||
}
|
||||
throw new Error("Real Chrome did not expose the local test page target");
|
||||
|
||||
@@ -145,10 +145,8 @@ function assertDossierProcedure(dossier, address) {
|
||||
dossier.procedure.classification === null ||
|
||||
dossier.procedure.classification.provenance !== "ghidra-function-manager" ||
|
||||
dossier.procedure.classification.external ||
|
||||
dossier.pseudocode.text.trim().length === 0 ||
|
||||
dossier.pseudocode.returned_chars !== [...dossier.pseudocode.text].length ||
|
||||
dossier.instruction_scan.scanned < 1 ||
|
||||
dossier.instruction_scan.truncated ||
|
||||
typeof dossier.pseudocode !== "string" ||
|
||||
dossier.pseudocode.trim().length === 0 ||
|
||||
!dossier.limitations.some((value) => /indirect|computed/u.test(value)) ||
|
||||
!dossier.limitations.some((value) => /Ghidra|Hopper|provider/u.test(value))
|
||||
)
|
||||
@@ -159,10 +157,7 @@ function assertDossierProcedure(dossier, address) {
|
||||
|
||||
function assertDossierReferences(dossier) {
|
||||
if (
|
||||
![
|
||||
...dossier.incoming_references.items,
|
||||
...dossier.outgoing_references.items,
|
||||
].every(
|
||||
![...dossier.incoming_references, ...dossier.outgoing_references].every(
|
||||
({ kind }) =>
|
||||
kind.available && kind.provenance === "ghidra-reference-manager",
|
||||
)
|
||||
@@ -172,16 +167,14 @@ function assertDossierReferences(dossier) {
|
||||
|
||||
function assertDossierCallees(dossier, expectedCallees) {
|
||||
for (const expected of expectedCallees)
|
||||
if (!dossier.callees.items.some(({ address: value }) => value === expected))
|
||||
if (!dossier.callees.some(({ address: value }) => value === expected))
|
||||
throw new Error(`Ghidra dossier missed callee ${expected}`);
|
||||
}
|
||||
|
||||
function assertDossierStrings(dossier, expectedString) {
|
||||
if (
|
||||
expectedString !== null &&
|
||||
!dossier.referenced_strings.items.some(
|
||||
({ value }) => value === expectedString,
|
||||
)
|
||||
!dossier.referenced_strings.some(({ value }) => value === expectedString)
|
||||
)
|
||||
throw new Error(
|
||||
`Ghidra dossier missed referenced string ${expectedString}`,
|
||||
@@ -189,20 +182,15 @@ function assertDossierStrings(dossier, expectedString) {
|
||||
}
|
||||
|
||||
function assertDossierAssembly(dossier, requireAssembly) {
|
||||
if (
|
||||
requireAssembly &&
|
||||
(dossier.assembly.items.length === 0 || dossier.assembly.truncated)
|
||||
)
|
||||
if (requireAssembly && dossier.assembly.length === 0)
|
||||
throw new Error("Ghidra dossier assembly was unavailable or truncated");
|
||||
}
|
||||
|
||||
function assertDossierMultiBlock(dossier, requireMultiBlock) {
|
||||
if (
|
||||
requireMultiBlock &&
|
||||
(dossier.basic_blocks.items.length < 2 ||
|
||||
!dossier.basic_blocks.items.some(
|
||||
({ successors }) => successors.length > 0,
|
||||
))
|
||||
(dossier.basic_blocks.length < 2 ||
|
||||
!dossier.basic_blocks.some(({ successors }) => successors.length > 0))
|
||||
)
|
||||
throw new Error(
|
||||
"Ghidra dossier CFG missed the multi-block branch structure",
|
||||
@@ -212,12 +200,12 @@ function assertDossierMultiBlock(dossier, requireMultiBlock) {
|
||||
export function dossierSummary(dossier) {
|
||||
return {
|
||||
address: dossier.procedure.address,
|
||||
pseudocode_chars: dossier.pseudocode.total_chars,
|
||||
instructions: dossier.instruction_scan.scanned,
|
||||
callees: dossier.callees.returned,
|
||||
outgoing_references: dossier.outgoing_references.returned,
|
||||
referenced_strings: dossier.referenced_strings.returned,
|
||||
basic_blocks: dossier.basic_blocks.returned,
|
||||
pseudocode_chars: [...dossier.pseudocode].length,
|
||||
instructions: dossier.assembly.length,
|
||||
callees: dossier.callees.length,
|
||||
outgoing_references: dossier.outgoing_references.length,
|
||||
referenced_strings: dossier.referenced_strings.length,
|
||||
basic_blocks: dossier.basic_blocks.length,
|
||||
native_parameters:
|
||||
dossier.native_api.available === true
|
||||
? dossier.native_api.parameters.length
|
||||
@@ -350,7 +338,6 @@ function assertStrings(strings) {
|
||||
const item = strings.find((candidate) => candidate.value === expected);
|
||||
if (
|
||||
item === undefined ||
|
||||
item.value_truncated ||
|
||||
typeof item.string.encoding !== "string" ||
|
||||
item.string.byte_length < expected.length
|
||||
)
|
||||
|
||||
@@ -118,10 +118,6 @@ export async function verifyDebugFunctionOperations(
|
||||
const switchDossier = await analyzeSwitchDossier(client, switchProcedure);
|
||||
const denseSwitchDossier = await functionCall(client, "analyze_function", {
|
||||
procedure: denseSwitchProcedure.address,
|
||||
include_assembly: true,
|
||||
limit: 500,
|
||||
max_pseudocode_chars: 100_000,
|
||||
max_instructions: 5_000,
|
||||
});
|
||||
assertDenseSwitchDossier(denseSwitchDossier, denseSwitchProcedure.address);
|
||||
assertIndirectDossier(indirectDossier, leaf.address);
|
||||
@@ -246,10 +242,6 @@ async function assertStringXrefs(client, entryStringAddress) {
|
||||
async function analyzeEntryDossier(client, entry, branch, indirect) {
|
||||
const entryDossier = await functionCall(client, "analyze_function", {
|
||||
procedure: entry.address,
|
||||
include_assembly: true,
|
||||
limit: 500,
|
||||
max_pseudocode_chars: 100_000,
|
||||
max_instructions: 5_000,
|
||||
});
|
||||
assertDossier(entryDossier, {
|
||||
address: entry.address,
|
||||
@@ -263,10 +255,6 @@ async function analyzeEntryDossier(client, entry, branch, indirect) {
|
||||
async function analyzeSwitchDossier(client, switchProcedure) {
|
||||
const dossier = await functionCall(client, "analyze_function", {
|
||||
procedure: switchProcedure.address,
|
||||
include_assembly: true,
|
||||
limit: 500,
|
||||
max_pseudocode_chars: 100_000,
|
||||
max_instructions: 5_000,
|
||||
});
|
||||
assertDossier(dossier, {
|
||||
address: switchProcedure.address,
|
||||
@@ -280,9 +268,6 @@ async function analyzeSwitchDossier(client, switchProcedure) {
|
||||
async function analyzeBranchDossier(client, branch) {
|
||||
const branchDossier = await functionCall(client, "analyze_function", {
|
||||
procedure: branch.address,
|
||||
limit: 500,
|
||||
max_pseudocode_chars: 100_000,
|
||||
max_instructions: 5_000,
|
||||
});
|
||||
assertDossier(branchDossier, {
|
||||
address: branch.address,
|
||||
@@ -294,10 +279,6 @@ async function analyzeBranchDossier(client, branch) {
|
||||
async function analyzeIndirectDossier(client, indirect) {
|
||||
const indirectDossier = await functionCall(client, "analyze_function", {
|
||||
procedure: indirect.address,
|
||||
include_assembly: true,
|
||||
limit: 500,
|
||||
max_pseudocode_chars: 100_000,
|
||||
max_instructions: 5_000,
|
||||
});
|
||||
assertDossier(indirectDossier, {
|
||||
address: indirect.address,
|
||||
@@ -307,13 +288,11 @@ async function analyzeIndirectDossier(client, indirect) {
|
||||
}
|
||||
|
||||
function assertIndirectDossier(indirectDossier, leafAddress) {
|
||||
if (
|
||||
indirectDossier.callees.items.some(({ address }) => address === leafAddress)
|
||||
)
|
||||
if (indirectDossier.callees.some(({ address }) => address === leafAddress))
|
||||
throw new Error(
|
||||
"Ghidra dossier falsely resolved a targetless callback as the fixture leaf",
|
||||
);
|
||||
if (!/\bcall\b/iu.test(indirectDossier.assembly.items.join("\n")))
|
||||
if (!/\bcall\b/iu.test(indirectDossier.assembly.join("\n")))
|
||||
throw new Error("Ghidra indirect-call fixture lost its computed call site");
|
||||
}
|
||||
|
||||
@@ -384,10 +363,6 @@ export async function verifyStrippedFunctionOperations(client, entryString) {
|
||||
throw new Error("Ghidra did not decompile the stripped function");
|
||||
const dossier = await functionCall(client, "analyze_function", {
|
||||
procedure: procedure.address,
|
||||
include_assembly: true,
|
||||
limit: 500,
|
||||
max_pseudocode_chars: 100_000,
|
||||
max_instructions: 5_000,
|
||||
});
|
||||
assertDossier(dossier, {
|
||||
address: procedure.address,
|
||||
@@ -449,9 +424,6 @@ export async function verifyCrossFormatOperations({
|
||||
const messageOwner = await findCrossStringOwner(client, messageXrefs);
|
||||
const stringDossier = await functionCall(client, "analyze_function", {
|
||||
procedure: messageOwner.procedure.address,
|
||||
limit: 500,
|
||||
max_pseudocode_chars: 100_000,
|
||||
max_instructions: 5_000,
|
||||
});
|
||||
assertDossier(stringDossier, {
|
||||
address: messageOwner.procedure.address,
|
||||
@@ -461,9 +433,6 @@ export async function verifyCrossFormatOperations({
|
||||
const branchAddress = await findCrossBranchAddress(client, variant, callees);
|
||||
const branchDossier = await functionCall(client, "analyze_function", {
|
||||
procedure: branchAddress,
|
||||
limit: 500,
|
||||
max_pseudocode_chars: 100_000,
|
||||
max_instructions: 5_000,
|
||||
});
|
||||
assertDossier(branchDossier, {
|
||||
address: branchAddress,
|
||||
|
||||
@@ -153,7 +153,6 @@ try {
|
||||
await functionOperation("xrefs", { address: procedure.address });
|
||||
await functionOperation("analyze_function", {
|
||||
procedure: procedure.value,
|
||||
include_assembly: true,
|
||||
});
|
||||
|
||||
const expected = [
|
||||
|
||||
@@ -29,8 +29,9 @@ import {
|
||||
requireWorkflowEvidenceProvider,
|
||||
} from "./lib/mcp-verifier-results.mjs";
|
||||
import { verifyHopperFunctionBasics } from "./lib/real-hopper-function-basics.mjs";
|
||||
import { openAndVerifyLargeFixture } from "./lib/real-hopper-pagination.mjs";
|
||||
import { openAndVerifyLargeFixture } from "./lib/real-hopper-exhaustive-search.mjs";
|
||||
import { completeVerifierRun, createVerifierRun } from "./lib/verifier-run.mjs";
|
||||
import { requireHopperSelection } from "./lib/real-hopper-selection.mjs";
|
||||
import { startUnrelatedHopperSentinel } from "./lib/unrelated-hopper-sentinel.mjs";
|
||||
const execFileAsync = promisify(execFile);
|
||||
const verifierRun = createVerifierRun();
|
||||
@@ -51,39 +52,6 @@ const sessionsBefore = new Set(
|
||||
const textValue = mcpTextValue;
|
||||
const requireSuccessfulTool = requireMcpResult;
|
||||
|
||||
const requireHopperSelection = (status, expected) => {
|
||||
const candidates = status.analysis_provider_candidates;
|
||||
const hopper = Array.isArray(candidates)
|
||||
? candidates.find(
|
||||
(candidate) => candidate?.provider?.id === HOPPER_PROVIDER_IDENTITY.id,
|
||||
)
|
||||
: undefined;
|
||||
if (
|
||||
hopper === undefined ||
|
||||
hopper.availability?.status !== "available" ||
|
||||
hopper.target_support?.status !== expected.targetSupport ||
|
||||
hopper.selected !== expected.selected
|
||||
) {
|
||||
throw new Error("binary_session omitted truthful Hopper candidate status");
|
||||
}
|
||||
if (!expected.selected) {
|
||||
if (status.analysis_provider_binding !== null)
|
||||
throw new Error("Target-free status unexpectedly selected a provider");
|
||||
return null;
|
||||
}
|
||||
const binding = status.analysis_provider_binding;
|
||||
if (
|
||||
binding?.provider?.id !== HOPPER_PROVIDER_IDENTITY.id ||
|
||||
typeof binding.provider.version !== "string" ||
|
||||
binding.selection_source !== "auto-single-candidate" ||
|
||||
binding.analysis_profile?.provider?.id !== HOPPER_PROVIDER_IDENTITY.id ||
|
||||
binding.analysis_profile.provider.version !== binding.provider.version
|
||||
) {
|
||||
throw new Error("binary_session omitted its concrete Hopper binding");
|
||||
}
|
||||
return binding;
|
||||
};
|
||||
|
||||
const requireOverview = (value, operation) => {
|
||||
if (
|
||||
value === null ||
|
||||
@@ -230,7 +198,7 @@ const verifyCurrentTarget = async (client, options) => {
|
||||
procedure: dossier.procedure,
|
||||
procedureCount: procedures.total,
|
||||
boundedPseudocodeChars: boundedPseudocode.length,
|
||||
analyzedPseudocodeChars: [...dossier.pseudocode.text].length,
|
||||
analyzedPseudocodeChars: [...dossier.pseudocode].length,
|
||||
callerCount: relationships.procedure_callers.length,
|
||||
calleeCount: relationships.procedure_callees.length,
|
||||
xrefCount: relationships.xrefs.length,
|
||||
@@ -287,24 +255,20 @@ try {
|
||||
onprogress: (update) => progressUpdates.push(update),
|
||||
};
|
||||
const fullSessionStatus = () =>
|
||||
client.callTool(
|
||||
{ name: "binary_session", arguments: { detail: "full" } },
|
||||
options,
|
||||
);
|
||||
client.callTool({ name: "binary_session", arguments: {} }, options);
|
||||
const initialSession = await fullSessionStatus();
|
||||
const initialStatus = requireMcpResult(initialSession, "binary_session");
|
||||
const listed = await client.listTools();
|
||||
const availableTools = initialStatus.tool_availability;
|
||||
if (!Array.isArray(availableTools))
|
||||
throw new Error("The real session omitted tool availability");
|
||||
const expectedNames = availableTools
|
||||
.filter(({ available }) => available === true)
|
||||
.map(({ name }) => name)
|
||||
.sort();
|
||||
const expectedNames = availableTools.map(({ name }) => name).sort();
|
||||
const actualNames = listed.tools.map(({ name }) => name).sort();
|
||||
if (JSON.stringify(actualNames) !== JSON.stringify(expectedNames)) {
|
||||
const expected = new Set(expectedNames);
|
||||
const actual = new Set(actualNames);
|
||||
throw new Error(
|
||||
"The real server tool inventory diverged from session availability",
|
||||
`The real server tool catalog diverged from session capability inventory (untracked tools: ${actualNames.filter((name) => !expected.has(name)).join(", ") || "none"}; missing catalog tools: ${expectedNames.filter((name) => !actual.has(name)).join(", ") || "none"})`,
|
||||
);
|
||||
}
|
||||
|
||||
@@ -345,18 +309,15 @@ try {
|
||||
{ name: "binary_overview", arguments: {} },
|
||||
options,
|
||||
);
|
||||
await Promise.all([
|
||||
requireEvidenceProvider(
|
||||
client,
|
||||
documents,
|
||||
"list_documents",
|
||||
HOPPER_PROVIDER_IDENTITY.id,
|
||||
),
|
||||
requireWorkflowEvidenceProvider(client, overview, "binary_overview", {
|
||||
workflowProviderId: REA_WORKFLOW_PROVIDER.id,
|
||||
upstreamProviderId: HOPPER_PROVIDER_IDENTITY.id,
|
||||
}),
|
||||
]);
|
||||
requireEvidenceProvider(
|
||||
documents,
|
||||
"list_documents",
|
||||
HOPPER_PROVIDER_IDENTITY.id,
|
||||
);
|
||||
requireWorkflowEvidenceProvider(overview, "binary_overview", {
|
||||
workflowProviderId: REA_WORKFLOW_PROVIDER.id,
|
||||
upstreamProviderId: HOPPER_PROVIDER_IDENTITY.id,
|
||||
});
|
||||
const segments = await client.callTool(
|
||||
{ name: "list_segments", arguments: {} },
|
||||
options,
|
||||
@@ -413,7 +374,33 @@ try {
|
||||
"binary_overview after target switch",
|
||||
);
|
||||
const secondAnalysis = await verifyCurrentTarget(client, options);
|
||||
const largePagination = await openAndVerifyLargeFixture({
|
||||
const documentsAfterTargetSwitch = requireMcpResult(
|
||||
await client.callTool({ name: "list_documents", arguments: {} }, options),
|
||||
"list_documents after target switch",
|
||||
);
|
||||
if (
|
||||
!Array.isArray(documentsAfterTargetSwitch) ||
|
||||
documentsAfterTargetSwitch.length !== firstDocuments.length + 1
|
||||
)
|
||||
throw new Error("A distinct target did not receive one Hopper document");
|
||||
const reopenedTarget = await client.callTool(
|
||||
{ name: "open_binary", arguments: { path: targetB } },
|
||||
options,
|
||||
);
|
||||
if (reopenedTarget.isError === true)
|
||||
throw new Error(textValue(reopenedTarget));
|
||||
const documentsAfterReopen = requireMcpResult(
|
||||
await client.callTool({ name: "list_documents", arguments: {} }, options),
|
||||
"list_documents after reopening target B",
|
||||
);
|
||||
if (
|
||||
!Array.isArray(documentsAfterReopen) ||
|
||||
documentsAfterReopen.length !== documentsAfterTargetSwitch.length
|
||||
)
|
||||
throw new Error(
|
||||
"Reopening the same target created a duplicate Hopper document",
|
||||
);
|
||||
const largeInventory = await openAndVerifyLargeFixture({
|
||||
client,
|
||||
options,
|
||||
normalizedResult: requireSuccessfulTool,
|
||||
@@ -454,7 +441,7 @@ try {
|
||||
segmentCount: firstOverview.segment_count,
|
||||
analyses: [firstAnalysis, secondAnalysis],
|
||||
fixtureAnalysis,
|
||||
largePagination,
|
||||
largeInventory,
|
||||
fixtureManifest: fixtureTargets.manifestPath,
|
||||
bundledMcpRunning,
|
||||
stderrBytes,
|
||||
@@ -466,6 +453,8 @@ try {
|
||||
targetHashes: [targetHashA, targetHashB, fixtureTargets.large.sha256],
|
||||
switched: true,
|
||||
secondOverview: verifiedSecondOverview,
|
||||
documentCountAfterTargetSwitch: documentsAfterTargetSwitch.length,
|
||||
documentCountAfterSameTargetReopen: documentsAfterReopen.length,
|
||||
};
|
||||
} finally {
|
||||
const keepAlive = setInterval(() => undefined, 100);
|
||||
|
||||
@@ -23,7 +23,6 @@ const javascriptPath = join(fixtureRoot, "javascript-cli");
|
||||
const electronPath = join(fixtureRoot, "electron");
|
||||
const environment = {
|
||||
...process.env,
|
||||
REA_INVESTIGATION_INPUT_ROOTS_JSON: JSON.stringify([fixtureRoot]),
|
||||
};
|
||||
const temporaryRoot = await mkdtemp(join(tmpdir(), "rea-readiness-"));
|
||||
|
||||
@@ -32,13 +31,11 @@ const nativeEvidence = await runCli(["inspect-artifact", nativePath, "--json"]);
|
||||
const javascriptCliEvidence = await runCli([
|
||||
"analyze-javascript-application",
|
||||
javascriptPath,
|
||||
"--approved",
|
||||
"--json",
|
||||
]);
|
||||
const electronCliEvidence = await runCli([
|
||||
"analyze-javascript-application",
|
||||
electronPath,
|
||||
"--approved",
|
||||
"--json",
|
||||
]);
|
||||
|
||||
@@ -62,11 +59,6 @@ try {
|
||||
catalog.tools,
|
||||
"evaluate_reconstruction_readiness",
|
||||
);
|
||||
const analysisTool = requireTool(
|
||||
catalog.tools,
|
||||
"analyze_javascript_application",
|
||||
);
|
||||
assertExactAstLimit(analysisTool);
|
||||
assert.equal(
|
||||
readinessTool.annotations?.readOnlyHint,
|
||||
false,
|
||||
@@ -141,14 +133,7 @@ try {
|
||||
const projectedReport = requireObject(projection.result);
|
||||
assert.equal(projectedReport.report_digest, cliReport.report_digest);
|
||||
assert.equal(projectedReport.status, "pass");
|
||||
const reportUri = projectedReport.report_resource_uri;
|
||||
assert.equal(typeof reportUri, "string");
|
||||
const resource = await client.readResource({ uri: reportUri });
|
||||
const resourceContent = resource.contents[0];
|
||||
if (resourceContent === undefined || !("text" in resourceContent))
|
||||
throw new TypeError("Readiness report resource is missing JSON text");
|
||||
const retained = JSON.parse(resourceContent.text);
|
||||
assert.equal(retained.report.report_digest, cliReport.report_digest);
|
||||
assert.equal(projectedReport.report_digest, cliReport.report_digest);
|
||||
|
||||
const tampered = structuredClone(input);
|
||||
tampered.replay.expected_source_digest = cliReport.source_digest;
|
||||
@@ -203,20 +188,13 @@ async function runCli(arguments_) {
|
||||
}
|
||||
|
||||
async function analyzeMcp(client_, inputPath) {
|
||||
const result = await client_.callTool({
|
||||
const response = await client_.callTool({
|
||||
name: "analyze_javascript_application",
|
||||
arguments: { input_path: inputPath, approved: true },
|
||||
arguments: { input_path: inputPath },
|
||||
});
|
||||
assert.notEqual(result.isError, true);
|
||||
const projected = requireObject(result.structuredContent);
|
||||
assert.equal(typeof projected.evidence_id, "string");
|
||||
const evidence = await client_.readResource({
|
||||
uri: `rea://evidence/${projected.evidence_id}`,
|
||||
});
|
||||
const content = evidence.contents[0];
|
||||
if (content === undefined || !("text" in content))
|
||||
throw new TypeError("Analysis Evidence resource is missing JSON text");
|
||||
return parseEvidence(JSON.parse(content.text));
|
||||
assert.notEqual(response.isError, true);
|
||||
const projected = requireObject(response.structuredContent);
|
||||
return { evidence_id: projected.evidence_id };
|
||||
}
|
||||
|
||||
function requireTool(tools, name) {
|
||||
@@ -225,15 +203,6 @@ function requireTool(tools, name) {
|
||||
return tool;
|
||||
}
|
||||
|
||||
function assertExactAstLimit(tool) {
|
||||
const properties = requireObject(tool.inputSchema.properties);
|
||||
const limits = requireObject(properties.limits);
|
||||
const limitProperties = requireObject(limits.properties);
|
||||
const astLimit = requireObject(limitProperties.max_ast_nodes);
|
||||
assert.equal(astLimit.default, 2_000_000, "effective AST limit is hidden");
|
||||
assert.equal(astLimit.maximum, 20_000_000, "schema AST limit is hidden");
|
||||
}
|
||||
|
||||
function requireObject(value) {
|
||||
if (typeof value !== "object" || value === null || Array.isArray(value))
|
||||
throw new TypeError("Expected an object");
|
||||
|
||||
Reference in New Issue
Block a user