Skip to content

fix: pnpm cache delete removes a package from all metadata cache directories - #12831

Merged
zkochan merged 3 commits into
pnpm:mainfrom
m2na7:fix/cache-delete-all-metadata-dirs
Jul 12, 2026
Merged

zkochan merged 3 commits into
pnpm:mainfrom
m2na7:fix/cache-delete-all-metadata-dirs

Conversation

@m2na7

@m2na7 m2na7 commented Jul 7, 2026 •

Copy link
Copy Markdown
Contributor

Fixes #12753.

The bug

pnpm cache delete <pkg> leaves the package's metadata behind in some cache
directories. Per the issue: a package cached under v11/metadata-full-filtered/
(e.g. @vue/compiler-core.jsonl) is not removed by
pnpm cache delete @vue/compiler-core.

Root cause

cache stores registry metadata under three directories depending on the
resolution mode used when it was fetched — v11/metadata (ABBREVIATED_META_DIR),
v11/metadata-full (FULL_META_DIR), and v11/metadata-full-filtered
(FULL_FILTERED_META_DIR). delete, however, resolves a single cacheDir from
the current mode and clears only that one
(pnpm11/cache/commands/src/cache.cmd.ts):

const cacheType = (opts.resolutionMode === 'time-based' && !opts.registrySupportsTimeField)
  ? FULL_FILTERED_META_DIR
  : ABBREVIATED_META_DIR
const cacheDir = path.join(opts.cacheDir, cacheType)
// ...
case 'delete':
  return cacheDelete({ ...opts, cacheDir, registry: opts.cliOptions['registry'] }, params.slice(1))

So metadata cached under a different mode is never deleted, and FULL_META_DIR
is never selected at all.

The fix

cache delete now runs cacheDelete against all three metadata directories and
returns the de-duplicated union of what it removed. No new dependency:
FULL_META_DIR is already exported from @pnpm/constants.

The change is confined to the delete branch. list / view /
list-registries intentionally stay mode-scoped reads — a package must be
deletable regardless of which mode it was cached under, whereas aggregating the
read commands across directories is a separate behavior change and out of scope
for #12753.

Testing

jest test/cacheDelete.cmd.test.ts (in pnpm11/cache/commands). Two
deterministic tests were added (no registry mock, since the delete path only
globs and unlinks — it never reads file content):

  • one seeds a metadata sentinel for a package in all three directories, runs
    cache delete <pkg>, and asserts it is removed from every one and that the
    returned list is the de-duplicated path;
  • one seeds only metadata-full-filtered (the reporter's case) and asserts the
    package is removed even when the other directories are absent.

The same tests, before and after the fix:

Before (fail — the non-selected directories keep the file):

● cache delete across metadata directories › deletes a package from every metadata cache directory...
  Expected: false
  Received: true
Tests: 2 failed, 1 skipped, 3 total

After (pass):

Tests: 1 skipped, 2 passed, 3 total

Summary by CodeRabbit

  • Bug Fixes

    • pnpm cache delete now removes a package’s cached metadata from all supported metadata cache directory variants, regardless of the active resolution mode.
    • Prevents stale metadata from lingering in alternate cache locations.
    • Consolidates deletion output into a clean, de-duplicated, sorted list.
  • Tests

    • Added unit and CLI integration coverage to verify deletion across abbreviated, full, and full-filtered metadata directories.

@m2na7
m2na7 requested a review from zkochan as a code owner July 7, 2026 03:26
@coderabbitai

coderabbitai Bot commented Jul 7, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: 3a84d0af-2dab-4cb7-a628-7134f9138cab

📥 Commits

Reviewing files that changed from the base of the PR and between eb453cf and 6d695c6.

📒 Files selected for processing (1)
  • pnpm/crates/cli/tests/cache.rs
🚧 Files skipped from review as they are similar to previous changes (1)
  • pnpm/crates/cli/tests/cache.rs

📝 Walkthrough

Walkthrough

cache delete now removes matching package metadata from abbreviated, full, and full-filtered cache directories in both CLI implementations. Tests cover all variants, and a changeset documents the release impact.

Changes

Cache delete multi-directory fix

Layer / File(s) Summary
Delete metadata from all cache directories
pnpm11/cache/commands/src/cache.cmd.ts, pnpm/crates/cli/src/cli_args/cache.rs
Both implementations search all three metadata directory variants, aggregate deleted paths, and sort and deduplicate the output.
Tests and release declaration
pnpm11/cache/commands/test/cacheDelete.cmd.test.ts, pnpm/crates/cli/tests/cache.rs, .changeset/cache-delete-all-metadata-dirs.md
Tests verify removal across metadata layouts, including a full-filtered-only case, and the changeset declares patch releases with the updated behavior.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Sequence Diagram(s)

sequenceDiagram
  participant User
  participant CacheDelete
  participant MetadataCache
  User->>CacheDelete: delete package metadata
  CacheDelete->>MetadataCache: search abbreviated, full, and full-filtered directories
  MetadataCache-->>CacheDelete: matching deleted paths
  CacheDelete-->>User: sorted, deduplicated paths
Loading

Assessment against linked issues

Objective Addressed Explanation
Delete the package’s metadata from metadata-full-filtered and other v11 metadata directories [#12753] ✅
Remove corresponding entries from index.db [#12753] ❌ The changed code deletes metadata files only; no SQLite index update is shown.
Refresh stale metadata automatically or provide a cache-bypass option [#12753] ❌ No resolution refresh mechanism or --force/--no-cache option is added.

Possibly related PRs

  • pnpm/pnpm#12553: Modifies cache deletion across multiple metadata directory variants with corresponding CLI tests.

Suggested labels: product: pnpm@11, product: pacquet

Suggested reviewers: zkochan

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@qodo-free-for-open-source-projects

qodo-free-for-open-source-projects Bot commented Jul 7, 2026 •

Copy link
Copy Markdown

PR Summary by Qodo

Fix pnpm cache delete to purge package metadata across all cache modes

🐞 Bug fix 🧪 Tests 📝 Documentation 🕐 10-20 Minutes

Grey Divider

AI Description

• Delete package metadata from metadata, metadata-full, and metadata-full-filtered
 directories.
• De-duplicate and sort delete output across directories for stable CLI results.
• Add deterministic tests to prevent metadata leftovers across resolution modes.
Diagram

graph TD
  U((User)) --> H["cache.cmd.ts handler"] --> D["cacheDelete (x3 dirs)"] --> F["findMetadataFiles (glob)"] --> FS[("Metadata cache")]

  subgraph Legend
    direction LR
    _u((User)) ~~~ _p["Command/logic"] ~~~ _db[(Filesystem cache)]
  end
Loading
High-Level Assessment

The following are alternative approaches to this PR:

1. Move multi-dir delete into @pnpm/cache.api
  • ➕ Keeps command handler thin; centralizes multi-dir behavior for any future callers
  • ➕ Enables shared de-dup/sort logic and reduces risk of divergent implementations
  • ➖ Changes API surface/semantics (needs new option or wrapper)
  • ➖ Slightly larger refactor for a targeted CLI bug fix
2. Unify metadata storage into a single directory (migration)
  • ➕ Eliminates cross-mode cleanup issues entirely
  • ➕ Simplifies mental model for cache read/write/delete operations
  • ➖ Requires migration strategy and backward-compat handling
  • ➖ Higher risk; broader scope than the reported bug

Recommendation: The current approach (CLI delete iterates all known metadata dirs and de-dups results) is the right scope for fixing #12753 with minimal behavioral change to read commands. If this pattern is needed elsewhere later, consider a follow-up to encapsulate the multi-directory delete in @pnpm/cache.api to avoid duplicating the same logic.

Files changed (3) +66 / -7

Bug fix (1) +15 / -7
cache.cmd.tsRun cacheDelete against all metadata cache directories +15/-7

Run cacheDelete against all metadata cache directories

• Extends 'cache delete' to execute 'cacheDelete' for 'metadata', 'metadata-full', and 'metadata-full-filtered' directories instead of only the current-mode directory. Aggregates results by splitting, de-duplicating, sorting, and re-joining into stable newline output.

pnpm11/cache/commands/src/cache.cmd.ts

Tests (1) +45 / -0
cacheDelete.cmd.test.tsAdd tests for deleting across metadata directories +45/-0

Add tests for deleting across metadata directories

• Adds deterministic tests that seed sentinel metadata files across all metadata directories (and the filtered-only case) and assert deletion removes them regardless of current resolution mode. Verifies returned output is de-duplicated when the same package exists in multiple directories.

pnpm11/cache/commands/test/cacheDelete.cmd.test.ts

Documentation (1) +6 / -0
cache-delete-all-metadata-dirs.mdAdd changeset for cache-delete cross-directory cleanup +6/-0

Add changeset for cache-delete cross-directory cleanup

• Adds a patch changeset for both '@pnpm/cache.commands' and 'pnpm'. Documents that 'pnpm cache delete' now removes package metadata from all metadata cache directories and closes #12753.

.changeset/cache-delete-all-metadata-dirs.md

ⓘ You are approaching your monthly quota for Qodo. Upgrade your plan

@qodo-free-for-open-source-projects

qodo-free-for-open-source-projects Bot commented Jul 7, 2026 •

Copy link
Copy Markdown

Code Review by Qodo

🐞 Bugs (5) 📘 Rule violations (1) 📜 Skill insights (0)

Grey Divider


Action required

1. Pacquet cache delete unsynced 📘 Rule violation ⌂ Architecture
Description
pnpm cache delete now deletes metadata across metadata, metadata-full, and
metadata-full-filtered, but pacquet's cache delete still only targets a single mode-derived
metadata directory. This creates a user-visible divergence between pnpm (TypeScript) and pacquet
(Rust) with no explicit call-out in the PR description.
Code

pnpm11/cache/commands/src/cache.cmd.ts[R81-94]

+    case 'delete': {
+      // A package's metadata can be cached under any of the metadata directories
+      // depending on the resolution mode used when it was fetched.
+      const deleted = await Promise.all(
+        [ABBREVIATED_META_DIR, FULL_META_DIR, FULL_FILTERED_META_DIR].map((metaDir) =>
+          cacheDelete({
+            ...opts,
+            cacheDir: path.join(opts.cacheDir, metaDir),
+            registry: opts.cliOptions['registry'],
+          }, params.slice(1))
+        )
+      )
+      return [...new Set(deleted.flatMap((result) => result.split('\n')).filter(Boolean))].sort().join('\n')
+    }
Evidence
The pnpm handler now runs cacheDelete across `[ABBREVIATED_META_DIR, FULL_META_DIR,
FULL_FILTERED_META_DIR]` and unions the results, making deletion behavior broader and user-visible.
Pacquet still computes a single metadata directory via meta_dir()/cache_dir() and performs
deletions only under that one directory, so behavior is no longer aligned between implementations.

Rule 713428: Keep pnpm TypeScript and pacquet Rust user-visible behavior changes in sync
pnpm11/cache/commands/src/cache.cmd.ts[81-94]
pacquet/crates/cli/src/cli_args/cache.rs[28-41]
pacquet/crates/cli/src/cli_args/cache.rs[130-141]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
This PR changes pnpm's `cache delete` to remove package metadata from all metadata cache directories, but pacquet's `cache delete` still resolves a single `cache_dir` from the current resolution mode and deletes only within that directory.
## Issue Context
Compliance requires pnpm TypeScript and pacquet Rust user-visible behavior to stay in sync, or for the PR description to explicitly call out any known divergence and follow-up work.
## Fix Focus Areas
- pnpm11/cache/commands/src/cache.cmd.ts[81-94]
- pacquet/crates/cli/src/cli_args/cache.rs[28-41]
- pacquet/crates/cli/src/cli_args/cache.rs[130-141]
- .changeset/cache-delete-all-metadata-dirs.md[1-6]

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools



Remediation recommended

2. Missing delete path containment 🐞 Bug ⛨ Security
Description
cache delete passes user-provided filters into glob patterns and then deletes `path.join(cacheDir,
metaFile)` without verifying the resolved path stays within the intended metadata cache root.
Because this PR runs the same delete flow against three cache roots, any glob result containing
traversal segments (or otherwise escaping cwd) would widen the scope of unintended deletions.
Code

pnpm11/cache/commands/src/cache.cmd.ts[R84-90]

+      const deleted = await Promise.all(
+        [ABBREVIATED_META_DIR, FULL_META_DIR, FULL_FILTERED_META_DIR].map((metaDir) =>
+          cacheDelete({
+            ...opts,
+            cacheDir: path.join(opts.cacheDir, metaDir),
+            registry: opts.cliOptions['registry'],
+          }, params.slice(1))
Evidence
The filter is interpolated directly into glob patterns, and the returned metaFile strings are
joined to cacheDir and unlinked without any containment check; the PR now executes this deletion
logic for all three metadata cache roots.

pnpm11/cache/commands/src/cache.cmd.ts[81-94]
pnpm11/cache/api/src/cacheList.ts[15-22]
pnpm11/cache/api/src/cacheDelete.ts[6-12]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
`cacheDelete()` deletes each matched entry via `fs.unlinkSync(path.join(opts.cacheDir, metaFile))` but does not enforce that the resolved path is still inside `opts.cacheDir`. Since `findMetadataFiles()` builds glob patterns from user-supplied filters, a crafted filter (or unexpected glob behavior) could yield paths that escape the cache root.
### Issue Context
This PR invokes `cacheDelete()` for three metadata directories, so any containment weakness now gets applied across multiple roots.
### Fix Focus Areas
- pnpm11/cache/api/src/cacheDelete.ts[6-12]
- pnpm11/cache/api/src/cacheList.ts[15-22]
- pnpm11/cache/commands/src/cache.cmd.ts[81-94]
### Suggested fix
1. In `cacheDelete()`, compute `const base = path.resolve(opts.cacheDir) + path.sep`.
2. For each `metaFile`, compute `const target = path.resolve(opts.cacheDir, metaFile)` and **skip or throw** if `!target.startsWith(base)`.
3. Optionally, add a lightweight input guard in `findMetadataFiles()` to reject filters containing `..` path segments or backslashes, while still allowing valid package patterns (scoped names include `/`).

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


3. Fail-fast multi-dir delete 🐞 Bug ☼ Reliability
Description
cache delete now runs three cacheDelete(...) calls under Promise.all, so any error from
scanning/unlinking in *any* metadata directory fails the whole command even if other directories
were successfully cleaned. Because cacheDelete uses synchronous unlinkSync without error
handling, this can leave users with a partial deletion state and an overall failure that's harder to
recover from.
Code

pnpm11/cache/commands/src/cache.cmd.ts[R81-94]

+    case 'delete': {
+      // A package's metadata can be cached under any of the metadata directories
+      // depending on the resolution mode used when it was fetched.
+      const deleted = await Promise.all(
+        [ABBREVIATED_META_DIR, FULL_META_DIR, FULL_FILTERED_META_DIR].map((metaDir) =>
+          cacheDelete({
+            ...opts,
+            cacheDir: path.join(opts.cacheDir, metaDir),
+            registry: opts.cliOptions['registry'],
+          }, params.slice(1))
+        )
+      )
+      return [...new Set(deleted.flatMap((result) => result.split('\n')).filter(Boolean))].sort().join('\n')
+    }
Evidence
The handler uses Promise.all across the three metadata directories, so any thrown error from one
delete rejects the entire command. cacheDelete performs synchronous unlinkSync calls without
handling exceptions, so permission/IO issues will throw and can occur after earlier directories
already removed files, creating partial cleanup + overall failure.

pnpm11/cache/commands/src/cache.cmd.ts[81-94]
pnpm11/cache/api/src/cacheDelete.ts[6-11]
pnpm11/cache/api/src/cacheList.ts[15-22]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
`pnpm cache delete` now deletes across three metadata directories using `Promise.all(...)`. `Promise.all` is fail-fast: if one directory scan/unlink throws (e.g. EACCES on a directory/file), the entire command rejects even if other directories already deleted files. Since `cacheDelete` uses `fs.unlinkSync` with no try/catch, this can produce partial cleanup + a hard failure with no clear accounting of what was removed.
## Issue Context
- The PR intentionally expands deletion scope to include `metadata`, `metadata-full`, and `metadata-full-filtered`.
- In real systems, cache directories can end up with mixed ownership/permissions (e.g. previous runs under different user/root, locked files, antivirus interference), so per-directory failures are plausible.
## Fix Focus Areas
- pnpm11/cache/commands/src/cache.cmd.ts[81-94]
- pnpm11/cache/api/src/cacheDelete.ts[6-11]
## Suggested fix
- Replace `Promise.all(...)` with either:
- a sequential `for ... of` loop that attempts all directories and collects results; or
- `Promise.allSettled(...)` and then merges only fulfilled results.
- If any directory fails, still attempt the others, then throw a single error that includes which directory failed and why (so the user can fix permissions and retry), while preserving the deletions that already succeeded.
- Keep the existing de-dupe/union output behavior for the successful directories.

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


4. Delete with no args purges 🐞 Bug ☼ Reliability
Description
cache delete does not validate that a package/pattern was provided, so an empty invocation expands
to a broad glob and deletes all metadata entries. With this PR it now purges across metadata,
metadata-full, and metadata-full-filtered, increasing the blast radius of an argument-omission
typo.
Code

pnpm11/cache/commands/src/cache.cmd.ts[R81-94]

+    case 'delete': {
+      // A package's metadata can be cached under any of the metadata directories
+      // depending on the resolution mode used when it was fetched.
+      const deleted = await Promise.all(
+        [ABBREVIATED_META_DIR, FULL_META_DIR, FULL_FILTERED_META_DIR].map((metaDir) =>
+          cacheDelete({
+            ...opts,
+            cacheDir: path.join(opts.cacheDir, metaDir),
+            registry: opts.cliOptions['registry'],
+          }, params.slice(1))
+        )
+      )
+      return [...new Set(deleted.flatMap((result) => result.split('\n')).filter(Boolean))].sort().join('\n')
+    }
Evidence
The handler’s delete branch passes params.slice(1) directly into cacheDelete() for all three
metadata directories. In the cache API, an empty filter becomes the ${prefix}/** glob, and
cacheDelete() unlinks every matched file, so pnpm cache delete (no args) becomes a full metadata
purge across all three directories after this change.

pnpm11/cache/commands/src/cache.cmd.ts[64-116]
pnpm11/cache/api/src/cacheList.ts[15-22]
pnpm11/cache/api/src/cacheDelete.ts[6-12]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
`pnpm cache delete` currently accepts an empty package/pattern list. Because the cache API treats an empty filter as “match everything”, this can unintentionally delete the entire metadata cache. After this PR, the command fans out across three metadata directories, increasing the scope of accidental deletion.
### Issue Context
- `cache.cmd.ts` calls `cacheDelete(..., params.slice(1))` without checking `params[1]`.
- `findMetadataFiles()` turns an empty `filter` into a `${prefix}/**` glob, and `cacheDelete()` unlinks all matches.
### Fix Focus Areas
- pnpm11/cache/commands/src/cache.cmd.ts[64-116]
- pnpm11/cache/api/src/cacheList.ts[15-22]
### Suggested fix
Add an explicit guard in the `delete` case (similar to the `view` case):
- If `!params[1]`, throw `new PnpmError('MISSING_PACKAGE_NAME', '`pnpm cache delete` requires the package name or pattern')`.
This still allows deleting everything explicitly via `pnpm cache delete "*"` while preventing accidental full metadata purges.

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


View more (1)
5. Promise.all aborts deletes 🐞 Bug ☼ Reliability
Description
cache delete now runs cacheDelete against three metadata directories using Promise.all, so any
single rejection (e.g., a transient unlinkSync failure) aborts the whole command even if other
directories already deleted files. This can leave the cache partially modified while returning an
error and no complete deleted list to the caller.
Code

pnpm11/cache/commands/src/cache.cmd.ts[R84-93]

+      const deleted = await Promise.all(
+        [ABBREVIATED_META_DIR, FULL_META_DIR, FULL_FILTERED_META_DIR].map((metaDir) =>
+          cacheDelete({
+            ...opts,
+            cacheDir: path.join(opts.cacheDir, metaDir),
+            registry: opts.cliOptions['registry'],
+          }, params.slice(1))
+        )
+      )
+      return [...new Set(deleted.flatMap((result) => result.split('\n')).filter(Boolean))].sort().join('\n')
Evidence
The new delete branch fans out deletions with Promise.all, which fails-fast on any rejection;
cacheDelete uses synchronous unlink operations that can throw, making partial deletion + command
failure plausible.

pnpm11/cache/commands/src/cache.cmd.ts[81-94]
pnpm11/cache/api/src/cacheDelete.ts[6-12]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
`pnpm cache delete` now calls `cacheDelete()` for three metadata dirs via `Promise.all(...)`. If any call throws, the entire command rejects even if deletions in other dirs already happened, creating a partial-success failure mode.
## Issue Context
`cacheDelete()` performs filesystem operations (glob + `fs.unlinkSync`) and can throw on common race/FS conditions (e.g. `ENOENT` if a file disappears between glob and unlink, permissions issues, or directory corruption). With fan-out, the probability of any single failure increases and now fails the whole command.
## Fix Focus Areas
- pnpm11/cache/commands/src/cache.cmd.ts[81-94]
## Suggested fix
- Replace `Promise.all` with `Promise.allSettled` (or sequential deletes) and:
- Aggregate successful deletions into the returned de-duplicated list.
- Decide error policy explicitly:
- Ignore/continue on expected transient errors (commonly `ENOENT`) to avoid failing after partial work.
- For other errors, either (a) rethrow after collecting successes with a clearer error message indicating which metadata dir failed, or (b) include failures in output/logging while returning non-zero exit code upstream (depending on CLI conventions).

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools



Informational

6. Redundant delete result sorting 🐞 Bug ➹ Performance
Description
The new multi-directory delete path de-duplicates and sorts results after each cacheDelete()
already sorts its own output, causing extra allocations (string split + Set) and redundant sorting
work. This is low-impact but avoidable overhead when deleting many entries.
Code

pnpm11/cache/commands/src/cache.cmd.ts[R84-93]

+      const deleted = await Promise.all(
+        [ABBREVIATED_META_DIR, FULL_META_DIR, FULL_FILTERED_META_DIR].map((metaDir) =>
+          cacheDelete({
+            ...opts,
+            cacheDir: path.join(opts.cacheDir, metaDir),
+            registry: opts.cliOptions['registry'],
+          }, params.slice(1))
+        )
+      )
+      return [...new Set(deleted.flatMap((result) => result.split('\n')).filter(Boolean))].sort().join('\n')
Evidence
cacheDelete() already sorts its results, and the handler sorts again after splitting/de-duping,
which is redundant work introduced by the new multi-directory aggregation.

pnpm11/cache/api/src/cacheDelete.ts[6-12]
pnpm11/cache/commands/src/cache.cmd.ts[81-94]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
`cacheDelete()` sorts `metaFiles` and joins them into a newline-delimited string, but the command handler then splits those strings, de-dups, and sorts again. This duplicates work and creates intermediate arrays/strings.
### Issue Context
This PR calls `cacheDelete()` three times (one per metadata directory), so the redundancy scales with the number of cache roots.
### Fix Focus Areas
- pnpm11/cache/commands/src/cache.cmd.ts[84-93]
- pnpm11/cache/api/src/cacheDelete.ts[6-12]
### Suggested fix options
- Preferred (API-safe): add a new internal helper in `@pnpm/cache.api` that returns `string[]` (unsorted), use it from the command, and keep the existing `cacheDelete()` behavior for compatibility.
- Minimal: remove the inner `metaFiles.sort()` in `cacheDelete()` and rely on the final sort in `cache.cmd.ts` (only if `cacheDelete()` has no external consumers relying on sorted output).

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


Grey Divider

Previous review results

Review updated until commit 777b254

Results up to commit 777b254


🐞 Bugs (5) 📘 Rule violations (1) 📜 Skill insights (0)


Action required
1. Pacquet cache delete unsynced 📘 Rule violation ⌂ Architecture
Description
pnpm cache delete now deletes metadata across metadata, metadata-full, and
metadata-full-filtered, but pacquet's cache delete still only targets a single mode-derived
metadata directory. This creates a user-visible divergence between pnpm (TypeScript) and pacquet
(Rust) with no explicit call-out in the PR description.
Code

pnpm11/cache/commands/src/cache.cmd.ts[R81-94]

+    case 'delete': {
+      // A package's metadata can be cached under any of the metadata directories
+      // depending on the resolution mode used when it was fetched.
+      const deleted = await Promise.all(
+        [ABBREVIATED_META_DIR, FULL_META_DIR, FULL_FILTERED_META_DIR].map((metaDir) =>
+          cacheDelete({
+            ...opts,
+            cacheDir: path.join(opts.cacheDir, metaDir),
+            registry: opts.cliOptions['registry'],
+          }, params.slice(1))
+        )
+      )
+      return [...new Set(deleted.flatMap((result) => result.split('\n')).filter(Boolean))].sort().join('\n')
+    }
Evidence
The pnpm handler now runs cacheDelete across `[ABBREVIATED_META_DIR, FULL_META_DIR,
FULL_FILTERED_META_DIR]` and unions the results, making deletion behavior broader and user-visible.
Pacquet still computes a single metadata directory via meta_dir()/cache_dir() and performs
deletions only under that one directory, so behavior is no longer aligned between implementations.

Rule 713428: Keep pnpm TypeScript and pacquet Rust user-visible behavior changes in sync
pnpm11/cache/commands/src/cache.cmd.ts[81-94]
pacquet/crates/cli/src/cli_args/cache.rs[28-41]
pacquet/crates/cli/src/cli_args/cache.rs[130-141]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
This PR changes pnpm's `cache delete` to remove package metadata from all metadata cache directories, but pacquet's `cache delete` still resolves a single `cache_dir` from the current resolution mode and deletes only within that directory.
## Issue Context
Compliance requires pnpm TypeScript and pacquet Rust user-visible behavior to stay in sync, or for the PR description to explicitly call out any known divergence and follow-up work.
## Fix Focus Areas
- pnpm11/cache/commands/src/cache.cmd.ts[81-94]
- pacquet/crates/cli/src/cli_args/cache.rs[28-41]
- pacquet/crates/cli/src/cli_args/cache.rs[130-141]
- .changeset/cache-delete-all-metadata-dirs.md[1-6]

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools



Remediation recommended
2. Missing delete path containment 🐞 Bug ⛨ Security
Description
cache delete passes user-provided filters into glob patterns and then deletes `path.join(cacheDir,
metaFile)` without verifying the resolved path stays within the intended metadata cache root.
Because this PR runs the same delete flow against three cache roots, any glob result containing
traversal segments (or otherwise escaping cwd) would widen the scope of unintended deletions.
Code

pnpm11/cache/commands/src/cache.cmd.ts[R84-90]

+      const deleted = await Promise.all(
+        [ABBREVIATED_META_DIR, FULL_META_DIR, FULL_FILTERED_META_DIR].map((metaDir) =>
+          cacheDelete({
+            ...opts,
+            cacheDir: path.join(opts.cacheDir, metaDir),
+            registry: opts.cliOptions['registry'],
+          }, params.slice(1))
Evidence
The filter is interpolated directly into glob patterns, and the returned metaFile strings are
joined to cacheDir and unlinked without any containment check; the PR now executes this deletion
logic for all three metadata cache roots.

pnpm11/cache/commands/src/cache.cmd.ts[81-94]
pnpm11/cache/api/src/cacheList.ts[15-22]
pnpm11/cache/api/src/cacheDelete.ts[6-12]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
`cacheDelete()` deletes each matched entry via `fs.unlinkSync(path.join(opts.cacheDir, metaFile))` but does not enforce that the resolved path is still inside `opts.cacheDir`. Since `findMetadataFiles()` builds glob patterns from user-supplied filters, a crafted filter (or unexpected glob behavior) could yield paths that escape the cache root.
### Issue Context
This PR invokes `cacheDelete()` for three metadata directories, so any containment weakness now gets applied across multiple roots.
### Fix Focus Areas
- pnpm11/cache/api/src/cacheDelete.ts[6-12]
- pnpm11/cache/api/src/cacheList.ts[15-22]
- pnpm11/cache/commands/src/cache.cmd.ts[81-94]
### Suggested fix
1. In `cacheDelete()`, compute `const base = path.resolve(opts.cacheDir) + path.sep`.
2. For each `metaFile`, compute `const target = path.resolve(opts.cacheDir, metaFile)` and **skip or throw** if `!target.startsWith(base)`.
3. Optionally, add a lightweight input guard in `findMetadataFiles()` to reject filters containing `..` path segments or backslashes, while still allowing valid package patterns (scoped names include `/`).

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


3. Fail-fast multi-dir delete 🐞 Bug ☼ Reliability
Description
cache delete now runs three cacheDelete(...) calls under Promise.all, so any error from
scanning/unlinking in *any* metadata directory fails the whole command even if other directories
were successfully cleaned. Because cacheDelete uses synchronous unlinkSync without error
handling, this can leave users with a partial deletion state and an overall failure that's harder to
recover from.
Code

pnpm11/cache/commands/src/cache.cmd.ts[R81-94]

+    case 'delete': {
+      // A package's metadata can be cached under any of the metadata directories
+      // depending on the resolution mode used when it was fetched.
+      const deleted = await Promise.all(
+        [ABBREVIATED_META_DIR, FULL_META_DIR, FULL_FILTERED_META_DIR].map((metaDir) =>
+          cacheDelete({
+            ...opts,
+            cacheDir: path.join(opts.cacheDir, metaDir),
+            registry: opts.cliOptions['registry'],
+          }, params.slice(1))
+        )
+      )
+      return [...new Set(deleted.flatMap((result) => result.split('\n')).filter(Boolean))].sort().join('\n')
+    }
Evidence
The handler uses Promise.all across the three metadata directories, so any thrown error from one
delete rejects the entire command. cacheDelete performs synchronous unlinkSync calls without
handling exceptions, so permission/IO issues will throw and can occur after earlier directories
already removed files, creating partial cleanup + overall failure.

pnpm11/cache/commands/src/cache.cmd.ts[81-94]
pnpm11/cache/api/src/cacheDelete.ts[6-11]
pnpm11/cache/api/src/cacheList.ts[15-22]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
`pnpm cache delete` now deletes across three metadata directories using `Promise.all(...)`. `Promise.all` is fail-fast: if one directory scan/unlink throws (e.g. EACCES on a directory/file), the entire command rejects even if other directories already deleted files. Since `cacheDelete` uses `fs.unlinkSync` with no try/catch, this can produce partial cleanup + a hard failure with no clear accounting of what was removed.
## Issue Context
- The PR intentionally expands deletion scope to include `metadata`, `metadata-full`, and `metadata-full-filtered`.
- In real systems, cache directories can end up with mixed ownership/permissions (e.g. previous runs under different user/root, locked files, antivirus interference), so per-directory failures are plausible.
## Fix Focus Areas
- pnpm11/cache/commands/src/cache.cmd.ts[81-94]
- pnpm11/cache/api/src/cacheDelete.ts[6-11]
## Suggested fix
- Replace `Promise.all(...)` with either:
- a sequential `for ... of` loop that attempts all directories and collects results; or
- `Promise.allSettled(...)` and then merges only fulfilled results.
- If any directory fails, still attempt the others, then throw a single error that includes which directory failed and why (so the user can fix permissions and retry), while preserving the deletions that already succeeded.
- Keep the existing de-dupe/union output behavior for the successful directories.

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


4. Delete with no args purges 🐞 Bug ☼ Reliability
Description
cache delete does not validate that a package/pattern was provided, so an empty invocation expands
to a broad glob and deletes all metadata entries. With this PR it now purges across metadata,
metadata-full, and metadata-full-filtered, increasing the blast radius of an argument-omission
typo.
Code

pnpm11/cache/commands/src/cache.cmd.ts[R81-94]

+    case 'delete': {
+      // A package's metadata can be cached under any of the metadata directories
+      // depending on the resolution mode used when it was fetched.
+      const deleted = await Promise.all(
+        [ABBREVIATED_META_DIR, FULL_META_DIR, FULL_FILTERED_META_DIR].map((metaDir) =>
+          cacheDelete({
+            ...opts,
+            cacheDir: path.join(opts.cacheDir, metaDir),
+            registry: opts.cliOptions['registry'],
+          }, params.slice(1))
+        )
+      )
+      return [...new Set(deleted.flatMap((result) => result.split('\n')).filter(Boolean))].sort().join('\n')
+    }
Evidence
The handler’s delete branch passes params.slice(1) directly into cacheDelete() for all three
metadata directories. In the cache API, an empty filter becomes the ${prefix}/** glob, and
cacheDelete() unlinks every matched file, so pnpm cache delete (no args) becomes a full metadata
purge across all three directories after this change.

pnpm11/cache/commands/src/cache.cmd.ts[64-116]
pnpm11/cache/api/src/cacheList.ts[15-22]
pnpm11/cache/api/src/cacheDelete.ts[6-12]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
`pnpm cache delete` currently accepts an empty package/pattern list. Because the cache API treats an empty filter as “match everything”, this can unintentionally delete the entire metadata cache. After this PR, the command fans out across three metadata directories, increasing the scope of accidental deletion.
### Issue Context
- `cache.cmd.ts` calls `cacheDelete(..., params.slice(1))` without checking `params[1]`.
- `findMetadataFiles()` turns an empty `filter` into a `${prefix}/**` glob, and `cacheDelete()` unlinks all matches.
### Fix Focus Areas
- pnpm11/cache/commands/src/cache.cmd.ts[64-116]
- pnpm11/cache/api/src/cacheList.ts[15-22]
### Suggested fix
Add an explicit guard in the `delete` case (similar to the `view` case):
- If `!params[1]`, throw `new PnpmError('MISSING_PACKAGE_NAME', '`pnpm cache delete` requires the package name or pattern')`.
This still allows deleting everything explicitly via `pnpm cache delete "*"` while preventing accidental full metadata purges.

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


View more (1)
5. Promise.all aborts deletes 🐞 Bug ☼ Reliability
Description
cache delete now runs cacheDelete against three metadata directories using Promise.all, so any
single rejection (e.g., a transient unlinkSync failure) aborts the whole command even if other
directories already deleted files. This can leave the cache partially modified while returning an
error and no complete deleted list to the caller.
Code

pnpm11/cache/commands/src/cache.cmd.ts[R84-93]

+      const deleted = await Promise.all(
+        [ABBREVIATED_META_DIR, FULL_META_DIR, FULL_FILTERED_META_DIR].map((metaDir) =>
+          cacheDelete({
+            ...opts,
+            cacheDir: path.join(opts.cacheDir, metaDir),
+            registry: opts.cliOptions['registry'],
+          }, params.slice(1))
+        )
+      )
+      return [...new Set(deleted.flatMap((result) => result.split('\n')).filter(Boolean))].sort().join('\n')
Evidence
The new delete branch fans out deletions with Promise.all, which fails-fast on any rejection;
cacheDelete uses synchronous unlink operations that can throw, making partial deletion + command
failure plausible.

pnpm11/cache/commands/src/cache.cmd.ts[81-94]
pnpm11/cache/api/src/cacheDelete.ts[6-12]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
`pnpm cache delete` now calls `cacheDelete()` for three metadata dirs via `Promise.all(...)`. If any call throws, the entire command rejects even if deletions in other dirs already happened, creating a partial-success failure mode.
## Issue Context
`cacheDelete()` performs filesystem operations (glob + `fs.unlinkSync`) and can throw on common race/FS conditions (e.g. `ENOENT` if a file disappears between glob and unlink, permissions issues, or directory corruption). With fan-out, the probability of any single failure increases and now fails the whole command.
## Fix Focus Areas
- pnpm11/cache/commands/src/cache.cmd.ts[81-94]
## Suggested fix
- Replace `Promise.all` with `Promise.allSettled` (or sequential deletes) and:
- Aggregate successful deletions into the returned de-duplicated list.
- Decide error policy explicitly:
- Ignore/continue on expected transient errors (commonly `ENOENT`) to avoid failing after partial work.
- For other errors, either (a) rethrow after collecting successes with a clearer error message indicating which metadata dir failed, or (b) include failures in output/logging while returning non-zero exit code upstream (depending on CLI conventions).

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools



Informational
6. Redundant delete result sorting 🐞 Bug ➹ Performance
Description
The new multi-directory delete path de-duplicates and sorts results after each cacheDelete()
already sorts its own output, causing extra allocations (string split + Set) and redundant sorting
work. This is low-impact but avoidable overhead when deleting many entries.
Code

pnpm11/cache/commands/src/cache.cmd.ts[R84-93]

+      const deleted = await Promise.all(
+        [ABBREVIATED_META_DIR, FULL_META_DIR, FULL_FILTERED_META_DIR].map((metaDir) =>
+          cacheDelete({
+            ...opts,
+            cacheDir: path.join(opts.cacheDir, metaDir),
+            registry: opts.cliOptions['registry'],
+          }, params.slice(1))
+        )
+      )
+      return [...new Set(deleted.flatMap((result) => result.split('\n')).filter(Boolean))].sort().join('\n')
Evidence
cacheDelete() already sorts its results, and the handler sorts again after splitting/de-duping,
which is redundant work introduced by the new multi-directory aggregation.

pnpm11/cache/api/src/cacheDelete.ts[6-12]
pnpm11/cache/commands/src/cache.cmd.ts[81-94]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
`cacheDelete()` sorts `metaFiles` and joins them into a newline-delimited string, but the command handler then splits those strings, de-dups, and sorts again. This duplicates work and creates intermediate arrays/strings.
### Issue Context
This PR calls `cacheDelete()` three times (one per metadata directory), so the redundancy scales with the number of cache roots.
### Fix Focus Areas
- pnpm11/cache/commands/src/cache.cmd.ts[84-93]
- pnpm11/cache/api/src/cacheDelete.ts[6-12]
### Suggested fix options
- Preferred (API-safe): add a new internal helper in `@pnpm/cache.api` that returns `string[]` (unsorted), use it from the command, and keep the existing `cacheDelete()` behavior for compatibility.
- Minimal: remove the inner `metaFiles.sort()` in `cacheDelete()` and rely on the final sort in `cache.cmd.ts` (only if `cacheDelete()` has no external consumers relying on sorted output).

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


Qodo Logo

@qodo-free-for-open-source-projects

qodo-free-for-open-source-projects Bot commented Jul 7, 2026 •

Copy link
Copy Markdown

Code Review by Qodo

Grey Divider

New Review Started

This review has been superseded by a new analysis

Grey Divider

Qodo Logo

@qodo-code-review

qodo-code-review Bot commented Jul 7, 2026 •

Copy link
Copy Markdown

Code Review by Qodo

🐞 Bugs (2) 📘 Rule violations (1) 📜 Skill insights (0)

Context used
✅ Compliance rules (platform): 18 rules

Grey Divider


Action required

1. Pacquet cache delete unsynced 📘 Rule violation ⌂ Architecture
Description
pnpm cache delete now deletes metadata across metadata, metadata-full, and
metadata-full-filtered, but pacquet's cache delete still only targets a single mode-derived
metadata directory. This creates a user-visible divergence between pnpm (TypeScript) and pacquet
(Rust) with no explicit call-out in the PR description.
Code

pnpm11/cache/commands/src/cache.cmd.ts[R81-94]

+    case 'delete': {
+      // A package's metadata can be cached under any of the metadata directories
+      // depending on the resolution mode used when it was fetched.
+      const deleted = await Promise.all(
+        [ABBREVIATED_META_DIR, FULL_META_DIR, FULL_FILTERED_META_DIR].map((metaDir) =>
+          cacheDelete({
+            ...opts,
+            cacheDir: path.join(opts.cacheDir, metaDir),
+            registry: opts.cliOptions['registry'],
+          }, params.slice(1))
+        )
+      )
+      return [...new Set(deleted.flatMap((result) => result.split('\n')).filter(Boolean))].sort().join('\n')
+    }
Evidence
The pnpm handler now runs cacheDelete across `[ABBREVIATED_META_DIR, FULL_META_DIR,
FULL_FILTERED_META_DIR]` and unions the results, making deletion behavior broader and user-visible.
Pacquet still computes a single metadata directory via meta_dir()/cache_dir() and performs
deletions only under that one directory, so behavior is no longer aligned between implementations.

Rule 713428: Keep pnpm TypeScript and pacquet Rust user-visible behavior changes in sync
pnpm11/cache/commands/src/cache.cmd.ts[81-94]
pacquet/crates/cli/src/cli_args/cache.rs[28-41]
pacquet/crates/cli/src/cli_args/cache.rs[130-141]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
This PR changes pnpm's `cache delete` to remove package metadata from all metadata cache directories, but pacquet's `cache delete` still resolves a single `cache_dir` from the current resolution mode and deletes only within that directory.

## Issue Context
Compliance requires pnpm TypeScript and pacquet Rust user-visible behavior to stay in sync, or for the PR description to explicitly call out any known divergence and follow-up work.

## Fix Focus Areas
- pnpm11/cache/commands/src/cache.cmd.ts[81-94]
- pacquet/crates/cli/src/cli_args/cache.rs[28-41]
- pacquet/crates/cli/src/cli_args/cache.rs[130-141]
- .changeset/cache-delete-all-metadata-dirs.md[1-6]

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools



Remediation recommended

2. Delete with no args purges 🐞 Bug ☼ Reliability
Description
cache delete does not validate that a package/pattern was provided, so an empty invocation expands
to a broad glob and deletes all metadata entries. With this PR it now purges across metadata,
metadata-full, and metadata-full-filtered, increasing the blast radius of an argument-omission
typo.
Code

pnpm11/cache/commands/src/cache.cmd.ts[R81-94]

+    case 'delete': {
+      // A package's metadata can be cached under any of the metadata directories
+      // depending on the resolution mode used when it was fetched.
+      const deleted = await Promise.all(
+        [ABBREVIATED_META_DIR, FULL_META_DIR, FULL_FILTERED_META_DIR].map((metaDir) =>
+          cacheDelete({
+            ...opts,
+            cacheDir: path.join(opts.cacheDir, metaDir),
+            registry: opts.cliOptions['registry'],
+          }, params.slice(1))
+        )
+      )
+      return [...new Set(deleted.flatMap((result) => result.split('\n')).filter(Boolean))].sort().join('\n')
+    }
Evidence
The handler’s delete branch passes params.slice(1) directly into cacheDelete() for all three
metadata directories. In the cache API, an empty filter becomes the ${prefix}/** glob, and
cacheDelete() unlinks every matched file, so pnpm cache delete (no args) becomes a full metadata
purge across all three directories after this change.

pnpm11/cache/commands/src/cache.cmd.ts[64-116]
pnpm11/cache/api/src/cacheList.ts[15-22]
pnpm11/cache/api/src/cacheDelete.ts[6-12]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

### Issue description
`pnpm cache delete` currently accepts an empty package/pattern list. Because the cache API treats an empty filter as “match everything”, this can unintentionally delete the entire metadata cache. After this PR, the command fans out across three metadata directories, increasing the scope of accidental deletion.

### Issue Context
- `cache.cmd.ts` calls `cacheDelete(..., params.slice(1))` without checking `params[1]`.
- `findMetadataFiles()` turns an empty `filter` into a `${prefix}/**` glob, and `cacheDelete()` unlinks all matches.

### Fix Focus Areas
- pnpm11/cache/commands/src/cache.cmd.ts[64-116]
- pnpm11/cache/api/src/cacheList.ts[15-22]

### Suggested fix
Add an explicit guard in the `delete` case (similar to the `view` case):
- If `!params[1]`, throw `new PnpmError('MISSING_PACKAGE_NAME', '`pnpm cache delete` requires the package name or pattern')`.
This still allows deleting everything explicitly via `pnpm cache delete "*"` while preventing accidental full metadata purges.

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


3. Promise.all aborts deletes 🐞 Bug ☼ Reliability
Description
cache delete now runs cacheDelete against three metadata directories using Promise.all, so any
single rejection (e.g., a transient unlinkSync failure) aborts the whole command even if other
directories already deleted files. This can leave the cache partially modified while returning an
error and no complete deleted list to the caller.
Code

pnpm11/cache/commands/src/cache.cmd.ts[R84-93]

+      const deleted = await Promise.all(
+        [ABBREVIATED_META_DIR, FULL_META_DIR, FULL_FILTERED_META_DIR].map((metaDir) =>
+          cacheDelete({
+            ...opts,
+            cacheDir: path.join(opts.cacheDir, metaDir),
+            registry: opts.cliOptions['registry'],
+          }, params.slice(1))
+        )
+      )
+      return [...new Set(deleted.flatMap((result) => result.split('\n')).filter(Boolean))].sort().join('\n')
Evidence
The new delete branch fans out deletions with Promise.all, which fails-fast on any rejection;
cacheDelete uses synchronous unlink operations that can throw, making partial deletion + command
failure plausible.

pnpm11/cache/commands/src/cache.cmd.ts[81-94]
pnpm11/cache/api/src/cacheDelete.ts[6-12]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
`pnpm cache delete` now calls `cacheDelete()` for three metadata dirs via `Promise.all(...)`. If any call throws, the entire command rejects even if deletions in other dirs already happened, creating a partial-success failure mode.

## Issue Context
`cacheDelete()` performs filesystem operations (glob + `fs.unlinkSync`) and can throw on common race/FS conditions (e.g. `ENOENT` if a file disappears between glob and unlink, permissions issues, or directory corruption). With fan-out, the probability of any single failure increases and now fails the whole command.

## Fix Focus Areas
- pnpm11/cache/commands/src/cache.cmd.ts[81-94]

## Suggested fix
- Replace `Promise.all` with `Promise.allSettled` (or sequential deletes) and:
 - Aggregate successful deletions into the returned de-duplicated list.
 - Decide error policy explicitly:
   - Ignore/continue on expected transient errors (commonly `ENOENT`) to avoid failing after partial work.
   - For other errors, either (a) rethrow after collecting successes with a clearer error message indicating which metadata dir failed, or (b) include failures in output/logging while returning non-zero exit code upstream (depending on CLI conventions).

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


Grey Divider

Previous review results

Review updated until commit 6d695c6

Results up to commit 9c0e94c


🐞 Bugs (1) 📘 Rule violations (1) 📎 Requirement gaps (0) 🎨 UX issues (0) 🔗 Cross-repo conflicts (0) 📜 Skill insights (0)


Action required
1. Pacquet cache delete unsynced 📘 Rule violation ⌂ Architecture
Description
pnpm cache delete now deletes metadata across metadata, metadata-full, and
metadata-full-filtered, but pacquet's cache delete still only targets a single mode-derived
metadata directory. This creates a user-visible divergence between pnpm (TypeScript) and pacquet
(Rust) with no explicit call-out in the PR description.
Code

pnpm11/cache/commands/src/cache.cmd.ts[R81-94]

+    case 'delete': {
+      // A package's metadata can be cached under any of the metadata directories
+      // depending on the resolution mode used when it was fetched.
+      const deleted = await Promise.all(
+        [ABBREVIATED_META_DIR, FULL_META_DIR, FULL_FILTERED_META_DIR].map((metaDir) =>
+          cacheDelete({
+            ...opts,
+            cacheDir: path.join(opts.cacheDir, metaDir),
+            registry: opts.cliOptions['registry'],
+          }, params.slice(1))
+        )
+      )
+      return [...new Set(deleted.flatMap((result) => result.split('\n')).filter(Boolean))].sort().join('\n')
+    }
Evidence
The pnpm handler now runs cacheDelete across `[ABBREVIATED_META_DIR, FULL_META_DIR,
FULL_FILTERED_META_DIR]` and unions the results, making deletion behavior broader and user-visible.
Pacquet still computes a single metadata directory via meta_dir()/cache_dir() and performs
deletions only under that one directory, so behavior is no longer aligned between implementations.

Rule 713428: Keep pnpm TypeScript and pacquet Rust user-visible behavior changes in sync
pnpm11/cache/commands/src/cache.cmd.ts[81-94]
pacquet/crates/cli/src/cli_args/cache.rs[28-41]
pacquet/crates/cli/src/cli_args/cache.rs[130-141]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
This PR changes pnpm's `cache delete` to remove package metadata from all metadata cache directories, but pacquet's `cache delete` still resolves a single `cache_dir` from the current resolution mode and deletes only within that directory.

## Issue Context
Compliance requires pnpm TypeScript and pacquet Rust user-visible behavior to stay in sync, or for the PR description to explicitly call out any known divergence and follow-up work.

## Fix Focus Areas
- pnpm11/cache/commands/src/cache.cmd.ts[81-94]
- pacquet/crates/cli/src/cli_args/cache.rs[28-41]
- pacquet/crates/cli/src/cli_args/cache.rs[130-141]
- .changeset/cache-delete-all-metadata-dirs.md[1-6]

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools



Remediation recommended
2. Promise.all aborts deletes 🐞 Bug ☼ Reliability
Description
cache delete now runs cacheDelete against three metadata directories using Promise.all, so any
single rejection (e.g., a transient unlinkSync failure) aborts the whole command even if other
directories already deleted files. This can leave the cache partially modified while returning an
error and no complete deleted list to the caller.
Code

pnpm11/cache/commands/src/cache.cmd.ts[R84-93]

+      const deleted = await Promise.all(
+        [ABBREVIATED_META_DIR, FULL_META_DIR, FULL_FILTERED_META_DIR].map((metaDir) =>
+          cacheDelete({
+            ...opts,
+            cacheDir: path.join(opts.cacheDir, metaDir),
+            registry: opts.cliOptions['registry'],
+          }, params.slice(1))
+        )
+      )
+      return [...new Set(deleted.flatMap((result) => result.split('\n')).filter(Boolean))].sort().join('\n')
Evidence
The new delete branch fans out deletions with Promise.all, which fails-fast on any rejection;
cacheDelete uses synchronous unlink operations that can throw, making partial deletion + command
failure plausible.

pnpm11/cache/commands/src/cache.cmd.ts[81-94]
pnpm11/cache/api/src/cacheDelete.ts[6-12]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
`pnpm cache delete` now calls `cacheDelete()` for three metadata dirs via `Promise.all(...)`. If any call throws, the entire command rejects even if deletions in other dirs already happened, creating a partial-success failure mode.

## Issue Context
`cacheDelete()` performs filesystem operations (glob + `fs.unlinkSync`) and can throw on common race/FS conditions (e.g. `ENOENT` if a file disappears between glob and unlink, permissions issues, or directory corruption). With fan-out, the probability of any single failure increases and now fails the whole command.

## Fix Focus Areas
- pnpm11/cache/commands/src/cache.cmd.ts[81-94]

## Suggested fix
- Replace `Promise.all` with `Promise.allSettled` (or sequential deletes) and:
 - Aggregate successful deletions into the returned de-duplicated list.
 - Decide error policy explicitly:
   - Ignore/continue on expected transient errors (commonly `ENOENT`) to avoid failing after partial work.
   - For other errors, either (a) rethrow after collecting successes with a clearer error message indicating which metadata dir failed, or (b) include failures in output/logging while returning non-zero exit code upstream (depending on CLI conventions).

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


Results up to commit 9c0e94c


🐞 Bugs (1) 📘 Rule violations (0) 📎 Requirement gaps (0) 🎨 UX issues (0) 🔗 Cross-repo conflicts (0) 📜 Skill insights (0)


Remediation recommended
1. Delete with no args purges 🐞 Bug ☼ Reliability
Description
cache delete does not validate that a package/pattern was provided, so an empty invocation expands
to a broad glob and deletes all metadata entries. With this PR it now purges across metadata,
metadata-full, and metadata-full-filtered, increasing the blast radius of an argument-omission
typo.
Code

pnpm11/cache/commands/src/cache.cmd.ts[R81-94]

+    case 'delete': {
+      // A package's metadata can be cached under any of the metadata directories
+      // depending on the resolution mode used when it was fetched.
+      const deleted = await Promise.all(
+        [ABBREVIATED_META_DIR, FULL_META_DIR, FULL_FILTERED_META_DIR].map((metaDir) =>
+          cacheDelete({
+            ...opts,
+            cacheDir: path.join(opts.cacheDir, metaDir),
+            registry: opts.cliOptions['registry'],
+          }, params.slice(1))
+        )
+      )
+      return [...new Set(deleted.flatMap((result) => result.split('\n')).filter(Boolean))].sort().join('\n')
+    }
Evidence
The handler’s delete branch passes params.slice(1) directly into cacheDelete() for all three
metadata directories. In the cache API, an empty filter becomes the ${prefix}/** glob, and
cacheDelete() unlinks every matched file, so pnpm cache delete (no args) becomes a full metadata
purge across all three directories after this change.

pnpm11/cache/commands/src/cache.cmd.ts[64-116]
pnpm11/cache/api/src/cacheList.ts[15-22]
pnpm11/cache/api/src/cacheDelete.ts[6-12]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

### Issue description
`pnpm cache delete` currently accepts an empty package/pattern list. Because the cache API treats an empty filter as “match everything”, this can unintentionally delete the entire metadata cache. After this PR, the command fans out across three metadata directories, increasing the scope of accidental deletion.

### Issue Context
- `cache.cmd.ts` calls `cacheDelete(..., params.slice(1))` without checking `params[1]`.
- `findMetadataFiles()` turns an empty `filter` into a `${prefix}/**` glob, and `cacheDelete()` unlinks all matches.

### Fix Focus Areas
- pnpm11/cache/commands/src/cache.cmd.ts[64-116]
- pnpm11/cache/api/src/cacheList.ts[15-22]

### Suggested fix
Add an explicit guard in the `delete` case (similar to the `view` case):
- If `!params[1]`, throw `new PnpmError('MISSING_PACKAGE_NAME', '`pnpm cache delete` requires the package name or pattern')`.
This still allows deleting everything explicitly via `pnpm cache delete "*"` while preventing accidental full metadata purges.

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


Qodo Logo

Comment on lines +81 to +94
case 'delete': {
// A package's metadata can be cached under any of the metadata directories
// depending on the resolution mode used when it was fetched.
const deleted = await Promise.all(
[ABBREVIATED_META_DIR, FULL_META_DIR, FULL_FILTERED_META_DIR].map((metaDir) =>
cacheDelete({
...opts,
cacheDir: path.join(opts.cacheDir, metaDir),
registry: opts.cliOptions['registry'],
}, params.slice(1))
)
)
return [...new Set(deleted.flatMap((result) => result.split('\n')).filter(Boolean))].sort().join('\n')
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Action required

1. Pacquet cache delete unsynced 📘 Rule violation ⌂ Architecture

pnpm cache delete now deletes metadata across metadata, metadata-full, and
metadata-full-filtered, but pacquet's cache delete still only targets a single mode-derived
metadata directory. This creates a user-visible divergence between pnpm (TypeScript) and pacquet
(Rust) with no explicit call-out in the PR description.
Agent Prompt
## Issue description
This PR changes pnpm's `cache delete` to remove package metadata from all metadata cache directories, but pacquet's `cache delete` still resolves a single `cache_dir` from the current resolution mode and deletes only within that directory.

## Issue Context
Compliance requires pnpm TypeScript and pacquet Rust user-visible behavior to stay in sync, or for the PR description to explicitly call out any known divergence and follow-up work.

## Fix Focus Areas
- pnpm11/cache/commands/src/cache.cmd.ts[81-94]
- pacquet/crates/cli/src/cli_args/cache.rs[28-41]
- pacquet/crates/cli/src/cli_args/cache.rs[130-141]
- .changeset/cache-delete-all-metadata-dirs.md[1-6]

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Addressed in 777b254 — mirrored the same all-metadata-directories deletion in pacquet's Rust cache delete (pacquet/crates/cli/src/cli_args/cache.rs), iterating ABBREVIATED_META_DIR / FULL_META_DIR / FULL_FILTERED_META_DIR instead of the single mode-derived dir, with a matching test (should_delete_packages_from_all_metadata_dirs). pnpm (TS) and pacquet (Rust) cache delete are now in sync.

@github-actions github-actions Bot added the reviewed: coderabbit CodeRabbit submitted an approving review label Jul 7, 2026
@qodo-code-review

Copy link
Copy Markdown

Code review by qodo was updated up to the latest commit 9c0e94c

ⓘ You are approaching your monthly quota for Qodo. Upgrade your plan

@m2na7
m2na7 force-pushed the fix/cache-delete-all-metadata-dirs branch from 9c0e94c to 9cf7ccc Compare July 7, 2026 08:06
@qodo-free-for-open-source-projects

Copy link
Copy Markdown

Code review by qodo was updated up to the latest commit 9cf7ccc

1 similar comment
@qodo-free-for-open-source-projects

Copy link
Copy Markdown

Code review by qodo was updated up to the latest commit 9cf7ccc

@qodo-code-review

Copy link
Copy Markdown

Qodo reviews are paused for this user.

Troubleshooting steps vary by plan Learn more →

On a Teams plan?
Reviews resume once this user has a paid seat and their Git account is linked in Qodo.
Link Git account →

Using GitHub Enterprise Server, GitLab Self-Managed, or Bitbucket Data Center?
These require an Enterprise plan - Contact us
Contact us →

@qodo-free-for-open-source-projects

Copy link
Copy Markdown

Code review by qodo was updated up to the latest commit 777b254

1 similar comment
@qodo-free-for-open-source-projects

Copy link
Copy Markdown

Code review by qodo was updated up to the latest commit 777b254

@codecov-commenter

codecov-commenter commented Jul 7, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 85.23%. Comparing base (c6fd0b7) to head (6d695c6).
⚠️ Report is 1 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main   #12831      +/-   ##
==========================================
+ Coverage   85.18%   85.23%   +0.05%     
==========================================
  Files         486      486              
  Lines       76975    77072      +97     
==========================================
+ Hits        65570    65696     +126     
+ Misses      11405    11376      -29     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@github-actions

github-actions Bot commented Jul 7, 2026 •

Copy link
Copy Markdown
Contributor

Integrated-Benchmark Report (Linux)

Commit: 6d695c6819d6

Each scenario reports direct installs and pnpr installs. Bencher consumes pacquet@HEAD and pnpr@HEAD.

Scenario: Isolated linker: fresh restore, cold cache + cold store

Command Mean [s] Min [s] Max [s] Relative
pacquet@HEAD 3.907 ± 0.162 3.690 4.114 1.87 ± 0.11
pacquet@main 3.782 ± 0.167 3.609 4.057 1.81 ± 0.11
pnpr@HEAD 2.149 ± 0.126 1.973 2.366 1.03 ± 0.07
pnpr@main 2.087 ± 0.085 1.983 2.218 1.00
BENCHMARK_REPORT.json
{
  "results": [
    {
      "command": "pacquet@HEAD",
      "mean": 3.9074332475400007,
      "stddev": 0.1623455270076966,
      "median": 3.93095148014,
      "user": 3.6636894599999996,
      "system": 3.3187742200000003,
      "min": 3.6898235771400003,
      "max": 4.11402859414,
      "times": [
        4.08348706414,
        4.06603303114,
        3.77050939714,
        3.6898235771400003,
        3.8941501081400003,
        4.11402859414,
        3.74020773714,
        4.0125172641399995,
        3.7358228501400004,
        3.9677528521400003
      ]
    },
    {
      "command": "pacquet@main",
      "mean": 3.7823390765400005,
      "stddev": 0.16705282291860526,
      "median": 3.73218962264,
      "user": 3.6493957599999987,
      "system": 3.33859142,
      "min": 3.60875116714,
      "max": 4.056921303139999,
      "times": [
        3.76426221414,
        3.91935085214,
        3.71765788214,
        3.73828319514,
        4.056921303139999,
        3.62761750014,
        3.7260960501400002,
        3.62207207414,
        3.60875116714,
        4.0423785271399995
      ]
    },
    {
      "command": "pnpr@HEAD",
      "mean": 2.14866568824,
      "stddev": 0.12631967774423933,
      "median": 2.13351643864,
      "user": 2.77180446,
      "system": 2.93803572,
      "min": 1.97311920914,
      "max": 2.36552885714,
      "times": [
        2.12024790714,
        2.31946487514,
        2.05040818214,
        2.14678497014,
        2.0489876271400003,
        2.06613387114,
        2.36552885714,
        2.24549128514,
        2.15049009814,
        1.97311920914
      ]
    },
    {
      "command": "pnpr@main",
      "mean": 2.0870246727399997,
      "stddev": 0.08521541530082495,
      "median": 2.07210467664,
      "user": 2.7571897599999997,
      "system": 2.92612852,
      "min": 1.9833299011400003,
      "max": 2.21773768214,
      "times": [
        2.02825118814,
        2.17223167814,
        2.10664855414,
        2.01726367914,
        2.08706403514,
        2.21773768214,
        2.20104865514,
        1.9833299011400003,
        2.05714531814,
        1.9995260361400002
      ]
    }
  ]
}

Scenario: Isolated linker: fresh restore, hot cache + hot store

Command Mean [ms] Min [ms] Max [ms] Relative
pacquet@HEAD 665.7 ± 11.2 649.1 681.5 1.01 ± 0.03
pacquet@main 661.1 ± 17.2 629.4 685.5 1.00
pnpr@HEAD 702.3 ± 18.2 679.3 747.3 1.06 ± 0.04
pnpr@main 778.8 ± 72.5 717.6 977.6 1.18 ± 0.11
BENCHMARK_REPORT.json
{
  "results": [
    {
      "command": "pacquet@HEAD",
      "mean": 0.6656678655199999,
      "stddev": 0.011170462651284453,
      "median": 0.6686323918200001,
      "user": 0.40750482000000005,
      "system": 1.3278987999999998,
      "min": 0.6490985518200001,
      "max": 0.6814517868200001,
      "times": [
        0.6683490028200001,
        0.68008528582,
        0.6814517868200001,
        0.6537494768200001,
        0.6585781528200001,
        0.66915415582,
        0.67262362082,
        0.6490985518200001,
        0.6546728408200001,
        0.6689157808200001
      ]
    },
    {
      "command": "pacquet@main",
      "mean": 0.66105430722,
      "stddev": 0.017206624858799147,
      "median": 0.6639233968200001,
      "user": 0.39674642,
      "system": 1.3242036000000001,
      "min": 0.6293675758200001,
      "max": 0.6855035748200001,
      "times": [
        0.6761597108200001,
        0.6855035748200001,
        0.6632935248200001,
        0.6712312308200001,
        0.6411796518200001,
        0.6293675758200001,
        0.6459630538200001,
        0.6645532688200001,
        0.66286950582,
        0.6704219748200001
      ]
    },
    {
      "command": "pnpr@HEAD",
      "mean": 0.7022787155200001,
      "stddev": 0.01816165952607296,
      "median": 0.70052969832,
      "user": 0.40822192,
      "system": 1.3409146,
      "min": 0.6793397648200001,
      "max": 0.7472796818200002,
      "times": [
        0.6793397648200001,
        0.70754026282,
        0.7059662068200001,
        0.6900965628200001,
        0.6973073568200001,
        0.7006149848200001,
        0.7004444118200001,
        0.7472796818200002,
        0.7055587888200001,
        0.6886391338200001
      ]
    },
    {
      "command": "pnpr@main",
      "mean": 0.7787500159199999,
      "stddev": 0.07246279795367515,
      "median": 0.75887152782,
      "user": 0.4127476199999999,
      "system": 1.4090507000000003,
      "min": 0.7176190628200001,
      "max": 0.9775527048200001,
      "times": [
        0.7790931778200001,
        0.74074365082,
        0.7616208278200001,
        0.7536688638200001,
        0.7176190628200001,
        0.7513170478200001,
        0.7590375098200001,
        0.7881417678200001,
        0.75870554582,
        0.9775527048200001
      ]
    }
  ]
}

Scenario: Isolated linker: fresh install, cold cache + cold store

Command Mean [s] Min [s] Max [s] Relative
pacquet@HEAD 4.290 ± 0.039 4.219 4.332 2.01 ± 0.12
pacquet@main 4.301 ± 0.032 4.246 4.347 2.01 ± 0.12
pnpr@HEAD 2.139 ± 0.124 1.974 2.388 1.00
pnpr@main 2.260 ± 0.138 2.036 2.416 1.06 ± 0.09
BENCHMARK_REPORT.json
{
  "results": [
    {
      "command": "pacquet@HEAD",
      "mean": 4.28996580298,
      "stddev": 0.039276902947226904,
      "median": 4.300897186679999,
      "user": 3.8411952199999995,
      "system": 3.32235602,
      "min": 4.219350157179999,
      "max": 4.33230426818,
      "times": [
        4.31525058018,
        4.292124729179999,
        4.23920603518,
        4.25462287518,
        4.321580658179999,
        4.3096696441799995,
        4.29026367818,
        4.219350157179999,
        4.33230426818,
        4.32528540418
      ]
    },
    {
      "command": "pacquet@main",
      "mean": 4.30093693268,
      "stddev": 0.032248435067784575,
      "median": 4.30227448668,
      "user": 3.83594942,
      "system": 3.3212645199999997,
      "min": 4.24551565018,
      "max": 4.3474167241799995,
      "times": [
        4.30445247718,
        4.324841764179999,
        4.24551565018,
        4.344831021179999,
        4.284149320179999,
        4.26778945418,
        4.30073929418,
        4.30380967918,
        4.3474167241799995,
        4.2858239421799995
      ]
    },
    {
      "command": "pnpr@HEAD",
      "mean": 2.1389232917800003,
      "stddev": 0.12436983853453332,
      "median": 2.15792546518,
      "user": 2.5790702199999997,
      "system": 2.8175189200000004,
      "min": 1.97439298818,
      "max": 2.38762186718,
      "times": [
        2.21244174918,
        2.1559372471800002,
        2.08273461418,
        2.15991368318,
        2.19012847918,
        2.01569279818,
        2.00292771318,
        2.38762186718,
        2.20744177818,
        1.97439298818
      ]
    },
    {
      "command": "pnpr@main",
      "mean": 2.25955944198,
      "stddev": 0.13760606843684814,
      "median": 2.2983381086800003,
      "user": 2.56597692,
      "system": 2.83198062,
      "min": 2.03592729718,
      "max": 2.41623455618,
      "times": [
        2.2895492921800003,
        2.15660833518,
        2.34779127918,
        2.16101128118,
        2.03592729718,
        2.37917679918,
        2.40943661118,
        2.30712692518,
        2.0927320431800003,
        2.41623455618
      ]
    }
  ]
}

Scenario: Isolated linker: fresh install, hot cache + hot store

Command Mean [s] Min [s] Max [s] Relative
pacquet@HEAD 1.415 ± 0.020 1.391 1.459 2.10 ± 0.05
pacquet@main 1.429 ± 0.041 1.401 1.543 2.12 ± 0.08
pnpr@HEAD 0.685 ± 0.055 0.657 0.842 1.02 ± 0.09
pnpr@main 0.674 ± 0.014 0.652 0.697 1.00
BENCHMARK_REPORT.json
{
  "results": [
    {
      "command": "pacquet@HEAD",
      "mean": 1.4148741397200002,
      "stddev": 0.019793712134983397,
      "median": 1.41331706482,
      "user": 1.3593002599999997,
      "system": 1.7253435400000001,
      "min": 1.39140061282,
      "max": 1.45925216282,
      "times": [
        1.45925216282,
        1.4232684948199998,
        1.42570324482,
        1.40953897282,
        1.42365316482,
        1.39978650782,
        1.4170951568199999,
        1.39140061282,
        1.40157820682,
        1.3974648728199999
      ]
    },
    {
      "command": "pacquet@main",
      "mean": 1.4289207257199998,
      "stddev": 0.041340421890517925,
      "median": 1.41736096182,
      "user": 1.3477570599999997,
      "system": 1.7581453399999998,
      "min": 1.40065844682,
      "max": 1.54278857582,
      "times": [
        1.43476204182,
        1.54278857582,
        1.4108002098199999,
        1.42838261882,
        1.41642902182,
        1.40223222982,
        1.40065844682,
        1.41536273682,
        1.41829290182,
        1.41949847382
      ]
    },
    {
      "command": "pnpr@HEAD",
      "mean": 0.6848615102200001,
      "stddev": 0.05546856009419719,
      "median": 0.6678851663200001,
      "user": 0.33977336,
      "system": 1.3089850399999998,
      "min": 0.65728710182,
      "max": 0.84225136982,
      "times": [
        0.6678479568200001,
        0.65728710182,
        0.6683153018200001,
        0.84225136982,
        0.66792237582,
        0.6667233438200001,
        0.66654871382,
        0.6735921218200001,
        0.67208429282,
        0.6660425238200001
      ]
    },
    {
      "command": "pnpr@main",
      "mean": 0.6742271675200001,
      "stddev": 0.014215751173943851,
      "median": 0.6716563358200001,
      "user": 0.34703716000000007,
      "system": 1.2830133399999997,
      "min": 0.65171930182,
      "max": 0.6965177398200001,
      "times": [
        0.68775626182,
        0.6899838208200001,
        0.6965177398200001,
        0.6685707058200001,
        0.6633368648200001,
        0.6617352028200001,
        0.66775210882,
        0.65171930182,
        0.6801577028200001,
        0.67474196582
      ]
    }
  ]
}

Scenario: Isolated linker: fresh install, cold cache + hot store

Command Mean [s] Min [s] Max [s] Relative
pacquet@HEAD 3.085 ± 0.022 3.045 3.117 4.67 ± 0.09
pacquet@main 3.141 ± 0.056 3.104 3.296 4.75 ± 0.12
pnpr@HEAD 0.675 ± 0.016 0.651 0.701 1.02 ± 0.03
pnpr@main 0.661 ± 0.012 0.647 0.685 1.00
BENCHMARK_REPORT.json
{
  "results": [
    {
      "command": "pacquet@HEAD",
      "mean": 3.08537044454,
      "stddev": 0.02170686076080629,
      "median": 3.08720524614,
      "user": 1.7721287799999998,
      "system": 2.01488712,
      "min": 3.0448249831400003,
      "max": 3.11713985414,
      "times": [
        3.09233414814,
        3.0448249831400003,
        3.08529986014,
        3.0683923871400003,
        3.10085271314,
        3.0661382341400003,
        3.07982102814,
        3.08911063214,
        3.11713985414,
        3.10979060514
      ]
    },
    {
      "command": "pacquet@main",
      "mean": 3.14092104104,
      "stddev": 0.056216879818985155,
      "median": 3.12987278664,
      "user": 1.7944489799999999,
      "system": 2.05702552,
      "min": 3.1039809221400003,
      "max": 3.29603294714,
      "times": [
        3.13453649114,
        3.1039809221400003,
        3.14088563414,
        3.1057201931400003,
        3.12680576114,
        3.1184025921400003,
        3.13293981214,
        3.10980505114,
        3.29603294714,
        3.14010100614
      ]
    },
    {
      "command": "pnpr@HEAD",
      "mean": 0.6753386085399999,
      "stddev": 0.015541910884820605,
      "median": 0.6702396156400001,
      "user": 0.34623778,
      "system": 1.30137762,
      "min": 0.6506214691400001,
      "max": 0.7014732491400001,
      "times": [
        0.66539185814,
        0.6876565801400001,
        0.6506214691400001,
        0.6631509871400001,
        0.68713376514,
        0.6717651371400001,
        0.66729651014,
        0.6901824351400001,
        0.7014732491400001,
        0.66871409414
      ]
    },
    {
      "command": "pnpr@main",
      "mean": 0.66136763994,
      "stddev": 0.011649794793257775,
      "median": 0.66099710014,
      "user": 0.34683468,
      "system": 1.25852762,
      "min": 0.6471968651400001,
      "max": 0.6848370531400001,
      "times": [
        0.6554881261400001,
        0.6649288551400001,
        0.65712221114,
        0.6471968651400001,
        0.65326505814,
        0.6682404201400001,
        0.6704137961400001,
        0.6473120251400001,
        0.6848370531400001,
        0.66487198914
      ]
    }
  ]
}

Scenario: Isolated linker: fresh resolve, hot cache, offline

Command Mean [ms] Min [ms] Max [ms] Relative
pacquet@HEAD 674.8 ± 33.8 650.3 757.7 6.01 ± 0.30
pacquet@main 676.5 ± 21.8 651.5 707.3 6.03 ± 0.20
pnpr@HEAD 112.7 ± 2.3 111.1 123.1 1.00 ± 0.02
pnpr@main 112.2 ± 0.6 111.2 113.3 1.00
BENCHMARK_REPORT.json
{
  "results": [
    {
      "command": "pacquet@HEAD",
      "mean": 0.67477298768,
      "stddev": 0.03377141399037269,
      "median": 0.66121583848,
      "user": 0.62656164,
      "system": 0.1581411,
      "min": 0.65034071348,
      "max": 0.75774556748,
      "times": [
        0.6623104454800001,
        0.75774556748,
        0.71234173548,
        0.65821540448,
        0.65849724348,
        0.66661457848,
        0.65034071348,
        0.6592325114800001,
        0.66215199948,
        0.66027967748
      ]
    },
    {
      "command": "pacquet@main",
      "mean": 0.67645661308,
      "stddev": 0.021751253051349773,
      "median": 0.66983128648,
      "user": 0.62928904,
      "system": 0.1616424,
      "min": 0.65148023848,
      "max": 0.70734520948,
      "times": [
        0.6855804614800001,
        0.65918684248,
        0.65148023848,
        0.70734520948,
        0.65628467048,
        0.67423533948,
        0.6584710394800001,
        0.66542723348,
        0.70449087548,
        0.7020642204800001
      ]
    },
    {
      "command": "pnpr@HEAD",
      "mean": 0.11269113123,
      "stddev": 0.002338403018078965,
      "median": 0.11217693648,
      "user": 0.029018839999999994,
      "system": 0.02286503333333333,
      "min": 0.11105462148,
      "max": 0.12312745148000001,
      "times": [
        0.11228481948,
        0.11119315848,
        0.11203282348,
        0.11382058548,
        0.11105462148,
        0.11204930848,
        0.11231834948000001,
        0.11202648248000001,
        0.11208579048,
        0.11244184948000001,
        0.11217274048,
        0.11208049248,
        0.11244204948,
        0.11218113248,
        0.11230938248,
        0.11234143048,
        0.11232330448000001,
        0.11118339948,
        0.11191407448,
        0.11380052948000001,
        0.11213544348,
        0.11144180348,
        0.12312745148000001,
        0.11382612648
      ]
    },
    {
      "command": "pnpr@main",
      "mean": 0.11223238197999998,
      "stddev": 0.0005979392168236275,
      "median": 0.11222914798,
      "user": 0.02932934,
      "system": 0.022051491666666662,
      "min": 0.11115059048,
      "max": 0.11332990948,
      "times": [
        0.11266350948000001,
        0.11212894448,
        0.11125405448,
        0.11298736048000001,
        0.11154188248,
        0.11247225048000001,
        0.11199147048000001,
        0.11231601248,
        0.11239657248,
        0.11253236448000001,
        0.11172559548000001,
        0.11227351948,
        0.11324062748000001,
        0.11115059048,
        0.11211115848,
        0.11269019848,
        0.11194245748000001,
        0.11212377648,
        0.11218477648,
        0.11245035248,
        0.11332990948,
        0.11142597048,
        0.11158128048,
        0.11306253248
      ]
    }
  ]
}

Scenario: Isolated linker: fresh restore, cold cache + cold store + cold pnpr

Command Mean [s] Min [s] Max [s] Relative
pacquet@HEAD 6.646 ± 0.075 6.519 6.767 1.34 ± 0.03
pacquet@main 6.573 ± 0.112 6.430 6.754 1.32 ± 0.03
pnpr@HEAD 4.967 ± 0.100 4.774 5.139 1.00
pnpr@main 4.987 ± 0.064 4.880 5.094 1.00 ± 0.02
BENCHMARK_REPORT.json
{
  "results": [
    {
      "command": "pacquet@HEAD",
      "mean": 6.645924849479999,
      "stddev": 0.07549281097427338,
      "median": 6.64555892898,
      "user": 3.8939385,
      "system": 3.583909319999999,
      "min": 6.51865153398,
      "max": 6.76663909698,
      "times": [
        6.66004018698,
        6.63107767098,
        6.581597813979999,
        6.71950459998,
        6.59662143998,
        6.51865153398,
        6.72012819198,
        6.66605501998,
        6.76663909698,
        6.598932939979999
      ]
    },
    {
      "command": "pacquet@main",
      "mean": 6.573470180679999,
      "stddev": 0.1119945730280112,
      "median": 6.5394829014799996,
      "user": 3.8816461,
      "system": 3.6059868199999996,
      "min": 6.42989757298,
      "max": 6.75438923698,
      "times": [
        6.639463388979999,
        6.73458602498,
        6.55607069198,
        6.5126287199799995,
        6.63165114898,
        6.5228951109799995,
        6.492313847979999,
        6.46080606298,
        6.75438923698,
        6.42989757298
      ]
    },
    {
      "command": "pnpr@HEAD",
      "mean": 4.96658296298,
      "stddev": 0.10043442423488641,
      "median": 4.961310141479999,
      "user": 2.8658138,
      "system": 3.1422386199999996,
      "min": 4.77433406798,
      "max": 5.13855216998,
      "times": [
        4.975910947979999,
        4.912675030979999,
        4.89917633398,
        5.13855216998,
        4.933345634979999,
        4.9467093349799995,
        5.041666437979999,
        4.77433406798,
        4.979930780979999,
        5.06352888998
      ]
    },
    {
      "command": "pnpr@main",
      "mean": 4.986524275779999,
      "stddev": 0.06400251195267616,
      "median": 4.9795479904799995,
      "user": 2.8601876,
      "system": 3.135018219999999,
      "min": 4.879507566979999,
      "max": 5.093690628979999,
      "times": [
        5.03817570898,
        4.95254866098,
        4.97893696098,
        4.879507566979999,
        5.06287842098,
        4.980159019979999,
        4.94185303698,
        4.94089129298,
        5.093690628979999,
        4.99660145998
      ]
    }
  ]
}

@github-actions

github-actions Bot commented Jul 7, 2026 •

Copy link
Copy Markdown
Contributor

🐰 Bencher Report

Branchpr/12831
Testbedpacquet
Click to view all benchmark results
BenchmarkLatencyBenchmark Result
milliseconds (ms)
(Result Δ%)
Upper Boundary
milliseconds (ms)
(Limit %)
isolated-linker.fresh-install.cold-cache.cold-store📈 view plot
🚷 view threshold
4,289.97 ms
(-0.34%)Baseline: 4,304.58 ms
5,165.50 ms
(83.05%)
isolated-linker.fresh-install.cold-cache.hot-store📈 view plot
🚷 view threshold
3,085.37 ms
(+0.78%)Baseline: 3,061.52 ms
3,673.83 ms
(83.98%)
isolated-linker.fresh-install.hot-cache.hot-store📈 view plot
🚷 view threshold
1,414.87 ms
(+1.91%)Baseline: 1,388.40 ms
1,666.09 ms
(84.92%)
isolated-linker.fresh-resolve.hot-cache.offline📈 view plot
🚷 view threshold
674.77 ms
(+3.35%)Baseline: 652.88 ms
783.46 ms
(86.13%)
isolated-linker.fresh-restore.cold-cache.cold-store📈 view plot
🚷 view threshold
3,907.43 ms
(-3.22%)Baseline: 4,037.43 ms
4,844.91 ms
(80.65%)
isolated-linker.fresh-restore.cold-cache.cold-store.cold-pnpr📈 view plot
🚷 view threshold
6,645.92 ms
(-8.73%)Baseline: 7,281.25 ms
8,737.50 ms
(76.06%)
isolated-linker.fresh-restore.hot-cache.hot-store📈 view plot
🚷 view threshold
665.67 ms
(+0.69%)Baseline: 661.13 ms
793.35 ms
(83.91%)
🐰 View full continuous benchmarking report in Bencher

@zkochan
zkochan force-pushed the fix/cache-delete-all-metadata-dirs branch from 777b254 to eb453cf Compare July 12, 2026 20:32

@coderabbitai coderabbitai Bot left a comment

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.

🧹 Nitpick comments (1)
pnpm/crates/cli/tests/cache.rs (1)

120-143: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Add stdout assertion to verify de-duplication.

The test proves files are removed from all three metadata directories but doesn't capture or assert the command's stdout output. Since the PR objective states the command returns a de-duplicated list, adding a stdout check would verify that the same package across multiple directories appears exactly once. Without it, accidentally removing deleted.dedup() would go undetected.

♻️ Proposed addition
-    cwd.pacquet.with_arg("cache").with_arg("delete").with_arg("is-positive").assert().success();
+    let output = cwd
+        .pacquet
+        .with_arg("cache")
+        .with_arg("delete")
+        .with_arg("is-positive")
+        .assert()
+        .success()
+        .get_output()
+        .stdout
+        .clone();
+    let stdout = String::from_utf8_lossy(&output);
+    assert_eq!(stdout.trim(), format!("{registry_name}/is-positive.jsonl"));
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@pnpm/crates/cli/tests/cache.rs` around lines 120 - 143, Add a stdout
assertion to should_delete_packages_from_all_metadata_dirs after the cache
delete command, verifying the deleted package is listed exactly once despite
existing in all three metadata directories. Keep the existing file-removal
assertions and assert the command output reflects de-duplication.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Nitpick comments:
In `@pnpm/crates/cli/tests/cache.rs`:
- Around line 120-143: Add a stdout assertion to
should_delete_packages_from_all_metadata_dirs after the cache delete command,
verifying the deleted package is listed exactly once despite existing in all
three metadata directories. Keep the existing file-removal assertions and assert
the command output reflects de-duplication.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: 2e63b308-92b7-4117-9db4-8e71e00424a8

📥 Commits

Reviewing files that changed from the base of the PR and between 777b254 and eb453cf.

📒 Files selected for processing (3)
  • .changeset/cache-delete-all-metadata-dirs.md
  • pnpm/crates/cli/src/cli_args/cache.rs
  • pnpm/crates/cli/tests/cache.rs
🚧 Files skipped from review as they are similar to previous changes (1)
  • .changeset/cache-delete-all-metadata-dirs.md

@qodo-code-review

Copy link
Copy Markdown

Code review by qodo was updated up to the latest commit eb453cf

@qodo-code-review

Copy link
Copy Markdown

PR Code Suggestions ✨

Warning

/improve is deprecated. Use /agentic_review instead (removal date not yet scheduled).

No code suggestions found for the PR.

Auto-approved notes - no code suggestions found
- 'approve_pr_on_self_review' flag enabled

@greptile-apps

greptile-apps Bot commented Jul 12, 2026 •

Copy link
Copy Markdown
Contributor

Confidence Score: 5/5

Safe to merge — the change is narrowly scoped to the delete branch, both implementations are updated in lockstep, and the fix has deterministic test coverage including the exact bug scenario from the issue report.

The logic in both stacks is straightforward and self-consistent: the TypeScript side uses Promise.all over the three directory constants and correctly deduplicates via Set, while the Rust side loops sequentially with an explicit exists() guard. The return-value contract of cacheDelete (newline-joined sorted paths) is handled correctly in the aggregation step. Tests cover the originally reported case and the all-directories case. No pre-existing behaviors are altered outside the delete branch.

No files require special attention.

Reviews (2): Last reviewed commit: "test(cli): use metadata-dir constants in..." | Re-trigger Greptile

Comment thread pnpm/crates/cli/tests/cache.rs Resolved
The cache delete multi-directory test hardcoded the metadata directory
names as string literals, which could drift from the constants the delete
logic actually uses. Reference ABBREVIATED_META_DIR / FULL_META_DIR /
FULL_FILTERED_META_DIR directly so the test and the code stay in lockstep.

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
@qodo-code-review

Copy link
Copy Markdown

Code review by qodo was updated up to the latest commit 6d695c6

@qodo-code-review

Copy link
Copy Markdown

PR Code Suggestions ✨

Warning

/improve is deprecated. Use /agentic_review instead (removal date not yet scheduled).

No code suggestions found for the PR.

Auto-approved notes - no code suggestions found
- 'approve_pr_on_self_review' flag enabled

@zkochan
zkochan added this pull request to the merge queue Jul 12, 2026
@github-actions

Copy link
Copy Markdown
Contributor

🐰 Bencher Report

Branchpr/12831
Testbedpnpr

⚠️ WARNING: No Threshold found!

Without a Threshold, no Alerts will ever be generated.

Click here to create a new Threshold
For more information, see the Threshold documentation.
To only post results if a Threshold exists, set the --ci-only-thresholds flag.

Click to view all benchmark results
BenchmarkLatencymilliseconds (ms)
isolated-linker.fresh-install.cold-cache.cold-store📈 view plot
⚠️ NO THRESHOLD
2,138.92 ms
isolated-linker.fresh-install.cold-cache.hot-store📈 view plot
⚠️ NO THRESHOLD
675.34 ms
isolated-linker.fresh-install.hot-cache.hot-store📈 view plot
⚠️ NO THRESHOLD
684.86 ms
isolated-linker.fresh-resolve.hot-cache.offline📈 view plot
⚠️ NO THRESHOLD
112.69 ms
isolated-linker.fresh-restore.cold-cache.cold-store📈 view plot
⚠️ NO THRESHOLD
2,148.67 ms
isolated-linker.fresh-restore.cold-cache.cold-store.cold-pnpr📈 view plot
⚠️ NO THRESHOLD
4,966.58 ms
isolated-linker.fresh-restore.hot-cache.hot-store📈 view plot
⚠️ NO THRESHOLD
702.28 ms
🐰 View full continuous benchmarking report in Bencher

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

pnpm cache delete does not clear v11/metadata-full-filtered/ cache

3 participants