fix(analysis): preserve producer identity and partial evidence

Reconcile Mach-O UUID observations without hiding malformed or conflicting sources. Require source-map identity digests to be supported by consistent observations. Keep truncated Android manifests as partial raw evidence, validate WABT section framing, and reject missing JEB inventories or error-marked success replies.

Consolidate native UUID parsing and simplify capacity and malformed-input fixtures. Focused source and public workflow checks pass, including native arm64e inspection and real WABT framing probes; a successful real JEB GUI project opening remains unverified.
This commit is contained in:
morluto
2026-10-12 12:37:00 +08:00
parent 1c64fe3eff
commit 6fb3a345fe
18 changed files with 680 additions and 50 deletions
+34
View File
@@ -23,6 +23,40 @@ describe("decodeJebToolResult", () => {
});
});
it.each([
[
"structured content",
{
isError: true,
structuredContent: {
success: true,
input_files: [],
units: [],
},
},
],
[
"JSON text",
{
isError: true,
content: [{ type: "text", text: '{"success":true}' }],
},
],
] as const)("rejects error-marked success in %s", (_source, result) => {
expect(() => decodeJebToolResult(result)).toThrow(AnalysisProtocolError);
});
it("preserves an explicit JEB failure envelope returned as JSON text", () => {
expect(
decodeJebToolResult({
isError: true,
content: [
{ type: "text", text: '{"success":false,"message":"missing"}' },
],
}),
).toEqual({ success: false, message: "missing" });
});
it("decodes a single JSON text block", () => {
expect(
decodeJebToolResult({
+23 -14
View File
@@ -38,26 +38,35 @@ export const decodeJebToolResult = (input: unknown): JsonValue => {
const blocks = result.content.flatMap((block) =>
block.type === "text" && block.text !== undefined ? [block.text] : [],
);
let decoded: JsonValue;
if (result.structuredContent !== undefined) {
// isError envelopes carry JEB's {success:false, message} refusal semantics;
// decode them so the provider can preserve the engine's own reason.
return jsonValueSchema.parse(result.structuredContent);
}
if (blocks.length !== 1)
throw new AnalysisProtocolError(
"JEB MCP omitted a single structured or text result; unsupported content cannot establish an empty observation.",
);
try {
return jsonValueSchema.parse(JSON.parse(blocks[0] ?? "null"));
} catch {
if (result.isError === true)
decoded = jsonValueSchema.parse(result.structuredContent);
} else {
if (blocks.length !== 1)
throw new AnalysisProtocolError(
`JEB MCP tool failed: ${blocks[0] ?? "unexplained engine failure"}`,
"JEB MCP omitted a single structured or text result; unsupported content cannot establish an empty observation.",
);
return blocks[0] ?? null;
const text = blocks[0] ?? "null";
try {
decoded = jsonValueSchema.parse(JSON.parse(text));
} catch {
decoded = text;
}
}
if (result.isError === true && !isJebFailureEnvelope(decoded))
throw new AnalysisProtocolError(
`JEB MCP tool failed: ${blocks[0] ?? "error-marked result without a JEB failure envelope"}`,
{ cause: decoded },
);
return decoded;
};
const isJebFailureEnvelope = (value: JsonValue): boolean =>
typeof value === "object" &&
value !== null &&
!Array.isArray(value) &&
value.success === false;
export type JebMcpConnectionFactory = (endpoint: URL) => JebMcpConnection;
/** Serve JEB requests from a running engine client over streamable HTTP. */
+57
View File
@@ -165,6 +165,63 @@ describe("JebProvider boundary", () => {
});
});
describe("JebProvider open project inventories", () => {
it.each(["input_files", "units"] as const)(
"rejects an omitted %s inventory from a successful project response",
async (omitted) => {
const project = {
success: true,
name: "empty-project",
creation_datetime: "2026-10-12T00:00:00",
input_files: [],
units: [],
};
const response = { ...project };
delete response[omitted];
const provider = providerWith(
scriptedConnection({
get_client_information: { success: true, version: "5.48.0" },
open_project: response,
}),
);
const result = await provider.execute({
operation: "open_jeb_project",
input: { path: "probe.apk" },
});
if (result.ok) throw new Error("Expected an omitted inventory failure");
expect(result.error).toBeInstanceOf(AnalysisProtocolError);
},
);
it("preserves explicitly empty project inventories", async () => {
const provider = providerWith(
scriptedConnection({
get_client_information: { success: true, version: "5.48.0" },
open_project: {
success: true,
name: "empty-project",
creation_datetime: "2026-10-12T00:00:00",
input_files: [],
units: [],
},
}),
);
const result = await provider.execute({
operation: "open_jeb_project",
input: { path: "probe.apk" },
});
if (!result.ok) throw result.error;
expect(result.value.result).toMatchObject({
input_files: [],
units: [],
});
});
});
describe("JebProvider target and endpoint selection", () => {
it("keeps the implicitly selected unit unknown when unit_path is omitted", async () => {
const provider = providerWith(
+10 -12
View File
@@ -69,16 +69,14 @@ const openProject = z
success: z.literal(true),
name: z.string().nullish(),
creation_datetime: z.string().nullish(),
input_files: z
.array(
z.object({
file_name: z.string(),
file_size: z.number().int().nonnegative(),
contents_sha256_hash: z.string(),
}),
)
.optional(),
units: z.array(unitEntry).optional(),
input_files: z.array(
z.object({
file_name: z.string(),
file_size: z.number().int().nonnegative(),
contents_sha256_hash: z.string(),
}),
),
units: z.array(unitEntry),
})
.passthrough();
const listUnits = z
@@ -292,8 +290,8 @@ export class JebProvider implements JebAnalysisPort {
engine,
project_name: opened.name ?? null,
creation_datetime: opened.creation_datetime ?? null,
input_files: opened.input_files ?? [],
units: opened.units ?? [],
input_files: opened.input_files,
units: opened.units,
});
return ok(
createAnalysisExecution(result, this.#identity, {