fix(reference): join internal symlink targets with the inventory NFC normalizer (#1535)

* fix(reference): join internal symlink targets with the inventory NFC normalizer

checkSymlinks resolved an internal symlink target with bare
posix.normalize and looked the result up in the inventoried path set.
A target that a filesystem reports in NFD (macOS readlink commonly
does) joined to an NFD spelling while the inventory holds NFC, so
validation reported "Internal symlink target must resolve to an
inventoried entry" for a target the inventory actually contains.

Route the join through normalizeJoinedLogicalPath, the same inventory
identity normalizer #1513 applied to the runtime, HTML/module, and
import joins from #1488. The feature-seed NFKC query fold stays a
query.

Refs #1488

* fix(reference): preserve source spelling during symlink lookup

---------

Co-authored-by: morluto <76467478+morluto@users.noreply.github.com>
This commit is contained in:
Anuj Singh
2026-10-10 23:02:10 +08:00
committed by GitHub
co-authored by morluto
parent 905e4866c4
commit 0363e5a8e1
2 changed files with 68 additions and 1 deletions
+15 -1
View File
@@ -4,6 +4,7 @@ import { z } from "zod";
import { canonicalJson } from "./comparisonSemantics.js";
import { digestCanonicalValue } from "./canonicalDigest.js";
import { normalizeJoinedLogicalPath } from "./artifactIdentity.js";
import { compareUnicodeCodePoints } from "./unicodeCodePointOrder.js";
import { digestSchema } from "./../domain/digests.js";
import { prefixedDigestSchema } from "./../domain/digests.js";
@@ -313,6 +314,14 @@ const checkSymlinks = (
paths: ReadonlySet<string>,
context: z.RefinementCtx,
): void => {
const normalizedPathCounts = new Map<string, number>();
for (const path of paths) {
const identity = normalizeJoinedLogicalPath(path);
normalizedPathCounts.set(
identity,
(normalizedPathCounts.get(identity) ?? 0) + 1,
);
}
for (const [index, entry] of graph.entries.entries()) {
if (entry.kind !== "symlink") continue;
if (entry.target === null) continue;
@@ -330,7 +339,12 @@ const checkSymlinks = (
const resolved = posix.normalize(
posix.join(posix.dirname(entry.path), entry.target),
);
if (resolved.startsWith("../") || resolved === ".." || !paths.has(resolved))
const normalized = normalizeJoinedLogicalPath(resolved);
if (
resolved.startsWith("../") ||
resolved === ".." ||
(!paths.has(resolved) && normalizedPathCounts.get(normalized) !== 1)
)
context.addIssue({
code: "custom",
message: "Internal symlink target must resolve to an inventoried entry",