fix(apple): report a recognized connector that cannot name its owner (#2484)
* fix(apple): report a connector that cannot name its owner as an omission A connector is recognized by class name and then dropped by an early `continue` when its owner cannot be resolved. Nothing recorded the drop, so connection coverage derived `complete` with `examined: 0` and `omitted: 0` for a connector that was present, recognized and discarded. Both producers of that coverage contract are affected and are changed together, because they share the facet and the reason value: - the keyed-archive parser records the drop as `unresolvedConnections` and reports it through the `connections:<path>` facet, the document `connection_count` and the graph omission total; - the NIBArchive projection in the artifact adapter recorded nothing at all, and the projected dictionary carried no trace of the dropped connector for a downstream consumer to find. Its count is taken where the connector is discarded and plumbed through the same per-document omission channel that already carries incomplete hierarchies, so the reason follows the cause. An unresolved source cannot be represented as a connection at all, because connection identity requires a non-empty source; that is unlike an unresolved destination, which the graph already retains as an unresolved edge. `connection_limit_reached` stays reserved for connections dropped by the hard cap and `serialized_view_hierarchy_incomplete` for hierarchy omissions. `connection_count` also includes the unresolved connectors. That field already counts connectors the parser recognized but could not emit, because connections dropped by the hard cap are counted there too, so unresolved connectors follow the existing rule rather than a new one. Verified with 98 focused Interface Builder and catalog tests, check:fast and verify:test-discovery on macOS arm64, and through the public CLI: a rooted archive holding one ownerless UIRuntimeOutletConnection reported complete with examined 0 and omitted 0 before this change and reports partial with the reason connection_unresolved and omitted 1 after it. * fix(apple): count ownerless NIBArchive connectors and keep the limit reason Greptile found two defects in the NIBArchive half of this change. The document summary was left unchanged, so the same recognized connector counted as one in a keyed archive and zero in a NIBArchive. The dictionary parser only sees connectors that were projected, so the omission recorded where the connector was dropped is added to the matching document here. The facet reason was overwritten unconditionally, so a NIBArchive holding both a connection dropped by the limit and an ownerless connector reported connection_unresolved and lost the cause a higher limit could recover. The existing reason is kept when the graph already named one, which is the precedence the keyed-archive producer applies. Verified with `npm run test:focused` over the bundle suite (42 passed, 1 skipped), `npm run lint` (0 errors) and `npm run check:fast` on macOS arm64. Reverting the reason precedence alone fails only the limit case; reverting the document count fails the count assertion in both cases. The new case moved into its own describe block because the enclosing callback crossed the repository's max-lines-per-function bound otherwise. --------- Co-authored-by: 吴佳浩 <wujiahao@supremind.com>
This commit is contained in:
@@ -510,6 +510,106 @@ describe("AppKit keyed archive connectors", () => {
|
||||
});
|
||||
});
|
||||
|
||||
describe("keyed archive unresolved connectors", () => {
|
||||
// A rooted UIKit archive whose only connector is UID 3, with UID 1 as the
|
||||
// owner, UID 2 as the destination and UID 7 as the "view" label.
|
||||
const rootedOutletArchive = (connection: Record<string, unknown>) => ({
|
||||
$archiver: "NSKeyedArchiver",
|
||||
$version: 100000,
|
||||
$objects: [
|
||||
"$null",
|
||||
{ $class: { CF$UID: 4 } },
|
||||
{ $class: { CF$UID: 5 } },
|
||||
{ $class: { CF$UID: 6 }, ...connection },
|
||||
{
|
||||
$classname: "UIViewController",
|
||||
$classes: ["UIViewController", "UIResponder", "NSObject"],
|
||||
},
|
||||
{ $classname: "UIView", $classes: ["UIView", "UIResponder", "NSObject"] },
|
||||
{
|
||||
$classname: "UIRuntimeOutletConnection",
|
||||
$classes: [
|
||||
"UIRuntimeOutletConnection",
|
||||
"UIRuntimeConnection",
|
||||
"NSObject",
|
||||
],
|
||||
},
|
||||
"view",
|
||||
{
|
||||
$class: { CF$UID: 11 },
|
||||
"NS.objects": [{ CF$UID: 1 }, { CF$UID: 2 }, { CF$UID: 3 }],
|
||||
},
|
||||
{ $class: { CF$UID: 11 }, "NS.objects": [{ CF$UID: 3 }] },
|
||||
{
|
||||
$class: { CF$UID: 11 },
|
||||
"NS.objects": [{ CF$UID: 1 }, { CF$UID: 2 }],
|
||||
},
|
||||
{ $classname: "NSArray", $classes: ["NSArray", "NSObject"] },
|
||||
],
|
||||
$top: {
|
||||
root: { CF$UID: 8 },
|
||||
UINibConnectionsKey: { CF$UID: 9 },
|
||||
UINibObjectsKey: { CF$UID: 10 },
|
||||
UINibTopLevelObjectsKey: { CF$UID: 10 },
|
||||
},
|
||||
});
|
||||
|
||||
const project = (raw: unknown) =>
|
||||
buildInterfaceBuilderAnalysis({
|
||||
targetSha256: hash,
|
||||
toolVersion: "test",
|
||||
documents: [
|
||||
{
|
||||
relativePath: "Main.nib",
|
||||
archiveSha256: hash,
|
||||
documentKind: "nib",
|
||||
raw,
|
||||
},
|
||||
],
|
||||
limits: interfaceBuilderLimitsSchema.parse({}),
|
||||
});
|
||||
|
||||
it("covers a resolvable connector as a complete examined connection", () => {
|
||||
const raw = rootedOutletArchive({
|
||||
UISource: { CF$UID: 1 },
|
||||
UIDestination: { CF$UID: 2 },
|
||||
UILabel: { CF$UID: 7 },
|
||||
});
|
||||
expect(parseInterfaceBuilderRecords(raw).unresolvedConnections).toBe(0);
|
||||
expect(project(raw).graph.coverage).toContainEqual(
|
||||
expect.objectContaining({
|
||||
facet: "connections:Main.nib",
|
||||
status: "complete",
|
||||
examined: 1,
|
||||
omitted: 0,
|
||||
}),
|
||||
);
|
||||
});
|
||||
|
||||
it("reports a recognized connector with no resolvable owner as unresolved", () => {
|
||||
const raw = rootedOutletArchive({
|
||||
UIDestination: { CF$UID: 2 },
|
||||
UILabel: { CF$UID: 7 },
|
||||
});
|
||||
expect(parseInterfaceBuilderRecords(raw).unresolvedConnections).toBe(1);
|
||||
|
||||
const analysis = project(raw);
|
||||
expect(analysis.graph.nodes.some(({ kind }) => kind === "outlet")).toBe(
|
||||
false,
|
||||
);
|
||||
expect(analysis.graph.coverage).toContainEqual(
|
||||
expect.objectContaining({
|
||||
facet: "connections:Main.nib",
|
||||
status: "partial",
|
||||
reason: "connection_unresolved",
|
||||
examined: 0,
|
||||
omitted: 1,
|
||||
}),
|
||||
);
|
||||
expect(analysis.graph.truncated).toBe(true);
|
||||
});
|
||||
});
|
||||
|
||||
it("names the archive once per evidence record", () => {
|
||||
const relativePath = "Views/Main.storyboardc/scene.nib/objects.nib";
|
||||
const result = buildInterfaceBuilderAnalysis({
|
||||
|
||||
Reference in New Issue
Block a user