fix(experiments): separate native facts from Evidence references
Keep original parent and derived IDs in run-specific provenance, compare selected facts exactly, and preserve existing jq answer arrays. Co-authored-by: factory-droid[bot] <138933559+factory-droid[bot]@users.noreply.github.com>
This commit is contained in:
co-authored by
factory-droid[bot] <138933559+factory-droid[bot]@users.noreply.github.com>
parent
b74b9b79ab
commit
ba5cf12bfa
@@ -57,6 +57,17 @@ const facts = (answer) =>
|
||||
const a = facts(leftAnswer);
|
||||
const b = facts(rightAnswer);
|
||||
const runSpecific = [];
|
||||
for (const [side, answer] of [
|
||||
["left", leftAnswer],
|
||||
["right", rightAnswer],
|
||||
]) {
|
||||
if (Object.hasOwn(answer, "evidence_ids"))
|
||||
runSpecific.push({
|
||||
side,
|
||||
path: ["evidence_ids"],
|
||||
value: answer.evidence_ids,
|
||||
});
|
||||
}
|
||||
// Binwalk assigns a new opaque region UUID in each invocation. Preserve both
|
||||
// original lookup values in this report; compare the observed region facts
|
||||
// separately. The product and original replies retain those IDs unchanged.
|
||||
|
||||
@@ -148,6 +148,14 @@ summary refusal probe. It does not select summary delivery from `analyze_functio
|
||||
The helper fingerprint participates in comparison, and missing native helper
|
||||
fingerprints are not treated as a comparable current driver.
|
||||
|
||||
The reviewed `entry-views` answer separates selected facet facts from run-specific
|
||||
references: `evidence_ids.retained_views` retains each facet's original view and
|
||||
parent ID, while `retained_views` holds its item, coverage, limitations and unknowns.
|
||||
The comparator preserves both runs' reference maps and compares the facts. Existing
|
||||
`entry`/`entry-and-main` answers keep their ID arrays. Historical SDK receipts above
|
||||
retain their original pre-review representation; no replies or measurements were
|
||||
rewritten, and no provider/model runs were repeated for this representation fix.
|
||||
|
||||
Relevant validation includes the real workflows above, recorded-reply regression,
|
||||
grader negative probes, JavaScript/Python syntax, formatting/diff checks and
|
||||
`npm run check:fast`. The cold type/lint gate passed in 112.602 seconds with
|
||||
|
||||
@@ -7,7 +7,8 @@ const normalized = (value) => value.normalized_result;
|
||||
const retainedEntryViews = async (call, info, inputSha, ToolFailure) => {
|
||||
const n = normalized(info);
|
||||
const retainedViews = [];
|
||||
let nativeSummaryOutcome;
|
||||
const retainedViewEvidence = [];
|
||||
let nativeSummaryOutcome, summaryEvidenceId;
|
||||
for (const facet of ["procedure", "pseudocode", "callers", "callees"]) {
|
||||
const selected = await call("inspect_analysis_view", {
|
||||
source: { kind: "retained-evidence", evidence_id: info.evidence_id },
|
||||
@@ -36,13 +37,16 @@ const retainedEntryViews = async (call, info, inputSha, ToolFailure) => {
|
||||
);
|
||||
retainedViews.push({
|
||||
facet,
|
||||
evidence_id: selected.evidence_id,
|
||||
parent_evidence_id: view.parent_evidence_id,
|
||||
item: view.item,
|
||||
coverage: view.coverage,
|
||||
limitations: view.limitations,
|
||||
unknowns: view.unknowns,
|
||||
});
|
||||
retainedViewEvidence.push({
|
||||
facet,
|
||||
evidence_id: selected.evidence_id,
|
||||
parent_evidence_id: view.parent_evidence_id,
|
||||
});
|
||||
}
|
||||
// Exercise the advertised summary recipe separately. A known refusal
|
||||
// is recorded as such; it does not validate a nonexistent capability.
|
||||
@@ -51,10 +55,8 @@ const retainedEntryViews = async (call, info, inputSha, ToolFailure) => {
|
||||
source: { kind: "retained-evidence", evidence_id: info.evidence_id },
|
||||
view: { kind: "summary" },
|
||||
});
|
||||
nativeSummaryOutcome = {
|
||||
status: "supported",
|
||||
evidence_id: summary.evidence_id,
|
||||
};
|
||||
nativeSummaryOutcome = { status: "supported" };
|
||||
summaryEvidenceId = summary.evidence_id;
|
||||
} catch (error) {
|
||||
if (
|
||||
!(error instanceof ToolFailure) ||
|
||||
@@ -66,7 +68,12 @@ const retainedEntryViews = async (call, info, inputSha, ToolFailure) => {
|
||||
error: error.value.error,
|
||||
};
|
||||
}
|
||||
return { retainedViews, nativeSummaryOutcome };
|
||||
return {
|
||||
retainedViews,
|
||||
retainedViewEvidence,
|
||||
nativeSummaryOutcome,
|
||||
summaryEvidenceId,
|
||||
};
|
||||
};
|
||||
|
||||
const retainedJqMain = async (call, ToolFailure) => {
|
||||
@@ -183,11 +190,17 @@ export const measureNativeEntry = async ({
|
||||
retained_views: selected.retainedViews,
|
||||
native_summary_outcome: selected.nativeSummaryOutcome,
|
||||
}),
|
||||
evidence_ids: [
|
||||
containing.evidence_id,
|
||||
info.evidence_id,
|
||||
...mainEvidenceIds,
|
||||
],
|
||||
evidence_ids:
|
||||
selected.retainedViews === undefined
|
||||
? [containing.evidence_id, info.evidence_id, ...mainEvidenceIds]
|
||||
: {
|
||||
containing_procedure: containing.evidence_id,
|
||||
function_dossier: info.evidence_id,
|
||||
retained_views: selected.retainedViewEvidence,
|
||||
...(selected.summaryEvidenceId === undefined
|
||||
? {}
|
||||
: { native_summary: selected.summaryEvidenceId }),
|
||||
},
|
||||
};
|
||||
} finally {
|
||||
await call("close_binary", {});
|
||||
|
||||
@@ -0,0 +1,117 @@
|
||||
import { execFile } from "node:child_process";
|
||||
import { mkdir, writeFile } from "node:fs/promises";
|
||||
import { join, resolve } from "node:path";
|
||||
import { promisify } from "node:util";
|
||||
|
||||
import { expect, it } from "vitest";
|
||||
|
||||
import { createTestTempDirectory } from "../../fixtures/temporaryDirectory.js";
|
||||
|
||||
const execute = promisify(execFile);
|
||||
|
||||
// A recording port checks the experimental producer/consumer representation.
|
||||
// Real provider verification remains in the separate native experiment receipts.
|
||||
const generate = `
|
||||
import {measureNativeEntry} from './experiments/analysis-efficiency/native-entry.mjs';
|
||||
const sha='0'.repeat(64);
|
||||
const dossier={procedure:{address:'0x1000'},pseudocode:'return;',callers:[],callees:[]};
|
||||
class ToolFailure extends Error {}
|
||||
const build=async digit=>{
|
||||
const parent='ev_'+digit.repeat(63)+'0';
|
||||
let ordinal=0;
|
||||
const call=async(name,args)=>{
|
||||
if(name==='open_binary'||name==='close_binary')return {};
|
||||
if(name==='resolve_containing_procedure')return {evidence_id:parent,normalized_result:{found:true}};
|
||||
if(name==='analyze_function')return {evidence_id:parent,subject:{digest:{sha256:sha}},normalized_result:dossier};
|
||||
const id='ev_'+digit.repeat(63)+(++ordinal);
|
||||
if(args.view.kind==='summary')return {evidence_id:id};
|
||||
const facet=args.view.facet;
|
||||
const item=facet==='pseudocode'?{text:dossier.pseudocode,unit:'utf16-code-units'}:dossier[facet];
|
||||
return {evidence_id:id,normalized_result:{parent_evidence_id:parent,artifact:{sha256:sha},item,coverage:{exhausted:true},limitations:[],unknowns:[]}};
|
||||
};
|
||||
return measureNativeEntry({seed:'0x1000',values:{path:'/selected/input','native-question':'entry-views'},call,inputSha:sha,ToolFailure});
|
||||
};
|
||||
process.stdout.write(JSON.stringify([await build('1'),await build('2')]));
|
||||
`;
|
||||
|
||||
it.each(["references", "item", "coverage", "limitations", "unknowns"])(
|
||||
"separates native references while comparing %s exactly",
|
||||
async (change) => {
|
||||
const { stdout: generated } = await execute(process.execPath, [
|
||||
"--input-type=module",
|
||||
"-e",
|
||||
generate,
|
||||
]);
|
||||
const [leftAnswer, rightAnswer] = JSON.parse(generated);
|
||||
if (change === "item")
|
||||
rightAnswer.retained_views[0].item.address = "0x1001";
|
||||
if (change === "coverage")
|
||||
rightAnswer.retained_views[0].coverage.exhausted = false;
|
||||
if (change === "limitations")
|
||||
rightAnswer.retained_views[0].limitations.push("partial");
|
||||
if (change === "unknowns")
|
||||
rightAnswer.retained_views[0].unknowns.push("unresolved");
|
||||
|
||||
const root = await createTestTempDirectory("rea-native-comparison-");
|
||||
const left = join(root, "left");
|
||||
const right = join(root, "right");
|
||||
const summary = {
|
||||
artifact: "sharex.exe",
|
||||
native_question: "entry-views",
|
||||
provider_search_path_sha256: "0".repeat(64),
|
||||
native_workflow_source_sha256: "1".repeat(64),
|
||||
calls: [],
|
||||
failure: null,
|
||||
};
|
||||
for (const [directory, answer] of [
|
||||
[left, leftAnswer],
|
||||
[right, rightAnswer],
|
||||
]) {
|
||||
await mkdir(directory);
|
||||
await writeFile(join(directory, "summary.json"), JSON.stringify(summary));
|
||||
await writeFile(join(directory, "answer.json"), JSON.stringify(answer));
|
||||
}
|
||||
const output = join(root, "comparison.json");
|
||||
const command = execute(process.execPath, [
|
||||
resolve("experiments/analysis-efficiency/compare.mjs"),
|
||||
"--left",
|
||||
left,
|
||||
"--right",
|
||||
right,
|
||||
"--output",
|
||||
output,
|
||||
]);
|
||||
if (change !== "references") {
|
||||
await expect(command).rejects.toMatchObject({
|
||||
code: 1,
|
||||
stdout: expect.stringContaining('"retained_views"'),
|
||||
});
|
||||
return;
|
||||
}
|
||||
const { stdout } = await command;
|
||||
expect(JSON.parse(stdout)).toMatchObject({
|
||||
settings_match: true,
|
||||
facts_match: true,
|
||||
preserved_run_specific_values: [
|
||||
{
|
||||
side: "left",
|
||||
path: ["evidence_ids"],
|
||||
value: leftAnswer.evidence_ids,
|
||||
},
|
||||
{
|
||||
side: "right",
|
||||
path: ["evidence_ids"],
|
||||
value: rightAnswer.evidence_ids,
|
||||
},
|
||||
],
|
||||
});
|
||||
expect(leftAnswer.evidence_ids).not.toEqual(rightAnswer.evidence_ids);
|
||||
expect(leftAnswer.evidence_ids.retained_views[0]).toMatchObject({
|
||||
evidence_id: "ev_" + "1".repeat(64),
|
||||
parent_evidence_id: "ev_" + "1".repeat(63) + "0",
|
||||
});
|
||||
expect(leftAnswer.evidence_ids.native_summary).toBe(
|
||||
"ev_" + "1".repeat(63) + "5",
|
||||
);
|
||||
},
|
||||
);
|
||||
Reference in New Issue
Block a user