diff --git a/src/artifacts/inventory/ArtifactGraphConstruction.ts b/src/artifacts/inventory/ArtifactGraphConstruction.ts index e5552878368..bd8e4c23d5f 100644 --- a/src/artifacts/inventory/ArtifactGraphConstruction.ts +++ b/src/artifacts/inventory/ArtifactGraphConstruction.ts @@ -12,8 +12,8 @@ import { import { artifactEdgeId, artifactIdForContent, - occurrenceIdForLocation, logicalPathNfc, + occurrenceIdForLocation, } from "../../domain/artifactIdentity.js"; import type { ArtifactEntry } from "../ArtifactReader.js"; import type { @@ -125,7 +125,15 @@ export const createOccurrence = ( entry.declaredSize === null ? null : { offset: entry.byteOffset, length: entry.declaredSize }, - limitations: [...entry.limitations], + limitations: [ + ...entry.limitations, + // The logical path is NFC for lookup; keep the member's own spelling. + ...(logicalPathNfc(entry.path) === entry.path + ? [] + : [ + `Member name ${JSON.stringify(entry.path)} is not in Unicode NFC; its logical path uses the NFC spelling.`, + ]), + ], ...(entry.declaredIntegrity === null ? {} : { declared_integrity: { ...entry.declaredIntegrity } }), diff --git a/tests/boundary/filesystem/artifactZipRelativePaths.test.ts b/tests/boundary/filesystem/artifactZipRelativePaths.test.ts index 6a346ddb902..3bea960e686 100644 --- a/tests/boundary/filesystem/artifactZipRelativePaths.test.ts +++ b/tests/boundary/filesystem/artifactZipRelativePaths.test.ts @@ -33,6 +33,26 @@ it("retains distinct occurrences when ZIP paths normalize to the same child", as ); }); +it("keeps a decomposed ZIP member name beside its NFC logical path", async () => { + // #5108: lookup uses NFC, but the source spelling must stay recoverable. + const root = await createTestTempDirectory("rea-zip-nfc-name-"); + const path = join(root, "decomposed.zip"); + await writeOrderedZip(path, ["café.txt", "plain.txt"]); + + const inventory = await inventoryArtifact(path); + expect(inventory.occurrences).toContainEqual( + expect.objectContaining({ + logical_path: "café.txt", + limitations: [ + 'Member name "café.txt" is not in Unicode NFC; its logical path uses the NFC spelling.', + ], + }), + ); + expect(inventory.occurrences).toContainEqual( + expect.objectContaining({ logical_path: "plain.txt", limitations: [] }), + ); +}); + it.each([".", "././."])( "rejects a non-directory ZIP entry spelled %s instead of skipping it as a root marker", async (name) => {