Skip to content

feat(native): page retained procedure references - #8588

Merged
morluto merged 33 commits into
mainfrom
codex/procedure-reference-stacked
Nov 8, 2026
Merged

morluto merged 33 commits into
mainfrom
codex/procedure-reference-stacked

Conversation

@morluto

@morluto morluto commented Nov 1, 2026 •

Copy link
Copy Markdown
Owner

Summary

A Ghidra procedure with many incoming references can produce an MCP response too large to inspect. Add an opt-in summary and retained pages for the procedure's references and unresolved calls, plus a one-shot CLI handoff. Refs #8587.

#8585, which supplied the underlying retained feature-view work, has merged. This branch has been reconciled with main at f8bb792f; its procedure-reference view remains the change under review.

Problem and expected behavior

On an 8,000-pointer fixture, Ghidra's procedure_references completed with 8,001 rows but exceeded the default MCP response budget. Exact-record retrieval also exceeded it; the complete export remained available. A caller seeking a small number of rows can now request detail: "summary" and page the retained parent without rerunning analysis.

Change and scope

  • Move the existing complete result shape to its domain owner; omitted detail remains complete. The new native-procedure-references view pages references or unresolved calls. Exact source/target filters apply to references, and source_index preserves original order and duplicates.
  • Each endpoint explicitly refers to the selected procedure, preserves null, or includes a different procedure. Identical procedure objects are represented once per page; no owner is inferred from address proximity. Pages retain direction, source provider/profile, parent ID and limitations.
  • Page construction uses a fixed 1 MiB projection allowance to leave room for Evidence and MCP encoding. byte_limited and next_offset identify a shortened page; a single oversized row or page context returns a resource error with parent recovery. Complete parent Evidence is not modified.
  • rea procedure-references ... --detail summary --evidence_output PATH saves the complete result and linked source Evidence for offline inspect-analysis-view. A missing source refuses publication.

Contract and boundary impact

  • Semantic owner: procedureReferencesSchema owns the existing provider result; a retained view projects it without reinterpreting provider kinds. Contribution scope: existing static read-only provider operations; no new target execution, mutation, injection, or protection recovery.
  • MCP adds optional detail, summary, and page schemas; default complete output is unchanged. CLI adds one provider-neutral procedure-reference command. Full output schema correlates page collection and rows; compact advertisement is intentionally reduced and runtime validates the canonical contract.
  • Original source and target identities, provider facts, uncertainty and body coverage remain available. Page exhaustion is not discovery completeness or runtime proof. Kuna currently reports this operation unavailable; no provider fallback is added.
  • The 1 MiB projection budget does not bound the provider's original result, its parsing, or retained session memory. Existing Ghidra session cleanup and target selection are unchanged. No generated output or binary is committed.

Expected effects of the existing workflow:

  • 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 and regression coverage

  • Real Ghidra 12.1.4/JDK 21, macOS arm64, both MCP schema profiles: an 8,000-pointer Mach-O produced a summary of 8,001 references; first/last pages matched the full parent and both profiles' advertised output schemas. A fresh target-free import reconstructed every original row from pages. The unexecuted binary remained unchanged.
  • A separate test-owned Ghidra project was edited by a headless Java script to give a function two body ranges. The page retained an interior-target reference and excluded a gap reference; exact xrefs found the gap reference. The executable was unchanged. A distinct two-indirect-call fixture preserved both unresolved sites and reasons through MCP pages and a CLI bundle. These are controlled fixtures, not general accuracy or coverage claims.
  • Real Ghidra existing-project CLI output retained its linked historical health Evidence and supported offline paging. Its repeated snapshot invocation re-observed the provider rather than proving snapshot-cache replay. Real Kuna 1.988 returned capability_unavailable and created no output bundle.
  • Synthetic public-boundary controls cover duplicate indices, intersecting exact filters, null versus inline endpoint identities, nonempty unresolved calls, offline import, and incompatible collection/filter schemas. A 24,003-row source reconstructed across 11 bounded pages; a single oversized row returned a recoverable resource error while a different collection remained readable.
  • Real compact MCP on a separate 24,000-pointer Mach-O: 25 pages returned 24,001 incoming procedure-reference rows. All (source, target, type) triples matched the complete exported inspect_native_instruction observation at the entry on this fixture. The target was unchanged and unexecuted. This is a function-specific comparison, not general equivalence; the instruction tool itself has no bounded view for this collection ([Design] Page retained native instruction references #8593).
  • Remaining gaps: no Hopper, Windows, Linux, autonomous-agent, CLI cancellation/final-cleanup or large real-world corpus control; source-result construction and retention remain unbounded by the page budget.

A controlled final-close cancellation with a real Ghidra project returned the completed procedure observation but omitted its already-captured linked source from the one-shot result; cleanup succeeded. This shared #8585 delivery boundary is tracked in #8589. Public-process cancellation and cleanup-failure recovery have not been reproduced.

Validation performed

  • CI follow-up: shard 5 hit stdout maxBuffer in the real HAR exhaustion test because its fixture sat near the default decoder heap threshold and its CLI/MCP calls had different inputs. Both calls now use the same explicit 64 MiB limit and sensitive value, retaining real exhaustion and recovery checks; a small separate MCP control preserves default-heap coverage. Merged main 1a0e2c77f2, preserving both retained-view contracts. Node 24: 39 focused HAR and MCP view tests passed, plus 36 decoder configuration/error tests before the merge; check:fast and format:check passed. Windows and Bun were not rerun. Hosted CI is pending.

  • Reconciled with main a67525cd after the documentation move. Node 24.22.1 targeted procedure-reference view, parent-view, MCP and CLI suites passed 54 tests; staged diff check passed. Real-provider evidence below predates this integration and was not rerun.

  • CI follow-up: Static checks failed on main's pre-existing formatting in cliHelpDefaultAnnotations.test.ts; merged main ac30fbd6 (which fixes it) into this branch. On Node 24.22.1, the full format:check, staged diff check and 54 focused tests passed after the merge. Hosted CI was restarted on the new head.

  • After reconciling with main f8bb792f, Node 24.22.1 focused source-view suites passed 49 tests and production-boundary MCP/CLI suites passed 5 tests. Changed conflict files passed oxfmt --check; git diff --cached --check passed.

  • Real Ghidra and Kuna results below predate this integration; they were not rerun on the reconciled head.

  • Focused CLI/MCP boundary suites: 5 tests passed, including missing-source refusal and oversized-row recovery.

  • npm run check:fast, npm run docs:check, changed-file oxfmt --check, and git diff --check passed.

  • Real-provider and schema checks above were performed on this host only. No target was executed.

Representative delivery measurement

One compact-MCP task requested the first and last of 3,001 incoming Ghidra references. Complete delivery used one call and 1,902,437 tokenx-estimated tokens for serialized SDK requests/replies; summary plus two pages used three calls and 9,904 estimated tokens. Additional compact catalog estimates were 161,639 and 161,760 respectively. Both selected original rows reconstructed identically. SDK serialization includes text and structured forms and may double-count; estimates are not model usage or billing.

Cold/warm elapsed seconds were 4.302/0.330 versus 4.040/0.258; sampled process-family CPU seconds 7.29/0.76 versus 7.57/0.71; sampled peak RSS MiB 948.7/1023.5 versus 918.2/946.3. One run each, 100 ms samples; server startup, catalog transfer and short-lived peaks are excluded. This demonstrates a delivery-shape tradeoff, not general latency or memory improvement. Both paths construct and retain the complete result.

Compatibility, safety, and release

No breaking change for existing calls that omit detail; the new CLI command and retained views are additive. Snapshot and source-closure behavior depends on #8585. Other hosts and providers remain unverified for the new workflow.

Author readiness

Human owner:

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

@greptile-apps

greptile-apps Bot commented Nov 1, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerView in GreptileConfidence Score: 5/5 Tier: plus

[Medium impact] The PR appears safe to merge based on this review; no new blocking issue was found.

Summary

Adds opt-in summaries and retained pages for procedure references and unresolved calls.

  • Procedure references can be summarized and read in bounded pages.
  • The CLI can inspect a procedure's references and save them for offline paging.
  • The historical capture resource test sets its heap limit explicitly.

Diagram

%%{init: {'theme': 'neutral'}}%%
flowchart TD
  A[Procedure reference observation] --> B[Complete parent Evidence]
  B --> C{Requested detail}
  C -->|complete| D[Complete result]
  C -->|summary| E[Retain parent and return summary]
  E --> F[Inspect retained parent]
  F --> G[Exact filters and matching-row offset]
  G --> H[Byte-bounded page with shared endpoints]
  B --> I[CLI bundle with linked source Evidence]
  I --> F
Loading

Reviews (20) · Last reviewed commit: "Merge branch 'main' of https://github.co..." · Reviewed by Greptile

Comment thread src/cli/coreNativeCommands.ts Resolved
Comment thread src/domain/analysisView/analysisView.ts Resolved
@morluto
morluto marked this pull request as ready for review November 4, 2026 16:53
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 4, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-08T01:00:54.046154Z 1c9487b 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.

Keep one-shot Evidence bundle capture and linked source closure together,
including snapshot replay and immutable bundle publication.
…-stacked

Update the stacked branch with the base that now contains origin/main. Keep
procedure-reference pages together with the landed feature-trace, value-trace,
and batch-decompile views.
@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 trace keeps linked sources on the result. Use those records for the
undelivered source closure as well as the bundle, so a refused output
does not report them as not captured.
@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.

The merge of origin/main did not start the CI workflow for this head.
Keep the native feature-trace view description and main's batch-decompile
status example that includes unavailable rows.
…-stacked

Keep the procedure-reference description with the updated feature-trace text
and the batch-decompile unavailable status example from main.
@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.

Base automatically changed from codex/native-feature-trace-views to main November 4, 2026 19:26
Retarget onto main after the feature-trace squash. Keep procedure-reference
pages with the landed feature-trace and batch-decompile view text.
@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.

Size the candidate before building one canonical identity, and reuse that
key for the selected-procedure and shared-endpoint checks.
@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.

…zing it

When the JSON size already exceeds every stored identity, skip the canonical
string and keep the row out of the page.
@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.

Avoid execution wording in the tool description, and give the CLI direction
option the help text the catalog requires.
@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.

Keep one running maximum of stored identity bytes. A multibyte selected
procedure is recognized when its JSON no longer fits the page.
@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.

The MCP tool has a CLI command, so it is no longer an MCP-only exception.
@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.

Use a 200,000-character multibyte selected procedure and a shorter ASCII
endpoint so the old JavaScript length check drops the selected row.
@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.

The required check failed because the toolchain install exceeded 15 minutes.
The same job completed on the previous head, and this commit does not change
the procedure-reference behavior.
@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 enabled auto-merge (squash) November 7, 2026 18:17
@morluto
morluto merged commit b81da90 into main Nov 8, 2026
53 of 55 checks passed
@morluto
morluto deleted the codex/procedure-reference-stacked branch November 8, 2026 02:16
@morluto morluto mentioned this pull request Nov 11, 2026
3 tasks done
@morluto morluto added area: native Native analysis and decompilation, including Ghidra, IDA, and Hopper analysis behavior enhancement New feature or request 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 enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants