Repository navigation
fix(apple): keep Interface Builder objects whose archived class is unresolved - #4118
Conversation
…resolved Interface Builder keyed-archive projection skipped every object-table entry without a resolved class name, so an archived object whose $class reference dangled vanished from the objects, its count and its coverage, which still reported complete; as a hierarchy root it lost its label. Entries that carry their own $class are archived objects: they are now kept with class_name null and the generic kind, their fields and labels preserved. Scalars and class descriptors remain excluded. Fixes #3958 Co-Authored-By: Claude Opus 5.5 <[email protected]>
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 10a2ebded5
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| // An archived object names its class with its own `$class` reference; | ||
| // when that reference cannot be resolved the object is still observed, | ||
| // with an unknown class. Scalars and class descriptors are not objects. | ||
| if (className === null && !Object.hasOwn(record(raw), "$class")) continue; |
There was a problem hiding this comment.
Preserve dangling class-reference evidence
When a $class UID is dangling—the case newly retained here—resolve() replaces the raw $class value with className: null, and the subsequent field projection drops className. The resulting unknown node therefore loses the original class reference (for example, UID 99), preventing analysts from tracing or distinguishing the unresolved source value; retain that raw reference or UID alongside class_name: null.
AGENTS.md reference: AGENTS.md:L29-L29
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Valid, fixed in e1761b1. Root cause: resolve() replaces $class with className, and the field projection drops className, so a dangling reference left no trace. When the class cannot be resolved, parseKeyedArchive now keeps the raw reference as the $class attribute, for example { UID: 99 }, next to class_name: null. Objects with resolved classes are unchanged, and the test asserts that they carry no $class attribute. Validation: npx vitest run src/domain/apple src/artifacts/apple tests/boundary/filesystem/interfaceBuilderBundle.test.ts tests/boundary/cli/interfaceBuilder tests/acceptance/applications passed 68 files (517 passed, 1 skipped), and npm run check:fast passed. TextEdit output is unchanged (result 18d1acdefd399d53).
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
[Medium impact] The PR appears safe to merge; no blocking issues remain. SummaryKeeps archived Interface Builder objects whose classes cannot be resolved.
Reviews (2) · Last reviewed commit: "fix(apple): keep the dangling class refe..." · Reviewed by Greptile |
| { $class: { UID: 2 }, "NS.string": "ok" }, | ||
| "plain scalar", | ||
| ], | ||
| $top: { root: { UID: 3 } }, |
There was a problem hiding this comment.
Root label lacks graph coverage
The new test calls only parseInterfaceBuilderRecords and points $top.root at resolved object 3. It does not cover the reported loss of the unresolved root’s label in the final graph. The test could keep passing if that graph behavior breaks again.
Add a case that calls buildInterfaceBuilderAnalysis with object 1 as the root, then checks its name, unknown kind, hierarchy link, object count, and coverage.
Prompt To Fix With AI
This is a comment left during a code review.
Path: src/domain/apple/interfaceBuilderGraph.test.ts
Line: 171
Comment:
**Root label lacks graph coverage**
The new test calls only `parseInterfaceBuilderRecords` and points `$top.root` at resolved object `3`. It does not cover the reported loss of the unresolved root’s label in the final graph. The test could keep passing if that graph behavior breaks again.
Add a case that calls `buildInterfaceBuilderAnalysis` with object `1` as the root, then checks its name, unknown kind, hierarchy link, object count, and coverage.
---
For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!
There was a problem hiding this comment.
Valid, added in e1761b1. The new graph-level case calls buildInterfaceBuilderAnalysis with $top.root set to the unresolved object 1. It asserts that the node keeps kind unknown, name Unresolved object and class_name: null, and that an observed contains edge reaches it from the document root. It also asserts object_count: 2 and complete object coverage with examined: 2. On main this case fails together with the parser case.
Review follow-up. An archived object kept with an unresolved class lost its original `$class` reference, because class resolution replaces it with a null class name. The object's attributes now retain that raw reference when the class cannot be resolved. A graph-level test covers the reported hierarchy-root case: the unresolved root keeps its label, unknown kind, containment edge, object count and coverage. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Summary
Fixes #3958. Interface Builder decoding dropped an archived object whose
$classreference could not be resolved. The document'sobject_countexcluded it and object coverage still saidcompletewith zero omissions. When that object was the hierarchy root, its node lost the serialized label. Such objects are now kept as explicit unknowns:class_name: null, the generic kind, and their fields and label preserved.Problem and expected behavior
parseKeyedArchive(src/domain/apple/interfaceBuilderKeyedArchive.ts) skipped every object-table entry with no resolved class name (if (className === null) continue;). That correctly excludes scalars,$nulland class descriptors. It also silently excluded archived objects whose class reference dangles. The node schema already allowsclass_name: null.Reproduced with the issue's generated app: object 1 has
$classUID 99, which doesn't exist; object 3 is aUIView. Run throughdecode-interface-builder --json:3(view);object_count: 1; objects coveragecomplete, examined 1, omitted 0; 4,671 bytes1(unknown,class_name: null, nameUnresolved object) and3;object_count: 2;complete, examined 2; 5,139 bytes1keeps its label;object_count: 2; hierarchy and objects complete1(view,UIView) and3;object_count: 2Change and scope
$classkey, even if the class does not resolve. Its raw$classreference (for example{ UID: 99 }) is retained as an attribute, so the dangling source value stays traceable. Such an entry is an archived object, and its unknown class is reported asnull. Entries without$class(scalars,$null, class descriptors) remain excluded.unknownkind.Contract and boundary impact
Semantic owner and earliest changed stage: keyed-archive object projection in
parseKeyedArchive.Contribution scope fit and linked maintainer decision: a bug fix within the existing static, read-only boundary; not applicable.
CLI and MCP/tool-catalog contract: schemas unchanged. Unresolved-class objects now appear as explicit unknowns, as the tool contract promises for unrecognized archive classes.
Provider, bridge, target-format, or platform compatibility: NSKeyedArchiver-based Interface Builder archives.
Evidence, artifact, provenance, or reconstruction contract: identity, label and fields of unresolved-class objects are preserved, and counts and coverage include them.
Target selection, authority, upstream behavior, and cleanup details: not applicable.
Generated metadata, package, or installation impact: none.
Read existing files or captured data.
Evidence and regression coverage
src/domain/apple/interfaceBuilderGraph.test.ts, newdescribe"keyed archive objects with unresolved classes".1is kept withclass_name: null, kindother, its name andlabelattribute;3stays aUIViewview; the descriptor and the scalar are not objects;objectCountis 2.decode-interface-builder, median of 3 runs, main vs this PR:/System/Applications/TextEdit.app18d1acdefd399d53/Applications/XLD.app6676c9d4384bb05cOutput is byte-identical for real apps whose classes resolve. Timing is within run-to-run variance.
$classreference was available, so that case is covered by the issue's generated archive and the unit test.Validation performed
npx vitest run src/domain/apple/interfaceBuilderGraph.test.ts— 19 passed; against main, 1 failed as expected.npx vitest run src/domain/apple src/artifacts/apple tests/boundary/filesystem/interfaceBuilderBundle.test.ts tests/boundary/cli/interfaceBuilder tests/acceptance/applications— 68 files, 516 passed, 1 skipped.npm run check:fast— passed. My first test placement exceeded the 150-linedescribelimit; I moved it into its owndescribe.Compatibility, safety, and release
Author readiness
Human owner:
Before merge
type(scope): outcome.🤖 Generated with Claude Code