chore: integrate upstream verification fixture owners

Integrate repaired Ghidra installation fixtures and the shared CI report invocation owner. Remove the superseded local report-environment override. Preserve Windows caller-evidence content checks through retry/teardown and add the upstream distinct-object identity assertion.

All ten PowerPC admission fixture tests and the original blob-report case pass with GITHUB_STEP_SUMMARY set; seven unrelated cases unselected. No real-Ghidra result is claimed from the fixture host. Original experiment files and measured runtime/data remain unchanged.

Co-authored-by: factory-droid[bot] <138933559+factory-droid[bot]@users.noreply.github.com>
Co-authored-by: Kaoru0822 <208281322+kaoru0822-kitauji@users.noreply.github.com>
This commit is contained in:
N0zoM1z0
2026-10-13 23:31:31 +00:00
co-authored by factory-droid[bot] <138933559+factory-droid[bot]@users.noreply.github.com> Kaoru0822
44 changed files with 728 additions and 254 deletions
@@ -0,0 +1,140 @@
import { join } from "node:path";
import { expect } from "vitest";
import { createTestTempDirectory } from "../../fixtures/temporaryDirectory.js";
import { cliTest } from "../../support/cli/cliFixture.js";
import { analyzeJavaScriptDirectory } from "../../support/cli/javascriptApplication.js";
import { writeFixtureFiles } from "../../support/javascriptApplicationFixture.js";
cliTest.for(["CLI", "stdio MCP"] as const)(
"maps arguments to runtime TypeScript parameters through %s",
async (surface, { cli, processes }) => {
const root = await createTestTempDirectory("rea-this-parameters-");
await writeFixtureFiles(root, {
"bundle.mts": [
"self.webpackChunkApp.push([[1], { 7: function(this: void, module: unknown, exports: Record<string, unknown>, require: (id: number) => unknown) { exports.answer = 42; } }, function(this: void, require: (id: number) => unknown) { require(7); }]);",
].join("\n"),
"interop.cts": [
"function identity<T>(this: void, value: T) { return value; }",
'const electron = identity(require("electron"));',
'electron.ipcRenderer.send("typed-identity");',
].join("\n"),
"ipc-wrapper.cts": [
'const { ipcRenderer } = require("electron");',
"function send(this: void, channel: string) { ipcRenderer.send(channel); }",
"function sendRest(this: void, ...channels: string[]) { ipcRenderer.send(...channels); }",
'send("typed-channel");',
'sendRest("typed-rest");',
].join("\n"),
"entry.mts": [
"function first(this: void, value: number) { return value; }",
"function rest(this: void, ...values: number[]) { return values; }",
"function destructured({ left }: { left: number }, right: number) { return left + right; }",
"function mixed(this: void, head: number, ...tail: number[]) { return [head, ...tail]; }",
"const a = first(7);",
"const b = rest(1, 2);",
"const c = destructured({ left: 3 }, 4);",
"const d = mixed(9, 10, 11);",
"console.log(JSON.stringify([a, b, c, d, first.length, rest.length, mixed.length]));",
].join("\n"),
});
const control = await processes.run(
process.execPath,
[join(root, "entry.mts")],
{ timeoutMs: 15_000 },
);
expect(control.exitCode, control.stderr).toBe(0);
expect(JSON.parse(control.stdout)).toEqual([
7,
[1, 2],
7,
[9, 10, 11],
1,
0,
1,
]);
const analysis = await analyzeJavaScriptDirectory(surface, cli, root);
const graph = analysis.semantic_graph;
const parameters = graph.nodes.filter(
(node) =>
node.kind === "parameter" && node.identity.module_path === "entry.mts",
);
expect(parameters.map((node) => node.label).sort()).toEqual([
"head",
"left",
"right",
"tail",
"value",
"values",
]);
const parameterIds = new Set(parameters.map((node) => node.node_id));
const flows = graph.relations.filter(
(relation) =>
relation.relation === "argument-to-parameter" &&
parameterIds.has(relation.target_node_id),
);
expect(
flows
.map((flow) => {
const source = graph.nodes.find(
(node) => node.node_id === flow.source_node_id,
);
const target = parameters.find(
(node) => node.node_id === flow.target_node_id,
);
const owner = graph.nodes.find(
(node) => node.node_id === target?.function_node_id,
);
return [
source?.identity.source_range?.start.line,
source?.label,
owner?.label,
target?.label,
];
})
.sort(),
).toEqual([
[5, "argument 0", "first", "value"],
[6, "argument 0", "rest", "values"],
[6, "argument 1", "rest", "values"],
[7, "argument 0", "destructured", "left"],
[7, "argument 1", "destructured", "right"],
[8, "argument 0", "mixed", "head"],
[8, "argument 1", "mixed", "tail"],
[8, "argument 2", "mixed", "tail"],
]);
expect(
analysis.graph.nodes
.flatMap((node) => node.observations)
.some(
(observation) =>
Array.isArray(observation.properties.exports) &&
observation.properties.exports.includes("answer"),
),
).toBe(true);
const channels = analysis.graph.nodes
.filter((node) => node.kind === "ipc-channel")
.flatMap((node) =>
node.observations.map((observation) => observation.properties.channel),
);
expect(channels).toEqual(
expect.arrayContaining(["typed-channel", "typed-rest", "typed-identity"]),
);
for (const [name, arity] of [
["first", 1],
["rest", 1],
["destructured", 2],
["mixed", 2],
] as const) {
const callable = graph.nodes.find(
(node) => node.kind === "function" && node.label === name,
);
expect(callable, name).toBeDefined();
const fingerprint = graph.fingerprints.find(
(value) => value.function_node_id === callable?.node_id,
);
expect(fingerprint?.components.parameter_arity, name).toBe(arity);
}
},
);
+53 -63
View File
@@ -17,6 +17,32 @@ import { workflowGit } from "../../support/workflowGit.js";
const execute = promisify(execFile);
const script = new URL("../../../scripts/ci/test-report.mjs", import.meta.url);
// Each report invocation owns its CI state and summary destination. Inherited
// workflow flags must not change fixture outcomes or append to the real job.
const executeTimingReport = async (
root: string,
environment: NodeJS.ProcessEnv = {},
) => {
const summary = join(root, "summary.md");
await writeFile(summary, "");
const output = await execute(process.execPath, [fileURLToPath(script)], {
cwd: root,
env: {
...process.env,
SHARD_RESULT: "success",
MERGE_RESULT: "success",
SOURCE_REQUIRED: "false",
SOURCE_RESULT: "",
CI_VERIFY_TEST_INVENTORY: "false",
CI_TEST_SELECTION: "",
...environment,
GITHUB_STEP_SUMMARY: summary,
},
});
return { ...output, summary: await readFile(summary, "utf8") };
};
const stepsSchema = z.array(
z.object({
name: z.string().optional(),
@@ -225,14 +251,8 @@ it("rejects successful shard reports with missing or duplicate portable files",
files: names.map((name) => ({ name, durationMs: 1 })),
}),
);
return execute(process.execPath, [fileURLToPath(script)], {
cwd: root,
env: {
...process.env,
SHARD_RESULT: "success",
MERGE_RESULT: "success",
CI_VERIFY_TEST_INVENTORY: "true",
},
return executeTimingReport(root, {
CI_VERIFY_TEST_INVENTORY: "true",
});
};
await expect(
@@ -308,17 +328,11 @@ it("exports portable timing history and removes it on a failed, partial, or inva
source?: string,
) => {
await writeFile(join(root, "test-timings.json"), JSON.stringify(value));
await writeFile(summary, "");
return execute(process.execPath, [fileURLToPath(script)], {
cwd: root,
env: {
...process.env,
GITHUB_STEP_SUMMARY: summary,
SHARD_RESULT: shards,
SOURCE_REQUIRED: String(source !== undefined),
SOURCE_RESULT: source ?? "",
MERGE_RESULT: merge,
},
return executeTimingReport(root, {
SHARD_RESULT: shards,
SOURCE_REQUIRED: String(source !== undefined),
SOURCE_RESULT: source ?? "",
MERGE_RESULT: merge,
});
};
await run(report);
@@ -381,7 +395,6 @@ it("exports portable timing history and removes it on a failed, partial, or inva
});
it("recovers complete module costs from real blob reports without executing tests again", async () => {
const reportEnvironment = { ...process.env, GITHUB_STEP_SUMMARY: "" };
const root = await createTestTempDirectory("rea-ci-module-timing-");
const config = join(root, "vitest.config.mjs");
await writeFile(
@@ -406,7 +419,7 @@ it("recovers complete module costs from real blob reports without executing test
const run = (args: string[]) =>
execute(process.execPath, [vitest, ...args, "--config", config], {
cwd: root,
env: reportEnvironment,
env: process.env,
timeout: 20_000,
});
await run(["run", "--reporter=blob"]);
@@ -459,29 +472,17 @@ it("recovers complete module costs from real blob reports without executing test
expect(file.durationMs).toBeCloseTo(
Object.values(file.phases).reduce((sum, value) => sum + value, 0),
);
const partial = await execute(process.execPath, [fileURLToPath(script)], {
cwd: root,
env: {
...reportEnvironment,
SHARD_RESULT: "skipped",
SOURCE_REQUIRED: "true",
SOURCE_RESULT: "success",
MERGE_RESULT: "success",
},
const partial = await executeTimingReport(root, {
SHARD_RESULT: "skipped",
SOURCE_REQUIRED: "true",
SOURCE_RESULT: "success",
});
expect(partial.stdout).toContain("Partial test diagnostics");
expect(partial.stdout).toContain("sample.test.js");
expect(partial.summary).toContain("Partial test diagnostics");
expect(partial.summary).toContain("sample.test.js");
await expect(
readFile(join(root, ".cache/ci-test-history/test-results.json")),
).rejects.toMatchObject({ code: "ENOENT" });
await execute(process.execPath, [fileURLToPath(script)], {
cwd: root,
env: {
...reportEnvironment,
SHARD_RESULT: "success",
MERGE_RESULT: "success",
},
});
await executeTimingReport(root);
expect(
parseTestDurations(
await readFile(
@@ -513,14 +514,7 @@ it("recovers complete module costs from real blob reports without executing test
files: [{ state: "failed" }],
});
// Even a caller accidentally marking the merge successful cannot publish this report.
await execute(process.execPath, [fileURLToPath(script)], {
cwd: root,
env: {
...reportEnvironment,
SHARD_RESULT: "success",
MERGE_RESULT: "success",
},
});
await executeTimingReport(root);
await expect(
readFile(join(root, ".cache/ci-test-history/test-results.json")),
).rejects.toMatchObject({ code: "ENOENT" });
@@ -552,21 +546,17 @@ it("records failed omissions from full reports without treating partial or unhan
};
const run = async (report: unknown, source = "failure") => {
await writeFile(join(root, "test-timings.json"), JSON.stringify(report));
await execute(process.execPath, [fileURLToPath(script)], {
cwd: root,
env: {
...process.env,
SHARD_RESULT: "failure",
SOURCE_REQUIRED: "true",
SOURCE_RESULT: source,
MERGE_RESULT: "failure",
CI_VERIFY_TEST_INVENTORY: "true",
CI_TEST_SELECTION: JSON.stringify(
planTestSelection(["src/sqlite/Provider.ts"], "pull_request", "fast"),
),
GITHUB_SHA: "merge-sha",
CI_PR_HEAD_SHA: "pr-head-sha",
},
await executeTimingReport(root, {
SHARD_RESULT: "failure",
SOURCE_REQUIRED: "true",
SOURCE_RESULT: source,
MERGE_RESULT: "failure",
CI_VERIFY_TEST_INVENTORY: "true",
CI_TEST_SELECTION: JSON.stringify(
planTestSelection(["src/sqlite/Provider.ts"], "pull_request", "fast"),
),
GITHUB_SHA: "merge-sha",
CI_PR_HEAD_SHA: "pr-head-sha",
});
return JSON.parse(
await readFile(
@@ -3,6 +3,7 @@ import { describe, expect, it } from "vitest";
import { EnhancedTools } from "../../../src/application/EnhancedTools.js";
import { connectGhidraMcp, sessionEvidence } from "./ghidraMcpHarness.js";
import { functionDossierSchema } from "../../../src/domain/hopperValues.js";
import { functionComparisonResultSchema } from "../../../src/domain/functionComparisonSchemas.js";
import { ghidraFunctionDossier } from "../../../src/domain/ghidraValues.fixture.js";
import {
jsonValueSchema,
@@ -14,6 +15,97 @@ import {
type GhidraFunctionOperation,
} from "../../../src/ghidra/GhidraFunctionValues.js";
it.each([true, false])(
"compares observed empty Ghidra facets while preserving pseudocode availability (%s)",
async (pseudocodeAvailable) => {
const dossier = functionDossierSchema.parse(ghidraFunctionDossier());
Object.assign(dossier, {
comments: [],
callers: [],
callees: [],
incoming_references: [],
outgoing_references: [],
referenced_strings: [],
referenced_names: [],
pseudocode: pseudocodeAvailable ? dossier.pseudocode : "",
facet_availability: {
pseudocode: pseudocodeAvailable
? { available: true }
: { available: false, reason: "Ghidra did not supply pseudocode." },
assembly: { available: true },
comments: { available: true },
callers: { available: true },
callees: { available: true },
references: { available: true },
strings_names: { available: true },
cfg: { available: true },
},
});
const harness = await connectGhidraMcp(
"ghidra-empty-dossier-coverage",
(operation) => {
if (operation !== "analyze_function")
throw new Error(`Unexpected operation: ${operation}`);
return Promise.resolve(
ok({ value: jsonValueSchema.parse(dossier), limitations: [] }),
);
},
);
try {
const analyzed = await harness.mcp.callTool({
name: "analyze_function",
arguments: { procedure: dossier.procedure.address },
});
expect(analyzed.isError).not.toBe(true);
const evidence = sessionEvidence(
harness.session,
analyzed.structuredContent,
);
expect(evidence.relationship_coverage).toMatchObject({
status: "complete",
});
expect(evidence.normalized_result).toEqual(dossier);
const reply = await harness.mcp.callTool({
name: "compare_functions",
arguments: { left: evidence, right: evidence },
});
expect(reply.isError).not.toBe(true);
const comparison = functionComparisonResultSchema.parse(
sessionEvidence(harness.session, reply.structuredContent)
.normalized_result,
);
expect(
Object.fromEntries(
comparison.dimensions.map(({ dimension, status }) => [
dimension,
status,
]),
),
).toEqual({
identity: "unchanged",
pseudocode: pseudocodeAvailable ? "unchanged" : "unknown",
assembly: "unchanged",
comments: "unchanged",
calls: "unchanged",
references: "unchanged",
strings_names: "unchanged",
cfg: "unchanged",
});
const replay = await harness.session.execute(
"analyze_function",
evidence.parameters,
);
if (!replay.ok) throw replay.error;
expect(replay.value.relationshipCoverage).toEqual(
evidence.relationship_coverage,
);
expect(harness.calls).toEqual(["analyze_function"]);
} finally {
await harness.close();
}
},
);
it("retains terminal-call qualifications across function views and snapshot replay", async () => {
const limitation =
"Ghidra Listing reports a terminal call at 0x401000 to EXTERNAL:0x20 __tls_get_addr (external=true, thunk=false, hasNoReturn=true); fallthrough is excluded by Ghidra's flow model. This records Ghidra's FunctionManager flag, not an independent verification that the callee cannot return.";
+1 -4
View File
@@ -246,10 +246,7 @@ const resultBuilders = new Map<GhidraOperation, GhidraResultBuilder>([
}),
],
["xrefs", () => ["0x401001"]],
[
"analyze_function",
(input) => ghidraFunctionDossier(input.include_assembly === true),
],
["analyze_function", () => ghidraFunctionDossier()],
]);
const resultFor = (
@@ -106,6 +106,8 @@ describe("Hopper analysis profiles", () => {
value: {
profile: {
parameters: {
function_dossier_coverage:
"observed-facets-and-call-relationships-v1",
loader: {
source: scenario.source,
arguments: scenario.arguments,
@@ -167,6 +167,19 @@ describe("Hopper API facade", () => {
},
native_api: null,
native_value_flow: null,
facet_availability: {
pseudocode: {
available: false,
reason: "Hopper did not supply pseudocode.",
},
assembly: { available: true },
comments: { available: true },
callers: { available: true },
callees: { available: true },
references: { available: true },
strings_names: { available: true },
cfg: { available: true },
},
});
expect(result.provider_faults.map((reply) => reply.error.message)).toEqual([
"TypeError: Hopper bridge operation failed",
+1 -1
View File
@@ -8,7 +8,7 @@ volatile int rea_c_global = 7;
/* Keep the full-size literal even when a loader does not type it as a string. */
__attribute__((used)) const char rea_long_literal[] =
"REA_LONG_LITERAL_" REA_LONG_1024 REA_LONG_1024 REA_LONG_1024 REA_LONG_1024 "needle";
/* Linux Hopper 6.4.2 recognizes this extent and splits it into native objects. */
/* Verified Hopper loaders recognize this extent and split it into native objects. */
__attribute__((used)) const char rea_fragmented_literal[] =
"REA_FRAGMENTED_LITERAL_" REA_LONG_256 REA_LONG_256 "fragment_tail";
__attribute__((used)) const char rea_utf8_literal[] = "REA_UTF8_é_😀";
@@ -1,6 +1,9 @@
import { expect, it } from "vitest";
import { verifyHopperStringObjects } from "../../../../scripts/lib/real-hopper-search.mjs";
import {
verifyHopperStringFragments,
verifyHopperStringObjects,
} from "../../../../scripts/lib/real-hopper-search.mjs";
const value = "REA_UTF8_é_😀";
const address = "0x402020";
@@ -22,6 +25,100 @@ const expectation = {
recognitionOptional: true,
};
const fragments = [
{
...item,
value: "REA_",
string: { ...item.string, termination: "missing" as const, byte_length: 4 },
},
{
...item,
address: "0x402024",
value: value.slice(4),
string: { ...item.string, byte_length: bytes.length - 4 },
},
] as const;
const fragmentBytes = async (
name: string,
args: Record<string, unknown> = {},
) => {
if (name !== "read_bytes") throw new Error(`Unmodeled call: ${name}`);
const offset =
args.address === expectation.symbol
? 0
: Number(BigInt(String(args.address)) - BigInt(address));
return {
address: `0x${(BigInt(address) + BigInt(offset)).toString(16)}`,
complete: true,
bytes_hex: bytes
.subarray(offset, offset + Number(args.length))
.toString("hex"),
};
};
it("verifies contiguous native fragments against the complete source bytes", async () => {
const result = await verifyHopperStringFragments(
fragmentBytes,
fragments,
expectation,
);
expect(result.recognition).toEqual({
address,
state: "observed",
decodedObject: "verified",
});
expect(result.sourceBytes).toBe(bytes.length);
});
it("reports unrecognized source bytes without accepting identical text at another address", async () => {
const elsewhere = [{ ...item, address: "0x403000" }];
const result = await verifyHopperStringFragments(
fragmentBytes,
elsewhere,
expectation,
);
expect(result.recognition).toEqual({
address,
state: "not_observed",
decodedObject: "unverified",
});
await expect(
verifyHopperStringFragments(fragmentBytes, elsewhere, {
...expectation,
recognitionOptional: false,
}),
).rejects.toThrow(/typed string fragments/u);
});
it.each([
["gap", [fragments[0], { ...fragments[1], address: "0x402025" }]],
["overlap", [fragments[0], { ...fragments[1], address: "0x402023" }]],
["missing prefix", [fragments[1]]],
["wrong decoded value", [{ ...item, value: "X" + value.slice(1) }]],
["missing tail", [fragments[0]]],
])(
"rejects %s even when fragment recognition is optional",
async (_label, inventory) => {
await expect(
verifyHopperStringFragments(fragmentBytes, inventory, expectation),
).rejects.toThrow();
},
);
it("rejects incomplete source bytes even with no native string objects", async () => {
await expect(
verifyHopperStringFragments(
async (name: string, args: Record<string, unknown> = {}) => ({
...(await fragmentBytes(name, args)),
complete: false,
}),
[],
expectation,
),
).rejects.toThrow();
});
it("keeps source identity and unknown decoding when the same text exists elsewhere", async () => {
const report = await verifyHopperStringObjects(
fixtureCall(),