test(experiments): expand real-provider corpus and grade Codex projections
This commit is contained in:
@@ -8,6 +8,33 @@ import { CodeModeBridge, connectUpstream, json } from "./bridge.mjs";
|
||||
|
||||
// Replay isolates transport/discovery costs. It does not simulate model reasoning.
|
||||
const workflows = {
|
||||
"sharex.dll": {
|
||||
tools: ["inspect_managed_artifact", "inspect_managed_native_boundaries"],
|
||||
question:
|
||||
"Report assembly/module identity, target framework and declared P/Invoke libraries with their uncertainty.",
|
||||
code: `
|
||||
const artifact = await call("inspect_managed_artifact", {path: input.path});
|
||||
const boundaries = await call("inspect_managed_native_boundaries", {});
|
||||
const n = artifact.normalized_result;
|
||||
return {artifact_sha256: artifact.subject?.digest.sha256,
|
||||
classification: n.classification, assembly: n.assembly, module: n.module,
|
||||
target_frameworks: n.target_frameworks, coverage: n.coverage,
|
||||
native_boundaries: boundaries.normalized_result,
|
||||
evidence_ids: [artifact.evidence_id, boundaries.evidence_id],
|
||||
limitations: [...artifact.limitations, ...boundaries.limitations]};`,
|
||||
},
|
||||
"sqlite.wasm": {
|
||||
tools: ["inspect_wasm_artifact"],
|
||||
question:
|
||||
"Report exact WASM validation, all exported names and runtime/network observation states without executing it.",
|
||||
code: `
|
||||
const wasm = await call("inspect_wasm_artifact", {path: input.path});
|
||||
const n = wasm.normalized_result;
|
||||
return {artifact_sha256: wasm.subject?.digest.sha256,
|
||||
validation: n.validation, sections: n.sections, exports: n.exports,
|
||||
runtime_execution: n.runtime_execution, network_fetch: n.network_fetch,
|
||||
evidence_ids: [wasm.evidence_id], limitations: [...wasm.limitations, ...n.limitations]};`,
|
||||
},
|
||||
"obsidian.asar": {
|
||||
tools: ["analyze_javascript_application", "inspect_analysis_view"],
|
||||
question:
|
||||
@@ -65,20 +92,20 @@ return {artifact_sha256: inspected.subject?.digest.sha256,
|
||||
jq: {
|
||||
tools: [
|
||||
"open_binary",
|
||||
"search_procedures",
|
||||
"resolve_containing_procedure",
|
||||
"analyze_function",
|
||||
"close_binary",
|
||||
],
|
||||
question:
|
||||
"Find jq_compile, analyze it and report its first 512 pseudocode units and caller/callee counts.",
|
||||
"Resolve the observed ELF entry address and report the recovered function's first 512 pseudocode units and caller/callee counts.",
|
||||
code: `
|
||||
await call("open_binary", {path: input.path, provider_id: "ghidra"});
|
||||
try {
|
||||
const found = await call("search_procedures", {pattern: "jq_compile", mode: "literal", case_sensitive: true});
|
||||
const fn = await call("analyze_function", {procedure: "jq_compile"});
|
||||
const found = await call("resolve_containing_procedure", {address: input.entry_address});
|
||||
const fn = await call("analyze_function", {procedure: input.entry_address});
|
||||
const n = fn.normalized_result;
|
||||
return {artifact_sha256: fn.subject?.digest.sha256,
|
||||
matches: found.normalized_result, procedure: n.procedure,
|
||||
entry_address: input.entry_address, containing_procedure: found.normalized_result, procedure: n.procedure,
|
||||
pseudocode_prefix: n.pseudocode.slice(0, 512),
|
||||
caller_count: n.callers.length, callee_count: n.callees.length,
|
||||
evidence_ids: [found.evidence_id, fn.evidence_id],
|
||||
@@ -125,6 +152,11 @@ const measure = (value) => {
|
||||
cl100k_estimated_tokens: encoding.encode(text).length,
|
||||
};
|
||||
};
|
||||
const modelText = (reply) =>
|
||||
reply.content
|
||||
.filter((item) => item.type === "text")
|
||||
.map((item) => item.text)
|
||||
.join("\n");
|
||||
const environment = values.providers
|
||||
? JSON.parse(await readFile(values.providers, "utf8"))
|
||||
: {};
|
||||
@@ -149,6 +181,7 @@ upstream.call = async (name, args, options) => {
|
||||
is_error: reply.isError === true,
|
||||
input: measure(args),
|
||||
output: measure(reply),
|
||||
text_output: measure(modelText(reply)),
|
||||
evidence_id: parsed.evidence_id,
|
||||
reply,
|
||||
});
|
||||
@@ -167,6 +200,11 @@ upstream.call = async (name, args, options) => {
|
||||
const bridge = new CodeModeBridge(upstream);
|
||||
const workflow = workflows[values.artifact];
|
||||
const input = { path: artifactPath };
|
||||
if (artifact.id === "jq") {
|
||||
if (bytes.subarray(0, 6).toString("hex") !== "7f454c460201")
|
||||
throw new Error("Expected ELF64 little-endian header for entry seed");
|
||||
input.entry_address = `0x${bytes.readBigUInt64LE(24).toString(16)}`;
|
||||
}
|
||||
const code = `const input = ${JSON.stringify(input)};
|
||||
async function call(name, args) {
|
||||
const reply = await tools[name](args);
|
||||
@@ -216,11 +254,22 @@ const summary = {
|
||||
operation_ms: performance.now() - operationStarted,
|
||||
original_calls: records.map(({ reply: _reply, ...metadata }) => metadata),
|
||||
exposed_catalog: catalogExposure ? measure(catalogExposure) : null,
|
||||
direct_input_definitions: measure(
|
||||
upstream.catalog.map((tool) => ({
|
||||
name: tool.name,
|
||||
description: tool.description,
|
||||
inputSchema: tool.inputSchema,
|
||||
})),
|
||||
),
|
||||
execution_code: values.mode === "bridge" ? measure(code) : null,
|
||||
exposed_tool_results:
|
||||
values.mode === "bridge"
|
||||
? [measure(bridgeReply)]
|
||||
: records.filter((x) => x.output).map((x) => x.output),
|
||||
exposed_text_results:
|
||||
values.mode === "bridge"
|
||||
? [measure(bridgeReply)]
|
||||
: records.filter((x) => x.text_output).map((x) => x.text_output),
|
||||
projection: value,
|
||||
failure: failure ?? null,
|
||||
correctness: failure
|
||||
@@ -242,7 +291,13 @@ console.log(
|
||||
calls: records.length,
|
||||
startup_ms: summary.startup_ms,
|
||||
operation_ms: summary.operation_ms,
|
||||
failure: summary.failure,
|
||||
failure: summary.failure
|
||||
? String(
|
||||
typeof summary.failure === "object"
|
||||
? summary.failure.message
|
||||
: summary.failure,
|
||||
).slice(0, 1000)
|
||||
: null,
|
||||
}),
|
||||
);
|
||||
if (failure) process.exitCode = 1;
|
||||
|
||||
Reference in New Issue
Block a user