fix(javascript): report located sources with differing digests as modified (#1216)

This commit is contained in:
Jay Hemnani
2026-10-09 16:20:42 +08:00
committed by GitHub
parent c89b3a00dc
commit 01174c4a81
3 changed files with 73 additions and 1 deletions
@@ -12,6 +12,7 @@ import {
} from "./sourceToBundleComparisonSchemas.js";
import {
buildSourceToBundleCandidateIndex,
candidateHasDigest,
candidateIdsForSource,
historicalSourceFiles,
scoreSourceToBundleCandidate,
@@ -125,7 +126,12 @@ const compareMappings = (
(candidate): candidate is SourceToBundleCandidate => candidate !== null,
)
.sort(compareCandidates);
const classification = classifyMapping(scored, projection.absenceComplete);
const classification = classifyMapping(
scored,
projection.absenceComplete,
(nodeId) =>
source.sha256 !== null && candidateHasDigest(projection.index, nodeId),
);
const semantic = {
source_path: source.path,
source_sha256: source.sha256,
@@ -175,6 +181,7 @@ const scoringModel = (): SourceToBundleComparisonResult["scoring"] => ({
const classifyMapping = (
candidates: readonly SourceToBundleCandidate[],
absenceComplete: boolean,
digestComparable: (nodeId: string) => boolean,
): ClassifiedMapping => {
const exact = candidates.filter((candidate) =>
hasSignal(candidate, "exact-source-digest"),
@@ -213,6 +220,15 @@ const classifyMapping = (
: pathCandidates.filter(({ score }) => score === topScore);
if (topPathCandidates.length === 1) {
const candidate = topPathCandidates[0];
if (candidate !== undefined && digestComparable(candidate.current_node_id))
return {
status: "modified",
confidence: candidate.confidence === "high" ? "high" : "medium",
currentNodeIds: [candidate.current_node_id],
limitations: [
"Location evidence links the source to the current node, but their source digests differ.",
],
};
return {
status: "unknown",
confidence: "unknown",