Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
83 commits
Select commit Hold shift + click to select a range
4de50d5
test(raw): pin raw-binary admission and identity
Entrpi Oct 27, 2026
893a023
refactor(raw): carry the raw load selection as one admitted value
Entrpi Oct 27, 2026
56f27b3
feat(raw): state the M-profile raw load contract
Entrpi Oct 27, 2026
f7b4496
feat(raw): admit M-profile loads at a separate base
Entrpi Oct 27, 2026
74b4a2c
feat(raw): give M-profile loads a versioned identity
Entrpi Oct 27, 2026
e1271f9
feat(ghidra): open M-profile loads at their base in Thumb state
Entrpi Oct 27, 2026
5962d2a
test(raw): check saved raw snapshots and schemas stay compatible
Entrpi Oct 27, 2026
6565d11
test(ghidra): verify M-profile raw loads against real Ghidra
Entrpi Oct 27, 2026
ea8ac34
feat(raw): add the armv8.1-m.main variant
Entrpi Oct 28, 2026
8bd006e
fix(ghidra): report Ghidra's ARMv8.1-M loop flow for armv8.1-m.main
Entrpi Oct 28, 2026
b45a7d4
test(ghidra): verify an ARMv8.1-M image against real Ghidra
Entrpi Oct 28, 2026
8d9e15a
refactor: name the variant vocabulary after architecture_variant
Entrpi Oct 28, 2026
63f2552
refactor(ghidra): keep variant decoder limitations beside the languages
Entrpi Oct 28, 2026
56a0587
fix(raw): require base_address with every architecture_variant
Entrpi Oct 28, 2026
808240d
fix(raw): align vector tables as VTOR does and refuse Reset inside them
Entrpi Oct 28, 2026
3bded52
fix(ghidra): key variant coordinates by base, not entry
Entrpi Oct 28, 2026
8315acc
refactor(raw): discriminate the segments load image by layout
Entrpi Oct 28, 2026
a2decdd
docs(raw): record why vector-table words keep their full width
Entrpi Oct 28, 2026
404b60f
docs(raw): record why the seeded entry function is named entry
Entrpi Oct 28, 2026
b381a01
fix(raw): name the refused load input in error details
Entrpi Oct 28, 2026
58ab75f
docs(raw): state that results keep no caller spellings yet
Entrpi Oct 28, 2026
3c4e4f5
docs(raw): explain why reused sessions cannot report stale vector words
Entrpi Oct 28, 2026
891a731
docs(raw): scope architecture_variant to the ARM M profiles
Entrpi Oct 28, 2026
3bc15c9
docs(raw): state each load pairing rule once in open_binary
Entrpi Oct 28, 2026
26cac3d
refactor(ghidra): let session limitations own the variant load facts
Entrpi Oct 28, 2026
33f1d13
refactor(ghidra): launch with the label policy the profile committed
Entrpi Oct 28, 2026
58c7e88
refactor(raw): let the vector-table read carry its length
Entrpi Oct 28, 2026
d7622e8
test(raw): compare saved raw images by their facts, not their prose
Entrpi Oct 28, 2026
36e0908
Merge upstream main into feat-ghidra-mprofile-raw
Entrpi Oct 28, 2026
d708eb4
test(ghidra): expect not-in-listing where the Cortex-M lane stops
Entrpi Oct 28, 2026
beaa182
test(raw): pin raw identity to main after its instruction-status revi…
Entrpi Oct 28, 2026
1b55c3a
test(ghidra): own the Cortex-M lane's LLVM and CLI commands
Entrpi Oct 29, 2026
a7451a0
test(raw): derive the Reset fixtures from one Thumb image
Entrpi Oct 29, 2026
bd985a4
docs(raw-binary): say that recording load spellings would not be addi…
Entrpi Oct 29, 2026
4731755
docs(raw-binary): tell callers how to keep their load spellings
Entrpi Oct 29, 2026
c943559
Merge upstream main into feat-ghidra-mprofile-raw
Entrpi Oct 29, 2026
13906c5
Merge upstream main into feat-ghidra-mprofile-raw
Entrpi Oct 29, 2026
a1c564e
Merge upstream main into feat-ghidra-mprofile-raw
Entrpi Oct 31, 2026
8745130
Merge upstream main into feat-ghidra-mprofile-raw
Entrpi Nov 1, 2026
93cde07
Merge upstream main into feat-ghidra-mprofile-raw
Entrpi Nov 1, 2026
54d4d33
Merge upstream main into feat-ghidra-mprofile-raw
Entrpi Nov 1, 2026
b250be1
Merge upstream main into feat-ghidra-mprofile-raw
Entrpi Nov 4, 2026
18c8965
Merge upstream main into feat-ghidra-mprofile-raw
Entrpi Nov 5, 2026
8aec915
test(ghidra): keep raw digests at main's byte-search and data-type re…
Entrpi Nov 5, 2026
8b78936
Merge upstream main into feat-ghidra-mprofile-raw
Entrpi Nov 5, 2026
a0717a6
Merge upstream main into feat-ghidra-mprofile-raw
Entrpi Nov 5, 2026
f45a6ca
Merge upstream main into feat-ghidra-mprofile-raw
Entrpi Nov 7, 2026
63b4fc8
Merge main into feat-ghidra-mprofile-raw
Entrpi Nov 7, 2026
46a8db4
test(domain): check raw-binary refusal facts, not sentences
Entrpi Nov 7, 2026
1238961
Merge main into feat-ghidra-mprofile-raw
Entrpi Nov 7, 2026
b82751a
Merge main into feat-ghidra-mprofile-raw
Entrpi Nov 7, 2026
7b4d25e
docs(adr): move the M-profile raw load decision into an ADR
Entrpi Nov 7, 2026
9251826
Merge main into feat-ghidra-mprofile-raw
Entrpi Nov 8, 2026
7c9d321
Merge main into feat-ghidra-mprofile-raw
Entrpi Nov 8, 2026
79ae54d
Merge main into feat-ghidra-mprofile-raw
Entrpi Nov 9, 2026
526c456
Merge main into feat-ghidra-mprofile-raw
Entrpi Nov 9, 2026
f0c95ab
test(ghidra): repin digests and replay for main's call-coverage revision
Entrpi Nov 9, 2026
ec36dc9
Merge branch 'main' into feat-ghidra-mprofile-raw
Entrpi Nov 10, 2026
68fa04d
Merge branch 'main' into feat-ghidra-mprofile-raw
Entrpi Nov 10, 2026
8ae3b4e
Merge branch 'main' into feat-ghidra-mprofile-raw
Entrpi Nov 10, 2026
ca775e7
Merge remote-tracking branch 'origin/main' into feat-ghidra-mprofile-raw
Entrpi Nov 11, 2026
69fb296
Merge remote-tracking branch 'origin/main' into feat-ghidra-mprofile-raw
Entrpi Nov 11, 2026
3760d36
chore(plugin): regenerate the skill bundle from the authored skill
Entrpi Nov 11, 2026
f032197
Merge remote-tracking branch 'origin/main' into feat-ghidra-mprofile-raw
Entrpi Nov 14, 2026
da137b0
Merge remote-tracking branch 'origin/main' into feat-ghidra-mprofile-raw
Entrpi Nov 14, 2026
cf445aa
Merge remote-tracking branch 'origin/main' into feat-ghidra-mprofile-raw
Entrpi Nov 21, 2026
9d7ab2c
test(raw): keep the target route diagnostics within the function leng…
Entrpi Nov 22, 2026
dd59ab0
docs(raw): record the M-profile lane on Ghidra 12.2
Entrpi Nov 22, 2026
583ecb7
refactor(raw): read vector words and own the Cortex-M workspace throu…
Entrpi Nov 22, 2026
0edf352
fix(raw): name raw-binary as the format of vector-table read failures
Entrpi Nov 22, 2026
207631c
fix(verify): remove the Cortex-M workspace after a verified run
Entrpi Nov 22, 2026
35fbcb8
chore(verify): record open_binary's input schema with the M-profile l…
Entrpi Nov 22, 2026
3d8e5c3
Merge remote-tracking branch 'origin/main' into feat-ghidra-mprofile-raw
Entrpi Nov 22, 2026
f6415fe
test(cli): expect open_binary's M-profile load flags in the CLI comma…
Entrpi Nov 22, 2026
c8a68a4
test(cli): record the CLI help goldens with the M-profile load flags
Entrpi Nov 22, 2026
0a66d7c
Merge remote-tracking branch 'origin/main' into feat-ghidra-mprofile-raw
Entrpi Nov 22, 2026
14bce8e
docs(raw-binary): qualify snapshot replay under the producer rule
Entrpi Nov 22, 2026
b660ef4
Merge remote-tracking branch 'origin/main' into feat-ghidra-mprofile-raw
Entrpi Nov 22, 2026
77d14bd
test(ghidra): report why Cortex-M verifier cleanup could not be checked
Entrpi Nov 22, 2026
5ecb56d
Merge remote-tracking branch 'origin/main' into feat-ghidra-mprofile-raw
Entrpi Nov 23, 2026
db9bc1d
Merge remote-tracking branch 'origin/main' into feat-ghidra-mprofile-raw
Entrpi Nov 23, 2026
07f639c
Merge remote-tracking branch 'origin/main' into feat-ghidra-mprofile-raw
Entrpi Nov 23, 2026
4f29527
fix(domain): compare raw-load functions by coordinates, not entry pro…
Entrpi Nov 23, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
test(raw): check saved raw snapshots and schemas stay compatible
The segments load image is the first persisted shape these inputs add,
so this commit adds the historical-snapshot and schema checks with it:

- A raw-binary snapshot written at d6f88be, before base_address,
  still parses. It matches the same load admitted today, and its
  load-image Evidence replays and equals what this version produces. An
  M-profile load of the same file does not match it.
- The earlier raw-binary Evidence schema rejects a segments image, so
  readers that predate it refuse the new shape instead of misreading
  it. An unknown segments version is rejected as well.
- The advertised inspect_native_load_image output accepts both the
  saved and the segments images. The advertised open_binary input
  accepts calls from before base_address beside the new inputs, and
  rejects variants outside the table.
  • Loading branch information
Entrpi committed Oct 27, 2026
commit 5962d2a74547116836ed81a4710a2f384d46b643
245 changes: 245 additions & 0 deletions tests/boundary/mcp/rawLoadCompatibility.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,245 @@
import { readFile } from "node:fs/promises";
import { resolve } from "node:path";

import { McpServer } from "@modelcontextprotocol/server";
import { Ajv2020 } from "ajv/dist/2020.js";
import { describe, expect, it } from "vitest";
import { z } from "zod";

import { parseConfig } from "../../../src/config/parseConfig.js";
import { toolContract } from "../../../src/contracts/toolContracts.js";
import {
parseAnalysisSnapshot,
snapshotEvidenceForQuery,
snapshotMatchesBinding,
snapshotMatchesTarget,
} from "../../../src/domain/analysisSnapshot.js";
import type { BinaryTarget } from "../../../src/domain/binaryTargetTypes.js";
import { createEvidence } from "../../../src/domain/evidence.js";
import {
jsonValueSchema,
type JsonValue,
} from "../../../src/domain/jsonValue.js";
import {
nativeLoadImageSchema,
nativeRawLoadImageSchema,
} from "../../../src/domain/native/nativeLoadImage.js";
import {
admittedRawLoad,
vectorTableWords,
} from "../../../src/domain/rawBinary.fixture.js";
import { ghidraProfileInstallationHost as host } from "../../../src/ghidra/GhidraInstallation.fixture.js";
import { attestGhidraRawBinaryLoadImage } from "../../../src/ghidra/GhidraLoadImageValues.js";
import { GhidraProvider } from "../../../src/ghidra/GhidraProvider.js";
import { fixtureRawBinaryLoadImage } from "../../../src/ghidra/GhidraRawBinaryLoadImage.fixture.js";
import { silentLogger } from "../../../src/logger.js";
import { toolRegistrationOptions } from "../../../src/server/toolRegistrationOptions.js";
import { mcpTest } from "../../support/mcp/mcpFixture.js";

// Written by REA at d6f88becd, before base_address existed, from the raw ARM
// load-image fixture with its Ghidra profile. Never regenerate it: it stands
// for snapshots that callers already saved.
const HISTORICAL_SNAPSHOT =
"tests/fixtures/snapshots/rawBinaryBeforeBaseAddress.json";

const historicalSnapshot = async () =>
parseAnalysisSnapshot(
JSON.parse(await readFile(resolve(HISTORICAL_SNAPSHOT), "utf8")),
);

const ghidraProfile = async (target: BinaryTarget) => {
const config = parseConfig({ GHIDRA_INSTALL_DIR: "/ghidra" });
if (!config.ok) throw config.error;
const resolved = await new GhidraProvider(
config.value,
silentLogger,
{},
host,
).resolveAnalysisProfile(target);
if (!resolved.ok) throw resolved.error;
if (resolved.value.profile === null) throw new Error("expected a profile");
return resolved.value.profile;
};

const segmentsImage = () => {
const f = fixtureRawBinaryLoadImage();
const rawLoad = admittedRawLoad(
{
architecture: "arm",
architectureVariant: "armv7-m",
entryPoint: undefined,
baseAddress: "0x8000000",
fileBytes: 8,
},
vectorTableWords(0x20005000, 0x08000003),
);
const target = { ...f.target, rawLoad };
f.observation.language_id = "ARM:LE:32:Cortex";
f.observation.entry_points = [rawLoad.entryPoint];
f.observation.entry_context = [
{
address: rawLoad.entryPoint,
registers: [{ name: "TMode", value_hex: "0x1" }],
},
];
const image = attestGhidraRawBinaryLoadImage(
f.snapshot,
target,
f.observation,
);
if (!image.ok) throw new Error(image.error);
return { target, image: image.value };
};

describe("raw-binary snapshots saved before base_address", () => {
it("replay for the same load admitted today", async () => {
const snapshot = await historicalSnapshot();
const f = fixtureRawBinaryLoadImage();
const target = {
...f.target,
rawLoad: admittedRawLoad({
architecture: "arm",
entryPoint: "0x08000000",
fileBytes: 4,
}),
};
const profile = await ghidraProfile(target);
expect(snapshotMatchesTarget(snapshot.target, target)).toBe(true);
expect(snapshotMatchesBinding(snapshot, target, profile)).toBe(true);
const replayed = snapshotEvidenceForQuery(snapshot, {
target,
bindingProfile: profile,
operation: "inspect_native_load_image",
parameters: {},
provider: profile.provider,
evidenceProfile: profile,
});
if (replayed === undefined) throw new Error("snapshot did not replay");
// The saved image still parses and equals what this version produces.
const current = attestGhidraRawBinaryLoadImage(
f.snapshot,
f.target,
f.observation,
);
if (!current.ok) throw new Error(current.error);
expect(nativeLoadImageSchema.parse(replayed.normalized_result)).toEqual(
current.value,
);
});

it("does not replay for an M-profile load of the same file", async () => {
const snapshot = await historicalSnapshot();
const f = fixtureRawBinaryLoadImage();
const target = {
...f.target,
rawLoad: admittedRawLoad({
architecture: "arm",
architectureVariant: "armv7-m",
entryPoint: "0x8000000",
fileBytes: 4,
}),
};
expect(snapshotMatchesTarget(snapshot.target, target)).toBe(false);
expect(
snapshotMatchesBinding(snapshot, target, await ghidraProfile(target)),
).toBe(false);
});
});

describe("raw-binary load-image Evidence shapes", () => {
it("keeps the earlier raw-binary shape closed to segments images", () => {
// Readers that predate segments parse load images with this schema; they
// refuse the new shape instead of misreading it as a raw-binary image.
const { image } = segmentsImage();
expect(nativeLoadImageSchema.safeParse(image).success).toBe(true);
expect(nativeRawLoadImageSchema.safeParse(image).success).toBe(false);
expect(
nativeLoadImageSchema.safeParse({ ...image, version: 2 }).success,
).toBe(false);
});

mcpTest(
"advertises output that accepts saved and segments images",
async ({ mcp }) => {
const contract = toolContract("inspect_native_load_image");
const server = new McpServer({ name: "raw-load-images", version: "1" });
server.registerTool(
contract.name,
toolRegistrationOptions(contract),
async () => ({ content: [] }),
);
const client = await mcp.connect(server);
const advertised = (await client.listTools()).tools.find(
({ name }) => name === contract.name,
);
if (advertised?.outputSchema === undefined)
throw new Error("Load-image output schema missing");
const ajv = new Ajv2020({ strict: false, validateFormats: false });
const validate = ajv.compile(
z.record(z.string(), z.unknown()).parse(advertised.outputSchema),
);
const evidence = (result: JsonValue) =>
createEvidence(
undefined,
{ id: "ghidra", name: "Ghidra", version: "12.1.4" },
{ operation: contract.name, parameters: {}, result },
);
const saved = (await historicalSnapshot()).entries[0]?.execution.result;
if (saved === undefined) throw new Error("fixture has no entry");
const image = jsonValueSchema.parse(segmentsImage().image);
expect(validate(evidence(saved))).toBe(true);
expect(validate(evidence(image))).toBe(true);
expect(
validate(
evidence(
jsonValueSchema.parse({ ...segmentsImage().image, version: 2 }),
),
),
).toBe(false);
},
);
});

describe("open_binary inputs from before base_address", () => {
mcpTest(
"stay valid in the advertised input schema beside the new inputs",
async ({ mcp }) => {
const contract = toolContract("open_binary");
const server = new McpServer({ name: "raw-load-inputs", version: "1" });
server.registerTool(
contract.name,
toolRegistrationOptions(contract),
async () => ({ content: [] }),
);
const client = await mcp.connect(server);
const advertised = (await client.listTools()).tools.find(
({ name }) => name === contract.name,
);
if (advertised === undefined) throw new Error("open_binary missing");
const ajv = new Ajv2020({ strict: false, validateFormats: false });
const validate = ajv.compile(
z.record(z.string(), z.unknown()).parse(advertised.inputSchema),
);
const legacy = {
path: "/tmp/ecu.bin",
format: "raw-binary",
architecture: "arm",
entry_point: "0x8000000",
};
expect(validate(legacy)).toBe(true);
expect(
validate({
path: "/tmp/flash.bin",
format: "raw-binary",
architecture: "arm",
architecture_variant: "armv8-m.main",
base_address: "0x08000000",
vector_table_address: "0x08000200",
}),
).toBe(true);
expect(validate({ ...legacy, architecture_variant: "cortex-m" })).toBe(
false,
);
},
);
});
Loading