Skip to content

fix(native): accept walkable Mach-O command tables - #8002

Merged
gensokyo-dev merged 2 commits into
mainfrom
fix/7696-macho-command-count
Oct 29, 2026
Merged

gensokyo-dev merged 2 commits into
mainfrom
fix/7696-macho-command-count

Conversation

@gensokyo-dev

@gensokyo-dev gensokyo-dev commented Oct 29, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

Fixes #7696. A valid 4097-command Mach-O table was refused as malformed by native dispatch inspection, even though it fit the selected slice and input-byte budget. Remove the separate 4096-command ceiling; the shared MachoLoadCommandCursor continues to validate command sizes, alignment, count and exact table exhaustion.

Change and boundary impact

The shared native Mach-O layout producer owns this change; dispatch decoding and its CLI/MCP consumers reuse it. Retain selected-slice bounds, CPU/FAT identity checks, input-byte admission, target digests, resource cleanup and existing partial/unsupported metadata semantics. There is no command inventory allocation: the cursor walks each header and retains only interpreted metadata. No schemas, response shape, provider capabilities or authority change. Maintainer scope decision: not applicable to this existing static parser fix.

Validation performed

  • Added thin/FAT valid-table and malformed-final-command regressions: all four failed on the base, then passed after the fix.
  • npm run test:local -- src/native/AppleMachoSelection.test.ts src/domain/apple/machoLoadCommands.test.ts src/native/AppleDispatchMetadata.test.ts — 177 passed.
  • npm run test:focused -- tests/boundary/filesystem/machoCommandAdmission.test.ts tests/boundary/providers/native/objcClassMetadataFallback.test.ts tests/boundary/providers/native/nativeDispatchMetadataFileCleanup.test.ts tests/boundary/cli/nativeDispatchInputBudget.test.ts tests/boundary/cli/nativeDispatchRecordBudget.test.ts — 27 passed, 3 existing macOS-only CLI tests skipped on Linux. This covers malformed framing, slice identity, unsupported formats and failed descriptor cleanup.
  • npm run check:fast, changed-file oxfmt --threads=2, node --check scripts/verify/apple/dispatch.mjs, git diff --check — passed.
  • Added the 4097-command regression to verify:apple-dispatch, already selected by the macOS CI lane: exercise public CLI and stdio MCP with an exact caller byte budget, assert admission/provenance and identical normalized results. The macOS 15 CI verifier step passed, including this case and the existing compiler-produced Objective-C/Swift fixtures. The full Apple CI job also passed 28 boundary files (401 tests passed, 5 skipped); dispatch verification reported 11 fixture variants. Local Linux skips are reported separately above.
  • Integrated the PR with newer main 54f5cf7e1 (including the MCP validation change) in a temporary merge worktree: 177 source tests and 8 public MCP boundary tests passed, 2 macOS-only tests skipped. MCP capability scenarios use an injected provider; this additional check does not claim macOS execution.
  • Executed the built production inspectAppleDispatchMetadata file workflow, including digest admission, result schema and scope cleanup: real 2,228,640-byte SevenZipJBinding macOS x86_64 dylib distributed with Ghidra 12.1.4, plus 65 KiB 4096/4097-command controls. The real artifact and 4096 control returned byte-identical results before/after; 4097 changed from a bounds exception to valid metadata.

Real-artifact SHA-256: dc0e3f370c2966c37c98c33a1f2070308c274f86fc2c1a44e525588fe5961915. The real dylib static file comparison ran on Linux x64 / Node 24.22.1; macOS CLI/MCP coverage is established separately by the CI verifier above.

  • GitHub CI — all 17 executed technical jobs passed, including source tests, all 8 portable shards, native package baseline and real Apple artifact CLI/MCP E2E.

Performance and limits

Production decoder/file workflow, first call then 10 warm calls (OS-cache cold runs unmeasured): real-artifact wall 41.8 → 48.1 ms first, 17.1 → 19.7 ms per warm call; CPU 103.1 → 111.7 ms first, 32.1 → 36.3 ms warm. Whole-probe sampled process-family peak RSS 184.1 → 185.2 MiB (5 ms sampling, no children; 512 MiB JS heap, 2 V8/IO workers). Timings include host variance; no speedup is claimed. The newly accepted 4097 table completed in 2.4 ms first / 2.8 ms warm. Prior failure latency is not a successful-task baseline.

The real normalized result remains 1,958 bytes; command headers are not added to agent replies. Actual agent tokens, client/catalog overhead and end-to-end macOS CLI costs were not measured; no token-reduction claim. No cache or retained command list was added.

Author readiness

Human owner: @gensokyo-dev

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

The user explicitly authorized a ready PR and waived the human-confirmation gate for this session. The unchecked declarations do not attest that a human reviewed the diff or validation evidence.

@chatgpt-codex-connector

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 ⚠️ Failed 2026-10-29T05:48:42.215755Z
We couldn’t complete this review. Comment @codex review to try again.
1f8054b 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 Oct 29, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerView in GreptileConfidence Score: 5/5

[Medium impact] The PR appears safe to merge; no blocking issue was found.

Summary

Removes the separate 4096-command ceiling from parseMachoLayout. The shared MachoLoadCommandCursor still checks command sizes, alignment, count, and exact table exhaustion.

  • Native Mach-O inspection reads valid command tables with more than 4096 entries.

Reviews (2) · Last reviewed commit: "test(native): verify large command table..." · Reviewed by Greptile

@gensokyo-dev
gensokyo-dev merged commit 45cc935 into main Oct 29, 2026
41 of 47 checks passed
@gensokyo-dev
gensokyo-dev deleted the fix/7696-macho-command-count branch October 29, 2026 06:39
@morluto morluto added area: native Native analysis and decompilation, including Ghidra, IDA, and Hopper analysis behavior bug Something isn't working 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.

[Bug] Dispatch metadata rejects a walkable 4097-command Mach-O table as malformed

2 participants