Skip to content

fix(apple): keep Interface Builder objects whose archived class is unresolved - #4118

Merged
kaoru0822-kitauji merged 2 commits into
mainfrom
fix/3958-ib-unresolved-class-objects
Oct 15, 2026
Merged

kaoru0822-kitauji merged 2 commits into
mainfrom
fix/3958-ib-unresolved-class-objects

Conversation

@kaoru0822-kitauji

@kaoru0822-kitauji kaoru0822-kitauji commented Oct 15, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

Fixes #3958. Interface Builder decoding dropped an archived object whose $class reference could not be resolved. The document's object_count excluded it and object coverage still said complete with 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, $null and class descriptors. It also silently excluded archived objects whose class reference dangles. The node schema already allows class_name: null.

Reproduced with the issue's generated app: object 1 has $class UID 99, which doesn't exist; object 3 is a UIView. Run through decode-interface-builder --json:

variant main this PR
object 1 unresolved, root = object 3 nodes: only 3 (view); object_count: 1; objects coverage complete, examined 1, omitted 0; 4,671 bytes nodes: 1 (unknown, class_name: null, name Unresolved object) and 3; object_count: 2; complete, examined 2; 5,139 bytes
root = unresolved object 1 identity-only node, label lost (as reported in the issue) node 1 keeps its label; object_count: 2; hierarchy and objects complete
class resolved (control) 1 (view, UIView) and 3; object_count: 2 unchanged

Change and scope

  • An object-table entry is kept when it has its own $class key, even if the class does not resolve. Its raw $class reference (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 as null. Entries without $class (scalars, $null, class descriptors) remain excluded.
  • The connection-class match now requires a resolved class name. An object of unknown class cannot be recognized as a connector, and this narrowing also satisfies the types.
  • No schema changes. The graph already maps a null-class object to its unknown kind.

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

  • Tests added or updated: src/domain/apple/interfaceBuilderGraph.test.ts, new describe "keyed archive objects with unresolved classes".
    • The issue's object table plus a plain scalar entry: the unresolved object 1 is kept with class_name: null, kind other, its name and label attribute; 3 stays a UIView view; the descriptor and the scalar are not objects; objectCount is 2.
    • It fails on main and passes with the fix.
  • Real applications, decode-interface-builder, median of 3 runs, main vs this PR:
app main this PR
/System/Applications/TextEdit.app 599 ms, 1,460,792 bytes, result 18d1acdefd399d53 571 ms, identical bytes and result
/Applications/XLD.app 2,017 ms, 6,731,008 bytes, result 6676c9d4384bb05c 2,091 ms, identical bytes and result

Output is byte-identical for real apps whose classes resolve. Timing is within run-to-run variance.

  • Remaining proof gaps: no shipped nib with a dangling $class reference 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-line describe limit; I moved it into its own describe.
  • The issue's fixture and both variants run through the built CLI, as tabulated.

Compatibility, safety, and release

  • Breaking changes or migration steps: none. Results gain previously missing unknown-class object nodes.
  • Real Hopper/Ghidra, browser, or OS coverage: macOS app bundles.
  • Package or release metadata impact: none.
  • Security, privacy, process, or containment review: static parsing only.

Author readiness

Human owner:

  • I reviewed the final diff and relevant existing code, understand the change and its edge cases, and take responsibility for the complete PR, including AI-assisted work.
  • I checked the evidence above, confirmed it supports the current change, and recorded meaningful validation gaps.
  • I declare this PR ready for initial maintainer review.

Before merge

  • This PR addresses a concrete problem or an agreed enhancement.
  • Material scope and authority questions are resolved, and any required maintainer scope decision covers the final diff.
  • The PR has one focused outcome and the title follows type(scope): outcome.
  • Related issue is linked, or the reason for not linking one is stated above.
  • Tests cover changed observable behavior and meaningful failure paths.
  • Owning docs, contracts, and generated metadata are updated where needed.
  • User-visible CLI/MCP changes include representative output.
  • I checked the final diff for secrets, unrelated cleanup, and unsupported claims.

🤖 Generated with Claude Code

…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]>
@kaoru0822-kitauji kaoru0822-kitauji added the track:perf Performance track PRs (issues & perf loop) label Oct 15, 2026

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 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;

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge 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 👍 / 👎.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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).

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 15, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-15T13:37:37.344675Z e1761b1 New commits
ℹ️ 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" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@greptile-apps

greptile-apps Bot commented Oct 15, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerView in GreptileConfidence Score: 5/5

[Medium impact] The PR appears safe to merge; no blocking issues remain.

Summary

Keeps archived Interface Builder objects whose classes cannot be resolved.

  • Interface Builder keeps objects with unresolved archived classes.

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 } },

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 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!

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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]>
@kaoru0822-kitauji
kaoru0822-kitauji merged commit a90c9ea into main Oct 15, 2026
32 of 33 checks passed
@kaoru0822-kitauji
kaoru0822-kitauji deleted the fix/3958-ib-unresolved-class-objects branch October 15, 2026 14:40
@morluto morluto added bug Something isn't working area: native Native analysis and decompilation, including Ghidra, IDA, and Hopper analysis behavior labels Nov 23, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: native Native analysis and decompilation, including Ghidra, IDA, and Hopper analysis behavior bug Something isn't working track:perf Performance track PRs (issues & perf loop)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug] Interface Builder decoding omits unresolved-class objects while claiming complete coverage

2 participants