fix(apple): report missing keyed archive hierarchy references (#1104)
* test(apple): qualify malformed native hierarchy references Freeze actual Foundation/AppKit producer, single-slot positive UID mutation and real optional nil control at filesystem and compiled CLI boundaries. Preserve original raw-byte evidence and existing CI. Signed-off-by: Rudy Celekli <rudy@gradiahq.com> * fix(apple): report missing keyed archive hierarchy references Preserve known hierarchy objects and links while reporting unresolved nonnil object-table references as partial coverage. Retain archived nil semantics and original byte evidence. Signed-off-by: Rudy Celekli <rudy@gradiahq.com> --------- Signed-off-by: Rudy Celekli <rudy@gradiahq.com>
This commit is contained in:
@@ -45,6 +45,7 @@ export const parseInterfaceBuilderRecords = (
|
||||
readonly objectCount: number;
|
||||
readonly omittedObjects: number;
|
||||
readonly omittedConnections: number;
|
||||
readonly omittedHierarchyReferences: number;
|
||||
} => {
|
||||
const root = record(value);
|
||||
const keyed = parseKeyedArchive(root);
|
||||
@@ -114,6 +115,7 @@ export const parseInterfaceBuilderRecords = (
|
||||
objectCount: objectEntries.length,
|
||||
omittedObjects: Math.max(0, objectEntries.length - 20_000),
|
||||
omittedConnections,
|
||||
omittedHierarchyReferences: 0,
|
||||
};
|
||||
};
|
||||
|
||||
@@ -194,7 +196,8 @@ const keyedArchiveTable = (objectTable: readonly unknown[]) => {
|
||||
}
|
||||
return output;
|
||||
};
|
||||
const hierarchy = (start: unknown): unknown[] => {
|
||||
const hierarchy = (start: unknown) => {
|
||||
let omittedReferences = 0;
|
||||
const visited = new Set<number>();
|
||||
const root: unknown[] = [];
|
||||
const pending: { readonly value: unknown; readonly output: unknown[] }[] = [
|
||||
@@ -227,9 +230,15 @@ const keyedArchiveTable = (objectTable: readonly unknown[]) => {
|
||||
const { value, output } = entry;
|
||||
const uid = archiveUid(value);
|
||||
if (uid !== undefined) {
|
||||
// UID0 is archived nil, not a missing hierarchy object.
|
||||
if (uid === 0) continue;
|
||||
const target = objectTable[uid];
|
||||
if (target === undefined) {
|
||||
omittedReferences += 1;
|
||||
continue;
|
||||
}
|
||||
if (visited.has(uid)) continue;
|
||||
visited.add(uid);
|
||||
const target = objectTable[uid];
|
||||
if (Array.isArray(target)) {
|
||||
for (let index = target.length - 1; index >= 0; index -= 1) {
|
||||
const child = target[index];
|
||||
@@ -260,7 +269,7 @@ const keyedArchiveTable = (objectTable: readonly unknown[]) => {
|
||||
appendNode(record(value), undefined, output);
|
||||
}
|
||||
}
|
||||
return root;
|
||||
return { items: root, omittedReferences };
|
||||
};
|
||||
const archivedArrayClass = (classReference: unknown): boolean => {
|
||||
const uid = archiveUid(classReference);
|
||||
@@ -386,11 +395,12 @@ const parseKeyedArchive = (
|
||||
return {
|
||||
objects,
|
||||
connections,
|
||||
hierarchy,
|
||||
hierarchy: hierarchy.items,
|
||||
classes,
|
||||
objectCount,
|
||||
omittedObjects: Math.max(0, objectCount - 20_000),
|
||||
omittedConnections,
|
||||
omittedHierarchyReferences: hierarchy.omittedReferences,
|
||||
};
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user