fix(android): reject invoke coverage without site evidence (#10679)

The JADX bridge emits or removes direct_invokes and direct_invokes_exhaustive together. A protocol item carrying only the coverage flag reached trace_android_references as a reference that claimed true or false coverage over a null site list, while the coverage summary counted it as unknown. The protocol schema now rejects that combination.

Rebased onto current main from morluto/rea#2850. The companion change that removed the null default from the result schema already landed on main.

Co-authored-by: LcokHcak <268763621+LcokHcak@users.noreply.github.com>
This commit is contained in:
David Muñoz ReyandLcokHcak authored and GitHub committed 2026-11-18 10:09:26 -05:00
1 parent c1c9783a9e
commit fbd6fd1c4f
2 files changed
+43 -21

No files matched your search

+32 -21
View File
@@ -162,27 +162,38 @@ export const jadxXrefsSchema = z.object({
count,
resolve_line: z.literal(false),
items: z.array(
z.object({
kind: z.string(),
name: z.string(),
full_name: z.string(),
containing_class: z.string(),
top_class: z.string(),
def_pos: z.int(),
source_selector: androidMethodSelectorSchema.optional(),
direct_invokes_exhaustive: z.boolean().optional(),
direct_invokes: z
.array(
z.object({
dex_entry: z.string().min(1),
source_raw_method_id: z.string().min(1),
dex_code_unit_offset: count,
dex_method_index: count,
opcode: z.string().regex(/^INVOKE_/u),
}),
)
.optional(),
}),
z
.object({
kind: z.string(),
name: z.string(),
full_name: z.string(),
containing_class: z.string(),
top_class: z.string(),
def_pos: z.int(),
source_selector: androidMethodSelectorSchema.optional(),
direct_invokes_exhaustive: z.boolean().optional(),
direct_invokes: z
.array(
z.object({
dex_entry: z.string().min(1),
source_raw_method_id: z.string().min(1),
dex_code_unit_offset: count,
dex_method_index: count,
opcode: z.string().regex(/^INVOKE_/u),
}),
)
.optional(),
})
// The bridge emits or removes the site list and its coverage together.
.refine(
(item) =>
item.direct_invokes_exhaustive === undefined ||
item.direct_invokes !== undefined,
{
message: "Invoke coverage requires a direct invoke site list",
path: ["direct_invokes_exhaustive"],
},
),
),
});
const toolResponse = z
@@ -925,6 +925,17 @@ it.each([
).rejects.toThrow();
});
it.each([true, false])(
"rejects invoke coverage %s without the direct invoke site list",
async (exhaustive) => {
// The bridge always emits the list with its coverage; one without the
// other must not become a reference that claims coverage over no sites.
await expect(
traceWithReference({ direct_invokes_exhaustive: exhaustive }),
).rejects.toThrow("Invoke coverage requires a direct invoke site list");
},
);
it("preserves bounded instruction coverage separately from using-node coverage", async () => {
const result = await traceWithReference({
direct_invokes: [invokeSite],