Skip to content

fix(comparison)!: preserve same-entry correspondence across renames - #8263

Merged
gensokyo-dev merged 3 commits into
mainfrom
fix/8213-same-entry-function-identity
Oct 31, 2026
Merged

gensokyo-dev merged 3 commits into
mainfrom
fix/8213-same-entry-function-identity

Conversation

@gensokyo-dev

@gensokyo-dev gensokyo-dev commented Oct 31, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

Fixes #8213. Comparing one function before and after an in-session rename now preserves its authenticated same-entry correspondence while independently reporting metadata and exact-text changes.

Problem and expected behavior

Real Ghidra previously reported both a renamed function and a genuinely different entry as mismatched / explicit. Matching considered names without the stronger same-artifact coordinate evidence. A rename must not invalidate correspondence; equal numeric addresses without applicable coordinate commitments must remain insufficient.

Change and scope

  • Compute coordinate applicability once from parsed artifact identity and the existing provider-owned mapping/slice contract. Reuse it for entry, call and reference comparison; remove the duplicated applicability rule.
  • Prefer established entry coordinates over names. A matched same-entry result includes its canonical entry_address; different entries in that common context remain mismatched. Inapplicable or unestablished same-artifact coordinates do not turn differing names into a mismatch.
  • Keep name/signature/local and text changes independent from correspondence, including when symbol origin is unknown. Complete source Evidence and links remain available through the existing record/reference workflow.
  • Extend the canonical result schema and existing tool description. Update both the native investigation guide and authored skill reference to describe the coordinate requirements; bump the packaged skill to 57 and regenerate its metadata. This is an existing comparison correction, with no new provider capability, target execution, or session authority. [Bug] Ghidra loader-created ELF entry labels are treated as exact source symbols #8257's cross-artifact symbol-provenance question remains separate.

Executed validation

  • Focused domain, call-path, five MCP comparison suites and compiled Evidence replay: 178 passed across 8 files.

  • Final MCP reference suite: 24 passed. The full focused selection covers retained-reference parity, distinct entries, unknown/malformed profiles, mapping/architecture/format/provider differences, qualified coordinates and selected-image controls.

  • The named compare_functions contract was registered with the actual MCP SDK; its converted schema passes Ajv2020 validation and a client call accepts the real comparison result. Removing the required same-entry address is rejected. Only that tool is registered for this schema check.

  • npm run check:fast — typecheck/lint passed.

  • npm run docs:check — passed, including 9 README consistency checks.

  • Real provider: Ghidra 12.1.4, supplied JDK 21, Linux x64, locally compiled unexecuted ELF. One public stdio MCP session each before/after: open → analyze evaluate and adjust → rename evaluate → analyze again → compare retained references → close. Baseline reproduced mismatched; fixed output reports matched / same-entry at 0x101129, with identity/pseudocode changed and assembly unchanged. The different-entry control remains mismatched. Target SHA-256 d738e59a5ddee9f07fd1f915d95c478e18e17b6e87228a2c974eda89cce8293d remained unchanged; both closes succeeded.

  • Real-Evidence handoff: after closing Ghidra, imported those complete observations into a fresh target-free MCP server with no provider configured. Retained-reference comparison returned the identical normalized result and original source links without opening the target.

  • Real application: repeated the public rename/compare workflow on unexecuted /usr/bin/true (coreutils 9.1-1, ELF64 x86-64). Ghidra entry 0x1023d0 remained matched / same-entry; the distinct _DT_INIT control remained mismatched, with identity/pseudocode changed and assembly unchanged. SHA-256 c79bf44242829108e323378531f4ac839513ca1fba45efd6583643526e1e9fd2 stayed unchanged and close succeeded. Independent readelf identifies the ELF file entry as 0x23d0; the comparison uses the provider-committed analysis coordinates.

Comparisons add no provider queries and reuse one coordinate-applicability observation. No speedup, token reduction, agent-discovery or other-provider claim is made. Real Ghidra verification above covers the selected ephemeral-session ELF workflow, not every format or existing-project mode.

Compatibility and evidence

BREAKING CHANGE: compare_functions can now return function_match: {status: "matched", method: "same-entry", entry_address, left_name, right_name}. Older closed result schemas accepting only matched/symbol reject this new variant. Update consumers to the current result schema or handle matched/same-entry and its canonical address explicitly; continue inspecting dimensions for metadata/text changes. For a previously valid before/after rename request, correspondence now matches while the overall observed metadata/text result remains changed. Existing symbol/explicit variants and request forms remain valid. Calling coordinate-based proof a symbol match would misstate its provenance; retaining the old mismatch would preserve the bug. Partial/unknown coverage and original Evidence remain intact. Validation used an existing local Ghidra/JDK installation; no tools were installed, and the target binary was not executed.

Author readiness

Human owner: @gensokyo-dev

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

The user explicitly authorized ready PRs and integration, including bypass of human-readiness gates. Personal human-review attestations remain unchecked.

@chatgpt-codex-connector

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-31T04:19:25.193897Z
We couldn’t complete this review. Comment @codex review to try again.
5023c58 PR opened
ℹ️ 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.

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

@greptile-apps

greptile-apps Bot commented Oct 31, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerView in GreptileConfidence Score: 5/5 Tier: apex

[Medium impact] The PR appears safe to merge; no blocking issue remains from this review.

Summary

Preserves function correspondence across renames when artifact identity, mapping, architecture and selected-image commitments establish the same entry.

  • Function comparisons keep a rename tied to its entry.

Diagram

%%{init: {'theme': 'neutral'}}%%
flowchart TD
  A[Two function observations] --> B[Check shared coordinate context once]
  B --> C[Compare function entries]
  B --> D[Compare calls and references]
  C --> E[Same entry: matched with canonical address]
  C --> F[Different entries: mismatched]
  C --> G[Unestablished coordinates: conservative name matching]
  E --> H[Compare metadata and text separately]
Loading

Reviews (2) · Last reviewed commit: "docs(comparison): align rename guidance ..." · Reviewed by Greptile

Comment thread src/contracts/sessionToolContracts.ts Resolved
@gensokyo-dev gensokyo-dev changed the title fix(comparison): preserve same-entry correspondence across renames fix(comparison)!: preserve same-entry correspondence across renames Oct 31, 2026
@gensokyo-dev
gensokyo-dev merged commit 6e2404b into main Oct 31, 2026
48 of 52 checks passed
@gensokyo-dev
gensokyo-dev deleted the fix/8213-same-entry-function-identity branch October 31, 2026 04:53
@greptile-apps greptile-apps Bot mentioned this pull request Oct 31, 2026
3 tasks done
@morluto morluto added bug Something isn't working area: evidence Evidence, artifacts, and reconstruction labels Nov 23, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: evidence Evidence, artifacts, and reconstruction bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug] Comparing a renamed Ghidra function reports the same entry as mismatched

2 participants