Skip to content

feat(artifacts): add dry-run plan for artifact extraction - #7177

Open
hannesstrydom664-hash wants to merge 18 commits into
morluto:mainfrom
hannesstrydom664-hash:feat/artifact-extraction-dry-run-5489
Open

hannesstrydom664-hash wants to merge 18 commits into
morluto:mainfrom
hannesstrydom664-hash:feat/artifact-extraction-dry-run-5489

Conversation

@hannesstrydom664-hash

Copy link
Copy Markdown

Summary

Fixes #5489

Adds a dry-run planning mode (dry_run: true / --dry-run) to extract_artifact so 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

  • Smallest trigger: Call extract_artifact (or CLI rea extract-artifact) when evaluating an archive or application package before deciding whether to materialize files on disk.
  • Violated invariant: Previously, extract_artifact always staged and moved extracted entries into output_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.
  • Expected behavior: When dry_run: true (or --dry-run) is passed, extract_artifact validates output_root admission via SafeOutputTree.checkDestination(input.outputRoot), traverses selected entries using the same normalizeDestinationPath and ArtifactPathRegistry rules as real extraction, creates zero destination directories/files or sidecar manifests, and returns a structured plan alongside dry_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: Add artifactExtractionPlanEntrySchema, artifactExtractionPlanTotalsSchema, and artifactExtractionPlanSchema, plus dry_run and plan fields on artifactExtractionResultSchema. 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 via byte_totals_basis: "declared-and-observed-content-estimates" and byte_totals_note.
  • src/artifacts/SafeOutputTree.ts & src/artifacts/extraction/ArtifactExtraction.ts: Export normalizeDestinationPath(relativePath, platform) so dry-run planning applies the exact same Windows/POSIX destination path rules (\, :, U+0001-U+001F, NFC normalization, and ArtifactPathRegistry prefix/collision checks) as SafeOutputTree.prototype.write(). When dryRun: true, extractArtifact validates the destination via SafeOutputTree.checkDestination(input.outputRoot) and walks reader.entries(signal, traversal) via planSelectedEntries() without creating outputRoot, staging directories, or sidecar files.
  • src/contracts/artifactToolContracts.ts, src/cli/artifactCommands.ts, src/artifacts/ArtifactProvider.ts: Add dry_run?: boolean to artifactExtractionInputSchema and --dry-run to the CLI extract-artifact command, forwarding dryRun and platform through ArtifactProvider.
  • 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

  • Semantic owner and earliest changed stage: src/domain/artifactGraph.ts and src/artifacts/extraction/ArtifactExtraction.ts.
  • Contribution scope fit and linked maintainer decision: Implements [Feature] Add a dry-run plan for artifact extraction #5489 (feat(artifacts): add dry-run plan for artifact extraction).
  • CLI and MCP/tool-catalog contract: Adds optional dry_run?: boolean to extract_artifact input and --dry-run to rea extract-artifact, and optional dry_run?: boolean + plan?: ArtifactExtractionPlan to artifactExtractionResultSchema.
  • Provider, bridge, target-format, or platform compatibility: Preserves platform-specific destination validation (win32 vs POSIX) across both dry-run and real extraction.
  • Evidence, artifact, provenance, or reconstruction contract: Dry-run results report created: false and bytes_written: 0 on selected entries while preserving verified inventory artifact_id and sha256 values and explicitly labeling byte estimates.
  • Target selection, authority, upstream behavior, and cleanup details (if applicable): SafeOutputTree.checkDestination runs before planning, and no staging directory or destination root is created when dryRun: true.
  • Generated metadata (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.

  • Read existing files or captured data.
  • Launch or attach to a process.
  • Inject instrumentation or run scripts/code.
  • Change process memory, registers, files, or configuration.
  • Contact network services.
  • Recover protected code or work around protections.
  • Documentation or usability only; no target interaction.
  • Not sure yet; investigation or maintainer guidance needed.

Evidence and regression coverage

  • Tests added or updated:
    • src/artifacts/extraction/ArtifactExtraction.test.ts
    • tests/boundary/providers/native/artifactProvider.extraction.test.ts
  • Base reproduction or other evidence:
    • Executed: Verified on safe archive fixtures containing regular files, directories, and symlinks that dryRun: true produces plan.entries (planned, unsupported, unresolved) and plan.totals while leaving output_root nonexistent on disk, and rejects NFC path collisions and Windows : ADS names identically to dryRun: false.
  • User-visible CLI/MCP output (if applicable):
    • extract_artifact with dry_run: true returns dry_run: true and plan: { destination_root, entries, totals: { planned_files, unsupported_entries, unresolved_links, observed_bytes_estimate, declared_bytes_estimate, byte_totals_basis, byte_totals_note } }.
  • Remaining proof gaps: None.

For evidence-bearing changes:

  • Observed, derived, and inferred claims remain distinguishable.
  • Artifact identity, source provenance, and failed attempts remain preserved.
  • Unsupported, incomplete, unavailable, or uncertain outcomes remain visible.

Validation performed

  • npx vitest run src/artifacts/extraction/ArtifactExtraction.test.ts tests/boundary/providers/native/artifactProvider.extraction.test.ts — passed (39/39 tests).
  • npm run typecheck — passed (tsc --noEmit, 0 errors).
  • npm run format:check — passed (oxfmt --check .).
  • npm run lint — passed (oxlint 0 warnings/0 errors; verify:module-boundaries passed).
  • 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

  • Breaking changes or migration steps: None (dry_run is optional and defaults to false).
  • Real Hopper/Ghidra, browser, or OS coverage: Tested with both POSIX and win32 platform normalization rules in ArtifactExtraction.test.ts.
  • Package or release metadata impact: None.
  • Security, privacy, process, or containment review: Ensures dry-run never writes to or creates output_root while enforcing identical path-traversal and collision checks.

Author readiness

Human owner: @hannesstrydom664-hash

  • I reviewed the final diff and relevant existing code, understand the change and its edge cases, and take responsibility for the complete PR, including AI-assisted work.
  • I checked the evidence above, confirmed it supports the current change, and recorded meaningful validation gaps.
  • I declare this PR ready for initial maintainer review.

Before merge

  • This PR addresses a concrete problem or an agreed enhancement.
  • Material scope and authority questions are resolved, and any required maintainer scope decision covers the final diff.
  • The PR has one focused outcome and the title follows type(scope): outcome.
  • Related issue is linked, or the reason for not linking one is stated above.
  • Tests cover changed observable behavior and meaningful failure paths.
  • Owning docs, contracts, and generated metadata are updated where needed.
  • User-visible CLI/MCP changes include representative output.
  • I checked the final diff for secrets, unrelated cleanup, and unsupported claims.

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 25, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-01T17:12:30.848304Z 0ffad06 New commits
ℹ️ About Codex in GitHub

Your team has set up Codex to 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" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@greptile-apps

greptile-apps Bot commented Oct 25, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerView in GreptileConfidence Score: 4/5 Tier: apex

[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.

Findings

  1. P1 Plans reuse the wrong layout ▶
  2. P2 Closed targets keep large plans ▶
  3. P2 Unused plan helpers remain ▶
Fix 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.

Summary

Adds dry-run artifact extraction with paged plans, labeled byte estimates, shared destination checks, and CLI/MCP options.

  • Artifact extraction can return a plan without creating output files.
  • CLI and tool callers can request and page through extraction plans.
  • Bundle and firmware output checks carry file cleanup details through failures.

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]
Loading

Reviews (21) · Last reviewed commit: "Merge remote-tracking branch 'origin/mai..." · Reviewed by Greptile

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 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);

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 👍 / 👎.

"format",
`Invalid expected extraction size for ${path}`,
);
const destinationPath = normalizeDestinationPath(path, platform);

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 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,

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 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 👍 / 👎.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 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".

Comment thread src/artifacts/SafeOutputTree.ts Outdated
if (!siblingEntries.includes(toggled)) {
const [original, candidate] = await Promise.all([
lstat(current, { bigint: true }).catch(() => undefined),
lstat(join(parent, toggled), { bigint: true }).catch(() => undefined),

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 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 👍 / 👎.

Comment thread src/artifacts/ArtifactPaths.ts Outdated
if (this.#caseInsensitive) {
const collision = destinationCaseCollision(
currentPath,
node.spellingsByFold.get(englishCaseFold(part)) ?? [],

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 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 👍 / 👎.

Comment thread src/artifacts/SafeOutputTree.ts Resolved

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 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".

Comment thread src/artifacts/ArtifactPaths.ts Outdated
platform: NodeJS.Platform = process.platform,
): string => {
let folded = "";
for (const char of part) folded += foldDestinationCodePoint(char, platform);

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 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 👍 / 👎.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 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".

Comment thread src/artifacts/SafeOutputTree.ts Outdated
Comment on lines +189 to +191
platform === "win32"
? "case-insensitive"
: await observeDirectoryCaseSensitivity(parent),

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 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 👍 / 👎.

Comment thread src/artifacts/SafeOutputTree.ts Outdated
const observeDirectoryCaseSensitivity = async (
directory: string,
): Promise<DestinationCaseSensitivity> => {
const entries = await readdir(directory).catch(() => undefined);

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 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 👍 / 👎.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 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);

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 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);

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 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 👍 / 👎.

Comment thread src/artifacts/SafeOutputTree.ts Outdated
} catch {
return "unknown";
} finally {
await dir.close().catch(() => undefined);

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 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 👍 / 👎.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 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".

Comment thread src/artifacts/ArtifactPaths.ts Outdated

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

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 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)

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 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 👍 / 👎.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 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,

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 👍 / 👎.

: "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."

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 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 👍 / 👎.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 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;

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 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 👍 / 👎.

@hannesstrydom664-hash

Copy link
Copy Markdown
Author

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.

@greptile-apps

greptile-apps Bot commented Oct 26, 2026

Copy link
Copy Markdown
Contributor

Want your agent to iterate on Greptile's feedback? Try greploops.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 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".

Comment on lines +547 to +551
inventory.occurrences
.filter(
(occurrence) =>
occurrence.logical_path !== "." &&
(occurrence.entry_kind === "directory" ||

ghost Oct 26, 2026

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 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)) {

ghost Oct 26, 2026

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 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 👍 / 👎.

@hannesstrydom664-hash

ghost commented Oct 26, 2026

Copy link
Copy Markdown
Author

Addressed both follow-up non-file reconciliation comments:

  1. Scoped expected non-file occurrences in planSelectedEntries using exposedByActiveReaderFilter (matching activeOccurrences) so nested ASAR/archive non-file members are not falsely flagged as missing from the top-level reader.
  2. Verified candidate.entry_kind === entry.kind when reconciling non-file entries and propagated kind/disappearance mismatches into unresolvedByOccurrenceId and createDryRunPlan so affected non-file entries are marked unresolved.

Codex, please re-review.

ghost left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 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."

ghost Oct 26, 2026

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 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.`,

ghost Oct 26, 2026

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 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 👍 / 👎.

@hannesstrydom664-hash

ghost commented Oct 26, 2026

Copy link
Copy Markdown
Author

Addressed both follow-up summary/limitation comments:

  1. Separated limitation-only non-file drift (unresolvedPlan.byOccurrenceId.size === 0 && unresolvedPlan.limitations.length > 0) from entry-level unresolved plans so adding a new directory/symlink after inventory does not claim the plan has unresolved entries or that all reader entries were validated.
  2. Updated the dry-run integrity contradiction limitation wording from planned to selected so unresolved selected occurrences with record-and-continue contradictions do not contradict planned_files: 0.

Codex, please re-review.

ghost left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 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);

ghost Oct 26, 2026

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 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 👍 / 👎.

Comment on lines +471 to +472
byteLength > MAX_PORTABLE_NAME_BYTES ||
segment.length > MAX_PORTABLE_NAME_BYTES

ghost Oct 26, 2026

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 👍 / 👎.

@hannesstrydom664-hash

ghost commented Oct 26, 2026

Copy link
Copy Markdown
Author

@chatgpt-codex-connector review — Pushed 8c31e5082af7 addressing both inline review items:

  1. Unpaired UTF-16 surrogates at the destination path boundary (SafeOutputTree.ts): normalizeDestinationPath and SafeOutputTree.#resolveDestination now reject ill-formed UTF-16 strings containing unpaired surrogates (0xD800..0xDFFF) before host UTF-8 encoding can coalesce distinct lone surrogates (such as \uD800.txt and \uD801.txt in ASAR JSON headers) into U+FFFD.
  2. Short destination component length limits (ArtifactExtraction.ts): overLimitDestinationReason now probes each unique destination path segment against the existing destination parent directory via lstat(join(destinationParent, segment)) (memoized per segment) in addition to the static NAME_MAX / PATH_MAX / MAX_PATH bounds, so filesystems with shorter component limits (such as eCryptfs mounts returning ENAMETOOLONG around ~143 plaintext bytes) mark affected occurrences unresolved in the dry-run plan without creating files.

@hannesstrydom664-hash

ghost commented Oct 26, 2026

Copy link
Copy Markdown
Author

@chatgpt-codex-connector review — Merged upstream main (99ff434) in ca681db13bb6, aligning SafeOutputTree.checkDestination with SafeOutputTree.resolveDestination and retaining all dry-run destination admission, unpaired UTF-16 surrogate checks, and component length probes.

Comment thread src/cli/artifactCommands.ts Resolved
@hannesstrydom664-hash

ghost commented Oct 26, 2026

Copy link
Copy Markdown
Author

Pushed 2c712cfdcd9a to address the two follow-up review items:

  1. Shared dry-run limitation constants & formatters (src/artifacts/extraction/ArtifactExtraction.ts, src/artifacts/extraction/ArtifactExtraction.test.ts): Exported the owning limitation constants and formatter helpers (DRY_RUN_VALIDATED_LIMITATION, DRY_RUN_UNRESOLVED_LIMITATION, DRY_RUN_NON_FILE_DRIFT_SUMMARY_LIMITATION, DRY_RUN_OVER_LIMIT_LIMITATION, DRY_RUN_UNKNOWN_CASE_LIMITATION, DRY_RUN_NON_ASCII_CASE_LIMITATION, DRY_RUN_NON_FILE_RECONCILIATION_LIMITATION, formatDryRunNonFileKindMismatchReason, formatDryRunNonFileAddedLimitation, and formatExtractionIntegrityContradictionLimitation) and updated ArtifactExtraction.test.ts to assert against those owning constants/formatters rather than frozen prose sentences.
  2. CLI/MCP dry-run planning examples and documentation (src/contracts/artifactToolContracts.ts, src/cli/artifactCommands.ts, docs/mcp-contracts.md, docs/node-sea.md): Added a { "dry_run": true } advertised input example and contract guidance on extract_artifact, expanded the CLI --dry-run option help, and documented plan.entries statuses (planned, unsupported, unresolved) and content-byte estimate semantics in docs/mcp-contracts.md and docs/node-sea.md.

@greptileai please review

ghost left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 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".

Comment on lines +375 to +376
const containerVerified =
zipSource !== undefined || reader.prepareContainer !== undefined;

ghost Oct 26, 2026

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 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) {

ghost Oct 26, 2026

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 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 👍 / 👎.

Comment on lines +505 to +508
const cached = cache.get(segment);
if (cached !== undefined) return cached;
abortIfNeeded(signal);
const probeFailure = await lstat(join(destinationParent, segment)).then(

ghost Oct 26, 2026

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 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 👍 / 👎.

@hannesstrydom664-hash

ghost commented Oct 26, 2026

Copy link
Copy Markdown
Author

Resolved the three Codex P2 review comments in 5a3afc512980:

  1. Revalidate transferred ZIP bytes during dry-run (4381683115): Dry-run now opens and verifies planned ZipArtifactReader member streams against inventoried SHA-256 and byte counts (matching non-dry extraction) and revalidates the borrowed descriptor's container SHA-256 and sameRegularFileState via revalidateTransferredZipSource, catching in-place source rewrites even when file size and mtime/ctime are unchanged.
  2. Bound component-limit probes across distinct names (4381683135): Replaced the per-segment-string lstat cache with DestinationComponentLimitProbeState + primeComponentLimitProbeState, probing the longest in-range segment first and binary-searching unique UTF-8 byte lengths (capped at MAX_COMPONENT_LIMIT_PROBES = 16) so accepted/rejected byte-length thresholds are reused across all segments without per-name lstat scaling.
  3. Page large dry-run plans before MCP delivery (4381683126): Added plan_offset (default 0) and plan_limit (default 500, max 1000) to dry-run extraction along with plan.page metadata (total_entries, offset, limit, returned_entries, next_offset, truncated), bounding plan.entries and artifacts per response while preserving full-inventory plan.totals and extraction_manifest.

@codex review

@hannesstrydom664-hash
hannesstrydom664-hash force-pushed the feat/artifact-extraction-dry-run-5489 branch from dd6d142 to e37d5ef Compare October 27, 2026 11:26
@chatgpt-codex-connector

ghost commented Oct 27, 2026

Copy link
Copy Markdown

Codex usage limits have been reached for code reviews. Please check with the admins of this repo to increase the limits by adding credits.
Repo admins can enable using credits for code reviews in their settings.

Comment thread src/artifacts/SafeOutputTree.ts Resolved
@hannesstrydom664-hash

ghost commented Oct 27, 2026

Copy link
Copy Markdown
Author

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.

@hannesstrydom664-hash

ghost commented Oct 27, 2026

Copy link
Copy Markdown
Author

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

  • Undefined zipSource / missing type — replaced with a proper type guard isStableRegularFileDescriptor that verifies the exact members revalidateTransferredZipSource + sameRegularFileState read (handle.read, handle.stat, and initial.size|dev|ino|mode|mtimeMs|ctimeMs). Unexpected shapes now throw ArtifactReaderFailure("integrity", …) instead of silently skipping.
  • Cancellation after final close — abortIfNeeded(signal) moved into a finally so it runs for directory, ASAR, and ZIP sources on both the success path and any throw. The finally only re-throws a genuine cancellation; unexpected throws from the pure check do not mask the original error.
  • Duplicate import — removed the unused asarHeaderBytes import in the test file.
  • Tests — isStableRegularFileDescriptor is exported; unit tests import the production symbol (no copy), live assertions, honest it.skip for the integration cases that still need fixtures. File is *.test.ts and matches the adapters project include (src/artifacts/**/*.test.ts).

Verification

Adversary (DeepSeek) verdict: CLEAR on all owned items after eleven rounds.
Proxy vitest run against the production guard: 19 passed | 5 skipped.
Branch config evidence confirms discovery and NodeNext + "type": "module" resolution (.js extension required and restored).

Follow-ups (advisories, not blockers)

  • F5 — ArtifactReaderFailure("integrity", …) for a malformed internal admission conflates an invariant violation with artifact corruption. Confirm against the caller's error taxonomy.
  • N1 — the guard enumerates exactly the fields sameRegularFileState reads today. A Pick type or sync comment would lock the coupling if that function gains fields later.

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.
@chatgpt-codex-connector

ghost commented Oct 27, 2026

Copy link
Copy Markdown

Codex usage limits have been reached for code reviews. Please check with the admins of this repo to increase the limits by adding credits.
Repo admins can enable using credits for code reviews in their settings.

@hannesstrydom664-hash

ghost commented Oct 27, 2026

Copy link
Copy Markdown
Author

Still actively maintaining this. Latest head is 2f987e4.

Working through the five remaining Greptile findings (three P1s first):

  • Preserve published extraction result instead of throwing from finally after files are published.
  • Fully budget dry-run pages, including limitations and oversized-entry diagnostics.
  • Retain cleanup scope around checkDestination so failed probe closes keep an owner.

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.
@chatgpt-codex-connector

ghost commented Oct 27, 2026

Copy link
Copy Markdown

Codex usage limits have been reached for code reviews. Please check with the admins of this repo to increase the limits by adding credits.
Repo admins can enable using credits for code reviews in their settings.

…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.
@chatgpt-codex-connector

ghost commented Oct 27, 2026

Copy link
Copy Markdown

Codex usage limits have been reached for code reviews. Please check with the admins of this repo to increase the limits by adding credits.
Repo admins can enable using credits for code reviews in their settings.

…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
Comment on lines +281 to +287
JSON.stringify([
sourcePath,
absoluteCallerPath(input.selectedPath ?? input.inputPath),
input.inputFormat,
input.platform ?? process.platform,
input.integrityPolicy,
input.asarHeaderAdmission ?? resolveAsarHeaderAdmission(input.environment),

ghost Nov 1, 2026

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

P1 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)

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.

Comment on lines +313 to +324
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,
});

ghost Nov 1, 2026

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

P2 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.

Comment on lines +1312 to +1315
const createDryRunPlan = (
inventory: ArtifactInventorySnapshot,
selected: readonly SelectedOccurrence[],
unresolvedCaseReasons: ReadonlyMap<string, string>,

ghost Nov 1, 2026

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

P2 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)

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!

ghost left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 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".

Comment on lines +281 to +285
JSON.stringify([
sourcePath,
absoluteCallerPath(input.selectedPath ?? input.inputPath),
input.inputFormat,
input.platform ?? process.platform,

ghost Nov 1, 2026

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 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 👍 / 👎.

Comment on lines +344 to +348
const currentStats = await lstat(sourcePath);
abortIfNeeded(signal);
if (
!currentStats.isFile() ||
!sameRegularFileState(cached.sourceFileState, currentStats) ||

ghost Nov 1, 2026

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 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 👍 / 👎.

Comment on lines 1544 to 1547
extraction_manifest: {
...extractionSemantic,
selected_occurrence_ids: returnedSelectedOccurrenceIds,
extraction_id: `aex_${digestCanonicalValue(extractionSemantic, "Artifact")}`,

ghost Nov 1, 2026

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 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 👍 / 👎.

Comment on lines +215 to +218
if (pageBytes + entryBytes > MAX_DRY_RUN_PLAN_PAGE_BYTES) {
if (pagedEntries.length === 0) {
const nextOffset = index + 1 < totalEntries ? index + 1 : null;
return {

ghost Nov 1, 2026

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 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>();

ghost Nov 1, 2026

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 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 👍 / 👎.

@morluto

ghost commented Nov 5, 2026

Copy link
Copy Markdown
Owner

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.

@morluto morluto added area: evidence Evidence, artifacts, and reconstruction enhancement New feature or request labels Nov 23, 2026

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: evidence Evidence, artifacts, and reconstruction enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Feature] Add a dry-run plan for artifact extraction

2 participants