Repository navigation
fix(native): find procedures by the secondary names exact lookup accepts - #8520
Merged
Merged
Conversation
search_procedures matched only each procedure's primary name, while exact lookup also accepts Kuna inventory aliases (versioned-symbol and generated sub_ names) and Ghidra symbols at an exact function entry. A search for a name procedure_address resolves returned nothing, and trace_feature silently missed the procedure. Both providers now match the same names their exact lookup accepts. A procedure still appears once under its primary name; the optional matched_aliases field lists the secondary names that matched, so aliases never become procedures of their own and list_procedures is unchanged. The shared domain helper owns that row rule for Kuna and for the Ghidra host-side Unicode folding pass. The Ghidra analysis profile records the new search semantics so older snapshots cannot replay alias-blind results. Fixes #8330 Co-Authored-By: Claude Opus 5.5 <[email protected]>
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
Contributor
[Medium impact] The PR appears safe to merge; no blocking defect was found in the changed search paths. SummaryProcedure search now covers the secondary names that exact lookup accepts in Kuna and Ghidra. Results keep each procedure’s primary name and report matching secondary names in
Diagram%%{init: {'theme': 'neutral'}}%%
flowchart TD
Query["Procedure search query"] --> Kuna["Kuna: primary name and aliases"]
Query --> Ghidra["Ghidra: shared entry-name matcher"]
Exact["Ghidra exact lookup"] --> Ghidra
Kuna --> Row["One primary-named row with matching aliases"]
Ghidra --> Row
Row --> Trace["Feature trace"]
Row --> View["Native inventory views"]
Reviews (3) · Last reviewed commit: "Merge remote-tracking branch 'origin/mai..." · Reviewed by Greptile |
procedure_address accepts each entry symbol's leaf or namespace-qualified spelling, but procedure search tested only qualified names, so a regex such as ^audit_alias$ missed a secondary symbol ns::audit_alias (and ^same$ missed a primary alpha::same) that exact lookup selects. Lookup and search now share one bridge definition of the names that select a procedure, so they cannot drift. Matching secondary symbols are still reported by their qualified names; because a leaf ends its qualified spelling, the host's Unicode literal pass stays exact over those names. Co-Authored-By: Claude Opus 5.5 <[email protected]>
2 tasks done
…arch-aliases Recompute the raw-binary profile digests for the merged shared policy, which commits both the relocation-symbol load-image revision and procedure search. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Entrpi
added a commit
to Entrpi/rea
that referenced
this pull request
Nov 1, 2026
main moved the real-toolchain lanes section from docs/testing.md to docs/testing-lanes.md. docs/testing.md takes main's version, the verify:ghidra:cortex-m paragraph moves to the same place in docs/testing-lanes.md, and the raw-binary guide links there. main's load-image observation (morluto#8531) and procedure search (morluto#8520) revisions change every Ghidra profile digest. With this branch's own bridge and shared semantics, the merged tree keeps every earlier pin, so the move is main's alone. The legacy pins take main's own digests at d3ab0fa, which the merged branch matches for all five loads; the variant digest is re-pinned. The compatibility test accepts the two new revisions beside instruction_status and still requires the rest of the saved profile.
Entrpi
added a commit
to Entrpi/rea
that referenced
this pull request
Nov 1, 2026
main's load-image observation (morluto#8531) and procedure search (morluto#8520) revisions change every Ghidra profile, so this branch's pins move again: morluto#7951's raw digests and its pre-morluto#7823 snapshot comparison, which now also sets aside the two revisions, Q10's digests outside the M-profile ELF lane, and morluto#8464's RISC-V images without an overlap. With this branch's earlier bridge and shared semantics, every earlier pin holds, so the move is main's alone. The legacy raw comment now says that these pins include Change 2's revision, as Q10's does.
Entrpi
added a commit
to Entrpi/rea
that referenced
this pull request
Nov 1, 2026
main's load-image observation (morluto#8531) and procedure search (morluto#8520) revisions change every Ghidra profile digest, so the profiles of images without an overlap move with main. With this branch's own bridge and shared semantics, the merged tree keeps the earlier pins, so the move is main's alone. Both pins take main's own digests at d3ab0fa, which the merged branch matches.
coyoteXujie
pushed a commit
to coyoteXujie/rea
that referenced
this pull request
Nov 2, 2026
…pts (morluto#8520) * fix(native): find procedures by the secondary names exact lookup accepts search_procedures matched only each procedure's primary name, while exact lookup also accepts Kuna inventory aliases (versioned-symbol and generated sub_ names) and Ghidra symbols at an exact function entry. A search for a name procedure_address resolves returned nothing, and trace_feature silently missed the procedure. Both providers now match the same names their exact lookup accepts. A procedure still appears once under its primary name; the optional matched_aliases field lists the secondary names that matched, so aliases never become procedures of their own and list_procedures is unchanged. The shared domain helper owns that row rule for Kuna and for the Ghidra host-side Unicode folding pass. The Ghidra analysis profile records the new search semantics so older snapshots cannot replay alias-blind results. Fixes morluto#8330 Co-Authored-By: Claude Opus 5.5 <[email protected]> * fix(ghidra): match leaf spellings of procedure names in search procedure_address accepts each entry symbol's leaf or namespace-qualified spelling, but procedure search tested only qualified names, so a regex such as ^audit_alias$ missed a secondary symbol ns::audit_alias (and ^same$ missed a primary alpha::same) that exact lookup selects. Lookup and search now share one bridge definition of the names that select a procedure, so they cannot drift. Matching secondary symbols are still reported by their qualified names; because a leaf ends its qualified spelling, the host's Unicode literal pass stays exact over those names. Co-Authored-By: Claude Opus 5.5 <[email protected]> --------- Co-authored-by: Claude Opus 5.5 <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What broke:
search_proceduresmatched only primary names, so a Kuna alias (versioned-symbol or generatedsub_name) or a Ghidra label at a function entry thatprocedure_addressresolves returned[], andtrace_featuresilently found no procedure.Fix: Kuna and the Ghidra bridge now search the same names their exact lookup accepts. Each procedure still appears once under its primary name, and an optional
matched_aliasesfield lists the secondary names that matched. The Ghidra analysis profile records the new search semantics.Risk: Low to medium. The output field is additive and
list_proceduresis unchanged. The Java bridge change was syntax-checked but not compiled or run here; CI's bridge job compiles it. Ghidra snapshots under the old profile are no longer replayed.Summary
Fixes #8330.
Before this change, exact lookup accepted secondary names but procedure search did not. Kuna's
#indexindexesnameandaliases, but#procedureListfiltered onnameonly. Ghidra'sresolveProcedurechecks every symbol at a function's exact entry, but the bridgesearchmatched only the primary inventory value. The search contract says it covers every analyzed procedure name, so a negative search could hide a name thatprocedure_addressaccepts. Both consumers of search,trace_featureandrea search/rea trace, inherited the gap.Search now matches the primary name plus every secondary name exact lookup accepts. A matching procedure is returned once, with its primary name as
value, andmatched_aliaseslists the distinct secondary spellings that matched. When an alias is shared by two entries, both entries are returned, each with its own primary name and address. Aliases never become rows of their own, andlist_proceduresoutput is unchanged.Problem and expected behavior
Smallest trigger (from the issue): a Kuna inventory row
{name: "audit_v1", aliases: ["audit_transform", "sub_1334"]}.procedure_address("sub_1334")returned0x1334, butsearch_procedures("sub_1334")returned[]. On Ghidra the same happened with an imported non-primary label at the entry (audit_primaryat the entry ofaudit_alias). The broken invariant: a name exact lookup accepts must be findable by the search that the not-found message points callers to.New behavior (fake-Kuna MCP, executed):
Change and scope
matchProcedureNamesinsrc/domain/analysisSearch.tstakes a primary-named row, the provider's secondary names and a predicate. It returns the row once, with distinct matching secondary names (never the primary spelling) inmatched_aliases, or nothing.addressedValueSchemagains the optionalmatched_aliases(min 1). Through that schema, the field reachestrace_featurematches, native-inventory view field selection and output schemas without separate handling.#procedureListuses the helper overentry.nameandentry.aliases, the same fields#indexuses for exact lookup. Regex runs once per distinct spelling in the existing worker. Mach-O data-entry omission and its limitation apply as before.matchProcedureNames, now defines the names that select a procedure: the primary name and every other symbol at its exact entry, in leaf or namespace-qualified spelling (labels inside the body stay excluded). BothresolveProcedure(exact equality) and procedure search (the query matcher) use it, so they cannot drift; the lookup set is unchanged. Matching secondary symbols are reported by their qualified names, sorted, asmatched_aliases. Because a leaf ends its qualified spelling, the host's Unicode literal pass stays exact over the reported names. For case-insensitive literals, the host-side Unicode folding pass (filterGhidraLiteralCandidates) now applies the same helper to the bridge's candidate aliases. The bridge result schema accepts the field forsearch_proceduresonly.procedure_search: "primary-and-exact-entry-symbol-names-v1"is added to the shared Ghidra profile, so snapshots of alias-blind results cannot replay (raw-profile digest test updated).list_procedures; promoting interior or data labels to procedures; Kuna's own missing source names (Kuna fix(process): handle launcher exit races and retain CommonJS regressions #1357); a cache for Ghidra entry-symbol lookups (see gaps).Contribution scope: an ordinary fix within existing boundaries, so no maintainer scope decision applies.
Contract and boundary impact
KunaInventoryFunction.{name,aliases}, and the Ghidra bridge's entry symbols. The domain owns the search row rule and its schema. Consumers (trace_feature, CLIsearch/trace, the native-inventory view) parse the same rows and do no matching of their own.search_proceduresdescription now names secondary-name matching andmatched_aliases. The output schema gains one optional string-array field, which also appears intrace_featureprocedure matches.value; the matching spelling is recorded. The Ghidra profile digest changes, so earlier search snapshots are not replayed.Expected effects:
Evidence and regression coverage
tests/boundary/providers/kuna/kunaAliasSearchMcp.test.ts: public MCP with fake Kuna. Covers shared and unique aliases; literal, regex and case-sensitive negative; a primary-only control; primary plus alias; an alias repeating the primary; a negative control; the unchanged listing; exact lookup (unique resolves, shared stays ambiguous with both addresses); summary detail plus the native-inventoryfields:["matched_aliases"]page;trace_featureby alias (match plus xref, with Kuna's unavailable containment kept explicit) and a primary-name control; and a Mach-O data entry sharing an alias with a code entry (data omitted with its limitation).tests/boundary/cli/procedureAliasSearchCli.test.ts: built CLIrea search --kind procedures --mode regexandrea traceby alias.tests/boundary/mcp/ghidraInventoryMcp.test.ts: Ghidra MCP with an injected bridge. Covers bridgematched_aliasespassthrough and the profile key; the Unicode folding pass dropping non-matching candidate aliases and rows while keeping ASCII matches (raw bridge output retained); rejection of an emptymatched_aliases; and namespaced names matched by leaf spelling (ns::audit_aliasalias,alpha::sameprimary) through regex and the folding pass. The injected tests pin the host contract only; the Java matching is exercised by the real lanes.scripts/lib/real-ghidra-entry-aliases.mjs(real-Ghidra lane, not run here): literal and anchored-regex search by the fixture's secondary entry label, listing unchanged,trace_featureby that label, and the interior-label control.scripts/lib/real-ghidra-namespace-annotations.mjs(real-Ghidra lane, not run here): leaf regex^same$returns each demangled<ns>::sameonce, matching lookup's existing ambiguity report.src/changes stashed, all 4 new Kuna/Ghidra MCP tests fail (expected [] to deeply equal [...], and so on); with the fix they pass.java-parser(syntax only), not compiled; the CIghidra-bridge-sourcesjob compiles it. Ghidra search now does one symbol-table lookup per procedure (the same per-procedure workresolveProcedurealready does on each name lookup). That cost is source-derived and unmeasured.Boundary regressions covered: identity (one row per entry, same-address and shared-alias entries), omission (Mach-O data), unknown or partial status (unavailable containment preserved in the trace), malformed producer output (empty alias list), and projection (summary and view field selection). Lifecycle: not applicable, since search ownership and cancellation paths are unchanged (the existing regex worker and
monitor.checkCancelled()are reused).Validation performed
vitestnew Kuna MCP (3), Ghidra MCP file (9) and CLI (1) tests: pass. The 4 original new MCP tests fail on base.After the leaf-spelling review fix: 39 related files (Ghidra MCP, evidence and routing, Kuna alias MCP, alias CLI,
src/ghidra): 1055 pass.check:fastandformat:checkpass. Java was re-parsed withjava-parser(syntax only).61 related boundary files (all 39 Kuna boundary files, Ghidra/trace/inventory-view/schema MCP files, CLI selector/coverage, snapshot replay, Ghidra client, Hopper regex, IDA containment): 651 pass, 2 fail. Both failures are in
kunaInstallationLifetime.test.ts(installation hash-close accounting,expected 3 to be 2) and also fail on unmodifiedaa48d494eon this Node 26 host; they are unrelated.65 related source and composition files (
src/ghidra,src/contracts, analysis search/view, snapshot cache, capability inventory, Hopper regex, IDA client, binary session): 1540 pass.npm run check:fast: pass.npm run format:check: pass.Docs:
generate-product-catalogand its--check,generate-error-schema --check, andreadmeConsistency.test.ts: pass. The fullnpm run docs:check/metadata:checkcould not run locally: the verifier source loader'sstripTypeScriptTypes({mode:"transform"})is rejected by Node 26.5 on unmodified scripts. That is a local toolchain limit; CI uses Node 24.22.1.Fake-Kuna in-process timing, 50,000 entries with 2 aliases each, median of 5 warm runs. This is one host's measurement, not a real-Kuna benchmark:
Responses are unchanged when no alias matches.
Compatibility, safety, and release
Author readiness
Human owner: @kaoru0822-kitauji
Before merge
type(scope): outcome.🤖 Generated with Claude Code