Skip to content

fix(apple): detect XML keyed archives by content - #2759

Closed
HeadmasterEggy wants to merge 18 commits into
morluto:mainfrom
HeadmasterEggy:codex/fix-xml-keyed-archive-extension
Closed

HeadmasterEggy wants to merge 18 commits into
morluto:mainfrom
HeadmasterEggy:codex/fix-xml-keyed-archive-extension

Conversation

@HeadmasterEggy

@HeadmasterEggy HeadmasterEggy commented Oct 13, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Fixes #2751. Also preserves cancellation semantics when the bounded XML probe is cancelled during its final size check.

Problem and expected behavior

inspect_keyed_archive rejects a valid XML NSKeyedArchiver when its filename is not .plist, although the same document opens when named .plist. Binary plists already use content detection independent of extension. XML plist content should receive the same treatment where no known artifact suffix has selected another format.

Change and scope

The shared target resolver now recognizes a bounded XML plist prolog after checking binary signatures and known named artifact formats. The recognizer supports UTF-8 and BOM-marked UTF-16, optional XML declarations/comments, and plist DOCTYPE or root tags. It identifies the format only; the existing plist reader remains responsible for decoding and validation.

Boundary Impact
Semantic owner and earliest changed stage appleArchiveFormat signature helper; BinaryTargetResolver format classification
Contribution scope fit and linked maintainer decision Existing local format-inspection bug; no new provider or capability
CLI and MCP/tool-catalog contract No schema or tool contract changes; both surfaces use the corrected shared resolver
Provider, bridge, target-format, or platform compatibility XML property lists with alternate suffixes become selectable; recognized .asar, .js, .map, and .plist names retain their current classifications
Evidence, artifact, provenance, or reconstruction contract No change; existing reader preserves the selected file digest and archive path
Target selection, authority, upstream behavior, and cleanup details Reads only the caller-selected local file through existing analysis; no target execution or mutation
Generated metadata, package, or installation impact None

Expected effects:

  • Read existing files or captured data.
  • Launch or attach to a process.
  • 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

  • Tests added or updated: target-format classification regression, a cancellation-during-final-stat boundary case, built CLI inspection, and stdio MCP open_binary plus inspect_keyed_archive flow.
  • Base reproduction or other evidence: issue [Bug] inspect_keyed_archive rejects XML keyed archives not named .plist #2751 documents the .archive versus .plist behavior. The base resolver recognizes binary plist magic and named .plist, but has no XML-content detection; the regression tests exercise the fixed case.
  • User-visible CLI/MCP output: both return a successful keyed-archive result with archive_path: "Model.archive", archive_format: "xml-plist", and the decoded leaf object.
  • Remaining proof gaps: no real-world archive corpus was run; tests use a source-generated XML archive.

For evidence-bearing changes:

  • 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

  • npm run test:focused -- tests/boundary/filesystem/binaryTarget.test.ts — 65 tests passed, including cancellation during the final probe stat().
  • Earlier focused CLI and MCP workflow coverage — 55 tests passed.
  • npm run check:fast — passed.
  • git diff --check — passed.
  • Push pre-check reran npm run check:fast — passed.

Merge Danger

  • Door: two-way; reverting restores the previous format classification.
  • Blast Radius: limited to classification of XML plist content without a recognized named format.

Compatibility, safety, and release

  • Breaking changes or migration steps: none.
  • Real Hopper/Ghidra, browser, or OS coverage: not applicable.
  • Package or release metadata impact: none.
  • Security, privacy, process, or containment review: local file classification only; parsing and existing resource limits are unchanged.

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

chatgpt-codex-connector Bot commented Oct 13, 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-13T18:44:46.234845Z 2fd7df4 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 13, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerConfidence Score: 5/5

[Medium impact] The PR appears safe to merge; no new actionable defect or security issue was found.

Summary

The current diff preserves inferred .hop database routing and separates root ASAR selection from nested XML content.

  • Unselected .hop files keep database routing when the probe is undecided.
  • Nested XML files named .asar appear as plist entries.

The previous review cannot serve as the comparison baseline because its merge base differs from the current head's. The full PR diff was reviewed instead.

All seven supplied previous threads are unnumbered, so none require a previousFindings entry. Current code addresses their reported causes. The entitlement thread was manually resolved without an explanatory reply; classifyArtifactContent now preserves that role.

Review was source-only. Tests and performance checks were not run. A check for superseding PR context was blocked by unavailable GitHub authentication.

Reviews (14) · Last reviewed commit: "fix(apple): preserve database and ASAR r..." · Reviewed by Greptile

Comment thread src/domain/apple/appleArchiveFormat.ts Resolved

@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: 77665054bf

ℹ️ About Codex in GitHub

Codex has been enabled to automatically 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 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment thread src/domain/apple/appleArchiveFormat.ts Resolved
Comment thread src/application/BinaryTargetResolver.ts Resolved
Comment thread src/application/BinaryTargetResolver.ts Resolved

@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: 3014750e8e

ℹ️ About Codex in GitHub

Codex has been enabled to automatically 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 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment thread src/domain/apple/appleArchiveFormat.ts Resolved
Comment thread src/application/BinaryTargetResolver.ts Resolved
Comment thread src/domain/apple/appleArchiveFormat.ts Resolved
Comment thread src/application/BinaryTargetResolver.ts Resolved

@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: c3ea2ca6cc

ℹ️ About Codex in GitHub

Codex has been enabled to automatically 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 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment thread src/domain/apple/appleArchiveFormat.ts Resolved
Comment thread src/application/BinaryTargetResolver.ts Resolved
Comment thread src/domain/apple/appleArchiveFormat.ts Resolved
Comment thread src/domain/apple/appleArchiveFormat.ts Resolved

@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: c52e244198

ℹ️ 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".

Comment thread src/application/BinaryTargetResolver.ts Resolved

@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: 62909b78b2

ℹ️ About Codex in GitHub

Codex has been enabled to automatically 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 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

@morluto

morluto commented Oct 13, 2026

Copy link
Copy Markdown
Owner

Review findings addressed at their producing boundaries and consumers. Latest changes were reviewed from source; tests and provider runs were skipped at the maintainer's request. Findings requiring separate decisions or verification remain open.

  1. thread 1

The plist-content role selection preserved JavaScript and source-map roles but omitted the existing entitlements role. Updated the owning role mapper to retain entitlements occurrences as well; path-independent content nodes continue to record plist bytes. Source-inspected and pushed in c52e2441985ad8568c4f431302dd208b7e919f68. Tests and checks were not run, as explicitly requested by the maintainer for this pass.

@morluto

morluto commented Oct 13, 2026

Copy link
Copy Markdown
Owner

Review findings addressed at their producing boundaries and consumers. Latest changes were reviewed from source; tests and provider runs were skipped at the maintainer's request. Findings requiring separate decisions or verification remain open.

  1. thread 1

The named-role override now belongs to classifyArtifactContent, where the owning byte classification is available, and applies only when the bytes are XML rather than bplist00. Binary plist magic retains its established precedence over JavaScript/source-map names, consistently with target resolution; XML occurrence roles and path-independent plist nodes remain distinct.

Source-inspected at 42007c0d9d25ebfffb362531fa35b86ecfba8b95. Tests, checks, builds and real-provider runs were not executed, as explicitly requested by the user. This resolves the source correction; no executed verification is claimed.

@morluto morluto added bug Something isn't working area: evidence Evidence, artifacts, and reconstruction area: domain Domain logic, errors, and pure functions P2: medium Medium priority issue labels Oct 13, 2026
dakjdakd and others added 3 commits October 14, 2026 01:00
* fix(comparison): preserve incomplete function call evidence

Keep missing, unknown, partial and unresolved call relationships unknown in function comparisons and reconstruction claims. Aggregate IDA caller and callee coverage without overwriting uncertainty.

Validate with 144 focused tests, typecheck/lint, docs checks and test discovery. Real providers were not verified; the full headless IDA session suite requires unavailable Windows native controls.

* fix(comparison): recheck historical calls-only changes

---------

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

@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: 27cef5dbdf

ℹ️ 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".

Comment on lines +357 to +358
if (size > bytesRead)
throw new BinaryTargetError(

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 Keep the XML limit from overriding .hop database routing

When an automatically inferred .hop file is larger than 1 MiB and starts with whitespace or an unterminated XML comment/PI through this limit, this throws before the .hop database branch at lines 177-186 can run. tests/boundary/filesystem/targetDiagnostics.test.ts:401-410 codifies that non-WASM .hop content routes automatically by suffix (and explicit targetKind: "database" already skips this probe), so the selected database now gets an XML file_format_rejected; let recognized database routing bypass this limit-only failure while preserving the earlier WASM header check.

AGENTS.md reference: AGENTS.md:L13-L13

Useful? React with 👍 / 👎.

if (
format === "plist" &&
!hasBinaryPlistSignature(prefix) &&
["javascript", "source-map", "entitlements"].includes(byPath.kind)

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 .asar precedence in root inventory roles

When XML plist bytes are named *.asar, detectArtifactFormat returns asar because namedArtifactFormat at BinaryTargetResolver.ts:313-314,367-373 runs before the XML probe, but this exception preserves only JavaScript/source-map/entitlements roles, so inspect_artifact reports a plist root while the active target remains an ASAR archive. Fresh evidence beyond the earlier JavaScript/source-map thread is the resolver's explicit .asar branch; preserve that resolved fact for root inventory without relabeling nested headerless .asar entries.

AGENTS.md reference: AGENTS.md:L19-L19

Useful? React with 👍 / 👎.

morluto added a commit that referenced this pull request Oct 14, 2026
Preserve XML and Interface Builder identity at their parsing boundary, retain usable Objective-C slots with precise coverage, and keep native trace failures distinct from absence. Add caller-selected Interface Builder summaries backed by complete retained Evidence, and preserve comparison limitations.

Reviewed fixes: #1969, #2088, #2108, #2513, #2639, #2684, #2731, #2759, #2875, #2888, #2889, #2970, #2971, #3002.

Validation: relevant native/domain focused lane passed 142 tests; earlier Interface Builder/MCP checks passed 24 tests. Real native UI and Ghidra producer coverage was not repeated.
morluto added a commit that referenced this pull request Oct 14, 2026
Normalize path facts once at the owning filesystem boundary, preserve caller spelling and unavailable inventory members, and retain typed read failures. Record exclusion entry kinds so only proven directories can establish descendant symlink targets; omitted legacy kinds stay unknown.

Reviewed fixes include #1969, #2642, #2759, and #2994.

Validation: 26 reference graph source tests passed; prior artifact checks passed 275 tests with one Windows-only skip. Updated compiled import workflows are included in final validation after regeneration.
@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

morluto commented Oct 15, 2026

Copy link
Copy Markdown
Owner

Superseded by the delivered behavior on main: ec271121e. XML keyed-archive classification follows content through the inventory owner; root ASAR XML behavior is covered by 55dd21a, and caller-selected .hop interpretation by 168bfe5. Current classification/target-selection boundaries cover the behavior, so the older implementation and its alternate end-to-end cases are superseded. Closing this earlier proposal; the linked report is already resolved. Current main qualification passed: https://github.com/morluto/rea/actions/runs/38690953281.

@morluto morluto closed this Oct 15, 2026
@morluto

morluto commented Oct 15, 2026

Copy link
Copy Markdown
Owner

Thank you @HeadmasterEggy for identifying keyed-archive XML by its contents rather than relying on the filename. Main includes content-aware archive admission.

@HeadmasterEggy
HeadmasterEggy deleted the codex/fix-xml-keyed-archive-extension branch October 15, 2026 08:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: domain Domain logic, errors, and pure functions area: evidence Evidence, artifacts, and reconstruction bug Something isn't working P2: medium Medium priority issue

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug] inspect_keyed_archive rejects XML keyed archives not named .plist

3 participants