Skip to content

armgit / rea

Public Imported from GitHub
0

Reverse engineer anything with agents, from app behavior down to native binaries.

fix(artifacts): never count occurrences on an unknown duplicate path as unchanged (#4100)

Kaoru0822d9295431985f
diff --git a/src/domain/artifactComparison.ts b/src/domain/artifactComparison.ts
index 76d59f4e3..8420cd5d8 100644
--- a/src/domain/artifactComparison.ts
+++ b/src/domain/artifactComparison.ts
@@ -483,16 +483,19 @@ const summarize = (
contradiction: 0,
};
for (const change of changes) counts[change.classification] += 1;
+ // Change rows are keyed by logical path, and one unknown row for a duplicate
+ // path stands for every left occurrence on it. Only occurrences on paths
+ // without a left-side change are affirmatively unchanged.
+ const changedPaths = new Set(
+ changes
+ .filter(({ classification }) => classification !== "added")
+ .map(({ logical_path: path }) => path),
+ );
return {
unchanged: covered
- ? Math.max(
- 0,
- left.occurrences.length -
- counts.removed -
- counts.changed -
- counts.contradiction -
- counts.unknown,
- )
+ ? left.occurrences.filter(
+ ({ logical_path: path }) => !changedPaths.has(path),
+ ).length
: 0,
...counts,
unknown: covered
diff --git a/tests/boundary/filesystem/artifactComparison.test.ts b/tests/boundary/filesystem/artifactComparison.test.ts
index 603201c46..1c3784efd 100644
--- a/tests/boundary/filesystem/artifactComparison.test.ts
+++ b/tests/boundary/filesystem/artifactComparison.test.ts
@@ -740,6 +740,13 @@ describe("duplicate archive occurrence ownership", () => {
expect(comparison.limitations).toContain(
"Duplicate logical paths cannot be paired across inventories; comparisons for those paths are unknown.",
);
+ // Occurrences on the unknown duplicate path are never counted unchanged.
+ // The archives differ, so the root changes and only neighbor.txt remains.
+ expect(comparison.summary).toMatchObject({ unchanged: 1, unknown: 1 });
+ expect(compareArtifacts(left, left).summary).toMatchObject({
+ unchanged: 2,
+ unknown: 1,
+ });
});
});