Repository navigation
feat(apple): project macOS bundle anatomy in application graphs - #922
Conversation
An APFS disk image attaches as an image disk plus a synthesized APFS container, and hdiutil reports both as whole disks. Detaching the container also ejects the image disk, so the reverse-order detach then failed with "No such file or directory" and every APFS DMG inventory ended in "DMG detach or mount-root cleanup failed". APFS is the default format of `hdiutil create` on current macOS. When a detach fails, ask `hdiutil info -plist` whether the device is still attached. A device that is gone counts as detached; one that is still listed, or whose state cannot be read, remains a cleanup failure. Co-Authored-By: Claude Opus 5.5 <[email protected]>
project_apple_application_graph accepted only IPA inventories. It now also projects macOS .app directories and ZIP or DMG inventories that contain applications. It reports application roots, platforms, and every nested bundle with its path-convention role, layout, parent, Info.plist path, executable candidates, and signing paths: - roles: app extensions, XPC services (including inside frameworks), frameworks, login items, system and driver extensions, plug-ins, resource bundles, and helper or nested applications; - privileged helpers in Contents/Library/LaunchServices and launchd plists in Contents/Library/LaunchAgents or LaunchDaemons; - direct files of Contents/Helpers; - symlinks by path. Their targets are not inventoried, so versioned frameworks are described through their real Versions/<version>/ directories. AppleDouble sidecars (._* and __MACOSX/) are excluded from roles. A DMG whose contents could not be inventoried is reported as partial. Other inventory formats remain input errors. The projection still reads no plist or CMS semantics; it points callers at inspect_plist. The result schema is additive. projection_id now covers the new fields, so IPA projection IDs differ from earlier versions. verify:macos-bundle compiles a source-owned app with clang (CLT only). It packs it as a directory, a ditto ZIP, and an APFS DMG, and checks identical anatomy through the CLI with stdio MCP parity. It runs in the macOS CI job. Co-Authored-By: Claude Opus 5.5 <[email protected]>
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. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: dd3e7aef0d
ℹ️ 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".
| frameworks: all.filter(({ path }) => /\.framework\//u.test(path)), | ||
| native_libraries: all.filter(({ path }) => /\.(?:dylib|so)$/iu.test(path)), | ||
| javascript: all.filter(({ format }) => format === "javascript-bundle"), |
There was a problem hiding this comment.
Scope projected components to discovered application roots
When a newly accepted ZIP or DMG contains an application plus sibling content, these filters classify every matching framework, dylib, or JavaScript file in the container, even when it is outside every application_roots entry. The same unscoped all collection feeds runtime-family detection, while unscoped JavaScript and native libraries generate cross-boundary bridge candidates, so unrelated installer or disk-image files are falsely attributed to the application. Filter all component and runtime inputs by withinApp (and sidecar status), as is already done for executables and anatomy components.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Agreed. In 5524970, directory, ZIP and DMG projections attribute only components inside an application root, and AppleDouble sidecars are excluded. That scope applies to the component categories, runtime families and bridge candidates. A limitation reports how many inventoried entries were left out. IPA projection is unchanged and still lists archive components such as SwiftSupport/. New domain tests cover a ZIP with sibling Extras/ content, and the IPA SwiftSupport case.
| if ( | ||
| /\.app$/iu.test(subjectName) && | ||
| /^Contents\/(?:Info\.plist|MacOS\/[^/]+)$/u.test(path) | ||
| ) { |
There was a problem hiding this comment.
Recognize the selected .app directory without content anchors
When the selected inventory subject itself ends in .app but the supplied inventory is empty, partial, malformed, or simply lacks Contents/Info.plist and a direct Contents/MacOS/* entry, this condition never adds .. The result consequently reports no application root and no platform despite the caller having selected an .app directory; derive the root from the directory subject identity and let coverage/limitations describe missing contents instead of discarding that identity.
AGENTS.md reference: AGENTS.md:L16-L16
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Agreed. In 5524970, a directory subject whose name ends in .app is its own root (.) by identity, whatever the inventory contains. Coverage and limitations still describe partial inventories. To avoid a guessed platform, ios is now claimed only for shallow roots with an Info.plist, so an empty .app inventory reports the root with platforms: []. Tests cover the empty and partial .app inventories.
The inventory snapshot captures reader provenance before close() runs, so a `hdiutil info -plist` entry recorded during cleanup never reached CLI or MCP results. Detach entries already share that timing. Record neither instead of implying the query is observable. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…tories Directory, ZIP, and DMG inventories can hold installers, disk-image extras, and AppleDouble sidecars beside the app. Those components were classified as the application's frameworks, libraries, JavaScript, and metadata, and fed runtime families and bridge candidates. For these formats, components outside every application root are now left out, with a limitation that counts them. IPA projection is unchanged. A selected directory whose name ends in .app is now its own root by identity, so an empty or partial inventory still reports it. iOS is claimed only for shallow roots that have an Info.plist, so an empty root reports no platform. 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: 55249704c5
ℹ️ 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".
| const all = visible.filter(({ path }) => | ||
| roots.some((root) => isWithin(path, root)), | ||
| ); |
There was a problem hiding this comment.
Partition bridge hypotheses by application root
When a ZIP or DMG contains two outer applications, this filter combines components from both roots into one flat all collection, and identifyBridgeCandidates later forms a Cartesian product from it. A JavaScript file in First.app is therefore reported as bridging to every native binary in Second.app, even though the paths identify separate applications; preserve each component's owning root and only pair components within that root.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Agreed. In 67743e9, bridge candidates pair a script only with native code owned by the same application root; components outside every root pair only with each other. A new test covers a ZIP with First.app and Second.app and checks that no cross-application pairs remain.
| ), | ||
| ) | ||
| .filter((path) => tree.files.has(path)); | ||
| return candidates.length === 1 ? (candidates[0] ?? null) : null; |
There was a problem hiding this comment.
Keep ambiguous framework Info.plist paths unknown
When a versioned framework has both Versions/A and Versions/B but only A contains Resources/Info.plist, this returns A's plist solely because there is one existing candidate. Since the inventory deliberately omits the Versions/Current symlink target, Current may select B, so the bundle's plist is still unknown; base this decision on an unambiguous version selection rather than the number of plist files.
AGENTS.md reference: AGENTS.md:L56-L56
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Agreed. In 67743e9, a versioned framework's info_plist_path is chosen only when exactly one real Versions/<v>/ directory exists. With several versions it stays null whether or not each has a plist, because Versions/Current is not inventoried. The limitation text now says this, and a test covers A having a plist while B does not.
feat(apple): project macOS bundle anatomy in application graphs
Builds on #921, which this branch includes as its first commit. The DMG case of the new real lane needs that fix. Once #921 merges, this diff shrinks to the feature commit.
Summary
project_apple_application_graphaccepted only IPA inventories. A macOS analyst's first question about a.app(what runs out of this bundle?) had no answer: XPC services, app extensions, login items, privileged helpers, system extensions and launchd jobs. The tool now projects macOS.appdirectories, and ZIP or DMG inventories that contain apps, into that anatomy. It stays execution-free and reads only paths and hashes.Change and scope
This extends the existing tool rather than adding one, because the intent (project an Apple app inventory) and the result contract are unchanged. The schema change is additive. The domain logic is in the new
src/domain/appleBundleAnatomy.ts.Application roots
Payload/*.app(unchanged).appdirectory.*.app/ContentsNew result fields
bundles: every application root and nested bundle, withparent_path,layout(macos-deep,versioned-frameworkorshallow), a path-conventionrole,info_plist_path,executable_candidatesandsigning_paths.app-extension,xpc-service(including XPC services inside frameworks),framework,login-item,system-extension,driver-extension,plug-in,resource-bundle,bundle,helper-applicationandnested-application.components.privileged_helpers:Contents/Library/LaunchServices/*.components.launchd_plists:Contents/Library/Launch{Agents,Daemons}/*.plist, each withdomain.components.helpers:Contents/Helpers/*.symlinksandplatforms.Behaviour
Versions/<version>/directories. If theInfo.plistthatVersions/Currentselects cannot be determined, it isnullwith a limitation.._*,__MACOSX/) are excluded from roles.partial.Not included: plist or CMS semantics. Roles come from path conventions, and the result points callers to
inspect_plistfor eachinfo_plist_path. Dylib-load resolution is the planned follow-up.Contract and boundary impact
src/domain/appleBundleAnatomy.tsandsrc/domain/appleApplication.ts.root_formatenum widens fromipatoipa | directory | zip | dmg. There is a new catalog example for a.appdirectory, and the descriptions are updated. Input is unchanged.ipa.projection_idnow covers the new fields, so IPA projection IDs differ from earlier versions. No doc promises cross-version ID stability, so this is not marked breaking.Sanitized MCP result for the lane's fixture app, as a directory and trimmed:
{ "root_format": "directory", "platforms": ["macos"], "application_roots": ["."], "bundles": [ { "path": ".", "role": "application", "layout": "macos-deep", "parent_path": null, "info_plist_path": "Contents/Info.plist", "executable_candidates": ["Contents/MacOS/MacFixture"], "signing_paths": ["Contents/_CodeSignature/CodeResources"], "role_basis": "path-convention" }, { "path": "Contents/Frameworks/Core.framework", "role": "framework", "layout": "versioned-framework", "parent_path": ".", "info_plist_path": "Contents/Frameworks/Core.framework/Versions/A/Resources/Info.plist" }, { "path": "Contents/Frameworks/Core.framework/Versions/A/XPCServices/FwSvc.xpc", "role": "xpc-service", "parent_path": "Contents/Frameworks/Core.framework" }, { "path": "Contents/Library/LoginItems/Login.app", "role": "login-item" }, { "path": "Contents/PlugIns/Ext.appex", "role": "app-extension" }, { "path": "Contents/XPCServices/Svc.xpc", "role": "xpc-service" } ], "components": { "privileged_helpers": [{ "path": "Contents/Library/LaunchServices/com.example.rea.helper" }], "launchd_plists": [ { "path": "Contents/Library/LaunchAgents/com.example.rea.agent.plist", "domain": "agent" }, { "path": "Contents/Library/LaunchDaemons/com.example.rea.helper.plist", "domain": "daemon" } ], "helpers": [{ "path": "Contents/Helpers/rea-tool" }] }, "symlinks": ["Contents/Frameworks/Core.framework/Versions/Current"] }Evidence and regression coverage
src/domain/appleApplication.test.ts(new, 8 cases):.appdirectory as its own root, plus every role;.appbundle directory that is not an application root;Versions/Current, and ambiguous versions;tests/composition/analysis-sessions/appleApplication.test.ts:.appdirectory inventory throughinventory_artifact;Real lane
npm run verify:macos-bundle, also added to the macOS CI job. It uses Command Line Tools only:clangand signs it ad hoc;dittoZIP, and an APFS DMG;Real apps in
/Applications, on this branch's build:Updater.appand two XPC services insideSparkle.framework/Versions/B.appexunderContents/Extensions; login item; 9 SwiftPM resource bundlesUpdaterPrivilegedHelper; 9 helper apps under the framework'sVersions/<ver>/Helpers.appex; a Catalyst bridge plug-inRemaining proof gaps: roles are path conventions, not plist-verified. ZIP/IPA inventories without directory entries still project, through implied ancestors.
Validation performed
npm run check:changed: 289 files passed.npm run test:focused -- tests/composition/analysis-sessions/appleApplication.test.ts tests/boundary/mcp/mobileApplicationGraphMcp.test.ts tests/boundary/cli/productCatalog.test.ts tests/boundary/mcp/toolSchemaValidity.test.ts tests/acceptance/contractPresentation.test.ts: passed.npm run docs:generate && npm run docs:check: passed.npm run verify:macos-bundle:{"ok":true,"mocked":false,"cli":true,"stdio_mcp":true,"containers":["directory","zip","dmg"],"bundles":6,"dmg_detached":true}.Compatibility, safety, and release
projection_idvalues change.🤖 Generated with Claude Code