Skip to content

fix(hopper): release a Spotlight not-found launch from the signed helper - #3011

Closed
bruno-candia wants to merge 7 commits into
morluto:mainfrom
bruno-candia:fix/hopper-verified-spotlight-recovery
Closed

bruno-candia wants to merge 7 commits into
morluto:mainfrom
bruno-candia:fix/hopper-verified-spotlight-recovery

Conversation

@bruno-candia

Copy link
Copy Markdown
Contributor

Summary

Builds on #2795 (its three commits are included here until it merges; review only the last two). #2795 now reports the Spotlight not-found failure with setup guidance but, after review, deliberately keeps ownership unknown: a custom launcher could forward the same report after a handoff. As a result the original bug remains — after a Spotlight not-found launch, every later open_binary in the session fails with cleanup_incomplete until the MCP server restarts, even once indexing is enabled.

This adds the provenance gate the review asked for (Greptile P1, Codex P2 on #2795): the not-found report confirms that no document exists only when the executed launcher is Hopper's own vendor-signed helper.

Refs #1808, #2795.

Problem and expected behavior

  • Trigger: macOS with Spotlight indexing off for Hopper's volume, open_binary through the native hopper helper.
  • Violated invariant: a launch that provably failed before handoff must leave the session reusable.
  • New behavior: before running the helper, HopperApplicationLauncher verifies the exact launcher file with codesign --verify --strict -R'= identifier "hopper" and anchor apple generic and certificate leaf[subject.OU] = "2AMA2753NF"'. Only a verified helper sets applicationNotFoundBeforeHandoff on the launch, and only then does HopperClient mark shutdown confirmed for the complete not-found report (exit 3, exact stderr, empty stdout). Wrappers, custom launchers, extra output and non-macOS hosts keep the conservative unknown-handoff outcome from fix(hopper): recover from a Spotlight not-found launch #2795.

Change and scope

  • src/hopper/BridgeLauncher.ts: applicationNotFoundBeforeHandoff launch metadata; injectable verifyNativeHelper dependency; default codesign verification reusing HOPPER_PUBLISHER.teamIdentifier. Verified only on macOS, for the non-owning native launch, before the helper runs.
  • src/hopper/HopperClient.ts: confirms shutdown for the not-found report only with that metadata.
  • tests/acceptance/providers/hopperStartupRecovery.test.ts (separate commit): the late-bridge rows used test.each, which does not pass the workspace fixture, so the file failed typecheck (Property 'workspace' does not exist) and the rows never ran. test.for runs them; the not-found row now expects provider_operation_health.state: "unknown", which is what a non-zero launcher exit produces and what the boundary tests already assert.
  • Not included: locating Hopper without Spotlight.

Ordinary fix within existing boundaries; maintainer scope decision: not applicable.

Contract and boundary impact

  • Semantic owner and earliest changed stage: Hopper launch metadata (src/hopper/BridgeLauncher.ts).

  • Contribution scope fit and linked maintainer decision: bug fix; follows the review on fix(hopper): recover from a Spotlight not-found launch #2795.

  • CLI and MCP/tool-catalog contract: none; error text unchanged from fix(hopper): recover from a Spotlight not-found launch #2795.

  • Provider, bridge, target-format, or platform compatibility: macOS native launch only; adds one codesign invocation per launch.

  • Evidence, artifact, provenance, or reconstruction contract: none.

  • Target selection, authority, upstream behavior, and cleanup details: cleanup completes only for the verified helper; every other launcher keeps the runtime and lease.

  • Generated metadata, package, or installation impact: none.

  • Launch or attach to a process.

Evidence and regression coverage

  • Tests added: boundary tests in hopperClient.helperFailure.test.ts (verified helper releases ownership and the same client starts again twice; unverified launcher and verified helper with extra stdout both stay cleanup_incomplete) and in bridgeLauncher.test.ts (flag only with a verified helper; no verification outside macOS; the default verifier rejects a non-Hopper executable).

  • Base reproduction: with HopperClient.ts from fix(hopper): recover from a Spotlight not-found launch #2795's head, releases a verified native helper's Spotlight not-found launch so the session can retry fails; with this change it passes.

  • Real signature: on macOS with Hopper Disassembler 6.6.0-demo, Contents/MacOS/hopper satisfies the requirement (Identifier=hopper, TeamIdentifier=2AMA2753NF); the main Hopper Disassembler executable does not, so the identifier pins the helper.

  • Remaining proof gaps: not reproduced end to end with Spotlight disabled on a real host (that needs changing the system indexing setting). The requirement was checked against the 6.6.0-demo build only.

  • Unsupported, incomplete, unavailable, or uncertain outcomes remain visible.

Validation performed

  • npm run check:fast — typecheck and lint passed (on fix(hopper): recover from a Spotlight not-found launch #2795's head it fails with the test.each typecheck error above)
  • npm run test:focused -- all src/hopper/*.test.ts, tests/boundary/providers/hopper/*.test.ts and tests/acceptance/providers/hopperStartupRecovery.test.ts — 30 files, 1 failure: retains a denial-shaped failure when caller arguments can alter the helper's AppleScript (ENOENT on loader-target in acquireHopperTargetLease), which fails the same way on fix(hopper): recover from a Spotlight not-found launch #2795's head and on main on this host
  • codesign --verify --strict -R'<requirement>' against the installed helper — satisfied

Compatibility, safety, and release

  • Breaking changes or migration steps: none.
  • Real Hopper/Ghidra, browser, or OS coverage: macOS, Hopper Disassembler 6.6.0-demo (signature check only).
  • Package or release metadata impact: none.
  • Security, privacy, process, or containment review: verification runs before the helper executes; a file swapped between verification and execution would need write access to the Hopper bundle. On failure the outcome stays conservative.

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. (No new output; message unchanged from fix(hopper): recover from a Spotlight not-found launch #2795.)
  • I checked the final diff for secrets, unrelated cleanup, and unsupported claims.

🤖 Generated with Claude Code

bruno-candia and others added 5 commits October 14, 2026 02:40
Hopper's native launcher locates the application through a fixed Spotlight
query before any Apple event. With indexing disabled it exits 3 with a
not-found report, but REA treated the external document as unconfirmed,
retained the runtime and failed every later open_binary until the server
restarted. Recognize the complete report as a pre-handoff failure, confirm
no document exists, and tell the caller to enable Spotlight indexing.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
test.each does not pass the workspace fixture, so the rows failed to
typecheck and never ran. With test.for they run, and the not-found row
now expects the unknown provider state that a non-zero launcher exit
leaves, matching the boundary tests.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
A Spotlight not-found report keeps ownership unknown because a custom
launcher could forward it after a handoff. Hopper's own helper fails its
Spotlight lookup before any Apple event, so verify the exact launcher
file with codesign against the vendor requirement (identifier hopper,
Apple anchor, team 2AMA2753NF) before it runs. Only then does the
complete report confirm that no document exists, so the session can
retry after the user enables indexing instead of restarting the server.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@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 🔄 Running since 2026-10-21T13:53:05.143584Z e757dfc 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

RetriggerView in GreptileConfidence Score: 5/5

[Low impact] The test-only change appears safe to merge.

Summary

Adds tests for native Hopper helper verification. This PR changes tests only; the implementation described in the PR is already in the base.

  • Boundary tests check which Hopper launches carry signature proof.

Reviews (3) · Last reviewed commit: "Merge remote-tracking branch 'origin/mai..." · Reviewed by Greptile

Comment thread src/hopper/BridgeLauncher.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: 2bd3124833

ℹ️ 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/BridgeLauncher.ts Outdated
HopperProcessError,
HopperStartError,
} from "../domain/hopperErrors.js";
import { HOPPER_PUBLISHER } from "../application/MacHopper.js";

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Move the publisher identity into a provider-owned module

BridgeLauncher is a provider adapter, but this value import pulls it outward into application/MacHopper (and transitively into setup/download implementation), reversing the required dependency direction. Put the publisher identity in a provider-owned module and let the installation workflow import that instead.

AGENTS.md reference: AGENTS.md:L17-L17

Useful? React with 👍 / 👎.

Comment thread src/hopper/BridgeLauncher.ts Outdated
Comment on lines 244 to 247
(await (
this.dependencies.verifyNativeHelper ?? verifyHopperNativeHelper
)(this.options.launcherPath, this.options.environment));
const started = await launchHopperProcess({

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Bind verification to the executable that is spawned

When the configured launcher path is replaceable (notably setup installs under ~/Applications and custom paths are allowed), this await verifies one path resolution, then launchHopperProcess performs asynchronous ownership preparation before spawn resolves the path again. A replacement in that window can run a wrapper while nativeHelper remains true; if it hands off a document and emits the exact exit-3 diagnostic, HopperClient marks shutdown confirmed and releases the lease/runtime. Execute an immutable verified copy or otherwise bind provenance to the executable identity.

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

Useful? React with 👍 / 👎.

Comment thread src/hopper/BridgeLauncher.ts Outdated
`-R${HOPPER_NATIVE_HELPER_REQUIREMENT}`,
launcherPath,
],
{ env: environment },

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 Pass the startup abort signal to codesign

When codesign stalls on a slow/unavailable launcher volume, or the caller cancels while verification runs, this execFile has neither a signal nor a timeout and the injected verifier contract cannot receive one. The ProviderStartupDeadline signal can therefore abort while start() remains blocked until codesign exits, so timeout and cancellation no longer bound this startup phase; thread the launch signal through the verifier and into the execFile options.

Useful? React with 👍 / 👎.

@morluto morluto added area: native Native analysis and decompilation, including Ghidra, IDA, and Hopper analysis behavior bug Something isn't working labels Oct 13, 2026
morluto added a commit that referenced this pull request Oct 14, 2026
Retain unresolved process identity and launch evidence through retryable cleanup. Share capture path normalization and preserve failed filesystem observations. Bound child output and drain Windows pipes without one-chunk throttling.

Reviewed fixes include #1628, #2632, #2644, #2784, #2928, #2931, #2965, #2992, and #3011.

Validation: 92 focused source tests passed; four platform-specific skips. Real Windows and Hopper lifecycle coverage was not rerun.
@kaoru0822-kitauji kaoru0822-kitauji added the ci-fix-wip Claimed by the CI-fix track label Oct 14, 2026
Main (599a8ee) already releases a Spotlight not-found launch only when the
native helper is verified, through `nativeHelperVerified` and its
`verifyNativeHelper` dependency. Keep main's launcher, client, diagnostic and
fixtures instead of adding a second verifier and an
`applicationNotFoundBeforeHandoff` flag. Port this branch's launcher-level
tests to main's API: only a verified helper is marked, verification never
runs outside macOS, and a real unsigned launcher stays unverified.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@kaoru0822-kitauji

Copy link
Copy Markdown
Collaborator

CI-fix track: the failing Static checks (format) and analysisView message-count shard came from main's state at the time, not this PR. I merged current main (2ac3452). Main already took this fix in 599a8ee (which lists #3011): BridgeLauncher sets nativeHelperVerified through a verifyNativeHelper dependency, and HopperClient confirms shutdown for the Spotlight not-found report only for that verified helper. I kept main's launcher, client, diagnostic and fixtures rather than add a second verifier and an applicationNotFoundBeforeHandoff flag. This PR now contributes its launcher-level tests ported to main's API: only a verified helper is marked, verification never runs outside macOS, and a real unsigned launcher on macOS stays unverified. Locally: Hopper source, boundary and acceptance tests pass (211, 5 skipped), and check:fast is clean.

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

@kaoru0822-kitauji kaoru0822-kitauji removed the ci-fix-wip Claimed by the CI-fix track label Oct 14, 2026
@greptile-apps

greptile-apps Bot commented Oct 14, 2026

Copy link
Copy Markdown
Contributor

Want your agent to iterate on Greptile's feedback? Try greploops.

@CassieFox23

Copy link
Copy Markdown
Contributor

Heads up: main covers this in its own way in 4acda94. The code is in src/hopper/BridgeLauncher.ts. The test releases the runtime and target lease after a provenance-verified Spotlight exit, then retries shows it. Only the tests are left. It is listed on tracker #3582. If this PR still adds something main doesn't have, please say so here and I'll take it off the list. Thanks for the fix!

🤖 Generated with Claude Code (Sonnet 5.5, verified by Opus 5.5) 🦊

# Conflicts:
#	tests/boundary/providers/hopper/bridgeLauncher.test.ts
@kaoru0822-kitauji

Copy link
Copy Markdown
Collaborator

CI-track update: I merged latest main (6d356b8) into this branch to clear the conflict (merge commit e757dfc, no force-push). The only conflict was in tests/boundary/providers/hopper/bridgeLauncher.test.ts, where this PR's native-helper verification tests and main's new Linux publisher-rejection test were both added at the same spot. I kept both blocks unchanged, this PR's first. Locally npm run check:fast, npm run format:check and npm run test:focused -- tests/boundary/providers/hopper/bridgeLauncher.test.ts passed (14 passed, 2 platform-conditional skips on macOS).

@morluto

morluto commented Oct 26, 2026

Copy link
Copy Markdown
Owner

Thanks for the Spotlight recovery investigation and helper-signature evidence. Main now verifies the native helper and uses that provenance for the not-found recovery path (4acda94), with provider boundary coverage. The remaining diff adds launcher-level controls for verified, unverified and non-macOS cases; I am closing that coverage-only overlap for now. Please reopen if those checks expose a distinct failure or an important missing signature case. A real Spotlight-disabled end-to-end run was not established here.

@morluto morluto closed this Oct 26, 2026
@morluto morluto added area: build Build, CI, packaging, and publishing provider: hopper Analysis provider / engine: hopper labels Nov 23, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: build Build, CI, packaging, and publishing 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.

4 participants