Skip to content

fix(apple): preserve NIBArchive resource keys in catalog joins - #2256

Closed
thangldw wants to merge 1 commit into
morluto:mainfrom
thangldw:codex/fix-nib-resource-keys
Closed

thangldw wants to merge 1 commit into
morluto:mainfrom
thangldw:codex/fix-nib-resource-keys

Conversation

@thangldw

Copy link
Copy Markdown
Contributor

Summary

Fixes #2176.

Asset catalog inspection dropped recognized resource keys from decoded NIBArchive objects. Normalize those keys at the NIBArchive producer so CLI and MCP retain the resource-key join, including its source node, archive path and digest.

Problem and expected behavior

A rooted NIBArchive containing an NSImage with NSImageName: "Toolbar" was decoded correctly, but inspect-asset-catalog returned resource_key_matches: []. With no catalog, the result must instead contain an unmatched NSImageName / Toolbar row with no renditions. One matching rendition is matched; multiple matching renditions are ambiguous and retained.

Change and scope

Share the existing recognized-field allowlist and nonempty scalar predicate in the domain layer. The NIBArchive producer exposes those fields directly while preserving the original nibValues representation and charging added property/string occurrences to the decode budget. The catalog consumer continues to inspect direct fields; it does not reinterpret a keyed archive's authored nested dictionary named nibValues.

Related open PRs discovered during the final update: #2248 and #2249 also address #2176. This implementation normalizes only the disjoint recognized scalar allowlist at the actual NIBArchive producer, rather than identifying format by the presence of an authored nibValues dictionary. The public keyed nested-dictionary negative control covers the resulting distinction; original nested data is retained.

Contract and boundary impact

  • Semantic owner and earliest changed stage: NIBArchive field projection, before Interface Builder graph construction and catalog resource joins.
  • Contribution scope fit and linked maintainer decision: ordinary static-analysis correctness fix within existing boundaries; a new authority/provider scope decision is not applicable.
  • CLI and MCP/tool-catalog contract: unchanged schemas and tools; additive normalized direct attributes and restored resource-key rows.
  • Provider, bridge, target-format, or platform compatibility: existing NIBArchive and keyed-archive paths; no engine protocol changes.
  • Evidence, artifact, provenance, or reconstruction contract: original nibValues, source node, archive path/hash and input bytes remain preserved. Corrected output changes derived Evidence identity.
  • Target selection, authority, upstream behavior, and cleanup details: unchanged existing read-only workflow; target applications are not executed.
  • Generated metadata, package, or installation impact: no dependency/version change or committed generated output.

Expected effects:

  • Read existing files or captured data.
  • Launch or attach to a process. Existing catalog inspection invokes assetutil when catalogs are present; this patch adds no process or target-execution authority.
  • Inject instrumentation or run scripts/code.
  • Change process memory, registers, files, or configuration.
  • Contact network services.
  • Recover protected code or work around protections.
  • Documentation or usability only; no target interaction.
  • Not sure yet; investigation or maintainer guidance needed.

Evidence and regression coverage

  • Added compiled CLI/real stdio MCP regression using the exact inert NIBArchive fixture from fix(apple): asset catalog inspection omits recognized NIBArchive resource keys #2176, with recognized alias, unrecognized title, keyed direct-field and keyed nested-dictionary controls. Assert exact source node/path/hash and adapter parity.

  • Original regression failed on main 59be866 because the expected unmatched row was absent. The keyed nested-dictionary control also failed against the initial consumer-only repair; producer normalization resolves that false interpretation.

  • Supplied assetutil metadata integration controls cover matched and ambiguous joins. Scalar-type, empty-value and arbitrary nested-field controls remain conservative.

  • Independent subagent review found the nested keyed-dictionary risk; after repair, independent re-review reported no actionable findings.

  • Remaining proof gaps: new resource-key fixtures are synthetic inert format bytes. Supplied metadata does not establish validity of a real Assets.car or native assetutil behavior for this fixture.

  • Observed, derived, and inferred claims remain distinguishable.

  • Artifact identity, source provenance, and failed attempts remain preserved.

  • Unsupported, incomplete, unavailable, or uncertain outcomes remain visible.

Validation performed

Node 24.18.0 / npm 11.16.0, macOS arm64, updated onto main d96550f without conflicts:

  • Focused regression, catalog workflow/projection, native artifact goldens, NIBArchive and Interface Builder bundle suites: 55 tests passed across 6 files. This includes actual Xcode-compiled storyboard NIB and Foundation-produced archive controls.
  • npm run check: passed typecheck, lint, formatting, knip, metadata, module boundaries and architecture guards.
  • npm run docs:check: passed generated-document checks and README consistency tests.
  • npm run verify:test-discovery: all 947 test files discovered exactly once.
  • git diff --check: passed.

Compatibility, safety, and release

  • Breaking changes or migration steps: none; original nested values retained, normalized fields added within existing attribute schema.
  • Real Hopper/Ghidra, browser, or OS coverage: CLI/MCP and Xcode/Foundation archive controls on macOS arm64; no Linux/Windows run. The public catalog regression is macOS-only because the production tool requires macOS.
  • Package or release metadata impact: none.
  • Security, privacy, process, or containment review: direct recognized fields only; no arbitrary nested-key inference, target execution, extraction or new authority. Added representation is accounted for in existing decode budgets.

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.

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex usage limits have been reached for code reviews. Please check with the admins of this repo to increase the limits by adding credits.
Repo admins can enable using credits for code reviews in their settings.

morluto added a commit to XiaoBinGan/rea that referenced this pull request Oct 12, 2026
Fold the complementary implementation from morluto#2256 into the earlier morluto#2248 proposal, retaining the original contribution history.

Co-authored-by: Thang Luu <[email protected]>
@morluto

morluto commented Oct 12, 2026

Copy link
Copy Markdown
Owner

Thanks @thangldw. Your producer-boundary normalization, shared recognized-key contract, budget accounting and CLI/MCP coverage are folded into the earlier active PR #2248 with coauthor credit (head 5198b8b), preserving the original contributor commit. Spec review also fixed non-resource field matches. All 49 focused tests plus full source/docs checks pass. Closing this duplicate so review continues on the original #2176 contribution.

@morluto morluto closed this Oct 12, 2026
morluto added a commit that referenced this pull request Oct 12, 2026
* fix(apple): join recognized keys from NIBArchive field maps

inspect-asset-catalog returned no resource-key matches for a decoded
NIBArchive resource whose recognized image key is present in the archive. The
NIBArchive projection groups an object's decoded fields under the node's
nibValues attribute beside the class, label and ID it derives from the same
archive, while the AppKit keyed-archive parser flattens the same fields onto
the node. The catalog join read only the top level, so a recognized NSImageName
on a decoded resource produced no row, and the empty-catalog limitation still
claimed resource keys were reported as unmatched.

Read an archive object's fields from both shapes, and give the namespace one
owner by exporting NIB_VALUES_ATTRIBUTE from the projection that writes it.
The recognized-field set stays in the catalog analysis, which owns that
contract.

Verified with 5 focused catalog tests, check:fast and verify:test-discovery on
macOS arm64, and through the public CLI against the reported NIBArchive
fixture. The keyed-archive control keeps its existing row, and a NIBArchive
with only an unrecognized title still produces none. The ibtool-dependent
native hierarchy lane requires full Xcode and was unavailable here.

* fix(apple): normalize resource keys at the NIBArchive producer

Fold the complementary implementation from #2256 into the earlier #2248 proposal, retaining the original contribution history.

Co-authored-by: Thang Luu <[email protected]>

* fix(apple): restrict catalog joins to parsed resource nodes

---------

Co-authored-by: 吴佳浩 <[email protected]>
Co-authored-by: morluto <[email protected]>
Co-authored-by: Thang Luu <[email protected]>
@morluto morluto added the bug Something isn't working label Oct 14, 2026
XiaoBinGan pushed a commit to XiaoBinGan/rea that referenced this pull request Nov 2, 2026
Fold the complementary implementation from morluto#2256 into the earlier morluto#2248 proposal, retaining the original contribution history.

Co-authored-by: Thang Luu <[email protected]>
@morluto morluto added the area: native Native analysis and decompilation, including Ghidra, IDA, and Hopper analysis behavior label Nov 26, 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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

fix(apple): asset catalog inspection omits recognized NIBArchive resource keys

2 participants