fix(experiments): reject reused native view identities
Check the distinct-reference verification claim across all selected facets and the optional summary without re-running providers or models. 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
ba5cf12bfa
commit
0e92a5da28
@@ -8,6 +8,7 @@ const retainedEntryViews = async (call, info, inputSha, ToolFailure) => {
|
||||
const n = normalized(info);
|
||||
const retainedViews = [];
|
||||
const retainedViewEvidence = [];
|
||||
const observedEvidenceIds = new Set([info.evidence_id]);
|
||||
let nativeSummaryOutcome, summaryEvidenceId;
|
||||
for (const facet of ["procedure", "pseudocode", "callers", "callees"]) {
|
||||
const selected = await call("inspect_analysis_view", {
|
||||
@@ -20,6 +21,8 @@ const retainedEntryViews = async (call, info, inputSha, ToolFailure) => {
|
||||
},
|
||||
});
|
||||
const view = normalized(selected);
|
||||
if (observedEvidenceIds.has(selected.evidence_id))
|
||||
throw new Error("Retained native view reused an Evidence identity");
|
||||
const expected =
|
||||
facet === "procedure"
|
||||
? n.procedure
|
||||
@@ -29,12 +32,12 @@ const retainedEntryViews = async (call, info, inputSha, ToolFailure) => {
|
||||
if (
|
||||
!isDeepStrictEqual(view.item, expected) ||
|
||||
view.parent_evidence_id !== info.evidence_id ||
|
||||
view.artifact.sha256 !== inputSha ||
|
||||
selected.evidence_id === info.evidence_id
|
||||
view.artifact.sha256 !== inputSha
|
||||
)
|
||||
throw new Error(
|
||||
"Retained native view changed the selected source facts or identity",
|
||||
);
|
||||
observedEvidenceIds.add(selected.evidence_id);
|
||||
retainedViews.push({
|
||||
facet,
|
||||
item: view.item,
|
||||
@@ -55,6 +58,8 @@ const retainedEntryViews = async (call, info, inputSha, ToolFailure) => {
|
||||
source: { kind: "retained-evidence", evidence_id: info.evidence_id },
|
||||
view: { kind: "summary" },
|
||||
});
|
||||
if (observedEvidenceIds.has(summary.evidence_id))
|
||||
throw new Error("Native summary reused an Evidence identity");
|
||||
nativeSummaryOutcome = { status: "supported" };
|
||||
summaryEvidenceId = summary.evidence_id;
|
||||
} catch (error) {
|
||||
|
||||
@@ -14,6 +14,7 @@ const execute = promisify(execFile);
|
||||
const generate = `
|
||||
import {measureNativeEntry} from './experiments/analysis-efficiency/native-entry.mjs';
|
||||
const sha='0'.repeat(64);
|
||||
const duplicate=process.argv[1]==='duplicate';
|
||||
const dossier={procedure:{address:'0x1000'},pseudocode:'return;',callers:[],callees:[]};
|
||||
class ToolFailure extends Error {}
|
||||
const build=async digit=>{
|
||||
@@ -23,7 +24,7 @@ const build=async digit=>{
|
||||
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);
|
||||
const id='ev_'+digit.repeat(63)+(duplicate?1:++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];
|
||||
@@ -34,6 +35,21 @@ const build=async digit=>{
|
||||
process.stdout.write(JSON.stringify([await build('1'),await build('2')]));
|
||||
`;
|
||||
|
||||
it("rejects a producer that reuses a view identity across facets", async () => {
|
||||
await expect(
|
||||
execute(process.execPath, [
|
||||
"--input-type=module",
|
||||
"-e",
|
||||
generate,
|
||||
"duplicate",
|
||||
]),
|
||||
).rejects.toMatchObject({
|
||||
stderr: expect.stringContaining(
|
||||
"Retained native view reused an Evidence identity",
|
||||
),
|
||||
});
|
||||
});
|
||||
|
||||
it.each(["references", "item", "coverage", "limitations", "unknowns"])(
|
||||
"separates native references while comparing %s exactly",
|
||||
async (change) => {
|
||||
|
||||
Reference in New Issue
Block a user