Skip to content

fix(apple): rethrow internal invariant violations while resolving a bundle's program file - #11392

Merged
N0zoM1z0 merged 5 commits into
morluto:mainfrom
Davmunrey:fix/app-bundle-invariant-rethrow
Nov 21, 2026
Merged

N0zoM1z0 merged 5 commits into
morluto:mainfrom
Davmunrey:fix/app-bundle-invariant-rethrow

Conversation

@Davmunrey

Copy link
Copy Markdown
Contributor

Summary

#11029 made plist consumers rethrow InternalInvariantError instead of reporting a REA defect as evidence about the input. Bundle target resolution is another consumer of the same decoder and still converts it.

resolveLayoutExecutable in src/application/AppBundleExecutable.ts decodes Info.plist through decodeInfoPlistValue, which uses the shared binary plist decoder (BinaryPlistMaterializer, which raises invariantViolation). Its catch reported any failure as a BinaryTargetError: "Info.plist is malformed, unsupported, or lacks CFBundleExecutable". The outer catches of resolveAppBundleExecutable and resolveAppleBundleExecutable wrapped anything else the same way. open_binary on a .app or .bundle therefore reported a REA defect as a problem with the caller's bundle.

No issue is linked. I found this while checking the other plist decoder callers after #11029.

Change and scope

src/application/AppBundleExecutable.ts: the decode catch and both outer catches rethrow InternalInvariantError, as translateArtifactFailure and the #11029 consumers do. File-system failures, malformed plists and a missing CFBundleExecutable keep their typed BinaryTargetErrors.

Not changed: the macOS Hopper installer also decodes Info.plist (minimumSystemVersion), and its outer catch reports any failure as the current install stage with a diagnostic. It must still run DMG cleanup, so changing it is a setup-lifecycle change of its own.

Evidence and regression coverage

tests/boundary/filesystem/appleBundleTargetInvariant.test.ts (isolated boundary project) opens a .app and a .bundle through parseBinaryTarget. Each has a binary Info.plist and a Mach-O program file. Like PlistDecodeInvariant.test.ts, it replaces the binary plist decoder with one that reports an invariant violation.

  • On main both opens resolve { ok: false } with a BinaryTargetError.
  • With the fix both reject with the InternalInvariantError. With the real decoder both still open.

Validation performed

Linux x64, Node 24.22.1:

  • npm run test:focused -- tests/boundary/filesystem/appleBundleTargetInvariant.test.ts tests/boundary/filesystem/appleBundleTargets.test.ts: 22 passed.
  • npm run test:local -- src/application/AppBundleExecutable.test.ts src/application/AppBundleExecutable.openStep.test.ts: 11 passed.
  • architecture-guards, check:ci:fast and format:check pass.

Not verified: how an MCP or CLI caller sees the rethrown invariant end to end. It takes the same path as the other #11029 consumers, which their tests cover through the provider adapter.

Author readiness

Human owner: @Davmunrey

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

…undle's program file

Bundle target resolution decodes Info.plist with the shared binary plist decoder, which reports a broken internal assumption as InternalInvariantError. The resolver caught every decode failure and reported it as a BinaryTargetError ("Info.plist is malformed, unsupported, or lacks CFBundleExecutable"), and its two outer catches wrapped anything else the same way. A REA defect therefore reached the caller as a fact about the user's bundle.

morluto#11029 made the other plist consumers rethrow the invariant. The resolver's decode site and both outer catches now do the same.

Tests: a boundary test opens a .app and a .bundle through parseBinaryTarget with the decoder replaced by one that reports an invariant violation. Before this change both resolved { ok: false } with a BinaryTargetError; now both reject with the InternalInvariantError. The same bundles open normally with the real decoder.
@chatgpt-codex-connector

Copy link
Copy Markdown
Codex Review Summary: ❌ Failed

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

Review Status Commit Review trigger
📝 Code Review ❌ Failed 2026-11-15T19:03:53.526045Z
We couldn’t complete this review. Comment @codex review to try again.
e6e4f64 PR opened
ℹ️ 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.

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

@greptile-apps

greptile-apps Bot commented Nov 15, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerView in GreptileConfidence Score: 5/5

[Low impact] This PR appears safe to merge.

Summary

Bundle executable lookup now preserves internal decoder defects instead of blaming the selected bundle.

  • Apple bundle opening lets internal plist errors escape as REA errors.

Reviews (7) · Last reviewed commit: "Merge morluto/rea main into app-bundle-i..." · Reviewed by Greptile

Main moved the binary plist materializer from src/artifacts/apple to
src/domain/apple, and AppBundleExecutable now imports it from there. The
invariant test still mocked the old path, which no longer exists, so tsc
failed and the mock would have intercepted nothing.

The test now mocks src/domain/apple/binaryPlistMaterializer.js. With the
rethrow removed from AppBundleExecutable both cases fail; with it they pass.
@Davmunrey

Copy link
Copy Markdown
Contributor Author

Merged main in 3f63824. Main moved the binary plist materializer to src/domain/apple (#11415), so 3fe25c5 mocks src/domain/apple/binaryPlistMaterializer.js. With the rethrow removed from AppBundleExecutable both cases fail; with it they pass. The branch also merges with main 072b578, and architecture-guards and tsc --noEmit pass there.

# Conflicts:
#	src/application/AppBundleExecutable.ts
# Conflicts:
#	src/application/AppBundleExecutable.ts

@gensokyo-dev gensokyo-dev left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Verified: the new invariant cases fail on main and pass here. Bundle executable resolution now rethrows InternalInvariantError the way the other plist consumers do since #11029. Thanks.

@N0zoM1z0
N0zoM1z0 merged commit 6aa3898 into morluto:main Nov 21, 2026
39 checks passed
@morluto morluto added bug Something isn't working area: native Native analysis and decompilation, including Ghidra, IDA, and Hopper analysis behavior labels Nov 22, 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.

4 participants