Summary
Closes #1947. When two builds only move code, compare_functions reports pseudocode and assembly as changed, because the provider text embeds addresses and address-derived names (FUN_140001470, LAB_…, CALL 0x1400014f0). This adds opt-in address-normalized views of that text beside the eight exact dimensions, so an agent can tell "only addresses moved" from "the code changed" without losing the exact results.
This continues #2124 by @Zburgers, which has had no activity since 2026-10-15 and now conflicts with main in 12 files. The branch keeps every #2124 commit with its authorship (@Zburgers, with fixes from @morluto and @N0zoM1z0), merges current main, and adds three small follow-ups. If @Zburgers prefers to update #2124 instead, I am happy to close this one.
Problem and expected behavior
- Before: comparing a function with its relocated copy reports
pseudocode: changedandassembly: changed, the same as a real edit.docs/mcp-contracts.mdstates that relocation normalization is unavailable. - With
include_normalized_views: true: the result addsnormalized_viewswithpseudocode_normalizedandassembly_normalized. A relocation-only pair readsunchangedwhen the masked text is equal, a real edit readschanged, and anything that cannot be established readsunknown. Without the option, the result and the Evidence parameters are unchanged.
Change and scope
From #2124, unchanged in design:
- Each view masks recognized address-derived identifiers and address operands only when the dossier corroborates the address, keeps exact entry-relative offsets inside the function body, and uses side-local ordinals outside it. Literals, comments, constants and ambiguous operands stay visible.
- Ordinals do not prove target identity or call order. When the masked text references a callee or thunk target and the exact
callsdimension isunknown, the view isunknown(it keeps its digests and masking record). - The eight exact dimensions,
changes, summary counts and overall status never change. Reconstruction claims, residual-unknown scopes and static/runtime selectors accept the two view names. Infind_changed_behavior, achangedorunknownview is reported as its own static candidate.
Merge with main (d87e73f2d):
- The view code now reads coordinates through
main'snativeAddressCoordinateInputSchemaand only accepts addresses without an address space, which matches the regular expression #2124 used.functionComparisonNormalization.tsismain's version. compareFunctionskeepsmain'sFunctionSnapshotsignature with the optional request. The tool resolves inputs withmain'sresolvePairedEvidenceRequest, soretained-evidencereferences work with the option.mainmoved the finding-link validation intoreadComparisonResult; the normalized view links now go through it (functionComparisonFindingLinks).- Asking
verify_reconstructionorcorrelate_static_runtimefor a normalized view that the comparison did not compute now returnsinvalid_requestwith the field path. #2124 threw aTypeError, which reached the caller as an internal error. - The documentation paragraph moved to "Function comparison limitations", next to the exact-text rules.
- Two tests that #2124 carried from older
mainmerges are dropped, because they are unrelated to this feature: the release-workflow job schema inreleaseCheckpoint.test.ts(currentmainparses only the selected job, so it is not needed) and a CommonJSvar requirecase injavascriptSemanticAnalysis.require_links.test.ts.
Follow-ups on top:
fix(comparison): describe entry-relative offsets in the normalized views option: the parameter description said all masked addresses become ordinal placeholders.fix(comparison): keep named symbols visible in normalized views: since 62f7b5e4c,maindecides whether a name is generated from the reported symbol origin. The views still recognized names by their shape, so a user-defined or imported symbol spelled likeFUN_00401000would have been masked. A name that the dossier reports with anamedorigin now stays visible; without origin metadata the shape rule still applies. The failure needs an unusual name, so it is unlikely, but it costs about 20 lines and makes the views follow the same rule as the other consumers. On real Ghidra theFUN_names reportsource: "default", so no result below changes.test(comparison): cover normalized views from retained session references.- From the Codex review: the callee guard also counts targets of outgoing references typed as calls, or as jumps into another procedure (tail calls), so a target masked through such a reference makes equal text
unknowneven when thecalleesfacet omits it; and anunknownview caused by an unresolved callee keeps both digests, counts and its masking record, with a nulltext_delta, instead of nulling them. - From the second Codex review: callee tracking also reads a partial
callclassification whenkindis unavailable (as Hopper reports it); a view whose bounded diff gives up keeps its projected facts like the masked-callee case;unchangedandchangedviews must carry their digests, counts and text delta; a named symbol is recognized under any qualifier by matching the reported names exactly instead of an ASCII grammar; and an unknown scoped only to a normalized view no longer blocks anoverallreconstruction claim. - From the third Codex review: an interior call target also counts the entry of the procedure that contains it, and the schema ties
unchangedandchangedto equal or different projections. Two findings were declined with reasons in their threads (numeric-looking named symbols, and Kuna's bare-hex assembly coordinates, which stay a visible-address coverage gap rather than a false result). - From the fourth Codex review: a Hopper call reference classified
unknown(type 1) also counts as a callee; onlynoneis excluded. - From the fifth Codex review and an earlier thread:
readComparisonResultrequiresnormalized_viewsto agree with the recordedinclude_normalized_views; named symbols are indexed once per projection instead of scanned per token; and a parse failure names the side that failed. Two findings were declined with reasons in their threads: IDA dossiers without body extents, and ordinal masking of Hopper branches, which could report swapped branch targets asunchanged. - From the second Greptile review: equal masked text that masks a target the exact calls dimension does not compare (tail jumps, call references without flags, interior-call entries, the own thunk target) is
unknowneven whencallsisunchanged. - From the sixth Codex review: a callee's thunk target counts as uncompared, since the calls projection never reads classifications; each normalized view must cite both recorded source selections; and the named-symbol index is linear in name length. A suffix-decorated named-symbol finding was declined with its reason in the thread.
- From the Greptile review: a named symbol is also recognized with its
ns::qualifier (ns::FUN_00401000), and the MCP test parses the response with the owning output schema instead of the full tool catalog.
Not included: callee matching across builds, tracked in #3506. Without it, a function that calls others usually reads unknown on stripped builds.
Contract and boundary impact
- Semantic owner and earliest changed stage: the function comparison domain (
compareFunctionsand the newfunctionComparisonNormalizedViews.ts), after bothanalyze_functiondossiers are parsed. - Contribution scope fit and linked maintainer decision: an opt-in extension of an existing derived comparison with no target interaction; #1947 is the agreed enhancement, and the maintainer reviewed and fixed #2124.
- CLI and MCP/tool-catalog contract:
compare_functionsgains an optionalinclude_normalized_viewsboolean (defaultfalse) and an optionalnormalized_viewsresult field;verify_reconstruction,correlate_static_runtimeand residual-unknown scopes acceptpseudocode_normalizedandassembly_normalized. Existing calls and results are unchanged. - Provider, bridge, target-format, or platform compatibility: provider-agnostic text processing; views are
unknownwhen the providers differ or a facet is unavailable. No bridge change. - Evidence, artifact, provenance, or reconstruction contract: comparison Evidence records
include_normalized_views: truein its parameters only when views were requested; each view cites both source Evidence records and declares its masking rules and counts. - Target selection, authority, upstream behavior, and cleanup details (if applicable): not applicable.
- Generated metadata (
docs/public/product-catalog.json), package, or installation impact (CI generates and validates ignored catalogs andskills/; edit authored instructions in.agents/skills/reverse-engineer-anything/and never commit build outputs): the generated catalogs pick up the new parameter;references/evidence-workflows.mdin the authored skill describes it.
Expected effects (check known effects; use documentation-only on its own). Unchecked items do not establish absence; leave uncertainties visible.
- 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
-
Tests added or updated:
functionComparisonNormalizedViews.test.ts(79 tests: masking, literals and comments, offsets, ambiguous operands, swapped callees, own-function thunks, typed and partially classified outgoing calls, tail jumps, interior call targets, the diff bound, known-view facts and their consistency, unavailable facets, consumers, and plain and qualified named symbols) andtests/boundary/mcp/functionComparisonMcp.test.ts(opt-out, opt-in and retained references), plus residual-unknown scopes and the overall-claim selection inreconstructionUnknowns.test.ts. -
Base reproduction or other evidence: the feature does not exist on
main. The named-symbol test fails on the commit before its fix (expected { … } to match object) and passes after it; the typed-outgoing-callee regression readsunchangedin both views on64f919764and passes after the review fix. -
User-visible CLI/MCP output (if applicable): real Ghidra, x64 -O0,
changed_constantagainst its relocation-only copy (digests shortened). The exactpseudocodeandassemblydimensions arechangedand the overall status staysunknown:{"dimension":"pseudocode_normalized","status":"unchanged","conclusion_kind":"derived_relationship", "left_digest":"7dae5eb3b6e9…","right_digest":"7dae5eb3b6e9…", "text_delta":{"added_lines":0,"removed_lines":0,"hunks":0}, "masking":{"policy":"rea-address-normalized-text-v1","provider_id":"ghidra", "rules":["address_derived_identifier","function_relative_address","corroborated_external_address"], "left":{"address_derived_identifiers":1,"unmasked_address_derived_identifiers":0,"corroborated_addresses":0,"visible_addresses":0}, "right":{"address_derived_identifiers":1,"unmasked_address_derived_identifiers":0,"corroborated_addresses":0,"visible_addresses":0}}} -
Remaining proof gaps: no IDA, Hopper or Linux provider run at this head; no measurement of agent token or task cost.
For evidence-bearing changes:
- Observed, derived, and inferred claims remain distinguishable.
- Artifact identity, source provenance, and failed attempts remain preserved.
- Unsupported, incomplete, unavailable, or uncertain outcomes remain visible.
Validation performed
Windows 11 x64 10.0.26300, Node 24.22.1, head a09ed3511 (main d361c53c5 merged):
-
npx vitest run src/domain/functionComparisonNormalizedViews.test.ts tests/boundary/mcp/functionComparisonMcp.test.ts src/domain/functionComparison.test.ts src/domain/changedBehavior.test.ts src/domain/reconstructionVerification.test.ts src/domain/staticRuntimeCorrelation.test.ts src/domain/residualUnknown.test.ts src/domain/reconstructionUnknowns.test.ts: 8 files, 222 tests passed. -
npx vitest run --project domain --project conformance: 8055 passed, 1 failed. The failure istests/conformance/providers/hopper/realHopperFixture.test.ts, which cannot create a symbolic link as a non-elevated Windows user (EPERM ... symlink); it fails the same way onmain. -
After
npm run compileand the catalog generators,npx vitest runonsrc/contracts,readmeConsistency,derivedEvidenceReplay,reconstructionScopedUnknowns,productCatalog,toolSchemaValidity,compactInputSchemaMcp,comparisonUnknownsMcp,inlineEvidenceCompositionMcpandfunctionComparisonMcp: 28 files, 266 tests passed. -
npx tsc --noEmit -p tsconfig.json: no errors.npm run check:fast: 2 of 2 tasks passed.npx oxfmt --checkon the changed files: pass.npx knip --cache: no findings.node scripts/verify/architecture-guards.mjs: passed across 1968 source files.node scripts/check-doc-facts.mjs: pass. -
Real Ghidra 12.1.4 (Temurin 21, non-elevated; the Windows addon from the published 6.7.0 package, since this checkout has no MinGW build) through the MCP workflow (
open_binary,analyze_functionwithdetail: "complete",compare_functionswithinclude_normalized_views: true) at802578f73(the same statuses as at64f919764) on the stripped PE pairs from rea-labfixtures/compare-pairsoffered in #1947. Normalized pseudocode / assembly; one value means both views agree:Pair Function x64 -O0 x64 -O2 x86 -O0 x86 -O2 relocation only unchangedunknown unknown unknown unknown relocation only changed_constantunchanged unchanged unchanged unchanged relocation only changed_callunknown unknown unknown unknown real change unchangedunknown unknown unknown unknown real change changed_constantchanged changed changed changed real change changed_callunknown changed / unknown unknown changed No view reports a false
unchangedor a falsechanged. Everyunknowncarries the limitation that the masked text references a callee while exactcallsisunknown. Relocation-only coverage is 4 of 12, the leaf function. The x64 -O2changed_calltail call, where an earlier head reported assemblyunchangedfor a changed target, now readsunknown; at x86 -O2main'scallsdimension now reports that change itself. -
The GhidraClass Wallace pair:
initializePeopleandgadgetreadchangedin both views.addPeoplereadsunknown, where earlier heads reportedunchanged, becausemain'scallsdimension is nowunknownfor it: Ghidra reports__RTC_CheckEspandthunk_FUN_00411860with adefaultsymbol origin.
Compatibility, safety, and release
- Breaking changes or migration steps: none; the option is off by default and the new result field is optional.
- Real Hopper/Ghidra, browser, or OS coverage: real Ghidra on Windows x64 as above; IDA, Hopper and other operating systems not run at this head.
- Package or release metadata impact: none beyond the generated catalogs.
- Security, privacy, process, or containment review: no provider reads, target execution, network access, installation or persistence are added; the views only transform text already in both Evidence records, with bounded diffs.
Author readiness
Human owner: @pablodiazjorge
- 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.
@morluto This is up to date with main (
54906fdb1, 6.9.0) and CI is green ona719b633e. Since the earlier merges I also addressed the automated reviews of the merged heads: the same-Evidence check now covers the normalized views, view sources are read in either the singular or the list form, and callers and incoming call sources count as call endpoints. The description lists each change and its validation. Two newer Codex P2s on imported records (self-comparisons that mask an uncompared endpoint, and a non-booleaninclude_normalized_views) are still open; I can address them here if you want them in this PR. Ready for review whenever you have time.