Skip to content

fix(kuna): guide inventory selector recovery - #8397

Merged
morluto merged 6 commits into
mainfrom
codex/kuna-xrefs-selector-recovery
Nov 7, 2026
Merged

morluto merged 6 commits into
mainfrom
codex/kuna-xrefs-selector-recovery

Conversation

@morluto

@morluto morluto commented Oct 31, 2026 •

Copy link
Copy Markdown
Owner

Summary

Fixes #8396 and #8478. Kuna xrefs accepts names from its inventory, including data names, but a missing name currently says no procedure was found and advises repairing the input schema. Ambiguous names likewise identify candidates while suggesting schema repair.

Change and scope

The Kuna selector owner now reports that a missing name was not found in its inventory, with conditional guidance to inspect symbols or exports and verify address coordinates. Ambiguous names retain all reported candidate addresses and advise selecting one. Both remain invalid_request; no schema-inspection recovery is emitted for these valid string selectors. Missing procedure names and entry addresses, and ambiguous procedure names, now receive inventory-search or explicit-address recovery as appropriate, with the exact selector in structured issues.

The MCP descriptions of xrefs and find_xrefs_to_name expose the existing Kuna inventory-name route and warn that an unlisted name may still exist. This does not turn the route into a general name inventory or silently select an ambiguous match. Related design discussion: #8183.

This is an existing static-analysis boundary: no new provider capability, target execution, injection, mutation, or protection recovery is introduced, so an additional maintainer scope decision is not applicable. REA may use its existing owned Kuna cache. No output schema or snapshot format changes. Mach-O code/data classification and its separate recovery remain open in #8352.

Evidence and regression coverage

  • On current main, a real Kuna 1.986 MCP and CLI xref query for a known exported data name absent from Kuna's inventory returned “no procedure named” and schema-inspection recovery. A separate export-to-address handoff found references. The new behavior reports the inventory scope and suggests verifying an address; it does not assert the symbol is absent from the target.

  • Real Kuna MCP and CLI controls on two unexecuted Mach-O fixtures exercised missing and ambiguous names, plus successful function and data inventory-name queries. Successful named results matched the corresponding exact-address results; an ambiguous overload retained both candidate addresses. Target hashes were unchanged. Successful MCP calls used fetched compact output schemas; error projections were inspected separately.

  • The real Kuna verifier now checks the missing-name error through public MCP. Against the old main entrypoint, this regression failed at the expected message and reported cleanup complete; against this branch, the full verifier passed. The focused producer-boundary test also covers ambiguous candidates, absent schema recovery, and the existing data-name success control.

  • Review follow-up moved xref guidance into a producer-owned formatter/constants. A deliberate wording-only change passed both the focused suite and real Kuna verifier; deliberately dropping an ambiguous candidate address failed the focused test. After restoring the producer, the focused suite, real verifier, baseline failure control, and check:fast passed or failed as expected, with real-verifier cleanup complete.

  • After the shared-selector follow-up, real Kuna 1.986 MCP and CLI xref controls again verified missing/ambiguous name recovery and successful function/data names against exact addresses; target hashes remained unchanged.

  • On final code, real Kuna 1.986 full and compact MCP profiles exercised missing and ambiguous procedure names through procedure_address, procedure_assembly, procedure_callers, and analyze_function; all four exact-address retries succeeded. The CLI decompile path exercised missing, ambiguous, and exact selectors. A well-formed missing address also returned inventory guidance with its exact original spelling through three procedure operations; graph-based procedure_callers retained its distinct unavailable-relationships result. Twenty-four MCP error payloads and three CLI error envelopes passed canonical schema validation. The target hash stayed unchanged. A separate compact MCP control saved and reopened a Kuna snapshot: ambiguous procedure and xref guidance still preserved both choices, and exact-address lookup succeeded before and after reopening. The full real Kuna verifier passed with new missing-procedure-name and address public MCP assertions, verified lineage, and complete cleanup.

  • Real Kuna mixed batch_decompile in full and compact MCP profiles preserved ambiguity, missing-name and missing-address recovery alongside one successful exact-address item. A separate Ghidra control showed that decompilation can succeed via file-offset fallback when the preliminary address lookup fails; the two provider observations must not be blindly collapsed. The successful batch item does not retain the producer mapping; see [Bug] Successful batch decompiles lose per-item provider provenance #8350 and [Design] Disambiguate analysis addresses from file offsets in decompilation #8178.

  • Fetched MCP tool descriptions were checked on a live compact server. No autonomous agent-selection trial, other operating system, broad corpus, or other provider verification was performed for this change.

  • Kuna 1.990 unflagged-section control on head 65939bc4a: in compact/full MCP, incoming xrefs identified the call site to 0x1000003e0; requesting assembly at that inventory-missing address returned invalid_request with the exact selector and inventory-scoped recovery, without schema-repair advice. An explicit same-session Ghidra 12.1.4 switch found the two-edge path; the earlier Kuna trace Evidence was retained exactly. The owned Mach-O hash stayed unchanged. This does not recover the missing Kuna entry or combine this branch with fix!: qualify call paths by provider discovery #8443; see [Bug] Kuna call paths can report complete negative despite omitted direct calls #8362.

  • Combined Kuna path recovery control: a disposable checkout combining fix!: qualify call paths by provider discovery #8443 head ef5a7e68b and fix(kuna): guide inventory selector recovery #8397 head 65939bc4a returned discovery-qualified unknown, an inventory-specific assembly refusal, and a reached Ghidra path after explicit same-session provider selection. The original Kuna trace was retained exactly; successful responses validated against fetched compact/full MCP schemas. This is one real Kuna 1.990 / Ghidra 12.1.4 fixture on macOS arm64, not an automatic fallback or a merge of either PR. Details: [Bug] Kuna call paths can report complete negative despite omitted direct calls #8362.

Validation performed

  • After merging current main, Node 24.22.1 focused source and in-memory MCP tests kunaMachoInventory and kunaAliasSearchMcp: 11 passed. Current main paging guidance and data-address recovery were preserved. Targeted formatting and git diff --cached --check passed. The full typecheck and real Kuna verification were not rerun for this merge; hosted CI is pending.

  • npm run test:focused -- tests/boundary/providers/kuna/kunaMachoInventory.test.ts — 7 passed.

  • npm run verify:kuna with caller-supplied Kuna 1.986 — passed on macOS arm64; the final rebuilt verifier also passed after the producer refactor, with verified lineage and cleanup complete.

  • Real MCP and CLI missing/ambiguous/name/address controls — passed as described above.

  • npm run check:fast, npm run docs:check, oxfmt --check on touched files, and git diff --check — passed. Documentation check ran after the contract-description change.

Compatibility, safety, and release

The existing error code remains invalid_request; accepted xref and procedure name lookups receive specific recovery rather than generic input-contract advice. Procedure lookup failures additionally preserve the exact selector in structured issues. No provider protocol, input/output schema, cache, or target authority changes. Real provider testing covered Kuna 1.986 and the narrower 1.988 control above, on macOS arm64 only.

Kuna 1.988 shared-alias control

Real Kuna 1.988 on macOS arm64, using full and compact stdio MCP, analyzed an unexecuted source-built x86-64 ELF where audit_transform names two versioned entries. For procedure_address, procedure_assembly, procedure_callers, and analyze_function, the error retained both candidates without schema-inspection recovery; retrying each operation with either exact address succeeded. Target SHA-256 1f158b0ea39494fcd3424844a1b02511325c567e073fbc0ed045e0bef5f0abfe remained unchanged. This is one additional provider version and fixture, not a broad corpus or autonomous-agent test.

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.

@greptile-apps

greptile-apps Bot commented Oct 31, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerView in GreptileConfidence Score: 5/5 Tier: plus

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

Summary

This PR centralizes Kuna selector guidance and preserves exact failed procedure selectors in structured errors.

  • Kuna lookup errors guide callers to the right inventory search or address retry.

Reviews (6) · Last reviewed commit: "chore: merge main for current static che..." · Reviewed by Greptile

@morluto
morluto marked this pull request as ready for review November 1, 2026 03:55
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 1, 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-07T15:17:35.162227Z 21b163a 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.

@morluto morluto changed the title fix(kuna): clarify xref name recovery fix(kuna): guide inventory selector recovery Nov 1, 2026
@morluto
morluto merged commit db0b9ac into main Nov 7, 2026
48 checks passed
@morluto
morluto deleted the codex/kuna-xrefs-selector-recovery branch November 7, 2026 17:21
@morluto morluto added bug Something isn't working provider: kuna Analysis provider / engine: kuna labels Nov 23, 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: kuna Analysis provider / engine: kuna

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug] Kuna xref name errors direct data lookups to procedure search

1 participant