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(extraction): guard transferred ZIP source and cancel after final …
…close

Replace the undeclared zipSource lookup with isStableRegularFileDescriptor.
Unexpected admissions throw ArtifactReaderFailure("integrity") instead of
skipping. Move abortIfNeeded into finally so directory, ASAR, and ZIP
sources check cancellation after the last close without masking an error
already propagating. Drop the duplicate asarHeaderBytes import.
  • Loading branch information
hannesstrydom664-hash committed Oct 27, 2026
commit 2f987e4186e3c95613ea1bf6f72bf61370e280ad
52 changes: 52 additions & 0 deletions src/artifacts/extraction/ArtifactExtraction.sourceGuard.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
import { expect, it } from "vitest";

import { ArtifactReaderFailure } from "../ArtifactReader.js";
import { isStableRegularFileDescriptor } from "./ArtifactExtraction.js";

it("accepts a descriptor with the members sameRegularFileState and revalidation read", () => {
const descriptor = {
handle: {
read: () => undefined,
stat: () => undefined,
},
initial: {
size: 4,
dev: 1,
ino: 2,
mode: 0o100644,
mtimeMs: 3,
ctimeMs: 4,
},
};
expect(isStableRegularFileDescriptor(descriptor)).toBe(true);
});

it.each([
null,
undefined,
"zip",
{ handle: { read: () => undefined } },
{
handle: { read: () => undefined, stat: () => undefined },
initial: { size: 1 },
},
])("rejects an unexpected transferred source shape", (value) => {
expect(isStableRegularFileDescriptor(value)).toBe(false);
});

it("names integrity when a caller treats a rejected shape as a ZIP admission", () => {
const admission: unknown = { kind: "node-sea" };
if (isStableRegularFileDescriptor(admission))
throw new Error("guard accepted a non-file admission");
const failure = new ArtifactReaderFailure(
"integrity",
"Transferred ZIP source is not a stable regular-file descriptor: /tmp/source.zip",
);
expect(failure.reason).toBe("integrity");
Comment thread
greptile-apps[bot] marked this conversation as resolved.
Resolved
});

// Integration coverage of a live transferred ZIP rewrite still needs a fixture
// that can mutate an admitted descriptor between inventory and dry-run.
it.skip("revalidates a live transferred ZIP descriptor after inventory", () => {
expect(true).toBe(true);
});
1 change: 0 additions & 1 deletion src/artifacts/extraction/ArtifactExtraction.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@ import { SafeOutputTree } from "../SafeOutputTree.js";
import { ZipArtifactReader } from "../ZipArtifactReader.js";
import { DirectoryArtifactReader } from "../DirectoryArtifactReader.js";
import { createTestTempDirectory } from "../../../tests/fixtures/temporaryDirectory.js";
import { asarHeaderBytes } from "../../../tests/fixtures/asarHeader.js";
import {
DRY_RUN_NON_ASCII_CASE_LIMITATION,
DRY_RUN_NON_FILE_DRIFT_SUMMARY_LIMITATION,
Expand Down
61 changes: 56 additions & 5 deletions src/artifacts/extraction/ArtifactExtraction.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,10 @@ import {
} from "../ArtifactEmbeddedFormatProbes.js";
import { withArtifactRegularFile } from "../ArtifactFileOperation.js";
import { readArtifactFileChunks } from "../readArtifactFileChunks.js";
import { sameRegularFileState } from "../../filesystem/RegularFile.js";
import {
sameRegularFileState,
type StableRegularFileDescriptor,
} from "../../filesystem/RegularFile.js";
import type {
ArtifactCleanupAttempt,
ArtifactResourceOwner,
Expand Down Expand Up @@ -365,6 +368,7 @@ const materializeSelection = async ({
let localReaderOwner: ArtifactResourceOwner | undefined = readerOwner;
let output: SafeOutputTree | undefined;
let completed: ArtifactExtractionResult | undefined;
let pendingFailure: unknown;
const extracted: ExtractedOccurrence[] = [];
try {
await reader.prepareContainer?.(inventory.manifest.root_sha256, signal);
Expand Down Expand Up @@ -410,13 +414,20 @@ const materializeSelection = async ({
traversal,
signal,
});
if (zipSource !== undefined)
if (isZipPackageFormat(inventory.manifest.root_format)) {
const admission = transferredSource?.admission;
if (!isStableRegularFileDescriptor(admission))
throw new ArtifactReaderFailure(
"integrity",
`Transferred ZIP source is not a stable regular-file descriptor: ${sourcePath}`,
);
await revalidateTransferredZipSource(
sourcePath,
zipSource.source,
admission,
inventory.manifest.root_sha256,
signal,
);
}
} else {
await writeSelectedEntries({
reader,
Expand Down Expand Up @@ -445,7 +456,6 @@ const materializeSelection = async ({
[sourceClose],
{ kind: "artifact-inventory", inventory },
);
if (transferredSource !== undefined) abortIfNeeded(signal);
extracted.sort((left, right) =>
compareUnicodeCodePoints(left.relative_path, right.relative_path),
);
Expand All @@ -463,6 +473,7 @@ const materializeSelection = async ({
if (output !== undefined) await output.commit(signal);

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 Recheck cancellation after dry-run cleanup

For a dry-run on a non-ZIP source such as a directory or ASAR, cancellation that arrives while resourceScope.release(readerOwner) performs the final reader close is never observed: the only post-close check is guarded by zipSource, and this conditional skips output.commit(signal) because no output tree exists. The call therefore returns a successful plan after the caller has cancelled; perform an unconditional signal check after the final release step.

AGENTS.md reference: AGENTS.md:L23-L23

Useful? React with 👍 / 👎.

return completed;
Comment thread
greptile-apps[bot] marked this conversation as resolved.
Resolved
} catch (cause: unknown) {
pendingFailure = cause;
const cleanupFailures = await releaseExtractionOwners(
input.resourceScope,
localReaderOwner,
Expand All @@ -481,6 +492,19 @@ const materializeSelection = async ({
}
if (output?.published === true && completed !== undefined) return completed;
throw cause;
} finally {
// Cancellation must run after the last close for every source. A pure
// check throw must not mask an error already propagating from the try.
try {
abortIfNeeded(signal);
} catch (abortCause: unknown) {
if (
pendingFailure === undefined &&
abortCause instanceof ArtifactReaderFailure &&
abortCause.reason === "cancelled"
)
throw abortCause;
Comment thread
greptile-apps[bot] marked this conversation as resolved.
Resolved
}
}
};

Expand Down Expand Up @@ -530,9 +554,36 @@ export const formatDryRunPlanPageLimitation = (
? `Dry-run plan entries are paged (${String(returnedEntries)} of ${String(totalEntries)} entries returned at offset ${String(offset)}; pass plan_offset=${String(nextOffset)} to inspect remaining entries).`
: `Dry-run plan entries are paged (${String(returnedEntries)} of ${String(totalEntries)} entries returned at offset ${String(offset)}).`;

export const isStableRegularFileDescriptor = (
value: unknown,
): value is StableRegularFileDescriptor => {
if (value === null || typeof value !== "object") return false;
const candidate = value as {
readonly handle?: { readonly read?: unknown; readonly stat?: unknown };
readonly initial?: {
readonly size?: unknown;
readonly dev?: unknown;
readonly ino?: unknown;
readonly mode?: unknown;
readonly mtimeMs?: unknown;
readonly ctimeMs?: unknown;
};
};
return (
typeof candidate.handle?.read === "function" &&
typeof candidate.handle?.stat === "function" &&
typeof candidate.initial?.size === "number" &&
typeof candidate.initial?.dev === "number" &&
typeof candidate.initial?.ino === "number" &&
typeof candidate.initial?.mode === "number" &&
typeof candidate.initial?.mtimeMs === "number" &&
typeof candidate.initial?.ctimeMs === "number"
);
};

const revalidateTransferredZipSource = async (
path: string,
source: TransferredZipInventorySource["source"],
source: StableRegularFileDescriptor,
expectedSha256: string,
signal?: AbortSignal,
): Promise<void> => {
Expand Down
Loading