Repository navigation
feat(artifacts): add dry-run plan for artifact extraction - #7177
hannesstrydom664-hash wants to merge 18 commits into
Conversation
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
[Medium impact] The change reaches artifact extraction through both the CLI and tool callers. Fix the ESP cache key and satisfy the cache-lifetime and cleanup requirements before merging. FindingsFix with agent prompt### Issue 1
src/artifacts/extraction/DryRunPlanCache.ts:281-287
`dryRunCacheSourceKey` omits `espFlashSelection`, although `flashOffset` and `partitionTableOffset` change which bytes become partitions. In one MCP server, a caller can plan an image, reopen the same file with another valid layout, and request a later page. The unchanged file passes the cache's file-state and root-hash checks, so the caller receives paths and digests from the earlier layout.
The repository requires cache keys to cover inputs that affect the result. Include the complete selection in this key.
### Issue 2
src/artifacts/extraction/DryRunPlanCache.ts:313-324
The new process-wide cache keeps complete inventories and catalogs, not just the returned pages. Its only capacity check counts eight entries, and neither client close nor investigation reset releases them. Several large archives can leave substantial memory pinned after the user closes them.
`AGENTS.md` requires bounded retained state and a defined cache lifetime. Give this cache an owner and a shared byte allowance, with release at the matching close or reset step. This repository requirement must be satisfied before merging.
### Issue 3
src/artifacts/extraction/ArtifactExtraction.ts:1312-1315
`createDryRunPlan` has no callers now that result creation uses `sliceDryRunPlanCatalogWithDiagnostics` directly. Its `sliceDryRunPlanCatalog` wrapper is otherwise unused, and `limitDryRunPlanText` is also an unused alias. These leftovers make maintainers distinguish the live path from helpers that return less diagnostic information.
`AGENTS.md` requires removing superseded representations, aliases, and wrappers after checking their consumers. Remove these leftovers so there is one current plan-building path. This repository requirement must be satisfied before merging.
Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!
---
For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.SummaryAdds dry-run artifact extraction with paged plans, labeled byte estimates, shared destination checks, and CLI/MCP options.
Diagram%%{init: {'theme': 'neutral'}}%%
flowchart TD
A[CLI or MCP extraction request] --> B{Dry run with later offset?}
B -->|Yes| C{Cached plan passes reuse checks?}
C -->|Yes| H[Return requested plan page]
C -->|No| D[Inventory selected source]
B -->|No| D
D --> E{Dry run?}
E -->|Yes| F[Check destination and plan reader entries]
F --> G[Cache complete plan]
G --> H
E -->|No| I[Write and verify files]
I --> J[Publish extraction receipt]
Reviews (21) · Last reviewed commit: "Merge remote-tracking branch 'origin/mai..." · Reviewed by Greptile |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 09d09d2a46
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
| reader.provenance(), | ||
| ); | ||
| await output.commit(signal); | ||
| if (output !== undefined) await output.commit(signal); |
There was a problem hiding this comment.
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 👍 / 👎.
| "format", | ||
| `Invalid expected extraction size for ${path}`, | ||
| ); | ||
| const destinationPath = normalizeDestinationPath(path, platform); |
There was a problem hiding this comment.
Reject Windows-invalid names in the dry-run plan
On win32, an archive entry such as bad?.txt reaches this point and is accepted because the Windows-specific checks in normalizeDestinationPath only reject backslashes, :, and control characters. The dry-run then reports the entry as planned even though real extraction's open on Windows rejects ? (likewise *, <, >, ", |, trailing dots/spaces, and reserved device names), so the plan cannot predict a common destination failure; complete the Windows name policy in the shared normalizer.
AGENTS.md reference: AGENTS.md:L27-L27
Useful? React with 👍 / 👎.
| entry_kind: occurrence.entry_kind, | ||
| status: "unsupported", | ||
| reason, | ||
| observed_bytes: null, |
There was a problem hiding this comment.
Retain observed sizes for unsupported nested files
When inventory expands a nested ASAR or PyInstaller member, a child file can be intentionally excluded from single-container extraction while still having an artifact_id backed by an observed ArtifactNode.size. This branch hard-codes observed_bytes: null, so the plan discards a verified fact and presents it as unknown precisely for unsupported entries; look up the occurrence's node and retain its size without adding it to planned-output totals.
AGENTS.md reference: AGENTS.md:L19-L19
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 09ebf275fc
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
| if (!siblingEntries.includes(toggled)) { | ||
| const [original, candidate] = await Promise.all([ | ||
| lstat(current, { bigint: true }).catch(() => undefined), | ||
| lstat(join(parent, toggled), { bigint: true }).catch(() => undefined), |
There was a problem hiding this comment.
Keep unobserved directory case sensitivity unknown
When the selected parent is the empty root of a case-insensitive mount below a case-sensitive host directory (for example, output under an empty NTFS mount at /mnt/usb), the entry loop has no probe and this lookup tests /mnt/Usb in the host filesystem. It therefore returns false even though /mnt/usb is case-insensitive, so dry-run planning accepts case-colliding output names that the destination cannot materialize; retain an unknown result or inspect the mounted directory's own case rules instead of inferring them from its parent.
AGENTS.md reference: AGENTS.md:L21-L21
Useful? React with 👍 / 👎.
| if (this.#caseInsensitive) { | ||
| const collision = destinationCaseCollision( | ||
| currentPath, | ||
| node.spellingsByFold.get(englishCaseFold(part)) ?? [], |
There was a problem hiding this comment.
Use the destination case table for collision checks
For a case-insensitive Windows destination, entries such as σ.txt and ς.txt receive different en-US lowercase keys here even though Windows case-insensitive lookup maps both sigma forms to Σ; the dry run succeeds, but real extraction fails the second exclusive create. englishCaseFold is explicitly only a logical-name diagnostic and not a filesystem case table, so use the platform/destination mapping (or preserve the comparison as unknown) before declaring the plan collision-free.
AGENTS.md reference: AGENTS.md:L27-L27
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 8e37162a70
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
| platform: NodeJS.Platform = process.platform, | ||
| ): string => { | ||
| let folded = ""; | ||
| for (const char of part) folded += foldDestinationCodePoint(char, platform); |
There was a problem hiding this comment.
Avoid Unicode code-point folding for NTFS names
When dry-running onto NTFS, an archive with 𐐀.txt and 𐐨.txt is rejected here because for...of feeds whole Unicode code points to JavaScript casing and both fold to U+10400. NTFS compares names through its 16-bit $UpCase table, so supplementary surrogate pairs are not case-mapped and real extraction can keep those two names distinct; this makes the plan falsely refuse a valid extraction. Fresh evidence beyond the earlier sigma report is that the replacement code-point loop now over-folds supplementary characters even though it handles sigma. Use the destination's comparison table, or leave unsupported folds unresolved.
AGENTS.md reference: AGENTS.md:L21-L21
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: bce0e70fd4
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
| platform === "win32" | ||
| ? "case-insensitive" | ||
| : await observeDirectoryCaseSensitivity(parent), |
There was a problem hiding this comment.
Observe case-sensitive Windows destination directories
When the chosen parent is an NTFS directory with per-directory case sensitivity enabled (for example, a WSL-managed tree), this hard-coded branch reports it as case-insensitive; planSelectedEntries then rejects Foo.txt/foo.txt, even though a newly created child inherits the case-sensitive setting and real extraction can materialize both names. Probe the parent on Windows too, or leave the result unknown when it cannot be observed.
AGENTS.md reference: AGENTS.md:L21-L21
Useful? React with 👍 / 👎.
| const observeDirectoryCaseSensitivity = async ( | ||
| directory: string, | ||
| ): Promise<DestinationCaseSensitivity> => { | ||
| const entries = await readdir(directory).catch(() => undefined); |
There was a problem hiding this comment.
Bound destination case-sensitivity scans
When a destination parent contains a very large number of entries, readdir(directory) materializes every name and the following Set retains additional state just to classify case sensitivity. Because the modified checkDestination is also used by existing firmware and environment preflights, those operations can now consume memory proportional to an unrelated shared parent such as a crowded /tmp, or stall before their real work; stream with opendir and bounded state, or return unknown after a bounded probe.
AGENTS.md reference: AGENTS.md:L53-L54
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: a41cc1a4ff
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
| `Regular artifact entry is missing from inventory: ${path}`, | ||
| ); | ||
| } | ||
| preflight(entry); |
There was a problem hiding this comment.
Verify source freshness before marking entries planned
When a directory source is modified after inventory but before this second traversal (for example, an existing file is replaced with different bytes at the same path), this branch only runs metadata preflight and then copies selectedItem.node from the old snapshot; it never opens or hashes the current entry. The dry-run therefore returns planned with a stale SHA/size while non-dry writeSelectedEntries opens the bytes and rejects the mismatch, so revalidate current content or retain its freshness as unknown.
AGENTS.md reference: AGENTS.md:L50-L52
Useful? React with 👍 / 👎.
| "format", | ||
| `Invalid expected extraction size for ${path}`, | ||
| ); | ||
| const destinationPath = normalizeDestinationPath(path, platform); |
There was a problem hiding this comment.
Keep over-limit destination names unresolved
On a destination with a 255-byte NAME_MAX such as ext4, a ZIP/ASAR entry containing one 256-byte ASCII segment passes this normalizer and the registry, so the plan marks it planned; non-dry SafeOutputTree.write instead fails its exclusive open with ENAMETOOLONG and rolls back. Include destination component/path limits in admission, or classify the entry as unresolved when the destination limit cannot be observed.
AGENTS.md reference: AGENTS.md:L21-L21
Useful? React with 👍 / 👎.
| } catch { | ||
| return "unknown"; | ||
| } finally { | ||
| await dir.close().catch(() => undefined); |
There was a problem hiding this comment.
Retain ownership when the case-probe close fails
If Dir.close() rejects after the bounded scan, this catch discards the failure and lets checkDestination return a case classification even though cleanup is unconfirmed. Because the same method is also used by the environment-bundle and firmware preflights, repeated close failures can leave directory handles unowned and callers have no way to report or retry cleanup; surface an owned cleanup failure instead.
AGENTS.md reference: AGENTS.md:L19-L19
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 4b6d216aa1
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
|
|
||
| const foldUnicodeCodePoint = (char: string): string => { | ||
| const upper = char.toUpperCase(); | ||
| const singleUpper = [...upper].length === 1 ? upper : char; |
There was a problem hiding this comment.
Preserve multi-code-point destination folds as unknown
On a known case-insensitive ext4 casefold destination, entries such as straße.txt and strasse.txt compare equal because the filesystem fold expands ß to ss; this branch falls back to the original character whenever uppercase expands, so destinationCaseCollisions gives them different keys and the dry-run marks both planned, while real extraction fails the second exclusive create. Fresh evidence beyond the earlier sigma report is that the replacement only handles 1-to-1 mappings; use the destination table or leave multi-code-point folds unresolved.
AGENTS.md reference: AGENTS.md:L21-L21
Useful? React with 👍 / 👎.
| } | ||
| const fullDestination = join(absoluteCallerPath(outputRoot), ...segments); | ||
| const fullBytes = Buffer.byteLength(fullDestination, "utf8"); | ||
| if (fullBytes > MAX_PORTABLE_PATH_BYTES) |
There was a problem hiding this comment.
Respect shorter destination path limits
On macOS, a nested destination can exceed Darwin's 1024-byte path limit while every component is below 255 bytes and the total remains below this 4095-byte threshold. Such an entry gets no unresolved reason and is reported planned, but the real mkdir/open path fails with ENAMETOOLONG; fresh evidence beyond the earlier 256-byte ext4 case is that the new check still assumes Linux's whole-path limit. Use the destination/platform limit or keep the unobserved range unresolved.
AGENTS.md reference: AGENTS.md:L21-L21
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 8362a1bcbe
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
| outputRoot: resolvedOutputRoot, | ||
| platform, | ||
| caseSensitivity: destinationCaseSensitivity, | ||
| verifyContent: !containerVerified, |
There was a problem hiding this comment.
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 👍 / 👎.
| : "All inventoried regular files exposed by the active reader were materialized; source traversal coverage is unknown, so the output is not established as a complete source copy.", | ||
| "Publication verifies the selected inventoried regular files; it does not establish complete content decoding.", | ||
| dryRun | ||
| ? "Dry-run extraction validated destination admission, path collisions, and reader entries without creating destination files or directories." |
There was a problem hiding this comment.
Do not report unresolved collisions as validated
When destination case sensitivity is unknown and the archive contains Foo.txt/foo.txt (or when a non-ASCII collision depends on the filesystem table), planSelectedEntries deliberately returns unresolved entries, but this unconditional top-level limitation says path collisions were validated. That makes the same result claim both certainty and uncertainty to CLI/MCP consumers; make this wording conditional on unresolvedPlan or say collisions were classified rather than validated.
AGENTS.md reference: AGENTS.md:L5-L5
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 91a2606e27
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
| for await (const entry of reader.entries(signal, traversal)) { | ||
| const path = normalizeArtifactPath(entry.path); | ||
| readerRegistry.add(path, entry.kind); | ||
| if (entry.kind !== "file" && entry.kind !== "slice") continue; |
There was a problem hiding this comment.
Reconcile non-file entries with the inventory snapshot
When a directory source gains or loses an empty directory or symlink after inventory but before this traversal, this continue means the second pass neither checks a newly observed non-file against the snapshot nor records that an inventoried one disappeared; createDryRunPlan later iterates the old inventory anyway. The dry run can therefore omit a current symlink or report a deleted one while claiming reader entries were validated, so reconcile every entry kind (or mark these facts unresolved) before returning the plan.
AGENTS.md reference: AGENTS.md:L50-L52
Useful? React with 👍 / 👎.
|
Addressed the non-file reconciliation comment. planSelectedEntries now compares live directory, symlink, and metadata entries with the inventory snapshot. A newly observed non-file or a disappeared inventoried non-file is reported as an unresolved limitation instead of being skipped. File and slice behaviour is unchanged. Codex, please re-review. |
|
Want your agent to iterate on Greptile's feedback? Try greploops. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 5281aebdd5
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
| inventory.occurrences | ||
| .filter( | ||
| (occurrence) => | ||
| occurrence.logical_path !== "." && | ||
| (occurrence.entry_kind === "directory" || |
There was a problem hiding this comment.
Exclude nested non-files from live reconciliation
When inventory expansion found a directory or metadata occurrence inside a nested ASAR/ZIP, this map includes it even though the active reader deliberately stops at the containing regular file. A stable second traversal can therefore never add that nested path to observedNonFile, and the result falsely reports that the entry disappeared and that non-file facts were not reconciled; restrict expected non-files to occurrences exposed by the active reader's ancestry.
AGENTS.md reference: AGENTS.md:L19-L19
Useful? React with 👍 / 👎.
| readerRegistry.add(path, entry.kind); | ||
| if (entry.kind !== "file" && entry.kind !== "slice") { | ||
| observedNonFile.add(path); | ||
| if (!inventoriedNonFile.has(path)) { |
There was a problem hiding this comment.
Compare non-file kinds during reconciliation
When an empty directory source entry is replaced by a symlink at the same path between inventory and the dry-run traversal, this path-only has succeeds, so no mismatch is emitted and the plan silently retains the stale directory status while claiming reader entries were validated. Fresh evidence after the earlier add/remove report is that the new reconciliation stores only the path in observedNonFile; compare the live entry.kind with the snapshot kind and mark a mismatch unresolved.
AGENTS.md reference: AGENTS.md:L50-L52
Useful? React with 👍 / 👎.
commented
Oct 26, 2026
|
Addressed both follow-up non-file reconciliation comments:
Codex, please re-review. |
left a comment
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: f7d41fa3cd
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
| ? unresolvedPlan.byOccurrenceId.size === 0 && | ||
| unresolvedPlan.limitations.length === 0 | ||
| ? "Dry-run extraction validated destination admission, path collisions, and reader entries without creating destination files or directories." | ||
| : "Dry-run extraction validated destination admission and reader entries and classified destination path collisions and length limits with unresolved entries without creating destination files or directories." |
There was a problem hiding this comment.
Separate limitation-only mismatches from unresolved entries
When a live directory gains a new directory or symlink after inventory, planSelectedEntries adds only a nonFileMismatches limitation because there is no inventory occurrence ID, so createDryRunPlan still returns unresolved_entries: 0; this branch nevertheless says the plan contains “unresolved entries” and that reader entries were validated. Fresh evidence beyond the earlier add/remove report is that the new limitation-only reconciliation path makes the summary contradict both the totals and the subsequent not-fully-reconciled limitation; distinguish source-level uncertainty from entry-level path uncertainty.
AGENTS.md reference: AGENTS.md:L19-L19
Useful? React with 👍 / 👎.
| ? [] | ||
| : [ | ||
| `${String(integrityContradictions.length)} extracted file(s) contradict declared integrity metadata; their bytes are observed-untrusted.`, | ||
| `${String(integrityContradictions.length)} ${dryRun ? "planned" : "extracted"} file(s) contradict declared integrity metadata; their bytes are observed-untrusted.`, |
There was a problem hiding this comment.
Do not label unresolved contradictions as planned
When record-and-continue retains an integrity contradiction for a selected file whose destination is unresolved—for example, a component over the portable name limit—integrityContradictions still counts the occurrence while createDryRunPlan marks it unresolved and omits it from planned_files; this message calls it “planned” anyway. CLI/MCP output can therefore report planned_files: 0 next to “1 planned file”; label the count as selected or filter out unresolved occurrence IDs.
AGENTS.md reference: AGENTS.md:L5-L5
Useful? React with 👍 / 👎.
commented
Oct 26, 2026
|
Addressed both follow-up summary/limitation comments:
Codex, please re-review. |
left a comment
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: a773c1d3ef
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
| "format", | ||
| `Invalid expected extraction size for ${path}`, | ||
| ); | ||
| const destinationPath = normalizeDestinationPath(path, platform); |
There was a problem hiding this comment.
Reject path spellings that collapse during host encoding
On POSIX, an ASAR JSON header can supply distinct escaped lone-surrogate names such as \uD800.txt and \uD801.txt. normalizeDestinationPath preserves them as distinct JavaScript strings even though Node encodes both filesystem pathnames using U+FFFD, so the dry-run registries mark both entries planned, while real extraction creates the first name and the second exclusive open fails with EEXIST. Reject non-well-formed UTF-16 at the owning path boundary or classify this encoding collision as unresolved.
AGENTS.md reference: AGENTS.md:L33-L33
Useful? React with 👍 / 👎.
| byteLength > MAX_PORTABLE_NAME_BYTES || | ||
| segment.length > MAX_PORTABLE_NAME_BYTES |
There was a problem hiding this comment.
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 👍 / 👎.
commented
Oct 26, 2026
|
@chatgpt-codex-connector review — Pushed
|
commented
Oct 26, 2026
|
@chatgpt-codex-connector review — Merged upstream |
commented
Oct 26, 2026
|
Pushed
@greptileai please review |
left a comment
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 2c712cfdcd
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
| const containerVerified = | ||
| zipSource !== undefined || reader.prepareContainer !== undefined; |
There was a problem hiding this comment.
Revalidate transferred ZIP bytes during dry-run
When a source ZIP is rewritten in place after inventory with the same size and unchanged/coarsened mtime/ctime (for example on a coarse-timestamp filesystem), this treats descriptor transfer as content verification and disables member reads. Fresh evidence beyond the earlier directory-source case is that ZipArtifactReader only rechecks borrowed-descriptor metadata before enumeration and does not snapshot the bytes, so dry-run can report the old inventory SHA/size as planned while non-dry extraction opens the member and rejects its CRC/SHA; rehash the container or verify its members before reporting current plans.
AGENTS.md reference: AGENTS.md:L50-L52
Useful? React with 👍 / 👎.
| let unresolvedEntries = 0; | ||
| let observedBytesEstimate = 0; | ||
| let declaredBytesEstimate: number | null = 0; | ||
| for (const occurrence of inventory.occurrences) { |
There was a problem hiding this comment.
Page large dry-run plans before MCP delivery
For a large source such as a ZIP with tens of thousands of empty members, this unconditional loop serializes one plan row for every occurrence while artifacts also carries every planned file. Because extract_artifact has no detail or page selector, ToolResultDelivery.successResult replaces an otherwise completed MCP dry-run with a transport resource_constraint once the response budget is crossed, and there is no artifact-plan continuation for the agent to inspect; retain the complete evidence but return a summary or page.
AGENTS.md reference: AGENTS.md:L45-L49
Useful? React with 👍 / 👎.
| const cached = cache.get(segment); | ||
| if (cached !== undefined) return cached; | ||
| abortIfNeeded(signal); | ||
| const probeFailure = await lstat(join(destinationParent, segment)).then( |
There was a problem hiding this comment.
Bound component-limit probes across distinct names
For a large flat archive whose filenames are all distinct, this cache is keyed by the full segment, so planning performs one awaited lstat against the destination parent per member. A 100k-entry package therefore adds 100k serial filesystem probes (especially costly when TMPDIR is remote) before returning any plan; bound the probe and leave the remainder unknown, or reuse an observed filesystem limit rather than caching each spelling.
AGENTS.md reference: AGENTS.md:L50-L52
Useful? React with 👍 / 👎.
commented
Oct 26, 2026
|
Resolved the three Codex P2 review comments in
@codex review |
…ed integrity contradictions
…mponent length limits
…, and page plan entries
dd6d142 to
e37d5ef
Compare
commented
Oct 27, 2026
|
Codex usage limits have been reached for code reviews. Please check with the admins of this repo to increase the limits by adding credits. |
commented
Oct 27, 2026
|
Still actively maintaining this. Latest readiness check is green. Continuing to work through the remaining open review comments (cancellation handling, Windows name policy, source freshness, component limits, etc.). Will push the next batch of fixes shortly. |
commented
Oct 27, 2026
Dry-run extraction fixes (Greptile P1 + Adversary CLEAR)Addresses the typecheck/runtime failures and the review findings on the dry-run ZIP revalidation path. Changes
VerificationAdversary (DeepSeek) verdict: CLEAR on all owned items after eleven rounds. Follow-ups (advisories, not blockers)
Ready for review / merge once CI is green under Vitest 5.0.3. |
…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.
commented
Oct 27, 2026
|
Codex usage limits have been reached for code reviews. Please check with the admins of this repo to increase the limits by adding credits. |
commented
Oct 27, 2026
|
Still actively maintaining this. Latest head is 2f987e4. Working through the five remaining Greptile findings (three P1s first):
Will push the fixes and request re-review once ready. The author-declaration failure was a service error; will re-trigger on the next push. |
…st-publish cancellation (morluto#5489) - Expose CLI --plan-offset and --plan-limit on extract-artifact (requiring --dry-run) and document serialized page byte budgets in docs/mcp-contracts.md. - Add DryRunPlanCache.ts with 8-entry LRU validated dry-run plan caching across continuation pages, finite offset/limit sanitization, and page-scoped truncation of extraction_manifest.selected_occurrence_ids, artifacts, limitations, and integrity_contradictions. - Budget complete dry-run pages within MAX_DRY_RUN_PLAN_PAGE_BYTES (512 KiB), bounding individual diagnostic strings and skipping oversized first entries with a bounded limitation and advancing next_offset. - Preserve completed extraction receipts in ArtifactExtraction.ts finally when signal aborts after SafeOutputTree publication (output?.published === true && completed !== undefined). - Require caller-owned ArtifactResourceScope in observeDirectoryCaseSensitivity and return unknown when checkDestination is called without a scope. - Export and test requireStableRegularFileDescriptor in ArtifactExtraction.sourceGuard.test.ts and use join(directory, "entry-") with upper and lower probe bounds in ArtifactExtraction.test.ts.
commented
Oct 27, 2026
|
Codex usage limits have been reached for code reviews. Please check with the admins of this repo to increase the limits by adding credits. |
…tries exceeding page budget (morluto#5489) - Measure raw occurrence limitation strings (`${logical_path}: ${limitation}`), integrity contradictions, and occurrence_id overhead into perOccurrenceOverheadBytes in buildDryRunPlanCatalog so entries with multi-megabyte ASAR diagnostics exceed MAX_DRY_RUN_PLAN_PAGE_BYTES and trigger the explicit oversized-entry skip outcome. - Remove formatDryRunOccurrenceLimitation and emit raw occurrence limitations for pagedEntryIds across both dry-run and non-dry-run paths while omitting skipped oversized entries via pagedEntryIds filtering. - Remove the MAX_DRY_RUN_PLAN_PAGE_BYTES / 2 clamp on sanitizedOverheadBytes in sliceDryRunPlanCatalogWithDiagnostics, bound individual base limitations against maxTotalBytes, and include full envelope metadata in baseOverheadBytes. - Update the 5 MiB invalid ASAR integrity hash dry-run test at planLimit: 1 to assert entries: [], returned_entries: 0, truncated: true, and the oversized-entry limitation within MAX_DRY_RUN_PLAN_PAGE_BYTES.
commented
Oct 27, 2026
|
Codex usage limits have been reached for code reviews. Please check with the admins of this repo to increase the limits by adding credits. |
…ion-dry-run-5489 # Conflicts: # src/artifacts/ArtifactPaths.test.ts # src/artifacts/ArtifactPaths.ts # src/artifacts/SafeOutputTree.ts # src/artifacts/extraction/ArtifactExtraction.ts # src/cli/artifactCommands.ts # tests/boundary/providers/native/artifactProvider.extraction.test.ts
| JSON.stringify([ | ||
| sourcePath, | ||
| absoluteCallerPath(input.selectedPath ?? input.inputPath), | ||
| input.inputFormat, | ||
| input.platform ?? process.platform, | ||
| input.integrityPolicy, | ||
| input.asarHeaderAdmission ?? resolveAsarHeaderAdmission(input.environment), |
There was a problem hiding this comment.
dryRunCacheSourceKey omits espFlashSelection, although flashOffset and partitionTableOffset change which bytes become partitions. In one MCP server, a caller can plan an image, reopen the same file with another valid layout, and request a later page. The unchanged file passes the cache's file-state and root-hash checks, so the caller receives paths and digests from the earlier layout.
The repository requires cache keys to cover inputs that affect the result. Include the complete selection in this key.
Context Used: AGENTS.md (source)
Prompt To Fix With AI
This is a comment left during a code review.
Path: src/artifacts/extraction/DryRunPlanCache.ts
Line: 281-287
Comment:
**Plans reuse the wrong layout**
`dryRunCacheSourceKey` omits `espFlashSelection`, although `flashOffset` and `partitionTableOffset` change which bytes become partitions. In one MCP server, a caller can plan an image, reopen the same file with another valid layout, and request a later page. The unchanged file passes the cache's file-state and root-hash checks, so the caller receives paths and digests from the earlier layout.
The repository requires cache keys to cover inputs that affect the result. Include the complete selection in this key.
**Context Used:** AGENTS.md ([source](https://github.com/morluto/rea/blob/main/AGENTS.md))
---
For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.| if (validatedDryRunPlanCache.size >= MAX_VALIDATED_DRY_RUN_CACHE_ENTRIES) { | ||
| const oldestKey = validatedDryRunPlanCache.keys().next().value; | ||
| if (oldestKey !== undefined) validatedDryRunPlanCache.delete(oldestKey); | ||
| } | ||
| validatedDryRunPlanCache.set(key, { | ||
| sourceFileState: regularFileState(sourceStats), | ||
| destinationParent: dirname(resolvedOutputRoot), | ||
| outputRootLength: resolvedOutputRoot.length, | ||
| outputRootByteLength: Buffer.byteLength(resolvedOutputRoot, "utf8"), | ||
| caseSensitivity, | ||
| snapshot, | ||
| }); |
There was a problem hiding this comment.
Closed targets keep large plans
The new process-wide cache keeps complete inventories and catalogs, not just the returned pages. Its only capacity check counts eight entries, and neither client close nor investigation reset releases them. Several large archives can leave substantial memory pinned after the user closes them.
AGENTS.md requires bounded retained state and a defined cache lifetime. Give this cache an owner and a shared byte allowance, with release at the matching close or reset step. This repository requirement must be satisfied before merging.
Context Used: AGENTS.md (source)
Prompt To Fix With AI
This is a comment left during a code review.
Path: src/artifacts/extraction/DryRunPlanCache.ts
Line: 313-324
Comment:
**Closed targets keep large plans**
The new process-wide cache keeps complete inventories and catalogs, not just the returned pages. Its only capacity check counts eight entries, and neither client close nor investigation reset releases them. Several large archives can leave substantial memory pinned after the user closes them.
`AGENTS.md` requires bounded retained state and a defined cache lifetime. Give this cache an owner and a shared byte allowance, with release at the matching close or reset step. This repository requirement must be satisfied before merging.
**Context Used:** AGENTS.md ([source](https://github.com/morluto/rea/blob/main/AGENTS.md))
---
For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.| const createDryRunPlan = ( | ||
| inventory: ArtifactInventorySnapshot, | ||
| selected: readonly SelectedOccurrence[], | ||
| unresolvedCaseReasons: ReadonlyMap<string, string>, |
There was a problem hiding this comment.
createDryRunPlan has no callers now that result creation uses sliceDryRunPlanCatalogWithDiagnostics directly. Its sliceDryRunPlanCatalog wrapper is otherwise unused, and limitDryRunPlanText is also an unused alias. These leftovers make maintainers distinguish the live path from helpers that return less diagnostic information.
AGENTS.md requires removing superseded representations, aliases, and wrappers after checking their consumers. Remove these leftovers so there is one current plan-building path. This repository requirement must be satisfied before merging.
Context Used: AGENTS.md (source)
Prompt To Fix With AI
This is a comment left during a code review.
Path: src/artifacts/extraction/ArtifactExtraction.ts
Line: 1312-1315
Comment:
**Unused plan helpers remain**
`createDryRunPlan` has no callers now that result creation uses `sliceDryRunPlanCatalogWithDiagnostics` directly. Its `sliceDryRunPlanCatalog` wrapper is otherwise unused, and `limitDryRunPlanText` is also an unused alias. These leftovers make maintainers distinguish the live path from helpers that return less diagnostic information.
`AGENTS.md` requires removing superseded representations, aliases, and wrappers after checking their consumers. Remove these leftovers so there is one current plan-building path. This repository requirement must be satisfied before merging.
**Context Used:** AGENTS.md ([source](https://github.com/morluto/rea/blob/main/AGENTS.md))
---
For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!
left a comment
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 0ffad060b5
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
| JSON.stringify([ | ||
| sourcePath, | ||
| absoluteCallerPath(input.selectedPath ?? input.inputPath), | ||
| input.inputFormat, | ||
| input.platform ?? process.platform, |
There was a problem hiding this comment.
Key cached plans by ESP flash selection
When two dry-runs of the same ESP dump use different flashOffset or partitionTableOffset values and their page requests interleave, this key is identical even though espFlashSelection is passed to inventory and reader construction. The later page-0 call overwrites the process-global entry, so the earlier caller's plan_offset > 0 request can return partitions and occurrence IDs from the other layout; include the selection or resulting manifest identity in the cache key.
AGENTS.md reference: AGENTS.md:L54-L56
Useful? React with 👍 / 👎.
| const currentStats = await lstat(sourcePath); | ||
| abortIfNeeded(signal); | ||
| if ( | ||
| !currentStats.isFile() || | ||
| !sameRegularFileState(cached.sourceFileState, currentStats) || |
There was a problem hiding this comment.
Revalidate bytes before serving cached continuations
When a cached regular archive is rewritten after page 0 with different bytes but the same inode, size, mode, and unchanged coarse mtime/ctime, this metadata-only check passes and returns the old SHA/size plan without revalidateTransferredZipSource or any hash. Fresh evidence beyond the earlier transferred-ZIP report is that continuation requests now take this new cache path and bypass full-container revalidation; hash or descriptor-validate the source before reporting the retained snapshot as current.
AGENTS.md reference: AGENTS.md:L54-L56
Useful? React with 👍 / 👎.
| extraction_manifest: { | ||
| ...extractionSemantic, | ||
| selected_occurrence_ids: returnedSelectedOccurrenceIds, | ||
| extraction_id: `aex_${digestCanonicalValue(extractionSemantic, "Artifact")}`, |
There was a problem hiding this comment.
Keep paged extraction manifests self-consistent
For any byte- or count-paged dry run, extractionSemantic is hashed from all selected occurrences and all extracted rows, but this projection overwrites selected_occurrence_ids with only the current page while leaving the full files_sha256 and hash-derived extraction_id. The manifest therefore cannot be recomputed or authenticated from the fields it exposes, and identical IDs label different manifest objects across pages; keep the full immutable commitment separate from the page-local projection.
AGENTS.md reference: AGENTS.md:L19-L19
Useful? React with 👍 / 👎.
| if (pageBytes + entryBytes > MAX_DRY_RUN_PLAN_PAGE_BYTES) { | ||
| if (pagedEntries.length === 0) { | ||
| const nextOffset = index + 1 < totalEntries ? index + 1 : null; | ||
| return { |
There was a problem hiding this comment.
Keep oversized plan entries retrievable
When one entry's serialized representation exceeds 512 KiB, this branch returns no row and advances next_offset past it. Following every advertised offset will therefore never yield that occurrence's full status, path, and reason; only a shortened limitation remains even though total_entries counts it. Fresh evidence beyond the earlier byte-budget reports is this final skip-and-advance branch; retain the complete row as Evidence or provide a compact retrievable reference.
AGENTS.md reference: AGENTS.md:L49-L53
Useful? React with 👍 / 👎.
| readonly snapshot: CachedDryRunSnapshot; | ||
| } | ||
|
|
||
| const validatedDryRunPlanCache = new Map<string, CachedValidatedDryRunPlan>(); |
There was a problem hiding this comment.
Bound retained dry-run snapshots by size and lifetime
In a long-running MCP process, each value in this global map retains the complete inventory, selected/extracted arrays, all-entry catalog, and supporting maps, but eviction is bounded only by eight keys and is not tied to client/session closure or a byte/occurrence budget. Repeated dry-runs of large ZIP64 archives with many empty members can therefore retain memory proportional to all members long after their 512 KiB response pages are delivered; bound retained size and lifetime as well as key count.
AGENTS.md reference: AGENTS.md:L57-L58
Useful? React with 👍 / 👎.
commented
Nov 5, 2026
|
Hey @hannesstrydom664-hash, thanks for putting this together, the addition looks useful. What's left: there are 39 unresolved review threads from Codex and Greptile (18 still on current code), e.g. "Plans reuse the wrong layout" and "Recheck cancellation after dry-run cleanup"; the 21 on outdated lines may just need resolving if they're already handled. Greptile is at 4/5 on the current head, mainly over "Plans reuse the wrong layout", so addressing that thread should bump it. Happy to merge once that's sorted. |
Summary
Fixes #5489
Adds a dry-run planning mode (
dry_run: true/--dry-run) toextract_artifactso agents and operators can inspect what an extraction will materialize, verify destination admission and path-collision rules, and review labeled byte estimates before touching disk.Problem and expected behavior
extract_artifact(or CLIrea extract-artifact) when evaluating an archive or application package before deciding whether to materialize files on disk.extract_artifactalways staged and moved extracted entries intooutput_root, providing no dry-run mode to validate destination path safety (Windows/POSIX reserved characters, NFC collisions, prefix collisions) and inspect planned vs. unsupported/unresolved entries without writing to disk.dry_run: true(or--dry-run) is passed,extract_artifactvalidatesoutput_rootadmission viaSafeOutputTree.checkDestination(input.outputRoot), traverses selected entries using the samenormalizeDestinationPathandArtifactPathRegistryrules as real extraction, creates zero destination directories/files or sidecar manifests, and returns a structuredplanalongsidedry_run: true.Change and scope
Follow the contribution scope.
Scoped enhancement implementing issue #5489 (
feat(artifacts): add dry-run plan for artifact extraction).src/domain/artifactGraph.ts: AddartifactExtractionPlanEntrySchema,artifactExtractionPlanTotalsSchema, andartifactExtractionPlanSchema, plusdry_runandplanfields onartifactExtractionResultSchema. Each non-root inventory occurrence is classified as"planned","unsupported"(directories, logical metadata declarations, or nested archive members not expanded during single-container extraction), or"unresolved"(symlinks), with byte totals explicitly labeled viabyte_totals_basis: "declared-and-observed-content-estimates"andbyte_totals_note.src/artifacts/SafeOutputTree.ts&src/artifacts/extraction/ArtifactExtraction.ts: ExportnormalizeDestinationPath(relativePath, platform)so dry-run planning applies the exact same Windows/POSIX destination path rules (\,:,U+0001-U+001F, NFC normalization, andArtifactPathRegistryprefix/collision checks) asSafeOutputTree.prototype.write(). WhendryRun: true,extractArtifactvalidates the destination viaSafeOutputTree.checkDestination(input.outputRoot)and walksreader.entries(signal, traversal)viaplanSelectedEntries()without creatingoutputRoot, staging directories, or sidecar files.src/contracts/artifactToolContracts.ts,src/cli/artifactCommands.ts,src/artifacts/ArtifactProvider.ts: Adddry_run?: booleantoartifactExtractionInputSchemaand--dry-runto the CLIextract-artifactcommand, forwardingdryRunandplatformthroughArtifactProvider.src/artifacts/extraction/ArtifactExtraction.test.ts&tests/boundary/providers/native/artifactProvider.extraction.test.ts: Add unit and provider boundary tests covering dry-run plans, zero destination writes, and parity of path-collision/invalid-name refusals between dry-run and real extraction.Contract and boundary impact
src/domain/artifactGraph.tsandsrc/artifacts/extraction/ArtifactExtraction.ts.feat(artifacts): add dry-run plan for artifact extraction).dry_run?: booleantoextract_artifactinput and--dry-runtorea extract-artifact, and optionaldry_run?: boolean+plan?: ArtifactExtractionPlantoartifactExtractionResultSchema.win32vs POSIX) across both dry-run and real extraction.created: falseandbytes_written: 0on selected entries while preserving verified inventoryartifact_idandsha256values and explicitly labeling byte estimates.SafeOutputTree.checkDestinationruns before planning, and no staging directory or destination root is created whendryRun: true.docs/public/product-catalog.json), package, or installation impact: Updated generated catalog metadata if applicable.Expected effects (check known effects; use documentation-only on its own).
Unchecked items do not establish absence; leave uncertainties visible.
Evidence and regression coverage
src/artifacts/extraction/ArtifactExtraction.test.tstests/boundary/providers/native/artifactProvider.extraction.test.tsdryRun: trueproducesplan.entries(planned,unsupported,unresolved) andplan.totalswhile leavingoutput_rootnonexistent on disk, and rejects NFC path collisions and Windows:ADS names identically todryRun: false.extract_artifactwithdry_run: truereturnsdry_run: trueandplan: { destination_root, entries, totals: { planned_files, unsupported_entries, unresolved_links, observed_bytes_estimate, declared_bytes_estimate, byte_totals_basis, byte_totals_note } }.For evidence-bearing changes:
Validation performed
npx vitest run src/artifacts/extraction/ArtifactExtraction.test.ts tests/boundary/providers/native/artifactProvider.extraction.test.ts— passed (39/39tests).npm run typecheck— passed (tsc --noEmit, 0 errors).npm run format:check— passed (oxfmt --check .).npm run lint— passed (oxlint0 warnings/0 errors;verify:module-boundariespassed).npm run verify:test-discovery— passed.npm run verify:architecture-guards— passed.npm run scan:todos— passed.npm run jscpd— passed.Compatibility, safety, and release
dry_runis optional and defaults tofalse).win32platform normalization rules inArtifactExtraction.test.ts.output_rootwhile enforcing identical path-traversal and collision checks.Author readiness
Human owner: @hannesstrydom664-hash
Before merge
type(scope): outcome.