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

* fix(comparison): preserve same-entry correspondence across renames

* docs(comparison): align rename guidance and focused contract checks
This commit is contained in:
gensokyo-dev authored and GitHub committed 2026-10-31 12:53:42 +08:00
1 parent 356cc50475
commit 6e2404b869
13 files changed
+399 -39

No files matched your search

+42 -3
View File
@@ -1,9 +1,15 @@
import { hasStableNativeSymbol } from "./native/nativeSymbol.js";
import { canonicalJson } from "./comparisonSemantics.js";
import { compareUnicodeCodePoints } from "./unicodeCodePointOrder.js";
import { nativeAddressCoordinateInputSchema } from "./native/nativeAddress.js";
import {
nativeAddressCoordinateInputSchema,
nativeAddressInputSchema,
} from "./native/nativeAddress.js";
import type { FunctionSnapshot } from "./functionDossierEvidence.js";
import type {
FunctionSnapshotCoordinateContext,
FunctionSnapshot,
} from "./functionDossierEvidence.js";
import type { FunctionComparisonResult } from "./functionComparisonSchemas.js";
export const identityProjection = (snapshot: FunctionSnapshot) => ({
@@ -17,9 +23,39 @@ export const identityProjection = (snapshot: FunctionSnapshot) => ({
export const functionMatch = (
left: FunctionSnapshot,
right: FunctionSnapshot,
coordinateContext: FunctionSnapshotCoordinateContext,
): FunctionComparisonResult["function_match"] => {
const leftName = left.dossier.procedure.name;
const rightName = right.dossier.procedure.name;
if (coordinateContext === "common") {
const leftEntry = nativeAddressInputSchema.safeParse(
left.dossier.procedure.address,
);
const rightEntry = nativeAddressInputSchema.safeParse(
right.dossier.procedure.address,
);
if (leftEntry.success && rightEntry.success)
return leftEntry.data === rightEntry.data
? {
status: "matched",
method: "same-entry",
entry_address: leftEntry.data,
left_name: leftName,
right_name: rightName,
}
: {
status: "mismatched",
method: "explicit",
left_name: leftName,
right_name: rightName,
};
return {
status: "ambiguous",
method: "explicit",
left_name: leftName,
right_name: rightName,
};
}
const stableNames =
hasStableNativeSymbol(leftName, left.dossier.procedure.symbol) &&
hasStableNativeSymbol(rightName, right.dossier.procedure.symbol);
@@ -31,7 +67,10 @@ export const functionMatch = (
right_name: rightName,
};
return {
status: stableNames ? "mismatched" : "ambiguous",
status:
stableNames && coordinateContext === "cross-artifact"
? "mismatched"
: "ambiguous",
method: "explicit",
left_name: leftName,
right_name: rightName,