Skip to content

fix(hopper): reconcile observed caller relationships - #7953

Merged
morluto merged 18 commits into
mainfrom
codex/hopper-tailcall-5438
Oct 29, 2026
Merged

morluto merged 18 commits into
mainfrom
codex/hopper-tailcall-5438

Conversation

@morluto

@morluto morluto commented Oct 29, 2026 •

Copy link
Copy Markdown
Owner

Summary

Fixes #5438. Hopper can report a resolved tail call in a forward callee inventory while omitting it from callers and incoming references. Reconcile those observations so backward graphs and paths can recover the caller and exact call site, while keeping relationship coverage unknown.

Problem and expected behavior

On the ARM64 fixture, _call_direct branches to _target_fn, but the base revision returns no corresponding caller and cannot reach it in a backward path. The new result retains the observed caller and direct call reference; it does not infer completeness from Hopper's independent APIs.

Change and scope

The Hopper bridge pages forward observations into a bounded reverse index owned by one composed workflow; standalone calls get a fresh scan. The same owner supplies callers, incoming references and dossiers. Evidence retains the native reply and the selected target's forward observations. Hopper capabilities are marked live because the document has no revision token. Safe live observations remain retainable as Evidence without snapshot replay. MCP progress now handles multiple child phases without dropping later updates.

The cooperative scan defaults to 2,000 ms and can be changed with REA_HOPPER_CALLER_SCAN_BUDGET_MS; it reports examined counts and capacity omissions. Pages contain at most 64 procedures, with 512 KiB per page or target list and 4 MiB retained encoded scan data. Cancellation is checked between pages. Hopper's synchronous native array calls cannot be interrupted or bounded by REA mid-call, and a live document can change during a scan.

Contract and boundary impact

  • Semantic owner: Hopper bridge observations; the workflow-scoped provider index supplies the three consumers.
  • Contribution scope: ordinary read-only analysis fix; no new execution, injection or mutation authority.
  • CLI/MCP: no tool input schema changes; adds opt-in progress and an environment budget. Hopper source observations no longer replay from snapshots.
  • Evidence: preserves native reply, selected forward caller/reference facts and unknown or incomplete coverage; safe live source Evidence remains retained.
  • Compatibility and cleanup: Hopper on supported hosts; no target execution or attached GUI save/close. Owned session cleanup remains with existing process supervision.
  • Generated metadata: no authored catalog change; adds a real-Hopper verifier command.

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.

Evidence and regression coverage

  • The baseline real-Hopper MCP reproduction omitted the synthetic tail caller; the new verifier checks forward and reverse calls, exact incoming direct reference, dossier, backward graph and reached path.
  • An independent real-Hopper run on macOS /bin/ls also recovered the branch at 0x10000078c into 0x10000071c across callers, references, dossier, graph and path; the artifact digest remained unchanged.
  • The 4,002-procedure synthetic scan checks opt-in monotonic progress, no notifications without a token, cancellation after partial progress, ping/retry and owned session cleanup. Unit/boundary checks cover page and instruction capacity, scope cleanup, live Evidence and no snapshot replay.
  • Manual GUI mutation, Hopper versions other than the installed macOS provider, Linux Hopper and interruption inside one synchronous native call were not verified. A complete scan still has unknown live consistency.

Validation performed

  • npm run verify:hopper:callers — passed against real Hopper on macOS ARM64, including retained forward Evidence and 4,002-procedure progress/cancellation/retry.
  • npm run test:local -- src/hopper/HopperProvider.test.ts src/hopper/HopperCallerReconciliation.test.ts src/server/mcpProgress.test.ts src/application/WorkflowEvidence.test.ts src/application/binary/BinarySessionLiveness.test.ts src/application/binary/AnalysisSnapshotCache.test.ts — 94 passed; the focused three-suite rerun after provenance changes passed 19.
  • npm run test:focused -- tests/boundary/providers/hopper/hopperCallerReconciliation.test.ts — passed.
  • npm run check:fast and npm run docs:check — passed; git diff --check passed.

A single-session, uncontrolled-cache/scheduling comparison on a 1,207-procedure synthetic target measured five warm backward graphs at 117–134 ms after the fix vs 1.8–4.8 ms on baseline. The complete open/caller/five-graph/close task took 4.66 s vs 3.68 s. Sampled process-family peak RSS was 592,752 vs 589,264 KiB and sampled CPU 1.88 vs 1.48 s. The index retained 587,580 encoded bytes; tokenx estimated 6,822 vs 6,705 reply tokens. These are single samples, not controlled cold/warm distributions; catalog tokens were not included, and the baseline did not provide the recovered relationship. The latency increase is material.

Compatibility, safety, and release

No caller migration is required. Native API allocations and single calls remain outside the cooperative page bound. Scope includes existing Hopper document analysis and owned temporary files; target binaries are not executed or modified.

Author readiness

Human owner: @morluto

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

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 29, 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 ⚠️ Failed 2026-10-29T14:32:45.047165Z
We couldn’t complete this review. Comment @codex review to try again.
cc47602 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 29, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerView in GreptileConfidence Score: 5/5 Tier: apex

[Medium impact] The changes since the last review appear safe to merge; no new blocking issue was found.

Summary

The PR combines Hopper’s reverse caller results with forward observations so callers, incoming references, dossiers, and backward walks can recover missing relationships. Coverage remains unknown.

  • Hopper's forward call observations restore callers and exact call sites to backward analysis.
  • Hopper caller scans report progress and stop within set time and size limits.
  • Composed workflows reuse provider scan state only until that workflow ends.
  • Safe live Hopper observations can be saved as Evidence without snapshot replay.

Diagram

%%{init: {'theme': 'neutral'}}%%
flowchart TD
  Native[Native caller or reference reply] --> Reconcile[Reconcile observed relationships]
  Pages[Bounded forward scan pages] --> Index[Workflow-owned reverse index]
  Index --> Reconcile
  Reconcile --> Results[Callers, incoming references, and dossiers]
  Results --> Walks[Backward graphs and paths]
  Reconcile --> Evidence[Retained source Evidence]
  Pages --> Failure[Cancellation or page failure]
  Failure --> Partial[Native reply and completed scan facts]
  Finish[Workflow finishes] --> Clear[Clear temporary index]
Loading

Reviews (9) · Last reviewed commit: "test(hopper): throw typed scan failures ..." · Reviewed by Greptile

Comment thread scripts/verify-real-hopper-callers.mjs 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: 057370657d

ℹ️ 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/HopperProvider.ts Resolved
Attach the native reply and collected forward facts when reconciliation
fails or is cancelled, and check scan stop codes separately from their
wording. Live observations keep REA evidence ids rather than provider
supplied ones, and the real Hopper verifier uses advertised MCP schemas.
@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.

Comment thread src/config/environment.ts Resolved
The packaged Hopper stand-in echoed unknown bridge methods, so
analyze_function rejected rea_caller_scan_target as an invalid scan
target and the native package baseline returned unreadable_output.
Failure partials repeated each caller identity under every destination.
The page budget counted compact replies, then schema parsing copied the
expanded form. Identities are stored once and destinations cite addresses.
The environment schema hard-coded the 2000 ms scan default. The domain
limit owner now names that millisecond budget and the schema reuses it.
compare_bundles reports each relative path as an invalid_format issue
instead of one joined diagnostic sentence.
@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.

Comment thread src/application/binary/BinarySession.ts Resolved
inspect_dart_aot reports the ABI label as an issue on path abi. The
message is the selector contract, without an abi: prefix.
@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.

A missing document selector blocks snapshot replay. Backward call-graph
and trace reads still keep the native result and forward observations,
and the workflow Evidence links those records.
@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.

Comment thread src/config/environment.ts Resolved
Comment thread bridge/hopper_bridge.py Resolved
…-5438

# Conflicts:
#	tests/boundary/mcp/flutterMcp.test.ts
…-5438

# Conflicts:
#	src/domain/flutter/flutterBuildAnalysis.ts
@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.

Caller and callee walks still stay in Evidence without a document.
procedure_pseudo_code does not, so decompile_all leaves each body in the
file-backed export instead of retaining the whole export in memory.
Scan facts stay in the domain. Environment recovery, including the time
budget bounds and the fixed allowances with no runtime override, is
appended from configuration. Setup forwards the budget, and the bridge
uses one byte allowance for instructions, native callers, and pages.
@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.

Comment thread src/application/binary/BinarySession.ts Resolved
Recovered call sites stay in the address form the scan already counted.
Expanded identity copies are measured before allocation and refused when
they exceed the retention budget. Instruction lists are not part of the
retained reply.
Documentless caller and callee reads stay in the ledger for the session.
Their evidence keeps call sites and drops instruction lists the scan
already consumed.
@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.

Comment thread src/application/binary/BinarySession.ts Resolved
A page reference marked source_procedure "caller" belongs to that page
item's caller. Saved sites record that address, and an owner missing from
the callee inventory is stored once instead of copied onto every site.
Documentless caller evidence stores the adapter's raw result unchanged.
The session no longer reads native_result.instructions.
@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.

Successful caller-scan results now throw the typed error instead of
returning after an ok check. Expected failures assert structured tags,
stop codes, and reported limits.
@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 merged commit ec4a0a0 into main Oct 29, 2026
47 checks passed
@morluto
morluto deleted the codex/hopper-tailcall-5438 branch October 29, 2026 14:55
Entrpi added a commit to Entrpi/rea that referenced this pull request Oct 29, 2026
Upstream's caller reconciliation (morluto#7953) and this branch both added
imports and tests to src/hopper/HopperProvider.test.ts; keep both
import sets. Together the tests took the "Hopper provider capabilities"
block to 172 lines, over the 150-line function limit, so the
inspectTargetSupport refusal tests move into their own "Hopper provider
target support" block, as the IDA tests do. Test bodies are unchanged.
@morluto morluto added bug Something isn't working provider: hopper Analysis provider / engine: hopper labels Nov 22, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working provider: hopper Analysis provider / engine: hopper

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug] Hopper reverse caller queries omit a resolved direct tail call

2 participants