Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
18 commits
Select commit Hold shift + click to select a range
777b04a
feat(artifacts): add dry-run extraction plan without destination writ…
hannesstrydom664-hash Oct 25, 2026
47f478c
fix(artifacts): address dry-run extraction plan review feedback (#5489)
hannesstrydom664-hash Oct 25, 2026
93c3ab3
fix(artifacts): preserve unknown mount case sensitivity and use desti…
hannesstrydom664-hash Oct 26, 2026
74029e0
fix(artifacts): handle hardlinked entries and leave non-ASCII case fo…
hannesstrydom664-hash Oct 26, 2026
77f9884
fix(artifacts): bound case-sensitivity probes and observe Windows dir…
hannesstrydom664-hash Oct 26, 2026
545c4e3
fix(artifacts): verify dry-run directory freshness, over-limit paths,…
hannesstrydom664-hash Oct 26, 2026
20ae0c4
fix(artifacts): resolve canonical output path limits and full Unicode…
hannesstrydom664-hash Oct 26, 2026
a0bf542
fix(artifacts): revalidate unpacked ASAR companions and qualify unres…
hannesstrydom664-hash Oct 26, 2026
8f417b4
fix(artifacts): reconcile non-file entries against the inventory snap…
hannesstrydom664-hash Oct 26, 2026
041f0ef
fix(artifacts): scope non-file reconciliation to active reader and ve…
hannesstrydom664-hash Oct 26, 2026
f2305a1
fix(artifacts): distinguish limitation-only non-file drift and select…
hannesstrydom664-hash Oct 26, 2026
4c411c0
fix(artifacts): reject unpaired UTF-16 destination paths and probe co…
hannesstrydom664-hash Oct 26, 2026
38a8e9d
docs(artifacts): document dry_run extraction planning and share limit…
hannesstrydom664-hash Oct 26, 2026
e37d5ef
fix(extraction): revalidate dry-run ZIP bytes, bound component probes…
hannesstrydom664-hash Oct 26, 2026
2f987e4
fix(extraction): guard transferred ZIP source and cancel after final …
hannesstrydom664-hash Oct 27, 2026
e29807d
fix(artifacts): unify dry-run plan paging cache, byte budgets, and po…
hannesstrydom664-hash Oct 27, 2026
8facdbb
fix(artifacts): budget raw dry-run occurrence limitations and skip en…
hannesstrydom664-hash Oct 27, 2026
0ffad06
Merge remote-tracking branch 'origin/main' into feat/artifact-extract…
hannesstrydom664-hash Nov 1, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
fix(artifacts): resolve canonical output path limits and full Unicode…
… case folds in dry-run plan

- Return canonicalOutput from SafeOutputTree.checkDestination and measure
  destination path length against the resolved parent path and portable
  1024-byte/260-char whole-path thresholds.
- Fold multi-code-point Unicode case expansions (such as ß/ss) in
  destinationCaseCollisions so case-table-dependent entries remain
  unresolved in dry-run plans.

Refs #5489
  • Loading branch information
hannesstrydom664-hash committed Oct 27, 2026
commit 20ae0c47c010736af97dd55f0694d537a8d0d620
14 changes: 13 additions & 1 deletion src/artifacts/ArtifactPaths.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -212,13 +212,18 @@ it("rejects ASCII case collisions in case-insensitive registries while leaving n
registry.add("ß.txt", "file");
expect(() => registry.add("SS.txt", "file")).not.toThrow();

registry.add("straße.txt", "file");
expect(() => registry.add("strasse.txt", "file")).not.toThrow();

const unresolved = destinationCaseCollisions([
"σ.txt",
"ς.txt",
"𐐀.txt",
"𐐨.txt",
"ß.txt",
"SS.txt",
"straße.txt",
"strasse.txt",
]);
expect(unresolved.get("ς.txt")?.[0]).toMatchObject({
prefix: "ς.txt",
Expand All @@ -228,5 +233,12 @@ it("rejects ASCII case collisions in case-insensitive registries while leaving n
prefix: "𐐨.txt",
other: "𐐀.txt",
});
expect(unresolved.get("ß.txt")).toBeUndefined();
expect(unresolved.get("ß.txt")?.[0]).toMatchObject({
prefix: "ß.txt",
other: "SS.txt",
});
expect(unresolved.get("straße.txt")?.[0]).toMatchObject({
prefix: "straße.txt",
other: "strasse.txt",
});
});
31 changes: 12 additions & 19 deletions src/artifacts/ArtifactPaths.ts
Original file line number Diff line number Diff line change
Expand Up @@ -77,9 +77,7 @@ export const normalizeArtifactPath = (input: string): string => {
* distinct unless destination case-folding rules are enabled.
*/
export type DestinationCaseSensitivity =
| "case-sensitive"
| "case-insensitive"
| "unknown";
"case-sensitive" | "case-insensitive" | "unknown";

export class ArtifactPathRegistry {
readonly #root: PathTrieNode = {
Expand Down Expand Up @@ -177,24 +175,19 @@ const asciiCaseFold = (part: string): string =>
String.fromCharCode(char.charCodeAt(0) + 0x20),
);

const foldUnicodeCodePoint = (char: string): string => {
const upper = char.toUpperCase();
const singleUpper = [...upper].length === 1 ? upper : char;
const lower = singleUpper.toLowerCase();
return [...lower].length === 1 ? lower : singleUpper;
};

/**
* Fold a path segment using 1-to-1 simple Unicode case mapping without
* 1-to-many expansion. Used after an OS `EEXIST` failure to name the colliding
* directory entry, and in dry-run planning to detect non-ASCII or unknown-mount
* case folds whose destination table behavior is not observed without disk I/O.
* Fold a path segment across 1-to-1 and multi-code-point Unicode case
* mappings. Used after an OS `EEXIST` failure to name the colliding directory
* entry, and in dry-run planning to detect non-ASCII or unknown-mount case
* folds whose destination table behavior is not observed without disk I/O.
*/
const unicodeCaseFold = (part: string): string => {
let folded = "";
for (const char of part) folded += foldUnicodeCodePoint(char);
return folded;
};
const unicodeCaseFold = (part: string): string =>
part
.toUpperCase()
.toLowerCase()
.toUpperCase()
.toLowerCase()
.replace(/i\u0307/gu, "i");

/**
* Record English (en-US) Unicode case collisions on each affected occurrence.
Expand Down
6 changes: 5 additions & 1 deletion src/artifacts/SafeOutputTree.ts
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,10 @@ export class SafeOutputTree {
static async checkDestination(
outputRoot: string,
options: { readonly resourceScope?: ArtifactResourceScope } = {},
): Promise<{ readonly caseSensitivity: DestinationCaseSensitivity }> {
): Promise<{
readonly caseSensitivity: DestinationCaseSensitivity;
readonly canonicalOutput: string;
}> {
const { canonicalOutput } = await this.resolveDestination(outputRoot);
const existing = await lstat(canonicalOutput).catch((cause: unknown) => {
if (cause instanceof Error && "code" in cause && cause.code === "ENOENT")
Expand Down Expand Up @@ -193,6 +196,7 @@ export class SafeOutputTree {
parent,
options.resourceScope,
),
canonicalOutput,
};
}

Expand Down
52 changes: 47 additions & 5 deletions src/artifacts/extraction/ArtifactExtraction.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -720,8 +720,8 @@ it("refuses case-folding file and parent directory collisions in dry-run mode wh
const checkDestinationSpy = vi
.spyOn(SafeOutputTree, "checkDestination")
.mockImplementation(async (outputRoot: string) => {
await realCheckDestination(outputRoot);
return { caseSensitivity: "case-insensitive" };
const checked = await realCheckDestination(outputRoot);
return { ...checked, caseSensitivity: "case-insensitive" };
});
try {
const fileOut = join(directory, "file-case-out");
Expand Down Expand Up @@ -758,6 +758,8 @@ it("refuses case-folding file and parent directory collisions in dry-run mode wh
await nonAsciiWriter.add("ς.txt", new TextReader("final"));
await nonAsciiWriter.add("𐐀.txt", new TextReader("deseret-upper"));
await nonAsciiWriter.add("𐐨.txt", new TextReader("deseret-lower"));
await nonAsciiWriter.add("straße.txt", new TextReader("sharp-s"));
await nonAsciiWriter.add("strasse.txt", new TextReader("double-s"));
await writeFile(nonAsciiZip, Buffer.from(await nonAsciiWriter.close()));
const nonAsciiOut = join(directory, "non-ascii-case-out");
const nonAsciiPlan = await extractArtifact({
Expand All @@ -768,7 +770,7 @@ it("refuses case-folding file and parent directory collisions in dry-run mode wh
expect(nonAsciiPlan.artifacts).toEqual([]);
expect(nonAsciiPlan.plan?.totals).toMatchObject({
planned_files: 0,
unresolved_entries: 4,
unresolved_entries: 6,
observed_bytes_estimate: 0,
});
expect(
Expand All @@ -777,6 +779,8 @@ it("refuses case-folding file and parent directory collisions in dry-run mode wh
status,
})),
).toEqual([
{ logical_path: "strasse.txt", status: "unresolved" },
{ logical_path: "straße.txt", status: "unresolved" },
{ logical_path: "ς.txt", status: "unresolved" },
{ logical_path: "σ.txt", status: "unresolved" },
{ logical_path: "𐐀.txt", status: "unresolved" },
Expand Down Expand Up @@ -1053,14 +1057,19 @@ it("rejects directory source content modified between inventory and dry-run plan
}
});

it("classifies over-limit destination path segments as unresolved in dry-run plans", async () => {
it("classifies over-limit destination path segments and resolved symlink paths as unresolved in dry-run plans", async () => {
const directory = await createTestTempDirectory(
"rea-extraction-dry-run-over-limit-segment-",
);
const archive = join(directory, "over-limit.zip");
const overLimitName = `${"a".repeat(256)}.txt`;
const overLimitNestedPath = Array.from(
{ length: 5 },
(_, index) => `${String(index)}-${"b".repeat(210)}`,
).join("/");
const writer = new ZipWriter(new Uint8ArrayWriter());
await writer.add(overLimitName, new TextReader("payload"));
await writer.add(overLimitNestedPath, new TextReader("nested"));
await writer.add("short.txt", new TextReader("ok"));
await writeFile(archive, Buffer.from(await writer.close()));
const resourceScope = new ArtifactResourceScope();
Expand All @@ -1080,7 +1089,7 @@ it("classifies over-limit destination path segments as unresolved in dry-run pla
expect(planned.plan?.totals).toMatchObject({
planned_files: 1,
unsupported_entries: 0,
unresolved_entries: 1,
unresolved_entries: 2,
observed_bytes_estimate: 2,
declared_bytes_estimate: 2,
});
Expand All @@ -1090,13 +1099,46 @@ it("classifies over-limit destination path segments as unresolved in dry-run pla
status,
})),
).toEqual([
{ logical_path: overLimitNestedPath, status: "unresolved" },
{ logical_path: overLimitName, status: "unresolved" },
{ logical_path: "short.txt", status: "planned" },
]);
expect(planned.limitations).toContain(
"Destination filesystem component and path length limits (such as 255-byte NAME_MAX) cannot be verified without creating files; over-limit paths remain unresolved in the dry-run plan.",
);
await expect(stat(outputRoot)).rejects.toMatchObject({ code: "ENOENT" });

if (process.platform !== "win32") {
const longParent = join(
directory,
...Array.from(
{ length: 4 },
(_, index) => `real-${String(index)}-${"d".repeat(180)}`,
),
);
await mkdir(longParent, { recursive: true });
const shortSymlinkParent = join(directory, "s");
await symlink(longParent, shortSymlinkParent);
const symlinkArchive = join(directory, "symlink-length.zip");
const borderlineEntry = `${"e".repeat(200)}/${"f".repeat(150)}.txt`;
const symlinkWriter = new ZipWriter(new Uint8ArrayWriter());
await symlinkWriter.add(borderlineEntry, new TextReader("deep"));
await writeFile(symlinkArchive, Buffer.from(await symlinkWriter.close()));
const symlinkOutputRoot = join(shortSymlinkParent, "out");
const symlinkPlan = await extractArtifact({
...zipInput(symlinkArchive, symlinkOutputRoot, resourceScope),
dryRun: true,
});
expect(symlinkPlan.plan?.entries).toEqual([
expect.objectContaining({
logical_path: borderlineEntry,
status: "unresolved",
}),
]);
await expect(stat(symlinkOutputRoot)).rejects.toMatchObject({
code: "ENOENT",
});
}
} finally {
await resourceScope.close();
}
Expand Down
29 changes: 22 additions & 7 deletions src/artifacts/extraction/ArtifactExtraction.ts
Original file line number Diff line number Diff line change
Expand Up @@ -349,12 +349,14 @@ const materializeSelection = async ({
const platform = input.platform ?? process.platform;
let destinationCaseSensitivity: DestinationCaseSensitivity =
"case-sensitive";
let resolvedOutputRoot = absoluteCallerPath(input.outputRoot);
if (dryRun) {
const destination = await SafeOutputTree.checkDestination(
input.outputRoot,
{ resourceScope: input.resourceScope },
);
destinationCaseSensitivity = destination.caseSensitivity;
resolvedOutputRoot = destination.canonicalOutput ?? resolvedOutputRoot;
} else {
try {
output = await SafeOutputTree.create(input.outputRoot, platform);
Expand All @@ -377,7 +379,7 @@ const materializeSelection = async ({
zipSource !== undefined || reader.prepareContainer !== undefined;
unresolvedPlan = await planSelectedEntries({
reader,
outputRoot: input.outputRoot,
outputRoot: resolvedOutputRoot,
platform,
caseSensitivity: destinationCaseSensitivity,
verifyContent: !containerVerified,

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Revalidate unpacked ASAR companions during dry-run

When an ASAR has an unpacked member and its .asar.unpacked companion is replaced or removed after inventory, reader.prepareContainer makes containerVerified true even though it snapshots only the ASAR container; this sets verifyContent false, so planSelectedEntries never opens the external companion and returns the stale size/SHA as planned, while real extraction opens it and rejects the mismatch or missing file. Fresh evidence beyond the earlier directory-source report is that these member bytes live outside the prepared container; revalidate unpacked entries or keep their freshness unresolved.

AGENTS.md reference: AGENTS.md:L50-L52

Useful? React with 👍 / 👎.

Expand Down Expand Up @@ -459,22 +461,34 @@ interface UnresolvedDryRunPlan {
}

const MAX_PORTABLE_NAME_BYTES = 255;
const MAX_PORTABLE_PATH_BYTES = 4095;
const MAX_PORTABLE_POSIX_PATH_BYTES = 1023;
const MAX_PORTABLE_WIN32_PATH_LENGTH = 259;

const overLimitDestinationReason = (
outputRoot: string,
resolvedOutputRoot: string,
destinationPath: string,
platform: NodeJS.Platform,
): string | undefined => {
const segments = destinationPath.split("/");
for (const segment of segments) {
const byteLength = Buffer.byteLength(segment, "utf8");
if (byteLength > MAX_PORTABLE_NAME_BYTES)
if (
byteLength > MAX_PORTABLE_NAME_BYTES ||
segment.length > MAX_PORTABLE_NAME_BYTES
Comment on lines +851 to +852

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Keep unobserved short component limits unresolved

When the selected destination has a component limit below 255 bytes, such as an eCryptfs mount with encrypted filenames and a roughly 143-byte usable plaintext limit, an ASCII segment between that limit and 255 bytes bypasses this branch and is reported planned, but non-dry extraction fails its open with ENAMETOOLONG. Fresh evidence beyond the earlier 256-byte ext4 case is that 255 is not a universal lower bound for the selected filesystem; observe the destination's actual limit or keep the unobserved range unresolved.

AGENTS.md reference: AGENTS.md:L81-L81

Useful? React with 👍 / 👎.

)
return `Destination filesystem component length limit (such as 255-byte NAME_MAX) is not observed without creating files; segment of ${String(byteLength)} UTF-8 bytes in ${destinationPath} remains unresolved during dry-run.`;
}
const fullDestination = join(absoluteCallerPath(outputRoot), ...segments);
const fullDestination = join(resolvedOutputRoot, ...segments);
if (
platform === "win32" &&
(fullDestination.length > MAX_PORTABLE_WIN32_PATH_LENGTH ||
Buffer.byteLength(fullDestination, "utf8") >
MAX_PORTABLE_WIN32_PATH_LENGTH)
)
return `Destination filesystem path length limit (such as 260-character Windows MAX_PATH) is not observed without creating files; destination path of ${String(fullDestination.length)} UTF-16 code units for ${destinationPath} remains unresolved during dry-run.`;
const fullBytes = Buffer.byteLength(fullDestination, "utf8");
if (fullBytes > MAX_PORTABLE_PATH_BYTES)
return `Destination filesystem path length limit (such as 4095-byte PATH_MAX) is not observed without creating files; destination path of ${String(fullBytes)} UTF-8 bytes for ${destinationPath} remains unresolved during dry-run.`;
if (fullBytes > MAX_PORTABLE_POSIX_PATH_BYTES)
return `Destination filesystem path length limit (such as 1024-byte Darwin/portable PATH_MAX) is not observed without creating files; destination path of ${String(fullBytes)} UTF-8 bytes for ${destinationPath} remains unresolved during dry-run.`;
return undefined;
};

Expand Down Expand Up @@ -604,6 +618,7 @@ const planSelectedEntries = async ({
const overLimitReason = overLimitDestinationReason(
outputRoot,
destinationPath,
platform,
);
if (overLimitReason !== undefined) {
unresolvedByOccurrenceId.set(
Expand Down