fix(native): report Objective-C class import binding coverage unknown when candidate completeness is unstated (#11139)

This commit is contained in:
morluto authored and GitHub committed 2026-11-15 21:19:20 +08:00
1 parent c966d6f49a
commit 1682d9c645
4 files changed
+25 -8

No files matched your search

+6 -1
View File
@@ -350,6 +350,11 @@ export const objcClassImportIdentitySchema = machoImportBindingSchema.omit({
export const objcClassImportBindingCoverageSchema =
nativeMetadataCoverageSchema.extend({
facet: z.literal("objc_class_import_bindings"),
/** `unknown` when the caller did not state whether the candidates are complete. */
status: z.enum([
...nativeMetadataCoverageSchema.shape.status.options,
"unknown",
]),
examined: z.number().int().nonnegative(),
decoded: z.number().int().nonnegative(),
});
@@ -466,7 +471,7 @@ export const nativeDispatchMetadataInputSchema = z.strictObject({
objc_class_import_addresses_complete: z
.boolean()
.describe(
"Whether the candidate addresses include every selected class-label row. false keeps binding coverage partial when the existing record budget truncates the scan; omitted is unknown and also keeps it partial.",
"Whether the candidate addresses include every selected class-label row. false keeps binding coverage partial when the existing record budget truncates the scan; omitted makes binding coverage unknown.",
)
.optional(),
max_input_bytes: z
+2 -2
View File
@@ -502,7 +502,7 @@ describe("Imported class symbol byte identities", () => {
});
describe("Imported class symbol candidate completeness", () => {
it("keeps binding coverage partial when the caller does not state the candidates are complete", () => {
it("reports binding coverage unknown when the caller does not state the candidates are complete", () => {
const result = decodeAppleDispatchMetadata(
swiftExternalSwiftBindingImage("objc-class"),
100,
@@ -514,7 +514,7 @@ describe("Imported class symbol candidate completeness", () => {
expect.objectContaining({ symbol: "_OBJC_CLASS_$_NSObject" }),
]);
expect(result.objc_class_import_binding_coverage).toMatchObject({
status: "partial",
status: "unknown",
reason: expect.stringContaining("objc_class_import_addresses_complete"),
});
});
@@ -227,14 +227,14 @@ describe("Objective-C import binding address inspection", () => {
});
describe("Objective-C import binding candidate completeness", () => {
it("keeps coverage partial when the candidates' completeness was not stated", () => {
it("reports coverage unknown when the candidates' completeness was not stated", () => {
for (const addresses of [["0x1000", "0x1008"], []])
expect(
inspectObjcClassImportBindings(
createInput({ addresses, addressesComplete: undefined }),
).coverage,
).toMatchObject({
status: "partial",
status: "unknown",
reason: expect.stringContaining("did not state"),
});
});
+15 -3
View File
@@ -5,7 +5,12 @@ import type { MachoImportBinding } from "../domain/native/objcSwiftMetadata.js";
export interface ObjcClassImportBindingScan {
readonly bindings: readonly MachoImportBinding[];
readonly coverage: {
readonly status: "complete" | "partial" | "unsupported" | "not_requested";
readonly status:
| "complete"
| "partial"
| "unknown"
| "unsupported"
| "not_requested";
readonly reason: string | null;
readonly examined: number;
readonly decoded: number;
@@ -25,7 +30,7 @@ export const inspectObjcClassImportBindings = (input: {
const { bytes, layout, fixups, addresses, addressesComplete, maxRecords } =
input;
// A candidate scan that is truncated, or whose completeness was not stated,
// keeps its limitation even when no candidate was retained.
// reports that limitation even when no candidate was retained.
if (
addresses === undefined ||
(addresses.length === 0 && addressesComplete === true)
@@ -112,7 +117,14 @@ export const inspectObjcClassImportBindings = (input: {
return {
bindings,
coverage: {
status: reason === null ? "complete" : "partial",
// Unstated candidate completeness leaves the whole scan's coverage
// unknown, even when other gaps are also known.
status:
addressesComplete === undefined
? "unknown"
: reason === null
? "complete"
: "partial",
reason,
examined: examinedAddresses.size,
decoded: bindings.length,