Skip to content

fix(hopper): preserve startup failures and recover denied launches - #1817

Merged
N0zoM1z0 merged 2 commits into
mainfrom
codex/fix-hopper-startup-recovery
Oct 11, 2026
Merged

N0zoM1z0 merged 2 commits into
mainfrom
codex/fix-hopper-startup-recovery

Conversation

@morluto

@morluto morluto commented Oct 11, 2026 •

Copy link
Copy Markdown
Owner

Refs #1808.

After a native Hopper launch failed, REA retained an unconfirmed GUI handoff but discarded the startup result. Later tools returned unreadable_output from an unrelated "already started" error, and operational health lost the original cause. Preserve the typed startup failure and launcher diagnostics while cleanup is pending, including deadlines during the initial health handshake.

Release a denied launch only when the helper returns its complete Apple Events authorization rejection (exit 2, no signal, closed and untruncated output) and all native invocation arguments are literal-safe. The vendor helper interpolates arguments into AppleScript without escaping: a real Hopper 6.6 probe opened a document and then emitted the identical rejection. Quotes, backslashes, and line breaks therefore withhold the pre-handoff conclusion without changing caller inputs. Other ambiguous failures retain the runtime and target reservation. An established denial reports the macOS Automation remedy and permits retry.

Cleanup requires a successful token-authenticated health handshake with the exact run identity. Disconnect a rejected initial handshake before cleanup so it cannot authorize document shutdown. Explicit close can reconnect to a late bridge or a previously valid session whose transport failed. The shipped Python bridge now accepts successive connections, survives disconnected writers, and remains available after an unconfirmed shutdown. Its idle reconnect window is 30 seconds, matching the cleanup handshake budget; expiry releases Hopper's Python execution thread without claiming document closure.

Add REA_HOPPER_STARTUP_TIMEOUT_MS to shared CLI/MCP provider configuration, using the same validated integer range as Ghidra and retaining Hopper's 120-second default. Document timeout and recovery behavior. Replace the touched CLI test's global lease scan with recovery of its exact target through the production lease API.

Validation:

  • Focused config/Hopper/CLI/MCP coverage: 25 files, 184 passing tests, two platform skips. Includes same-server denial recovery, caller-controlled arguments, mismatched initial and late run/token handshakes, health deadline diagnostics, transport loss, lost replies, unconfirmed shutdown retry, and reconnect expiry.
  • Ghidra provider configuration regression: 40 tests passed in the original change.
  • npm run check, npm run docs:check, npm run verify:test-discovery, and the pre-push check passed; all 838 test files are discovered exactly once.
  • Real npm run verify:hopper passed on Hopper 6.6.0-demo after these changes: 200 successful calls, 63 expected rejections, confirmed cleanup, and survival of an unrelated process. The original change also passed on Hopper 6.1.0-demo.
  • Real Hopper 6.6 reconnect probe: interrupt a successfully authenticated session through a local socket relay, then explicitly close through the production client and native launcher. A fresh connection authenticated the same run, confirmed document closure, and removed the runtime.
  • Real native Hopper 6.6 diagnostic probe: an owned target opened before the helper emitted the exact authorization rejection. Through the compiled stdio MCP server, REA returned cleanup_incomplete, retained its exact runtime, preserved the failure on repeated calls, and refused to claim successful close. A separate authenticated session observed document creation, and explicit probe cleanup confirmed the exact executable path. This supersedes the earlier inference that matching diagnostic text alone established no handoff. The initial 6.1/6.6 fault probes establish diagnostic compatibility only; simulated denial recovery does not establish a real Claude Desktop TCC-denial reproduction.
  • Real CLI analyze /usr/libexec/sharingd --provider hopper --json with Hopper 6.6 and REA_HOPPER_STARTUP_TIMEOUT_MS=900000 exited successfully in 46.30 seconds, returning 41,920 procedures and 25,495 strings. Hopper returned to idle and no new Hopper crash report appeared. This host runs macOS 26.3 arm64, not the reporter's macOS 27.

The native helper does not expose a structured authorization error. Changed or localized diagnostics, incomplete output, signals, and other script failures retain conservative ownership. The reporter's macOS 27 Hopper SIGSEGV remains unverified; launcher exit 0 and missing bridge readiness do not establish a GUI crash.

@morluto
morluto marked this pull request as ready for review October 11, 2026 12:48
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 11, 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-11T13:15:31.841561Z 02d4c2e 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.

@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: 02d4c2edb6

ℹ️ 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/hopper/HopperClient.ts Resolved

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

Reviewed the startup-failure, retained ownership, authenticated cleanup, and bridge reconnect paths. The exact contributor head is 02d4c2edb6eeab2e91bc076b14605b9384222992; all 31 check runs are successful.

On a separate branch composed with main ed1519ddee02739f57136e356786f64c7f74fed0, the expected Git merge tree matched the tested tree. A fresh runtime and MCP bundle build passed, followed by 65 focused configuration/diagnostic/cleanup/handshake/bridge tests. The ordinary focused prerequisite rebuild exceeded the bounded memory budget before reaching tests; the exact runtime and skill prerequisites were subsequently generated with the compiler's single-threaded mode and the same planned tests passed.

Real headless Linux Hopper 6.4.2-demo on a 23 KiB source-built ELF passed the public MCP semantic workflow: known call edges, string/global references, CFG, pseudocode, ephemeral comment readback, malformed-selector recovery, close/reopen, unchanged target digest, and canonical output schemas. Private runtime cleanup completed. This verifies Linux engine and owned-process behavior; it does not establish macOS AppleEvents denial, macOS SIGSEGV recovery, or saved-HOP behavior. The reauthentication protocol is separately covered by the shipped Python bridge test.

The later main change 5876779013726964deef748120c48f5fa0155546 changes README files only. Runtime, bridge, contracts, scripts, dependencies, and TypeScript configuration are unchanged relative to the tested base; its merge tree is conflict-free.

@N0zoM1z0
N0zoM1z0 merged commit 069308b into main Oct 11, 2026
31 checks passed
@N0zoM1z0
N0zoM1z0 deleted the codex/fix-hopper-startup-recovery branch October 11, 2026 14:35
@morluto morluto mentioned this pull request Oct 13, 2026
3 tasks done
@morluto morluto added bug Something isn't working area: native Native analysis and decompilation, including Ghidra, IDA, and Hopper analysis behavior labels Oct 14, 2026
@morluto morluto added the provider: hopper Analysis provider / engine: hopper label Nov 23, 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 provider: hopper Analysis provider / engine: hopper

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants