fix!: restore caching, preserve failures, and verify fixture claims (#1211)
Restore profile-bound Ghidra snapshot reuse, preserve direct-analysis results through cleanup failures, and grade configured agent fixture claims against returned evidence. Register the compiled agent-evaluation fixture entry for static analysis. Co-authored-by: YouWish <29498139+Y0UW1SH@users.noreply.github.com> Co-authored-by: N0zoM1z0 <161784452+N0zoM1z0@users.noreply.github.com>
This commit is contained in:
@@ -0,0 +1,163 @@
|
||||
import { readFile } from "node:fs/promises";
|
||||
|
||||
import { parse } from "@babel/parser";
|
||||
import { describe, expect, it } from "vitest";
|
||||
|
||||
import {
|
||||
agentEvaluationPassed,
|
||||
summarizeFactualCorrectness,
|
||||
} from "../../../src/evaluation/AgentEvaluationReport.js";
|
||||
|
||||
const routingSuccess = {
|
||||
exitCode: 0,
|
||||
naturalUse: true,
|
||||
correctFirstTool: true,
|
||||
repeatedCallCount: 0,
|
||||
inputValidationFailureCount: 0,
|
||||
requiredToolSubsequenceMet: true,
|
||||
inputTokens: 100,
|
||||
answerHeuristicsMet: true,
|
||||
epistemicCuePresent: true,
|
||||
};
|
||||
|
||||
describe("agent evaluation release gate", () => {
|
||||
it("rejects incorrect fixture claims even when every text heuristic passes", async () => {
|
||||
const predicate = await runnerFailurePredicate();
|
||||
expect(
|
||||
predicate({
|
||||
exitCode: 0,
|
||||
naturalUse: true,
|
||||
correctFirstTool: true,
|
||||
repeatedCallCount: 0,
|
||||
inputValidationFailureCount: 0,
|
||||
requiredToolSubsequenceMet: true,
|
||||
inputTokens: 100,
|
||||
answerHeuristicsMet: true,
|
||||
epistemicCuePresent: true,
|
||||
factualCorrectness: "failed",
|
||||
}),
|
||||
).toBe(true);
|
||||
});
|
||||
});
|
||||
|
||||
async function runnerFailurePredicate(): Promise<(item: unknown) => unknown> {
|
||||
const source = await readFile("scripts/verify-agent-experience.mjs", "utf8");
|
||||
const program = parse(source, { sourceType: "module" }).program;
|
||||
for (const top of program.body) {
|
||||
if (top.type !== "TryStatement") continue;
|
||||
for (const statement of top.block.body) {
|
||||
if (statement.type !== "VariableDeclaration") continue;
|
||||
for (const declaration of statement.declarations) {
|
||||
if (
|
||||
declaration.id.type !== "Identifier" ||
|
||||
declaration.id.name !== "failed"
|
||||
)
|
||||
continue;
|
||||
const initializer = declaration.init;
|
||||
if (initializer?.type !== "CallExpression") continue;
|
||||
const argument = initializer.arguments[0];
|
||||
if (
|
||||
argument?.type !== "ArrowFunctionExpression" ||
|
||||
typeof argument.start !== "number" ||
|
||||
typeof argument.end !== "number"
|
||||
)
|
||||
continue;
|
||||
const factory = new Function(
|
||||
"agentEvaluationPassed",
|
||||
`return (${source.slice(argument.start, argument.end)});`,
|
||||
);
|
||||
const result: unknown = factory(agentEvaluationPassed);
|
||||
if (typeof result !== "function")
|
||||
throw new Error("Runner gate is not callable");
|
||||
return (item) => result(item);
|
||||
}
|
||||
}
|
||||
}
|
||||
throw new Error("Runner failure gate missing");
|
||||
}
|
||||
|
||||
describe("scoped factual report", () => {
|
||||
it("accepts correct structured facts without superficial prose cues", () => {
|
||||
expect(
|
||||
agentEvaluationPassed({
|
||||
...routingSuccess,
|
||||
answerHeuristicsMet: false,
|
||||
epistemicCuePresent: false,
|
||||
factualCorrectness: "passed",
|
||||
}),
|
||||
).toBe(true);
|
||||
});
|
||||
|
||||
it("retains workflow and execution checks for factually correct answers", () => {
|
||||
for (const change of [
|
||||
{ exitCode: 1 },
|
||||
{ naturalUse: false },
|
||||
{ correctFirstTool: false },
|
||||
{ repeatedCallCount: 1 },
|
||||
{ inputValidationFailureCount: 1 },
|
||||
{ requiredToolSubsequenceMet: false },
|
||||
{ inputTokens: 0 },
|
||||
])
|
||||
expect(
|
||||
agentEvaluationPassed({
|
||||
...routingSuccess,
|
||||
factualCorrectness: "passed",
|
||||
...change,
|
||||
}),
|
||||
).toBe(false);
|
||||
});
|
||||
|
||||
it("retains heuristic checks only for unassessed scenarios", () => {
|
||||
expect(
|
||||
agentEvaluationPassed({
|
||||
...routingSuccess,
|
||||
factualCorrectness: "not_assessed",
|
||||
}),
|
||||
).toBe(true);
|
||||
expect(
|
||||
agentEvaluationPassed({
|
||||
...routingSuccess,
|
||||
factualCorrectness: "not_assessed",
|
||||
answerHeuristicsMet: false,
|
||||
}),
|
||||
).toBe(false);
|
||||
expect(
|
||||
agentEvaluationPassed({
|
||||
...routingSuccess,
|
||||
factualCorrectness: "not_assessed",
|
||||
epistemicCuePresent: false,
|
||||
}),
|
||||
).toBe(false);
|
||||
expect(
|
||||
agentEvaluationPassed({
|
||||
...routingSuccess,
|
||||
factualCorrectness: "failed",
|
||||
}),
|
||||
).toBe(false);
|
||||
});
|
||||
|
||||
it("reports assessed failures separately from unassessed scenarios", () => {
|
||||
expect(
|
||||
summarizeFactualCorrectness([
|
||||
{ factualCorrectness: "passed" },
|
||||
{ factualCorrectness: "failed" },
|
||||
{ factualCorrectness: "not_assessed" },
|
||||
]),
|
||||
).toEqual({
|
||||
status: "failed",
|
||||
scope: "configured_fixture_claims",
|
||||
counts: { assessed: 2, passed: 1, failed: 1, notAssessed: 1 },
|
||||
});
|
||||
expect(
|
||||
summarizeFactualCorrectness([
|
||||
{ factualCorrectness: "passed" },
|
||||
{ factualCorrectness: "not_assessed" },
|
||||
]).status,
|
||||
).toBe("passed");
|
||||
expect(
|
||||
summarizeFactualCorrectness([{ factualCorrectness: "not_assessed" }])
|
||||
.status,
|
||||
).toBe("not_assessed");
|
||||
expect(summarizeFactualCorrectness([]).status).toBe("not_assessed");
|
||||
});
|
||||
});
|
||||
@@ -3,7 +3,7 @@ import { describe, expect, it } from "vitest";
|
||||
import { evaluateCodexEvents } from "../../../src/evaluation/CodexAgentEval.js";
|
||||
|
||||
describe("Codex agent release evaluation", () => {
|
||||
it("measures natural routing, repeated calls, tokens, and epistemic completion", () => {
|
||||
it("measures natural routing, repeated calls, tokens, and answer heuristics", () => {
|
||||
const call = {
|
||||
id: "item-tool-1",
|
||||
type: "mcp_tool_call",
|
||||
@@ -43,8 +43,8 @@ describe("Codex agent release evaluation", () => {
|
||||
inputTokens: 12_345,
|
||||
cachedInputTokens: 10_000,
|
||||
outputTokens: 321,
|
||||
completionQuality: true,
|
||||
authorityHonesty: true,
|
||||
answerHeuristicsMet: true,
|
||||
epistemicCuePresent: true,
|
||||
});
|
||||
expect(metrics.reaCalls).toHaveLength(1);
|
||||
});
|
||||
@@ -79,7 +79,7 @@ describe("Codex agent release evaluation", () => {
|
||||
).toMatchObject({
|
||||
evidenceIds: [evidenceId],
|
||||
finalCitesEvidence: true,
|
||||
completionQuality: true,
|
||||
answerHeuristicsMet: true,
|
||||
});
|
||||
});
|
||||
|
||||
@@ -126,7 +126,53 @@ describe("Codex agent release evaluation", () => {
|
||||
});
|
||||
|
||||
describe("Codex agent completion evaluation", () => {
|
||||
it("requires scenario-specific answer facts when configured", () => {
|
||||
it("does not present matching answer terms as factual correctness or honesty", () => {
|
||||
const evidenceId = `ev_${"a".repeat(64)}`;
|
||||
const metrics = evaluateCodexEvents(
|
||||
[
|
||||
{
|
||||
type: "item.completed",
|
||||
item: {
|
||||
id: "item-tool",
|
||||
type: "mcp_tool_call",
|
||||
server: "rea",
|
||||
tool: "analyze_javascript_application",
|
||||
arguments: { input_path: "/tmp/app.asar" },
|
||||
result: { evidence_id: evidenceId },
|
||||
},
|
||||
},
|
||||
{
|
||||
type: "item.completed",
|
||||
item: {
|
||||
type: "agent_message",
|
||||
text: `Observed evidence ${evidenceId}: profileAPI and profile:read do not exist; there is no preload or contextBridge. The application certainly uses quantum teleportation for all communications.`,
|
||||
},
|
||||
},
|
||||
],
|
||||
"analyze_javascript_application",
|
||||
{
|
||||
requireEvidence: true,
|
||||
requiredAnswerTermGroups: [
|
||||
["profileapi"],
|
||||
["profile:read"],
|
||||
["preload", "contextbridge"],
|
||||
],
|
||||
},
|
||||
);
|
||||
|
||||
expect(metrics).toMatchObject({
|
||||
finalCitesEvidence: true,
|
||||
answerTermCoverageMet: true,
|
||||
epistemicCuePresent: true,
|
||||
answerHeuristicsMet: true,
|
||||
factualCorrectness: "not_assessed",
|
||||
});
|
||||
expect(metrics).not.toHaveProperty("completionQuality");
|
||||
expect(metrics).not.toHaveProperty("authorityHonesty");
|
||||
expect(metrics).not.toHaveProperty("contentCriteriaMet");
|
||||
});
|
||||
|
||||
it("requires scenario-specific answer terms when configured", () => {
|
||||
const event = (text: string) => [
|
||||
{
|
||||
type: "item.completed",
|
||||
@@ -151,7 +197,7 @@ describe("Codex agent completion evaluation", () => {
|
||||
"analyze_javascript_application",
|
||||
options,
|
||||
),
|
||||
).toMatchObject({ contentCriteriaMet: true, completionQuality: true });
|
||||
).toMatchObject({ answerTermCoverageMet: true, answerHeuristicsMet: true });
|
||||
expect(
|
||||
evaluateCodexEvents(
|
||||
event(
|
||||
@@ -160,7 +206,10 @@ describe("Codex agent completion evaluation", () => {
|
||||
"analyze_javascript_application",
|
||||
options,
|
||||
),
|
||||
).toMatchObject({ contentCriteriaMet: false, completionQuality: false });
|
||||
).toMatchObject({
|
||||
answerTermCoverageMet: false,
|
||||
answerHeuristicsMet: false,
|
||||
});
|
||||
});
|
||||
|
||||
it("recognizes Codex MCP failed status when the error field is null", () => {
|
||||
@@ -234,7 +283,7 @@ describe("Codex agent workflow evaluation", () => {
|
||||
expect(valid).toMatchObject({
|
||||
requiredToolSubsequenceMet: true,
|
||||
inputValidationFailureCount: 0,
|
||||
completionQuality: true,
|
||||
answerHeuristicsMet: true,
|
||||
});
|
||||
|
||||
const invalid = evaluateCodexEvents(
|
||||
@@ -254,7 +303,7 @@ describe("Codex agent workflow evaluation", () => {
|
||||
expect(invalid).toMatchObject({
|
||||
requiredToolSubsequenceMet: false,
|
||||
inputValidationFailureCount: 1,
|
||||
completionQuality: false,
|
||||
answerHeuristicsMet: false,
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
@@ -0,0 +1,449 @@
|
||||
import { describe, expect, it } from "vitest";
|
||||
|
||||
import { toolContract } from "../../../src/contracts/toolContracts.js";
|
||||
import { createEvidence, type Evidence } from "../../../src/domain/evidence.js";
|
||||
import type { JsonValue } from "../../../src/domain/jsonValue.js";
|
||||
import { evaluateCodexEvents } from "../../../src/evaluation/CodexAgentEval.js";
|
||||
import type { FixtureClaimExpectation } from "../../../src/evaluation/KnownAnswerEvaluation.js";
|
||||
import { toEvidenceToolResult } from "../../../src/server/toolResult.js";
|
||||
|
||||
const provider = { id: "fixture", name: "Fixture analysis", version: "1" };
|
||||
const subject = {
|
||||
path: "/targets/app.asar",
|
||||
sha256: "a".repeat(64),
|
||||
format: "asar",
|
||||
};
|
||||
const createObservation = (
|
||||
result: JsonValue = {
|
||||
fact: { present: true, channel: "profile:read" },
|
||||
unrelated: 1,
|
||||
},
|
||||
path = subject.path,
|
||||
): Evidence =>
|
||||
createEvidence({ ...subject, path, format: "asar" }, provider, {
|
||||
operation: "analyze_javascript_application",
|
||||
parameters: { format: "asar" },
|
||||
result,
|
||||
confidence: "derived",
|
||||
authority: "shipped-artifact",
|
||||
});
|
||||
const resultFor = (evidence: Evidence) =>
|
||||
toEvidenceToolResult(
|
||||
evidence,
|
||||
toolContract("analyze_javascript_application"),
|
||||
undefined,
|
||||
);
|
||||
const delivered = (
|
||||
evidence: Evidence,
|
||||
overrides: Record<string, unknown> = {},
|
||||
) => ({
|
||||
type: "item.completed",
|
||||
item: {
|
||||
id: evidence.evidence_id,
|
||||
type: "mcp_tool_call",
|
||||
server: "rea",
|
||||
tool: evidence.operation,
|
||||
status: "completed",
|
||||
result: resultFor(evidence),
|
||||
...overrides,
|
||||
},
|
||||
});
|
||||
const final = (text: string) => ({
|
||||
type: "item.completed",
|
||||
item: { type: "agent_message", text },
|
||||
});
|
||||
const claimFor = (
|
||||
evidence: Evidence,
|
||||
overrides: Record<string, unknown> = {},
|
||||
) => ({
|
||||
id: "bridge",
|
||||
value: { present: true, channel: "profile:read" },
|
||||
evidence_id: evidence.evidence_id,
|
||||
confidence: "derived",
|
||||
authority: "shipped-artifact",
|
||||
...overrides,
|
||||
});
|
||||
const expected = (): FixtureClaimExpectation => ({
|
||||
id: "bridge",
|
||||
expectedValue: { present: true, channel: "profile:read" },
|
||||
source: {
|
||||
operation: "analyze_javascript_application",
|
||||
confidence: "derived",
|
||||
authority: "shipped-artifact",
|
||||
subject: { path: subject.path, sha256: subject.sha256 },
|
||||
parameters: { format: "asar" },
|
||||
select: (value) =>
|
||||
value !== null && typeof value === "object" && !Array.isArray(value)
|
||||
? value.fact
|
||||
: undefined,
|
||||
},
|
||||
});
|
||||
const assess = (
|
||||
events: readonly unknown[],
|
||||
text: string,
|
||||
fixtureClaims: readonly FixtureClaimExpectation[] = [expected()],
|
||||
) =>
|
||||
evaluateCodexEvents(
|
||||
[...events, final(text)],
|
||||
"analyze_javascript_application",
|
||||
{
|
||||
fixtureClaims,
|
||||
},
|
||||
);
|
||||
const answer = (claims: readonly unknown[]) => JSON.stringify({ claims });
|
||||
|
||||
// Removing exact fixture comparison or accepted-source validation must break these regressions.
|
||||
describe("known-answer fixture grading", () => {
|
||||
it("passes closed claims against authenticated production MCP Evidence", () => {
|
||||
const evidence = createObservation();
|
||||
expect(
|
||||
assess([delivered(evidence)], answer([claimFor(evidence)])),
|
||||
).toMatchObject({
|
||||
factualCorrectness: "passed",
|
||||
factualAssessment: {
|
||||
scope: "configured_fixture_claims",
|
||||
status: "passed",
|
||||
},
|
||||
});
|
||||
});
|
||||
|
||||
it("rejects fabricated prose despite expected terms and a produced Evidence ID", () => {
|
||||
const evidence = createObservation();
|
||||
const text = `Observed evidence ${evidence.evidence_id}: profileApi and profile:read do not exist; there is no preload or contextBridge. All communications use quantum teleportation.`;
|
||||
expect(assess([delivered(evidence)], text).factualCorrectness).toBe(
|
||||
"failed",
|
||||
);
|
||||
});
|
||||
|
||||
it.each([
|
||||
{ present: false, channel: "profile:read" },
|
||||
{ present: true, channel: "invented:channel" },
|
||||
{ present: true, channel: "profile:read", fabricated: "teleportation" },
|
||||
"profile:read does not exist",
|
||||
])("rejects a wrong or contradictory value %j", (value) => {
|
||||
const evidence = createObservation();
|
||||
expect(
|
||||
assess([delivered(evidence)], answer([claimFor(evidence, { value })]))
|
||||
.factualCorrectness,
|
||||
).toBe("failed");
|
||||
});
|
||||
|
||||
it("retains not_assessed without a fixture rubric", () => {
|
||||
expect(
|
||||
evaluateCodexEvents(
|
||||
[final("Observed metadata remains unknown.")],
|
||||
"analyze_javascript_application",
|
||||
).factualCorrectness,
|
||||
).toBe("not_assessed");
|
||||
});
|
||||
|
||||
it.each([{ rubric: [] }, { rubric: [expected(), expected()] }])(
|
||||
"fails closed for an empty or duplicate rubric",
|
||||
({ rubric }) => {
|
||||
const evidence = createObservation();
|
||||
expect(
|
||||
assess([delivered(evidence)], answer([claimFor(evidence)]), rubric)
|
||||
.factualCorrectness,
|
||||
).toBe("failed");
|
||||
},
|
||||
);
|
||||
|
||||
it("rejects selector failures without crashing the evaluation", () => {
|
||||
const evidence = createObservation();
|
||||
const expectation = expected();
|
||||
const rubric = [
|
||||
{
|
||||
...expectation,
|
||||
source: {
|
||||
...expectation.source,
|
||||
select: () => {
|
||||
throw new TypeError("Malformed result");
|
||||
},
|
||||
},
|
||||
},
|
||||
];
|
||||
expect(
|
||||
assess([delivered(evidence)], answer([claimFor(evidence)]), rubric)
|
||||
.factualCorrectness,
|
||||
).toBe("failed");
|
||||
});
|
||||
});
|
||||
|
||||
describe("closed final claim manifests", () => {
|
||||
it.each([
|
||||
"missing",
|
||||
"duplicate",
|
||||
"unknown",
|
||||
"extra-field",
|
||||
"extra-top-level",
|
||||
"surrounding-prose",
|
||||
"missing-authority",
|
||||
])("rejects %s claims", (kind) => {
|
||||
const evidence = createObservation();
|
||||
const claim = claimFor(evidence);
|
||||
let text = answer([claim]);
|
||||
if (kind === "missing") text = answer([]);
|
||||
if (kind === "duplicate") text = answer([claim, claim]);
|
||||
if (kind === "unknown")
|
||||
text = answer([claim, { ...claim, id: "fabrication" }]);
|
||||
if (kind === "extra-field")
|
||||
text = answer([{ ...claim, explanation: "Also teleportation" }]);
|
||||
if (kind === "extra-top-level")
|
||||
text = JSON.stringify({
|
||||
claims: [claim],
|
||||
explanation: "Also teleportation",
|
||||
});
|
||||
if (kind === "surrounding-prose") text = `${text}\nAlso teleportation.`;
|
||||
if (kind === "missing-authority")
|
||||
text = answer([
|
||||
{
|
||||
id: claim.id,
|
||||
value: claim.value,
|
||||
evidence_id: claim.evidence_id,
|
||||
confidence: claim.confidence,
|
||||
},
|
||||
]);
|
||||
expect(assess([delivered(evidence)], text).factualCorrectness).toBe(
|
||||
"failed",
|
||||
);
|
||||
});
|
||||
|
||||
it("rejects duplicate object members containing contradictory values", () => {
|
||||
const evidence = createObservation();
|
||||
const text = answer([claimFor(evidence)]).replace(
|
||||
'"present":true',
|
||||
'"present":false,"present":true',
|
||||
);
|
||||
expect(assess([delivered(evidence)], text).factualCorrectness).toBe(
|
||||
"failed",
|
||||
);
|
||||
});
|
||||
|
||||
it("fails closed for a deeply nested generated answer", () => {
|
||||
const text = `${"[".repeat(20_000)}null${"]".repeat(20_000)}`;
|
||||
expect(assess([], text).factualCorrectness).toBe("failed");
|
||||
});
|
||||
|
||||
it.each(["confidence", "authority"])("rejects an overstated %s", (field) => {
|
||||
const evidence = createObservation();
|
||||
const claim = claimFor(evidence, {
|
||||
[field]: field === "confidence" ? "observed" : "controlled-replay",
|
||||
});
|
||||
expect(
|
||||
assess([delivered(evidence)], answer([claim])).factualCorrectness,
|
||||
).toBe("failed");
|
||||
});
|
||||
});
|
||||
|
||||
describe("successful Evidence grounding", () => {
|
||||
it.each([
|
||||
{ server: "other" },
|
||||
{ server: null },
|
||||
{ status: "failed" },
|
||||
{ status: "in_progress" },
|
||||
{ error: { code: "unavailable" } },
|
||||
{ tool: "other_tool" },
|
||||
])("rejects a foreign or unsuccessful completion %j", (overrides) => {
|
||||
const evidence = createObservation();
|
||||
expect(
|
||||
assess([delivered(evidence, overrides)], answer([claimFor(evidence)]))
|
||||
.factualCorrectness,
|
||||
).toBe("failed");
|
||||
});
|
||||
|
||||
it("rejects IDs present only in arguments or unrelated metadata", () => {
|
||||
const evidence = createObservation();
|
||||
const event = delivered(evidence, {
|
||||
arguments: { evidence },
|
||||
result: {
|
||||
structuredContent: { metadata: { evidence_id: evidence.evidence_id } },
|
||||
},
|
||||
});
|
||||
expect(
|
||||
assess([event], answer([claimFor(evidence)])).factualCorrectness,
|
||||
).toBe("failed");
|
||||
});
|
||||
|
||||
it("rejects a tampered envelope even with a valid-looking Evidence ID", () => {
|
||||
const evidence = createObservation();
|
||||
const event = delivered(evidence, {
|
||||
result: {
|
||||
structuredContent: {
|
||||
evidence_id: evidence.evidence_id,
|
||||
result: evidence.normalized_result,
|
||||
evidence: { ...evidence, authority: "controlled-replay" },
|
||||
},
|
||||
},
|
||||
});
|
||||
expect(
|
||||
assess([event], answer([claimFor(evidence)])).factualCorrectness,
|
||||
).toBe("failed");
|
||||
});
|
||||
|
||||
it.each(["id", "result", "error"])(
|
||||
"rejects inconsistent or failed MCP wrapper %s",
|
||||
(field) => {
|
||||
const evidence = createObservation();
|
||||
const projection = {
|
||||
evidence_id: evidence.evidence_id,
|
||||
result: evidence.normalized_result,
|
||||
evidence,
|
||||
};
|
||||
const event = delivered(evidence, {
|
||||
result: {
|
||||
structuredContent: {
|
||||
...projection,
|
||||
...(field === "id"
|
||||
? { evidence_id: `ev_${"b".repeat(64)}` }
|
||||
: field === "result"
|
||||
? { result: { fabricated: true } }
|
||||
: {}),
|
||||
},
|
||||
...(field === "error" ? { isError: true } : {}),
|
||||
},
|
||||
});
|
||||
expect(
|
||||
assess([event], answer([claimFor(evidence)])).factualCorrectness,
|
||||
).toBe("failed");
|
||||
},
|
||||
);
|
||||
|
||||
it.each(["error", "contradictory-data"])(
|
||||
"rejects conflicting outer result/output aliases containing %s",
|
||||
(kind) => {
|
||||
const evidence = createObservation();
|
||||
const output =
|
||||
kind === "error"
|
||||
? { isError: true, structuredContent: { error: { code: "denied" } } }
|
||||
: {
|
||||
...resultFor(evidence),
|
||||
structuredContent: {
|
||||
evidence_id: evidence.evidence_id,
|
||||
evidence,
|
||||
result: { fact: { present: false, channel: "profile:read" } },
|
||||
},
|
||||
};
|
||||
const event = delivered(evidence, { output });
|
||||
expect(
|
||||
assess([event], answer([claimFor(evidence)])).factualCorrectness,
|
||||
).toBe("failed");
|
||||
},
|
||||
);
|
||||
|
||||
it("accepts JSON-equal separately allocated outer result/output aliases", () => {
|
||||
const evidence = createObservation();
|
||||
const event = delivered(evidence, { output: resultFor(evidence) });
|
||||
expect(
|
||||
assess([event], answer([claimFor(evidence)])).factualCorrectness,
|
||||
).toBe("passed");
|
||||
});
|
||||
|
||||
it("accepts the documented snake-case structured-content transcript representation", () => {
|
||||
const evidence = createObservation();
|
||||
const event = delivered(evidence, {
|
||||
result: { structured_content: resultFor(evidence).structuredContent },
|
||||
});
|
||||
expect(
|
||||
assess([event], answer([claimFor(evidence)])).factualCorrectness,
|
||||
).toBe("passed");
|
||||
});
|
||||
|
||||
it("rejects authentic unrelated Evidence containing the same value elsewhere", () => {
|
||||
const evidence = createObservation({ unrelated: expected().expectedValue });
|
||||
expect(
|
||||
assess([delivered(evidence)], answer([claimFor(evidence)]))
|
||||
.factualCorrectness,
|
||||
).toBe("failed");
|
||||
});
|
||||
});
|
||||
|
||||
describe("fixture identity and provenance binding", () => {
|
||||
it("rejects Evidence for a different subject despite an equal supported value", () => {
|
||||
const evidence = createObservation(undefined, "/targets/other.asar");
|
||||
expect(
|
||||
assess([delivered(evidence)], answer([claimFor(evidence)]))
|
||||
.factualCorrectness,
|
||||
).toBe("failed");
|
||||
});
|
||||
|
||||
it("rejects a wrong required source parameter", () => {
|
||||
const evidence = createObservation();
|
||||
const expectation = expected();
|
||||
const rubric = [
|
||||
{
|
||||
...expectation,
|
||||
source: { ...expectation.source, parameters: { format: "directory" } },
|
||||
},
|
||||
];
|
||||
expect(
|
||||
assess([delivered(evidence)], answer([claimFor(evidence)]), rubric)
|
||||
.factualCorrectness,
|
||||
).toBe("failed");
|
||||
});
|
||||
|
||||
it("rejects conflicting subject diagnostics for the same semantic Evidence ID", () => {
|
||||
const evidence = createObservation();
|
||||
const conflicting = {
|
||||
...evidence,
|
||||
subject:
|
||||
evidence.subject === null
|
||||
? null
|
||||
: { ...evidence.subject, local_path: "/targets/other.asar" },
|
||||
};
|
||||
expect(
|
||||
assess(
|
||||
[delivered(evidence), delivered(conflicting)],
|
||||
answer([claimFor(evidence)]),
|
||||
).factualCorrectness,
|
||||
).toBe("failed");
|
||||
});
|
||||
|
||||
it("requires linked source Evidence to be delivered and match the configured artifact", () => {
|
||||
const source = createObservation(undefined, "/targets/parser-v1");
|
||||
const evidence = createEvidence({ ...subject, format: "asar" }, provider, {
|
||||
operation: "analyze_javascript_application",
|
||||
parameters: { format: "asar" },
|
||||
result: { fact: expected().expectedValue },
|
||||
confidence: "derived",
|
||||
authority: "shipped-artifact",
|
||||
evidenceLinks: [source.evidence_id],
|
||||
});
|
||||
const expectation = expected();
|
||||
const rubric = [
|
||||
{
|
||||
...expectation,
|
||||
source: {
|
||||
...expectation.source,
|
||||
linkedSubjects: [
|
||||
{
|
||||
operation: source.operation,
|
||||
path: "/targets/parser-v1",
|
||||
sha256: subject.sha256,
|
||||
},
|
||||
],
|
||||
},
|
||||
},
|
||||
];
|
||||
const text = answer([claimFor(evidence)]);
|
||||
expect(assess([delivered(evidence)], text, rubric).factualCorrectness).toBe(
|
||||
"failed",
|
||||
);
|
||||
expect(
|
||||
assess([delivered(source), delivered(evidence)], text, rubric)
|
||||
.factualCorrectness,
|
||||
).toBe("passed");
|
||||
expect(
|
||||
assess([delivered(source), delivered(evidence)], text, [
|
||||
{
|
||||
...expectation,
|
||||
source: {
|
||||
...expectation.source,
|
||||
linkedSubjects: [
|
||||
{ operation: source.operation, path: "/targets/other-parser" },
|
||||
],
|
||||
},
|
||||
},
|
||||
]).factualCorrectness,
|
||||
).toBe("failed");
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user