fix(evidence): order canonical projections independently of locale

This commit is contained in:
morluto
2026-10-10 05:13:53 +08:00
parent 0f10499245
commit 614fb7681e
22 changed files with 123 additions and 81 deletions
+5 -8
View File
@@ -10,6 +10,7 @@ import {
parseFunctionEvidence,
type FunctionSnapshot,
} from "./functionDossierEvidence.js";
import { compareUnicodeCodePoints } from "./unicodeCodePointOrder.js";
/** Minimal directed caller-to-callee adjacency for call-path search. */
class CallGraph {
@@ -104,9 +105,7 @@ export const buildCallPath = (input: CallPathInput): CallPathResult => {
goal: parsed.goal.address,
explored: summarizeSearch(graph, search.reached),
evidence_links: uniqueEvidence(snapshots.values()),
limitations: [...new Set(limitations)].sort((left, right) =>
left.localeCompare(right),
),
limitations: [...new Set(limitations)].sort(compareUnicodeCodePoints),
};
const searchScope = { exhaustive };
if (found)
@@ -242,9 +241,7 @@ const inspectSearch = ({
);
continue;
}
const neighbors = graph
.outNeighbors(node)
.sort((left, right) => left.localeCompare(right));
const neighbors = graph.outNeighbors(node).sort(compareUnicodeCodePoints);
for (const neighbor of neighbors)
if (!reached.has(neighbor)) {
reached.set(neighbor, depth + 1);
@@ -289,7 +286,7 @@ const enumeratePaths = ({
distance !== undefined &&
goalDistances.get(neighbor) === distance - 1,
)
.sort((left, right) => left.localeCompare(right));
.sort(compareUnicodeCodePoints);
neighbors.set(node, candidates);
}
return { neighbors: candidates, nextIndex: 0 };
@@ -370,4 +367,4 @@ const snapshotLinks = (snapshot: FunctionSnapshot | undefined): string[] => {
const uniqueEvidence = (snapshots: Iterable<FunctionSnapshot>): string[] =>
[
...new Set([...snapshots].flatMap((snapshot) => snapshotLinks(snapshot))),
].sort((left, right) => left.localeCompare(right));
].sort(compareUnicodeCodePoints);