Skip to content

fix(lockfile): compute tarball integrity upon download - #12491

Merged
zkochan merged 42 commits into
pnpm:mainfrom
ajeetdsouza:integrity
Jun 22, 2026
Merged

zkochan merged 42 commits into
pnpm:mainfrom
ajeetdsouza:integrity

Conversation

@ajeetdsouza

@ajeetdsouza ajeetdsouza commented Jun 18, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Fixes #12145.

Since v11.4 pnpm requires every registry tarball to carry an integrity in the lockfile and fails with ERR_PNPM_MISSING_TARBALL_INTEGRITY when it is missing, so it can verify the bytes it downloads. That assumes the registry's packument lists an integrity for each version. Some registries generate tarballs on-demand and cannot provide one, so the first pnpm install writes integrity-less lockfile entries and the next install (after node_modules was removed) fails — pnpm can't install from its own generated lockfile.

This PR makes pnpm compute the missing integrity from the downloaded tarball and write it into the lockfile, so the entry is verifiable on later installs:

  • Write side (fetcher-owned). Fetchers now expose an optional resolutionNeedsFetch contract; the remote-tarball fetcher reports true when a resolution has no integrity. The package requester then downloads the tarball, computes its sha512, and writes it back into the resolution — even under --lockfile-only / skipFetch / not-installable-here, because the lockfile entry must carry a platform-independent integrity. The fill is non-blocking (deferred onto the fetching promise); the deps-resolver awaits just those entries before building the lockfile snapshot and the virtual-store paths hashed from it.
  • Read side (resolver-owned). Enforcement lives in the npm resolver's lockfile verifier (createNpmResolutionVerifier): a registry/http(s) tarball entry whose integrity is missing, empty, or non-string is rejected with MISSING_TARBALL_INTEGRITY. It fails closed — no silent re-fetch — and the check runs before the URL-keyed and semver short-circuits, so a tampered non-semver/URL-keyed entry can't dodge it. file: and git-hosted tarballs are anchored another way and stay exempt.

Ported to the Rust pacquet/ port in the same PR (the PrefetchingResolver computes integrity for integrity-less tarball resolutions during resolution, with a per-URL singleflight cache).

Related follow-up (not in this PR): #12562 — packages whose integrity is computed during fetch are indexed under a pre-fetch fallback store key, so the immediately-following install re-downloads once before re-keying the store.

Squash Commit Body

Some registries generate tarballs on demand and cannot list an integrity in
their packument. pnpm then wrote integrity-less lockfile entries on the first
install and failed the next one with ERR_PNPM_MISSING_TARBALL_INTEGRITY, unable
to install from its own lockfile.

Compute the missing integrity from the downloaded bytes and write it into the
resolution before the lockfile is built:

- Add an optional `resolutionNeedsFetch` contract to the fetcher API (backward
  compatible, since custom fetchers come from hooks). The remote-tarball fetcher
  reports it when a resolution lacks integrity; the picked fetcher's signal flows
  through PackageResponse -> ResolvedPackage so nothing re-derives it.
- The package requester downloads such tarballs (including under --lockfile-only /
  skipFetch / not-installable) and fills the computed integrity onto the resolution
  via the already-running `fetching` promise, so dependency resolution isn't
  blocked. The deps-resolver awaits only the flagged entries before updateLockfile,
  because the integrity feeds the global virtual-store paths.
- Move read-side enforcement into the npm resolver's lockfile verifier
  (MISSING_TARBALL_INTEGRITY): reject a registry/http(s) tarball entry whose
  integrity is missing/empty/non-string, fail-closed, before the URL-keyed and
  semver short-circuits. Drop the earlier read-side auto-heal (a missing-field
  bypass). Harden against tampered lockfiles (non-string tarball/integrity).
- Reuse the fetcher picked during resolution on the fetch path instead of running
  pickFetcher (and a custom fetcher's async canFetch) twice per package.

Mirrored in pacquet: PrefetchingResolver computes the integrity for integrity-less
tarball resolutions during resolution (FetchTarballForResolution::run), deduped per
URL with a singleflight cache.

Closes pnpm/pnpm#12145.

Checklist

  • The change is implemented in both the TypeScript CLI and the Rust
    pacquet/ port.
  • Added a changeset (pnpm changeset).
  • Added or updated tests.
  • Updated the documentation if needed (no docs-site change needed; the
    changeset carries the user-facing release note).

Summary by CodeRabbit

  • Bug Fixes
    • pnpm now reliably computes missing tarball integrity checksums from downloaded tarballs and records them in the lockfile, including for --lockfile-only and skipFetch.
    • Installs now fail closed when the lockfile still lacks required tarball integrity, instead of silently retrying.
  • Tests
    • Added/expanded coverage to ensure fail-closed lockfile verification, integrity computation on cache/store hits, and correct behavior when registry metadata omits integrity.

@ajeetdsouza
ajeetdsouza requested a review from zkochan as a code owner June 18, 2026 09:13
Copilot AI review requested due to automatic review settings June 18, 2026 09:13
@coderabbitai

coderabbitai Bot commented Jun 18, 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
📝 Walkthrough

Walkthrough

Implements missing tarball integrity computation and fail-closed handling for registry packages that omit checksums in metadata. When a registry provides no integrity, pnpm downloads the tarball to compute it, persists it in the lockfile, and refetches from store if needed. Frozen installs fail if integrity remains unavailable; non-frozen installs repair the lockfile. Consolidates integrity-requirement and resolution-classification logic into reusable helpers in resolver-base.

Changes

Missing Tarball Integrity Recovery

Layer / File(s) Summary
Resolution classification and integrity-requirement helpers
pnpm11/resolving/resolver-base/src/index.ts
Introduces isGitHostedTarballUrl to detect Git-hosted archives, ResolutionKind union type to categorize resolution sources, and classifyResolution to map resolutions to their source category.
Fetcher-base resolution contract
pnpm11/fetching/fetcher-base/src/index.ts
Adds ResolutionFetchContract interface with optional resolutionNeedsFetch and completeResolution hooks, and updates FetchFunction type to intersect with this contract.
Custom fetcher contract extension
pnpm11/hooks/types/src/index.ts
Updates CustomFetcher interface to extend ResolutionFetchContract, aligning custom fetchers with the new resolution-capability contract.
Fetcher classification refactor using resolution helpers
pnpm11/fetching/pick-fetcher/src/index.ts
Replaces manual tarball/file:/gitHosted classification with classifyResolution, treats custom classifications as unsupported, forwards resolutionNeedsFetch and completeResolution from custom fetchers, and removes the obsolete isGitHostedPkgUrl export.
Tarball fetcher integrity-requirement declaration
pnpm11/fetching/tarball-fetcher/src/index.ts
Implements resolutionNeedsFetch on remoteTarballFetcher to return true for registry tarballs lacking integrity, signaling that fetch is required to compute checksums.
Lockfile utilities consolidation using new helpers
pnpm11/lockfile/utils/src/pkgSnapshotToResolution.ts, pnpm11/lockfile/utils/src/toLockfileResolution.ts, pnpm11/lockfile/utils/src/index.ts, pnpm11/lockfile/utils/test/pkgSnapshotToResolution.ts
Removes inline integrity checks from pkgSnapshotToResolution, moves isGitHostedTarballUrl import and export to resolver-base, and restructures test coverage to reflect that integrity enforcement now lives in the npm resolver verifier.
NPM resolver lockfile verifier fail-closed enforcement
pnpm11/resolving/npm-resolver/src/createNpmResolutionVerifier.ts, pnpm11/resolving/npm-resolver/src/violationCodes.ts, pnpm11/resolving/npm-resolver/test/createNpmResolutionVerifier.test.ts
Adds explicit fail-closed integrity requirement for registry tarball lockfile entries during verification; registry tarballs lacking integrity are rejected with MISSING_TARBALL_INTEGRITY_VIOLATION_CODE. Extends cached-policy contract with integrityRequired flag so verification results remain valid across code changes.
Package requester integrity computation and fail-closed handling
pnpm11/installing/package-requester/src/packageRequester.ts
Prevents early returns during skipFetch when integrity is required, computes missing tarball integrity after fetch via completeResolution, refetches cached store entries for integrity computation, and fails closed by throwing MISSING_TARBALL_INTEGRITY when integrity remains unavailable. Wires fetcher information and introduces mustComputeIntegrity flag through fetch-to-store layer.
Store controller type additions
pnpm11/store/controller-types/src/index.ts
Adds mustComputeIntegrity optional flag to FetchPackageToStoreOptions to signal when cached store entries should be re-downloaded for checksum computation.
Patching commands dependency cleanup
pnpm11/patching/commands/src/getPatchedDependency.ts, pnpm11/patching/commands/package.json, pnpm11/patching/commands/tsconfig.json
Removes @pnpm/fetching.pick-fetcher workspace dependency, updates imports to use isGitHostedTarballUrl from @pnpm/lockfile.utils, and removes the corresponding tsconfig reference.
Test coverage for integrity computation and fail-closed behavior
pnpm11/installing/deps-installer/test/brokenLockfileIntegrity.ts, pnpm11/installing/package-requester/test/index.ts
Adds test cases verifying frozen and non-frozen installs reject lockfiles with missing tarball integrity; that integrity is computed even for cached packages; and that skipFetch does not skip downloads when registry metadata omits integrity.
Release notes and version bump declaration
.changeset/compute-missing-tarball-integrity.md
Declares version bumps across multiple packages and documents missing tarball integrity computation, persistence in lockfiles, and fail-closed behavior on frozen installs.

Sequence Diagram

sequenceDiagram
  participant Client as pnpm install
  participant Requester as packageRequester
  participant Fetcher as Fetcher
  participant Registry as Registry
  participant Store as Content Store
  
  Client->>Requester: requestPackage(resolution)
  Requester->>Fetcher: resolutionNeedsFetch(resolution)?
  alt integrity required
    Requester->>Registry: download tarball
    Requester->>Fetcher: completeResolution with computed integrity
    Requester->>Requester: mustComputeIntegrity = true
  end
  Requester->>Store: doFetchToStore(mustComputeIntegrity)
  alt cached && mustComputeIntegrity
    Store->>Registry: refetch tarball
    Store->>Store: recompute integrity
  else cached && !mustComputeIntegrity
    Store->>Store: return cached entry
  end
  alt integrity still missing
    Requester->>Client: throw MISSING_TARBALL_INTEGRITY
  else integrity present
    Requester->>Client: return resolution with integrity
  end
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~60 minutes

Assessment against linked issues

Objective Addressed Explanation
Compute tarball integrity when registry metadata omits it and persist in lockfile [#12145] ✅
Handle case where package already exists in local store (re-download for integrity computation) [#12145] ✅
Prevent skipping fetch when integrity is required (including --lockfile-only mode) [#12145] ✅
Fail closed (reject installs) when lockfile integrity is missing [#12145] ✅

Possibly related PRs

  • pnpm/pnpm#11481: Updates installing/package-requester to pin tarball integrity by computing and propagating values from downloaded tarballs into the lockfile, specifically for git-hosted tarballs — the same core mechanism extended here to registry metadata lacking integrity.
  • pnpm/pnpm#11966: Enforces MISSING_TARBALL_INTEGRITY at lockfile read time for tarball resolutions missing integrity — directly related through the same integrity validation and resolution helpers.
  • pnpm/pnpm#12040: Fixes packageRequester.resolveAndFetch to carry existing tarball integrity forward when the resolver returns none, addressing the same fetch path and integrity-handling code flow.

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 and usage tips.

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

Copy link
Copy Markdown

PR Summary by Qodo

Fix missing tarball integrity by hashing downloaded tarballs and repairing lockfile
🐞 Bug fix 🧪 Tests ⚙️ Configuration changes 🕐 40+ Minutes

Grey Divider

Description

• Compute and persist tarball integrity when registry metadata omits it.
• Non-frozen installs detect/repair missing-integrity lockfile entries via full re-resolution.
• Force re-download when needed to compute integrity, even on store cache hits.
Diagram

graph TD
  A["deps-installer"] --> B{"Frozen install?"} -->|"no"| C["deps-resolver"] --> E["package-requester"] --> F["fetch worker"] --> H[("pnpm-lock.yaml")]
  C --> D["lockfile.utils"]
  E --> D
  E --> G[("CAFS store")]
  F --> G

  subgraph Legend
    direction LR
    _mod["Module"] ~~~ _dec{"Decision"} ~~~ _db[("Data store")]
  end
Loading
High-Level Assessment

The following are alternative approaches to this PR:

1. Compute integrity from already-stored content (no network refetch)
  • ➕ Avoids extra tarball download when the store already has the package bytes
  • ➕ Faster installs in cache-hit scenarios
  • ➖ Store layout is content-addressed by integrity, so locating the correct content without integrity is non-trivial
  • ➖ Requires additional indexing/lookup metadata and careful invalidation/verification
2. Add a separate local metadata cache for “computed integrity” keyed by tarball URL
  • ➕ Could avoid re-resolution and reduce network traffic
  • ➕ Does not require lockfile mutation for subsequent installs on the same machine
  • ➖ Introduces a new state store with portability issues (CI, shared repos)
  • ➖ Still leaves the lockfile invalid for other machines/users, undermining reproducibility
3. Relax integrity requirement for registries that don’t provide it
  • ➕ No refetch and minimal behavioral changes
  • ➕ Simpler implementation
  • ➖ Security regression: cannot verify downloaded tarball bytes from lockfile
  • ➖ Makes lockfile less tamper-evident and less deterministic

Recommendation: Keep the PR’s approach: repair missing integrity only on non-frozen installs by recomputing from downloaded tarball bytes, and continue failing closed on frozen installs. The forced refetch on cache hits is a reasonable tradeoff given the store is addressed by integrity; alternatives that avoid refetch generally require new indexing state or weaken verification guarantees.

Files changed (11) +186 / -19

Bug fix (4) +57 / -18
index.tsForce full resolution to repair missing tarball integrity (non-frozen) +13/-1

Force full resolution to repair missing tarball integrity (non-frozen)

• Adds a non-frozen repair path: if any package snapshot resolution lacks required integrity, the install triggers a full resolution run. Introduces a helper that scans lockfile package snapshots using the centralized integrity predicate.

installing/deps-installer/src/install/index.ts

resolveDependencies.tsAllow resolver to read integrity-less lockfile entries for auto-repair +2/-1

Allow resolver to read integrity-less lockfile entries for auto-repair

• Updates lockfile-to-resolution conversion to allow missing integrity during the resolution phase. This enables downstream fetching to recompute integrity instead of throwing immediately.

installing/deps-resolver/src/resolveDependencies.ts

packageRequester.tsCompute integrity from fetched tarballs and refetch cache hits when needed +34/-8

Compute integrity from fetched tarballs and refetch cache hits when needed

• If a tarball resolution lacks integrity, awaits the fetch result and writes back the worker-computed integrity into the resolution. Forces a refetch even when the package is already present in the store when integrity is missing, and throws a clearer error if integrity still cannot be computed.

installing/package-requester/src/packageRequester.ts

pkgSnapshotToResolution.tsCentralize integrity enforcement with optional allow-missing mode +8/-8

Centralize integrity enforcement with optional allow-missing mode

• Replaces duplicated integrity checks with resolutionNeedsIntegrity, and adds an option to allow missing integrity during non-frozen repair flows. Keeps strict failure behavior as the default.

lockfile/utils/src/pkgSnapshotToResolution.ts

Refactor (2) +23 / -1
index.tsExport resolutionNeedsIntegrity and isGitHostedTarballUrl from lockfile utils +1/-1

Export resolutionNeedsIntegrity and isGitHostedTarballUrl from lockfile utils

• Re-exports the new/shared integrity predicate and git-hosted tarball URL helper so other packages can share a single implementation.

lockfile/utils/src/index.ts

toLockfileResolution.tsIntroduce resolutionNeedsIntegrity helper for consistent integrity rules +22/-0

Introduce resolutionNeedsIntegrity helper for consistent integrity rules

• Adds a documented helper that determines when a tarball resolution must include integrity, excluding file: and git-hosted tarballs. This removes duplicated logic across call sites and keeps bypass rules consistent.

lockfile/utils/src/toLockfileResolution.ts

Tests (2) +99 / -0
brokenLockfileIntegrity.tsAdd regression test for recomputing missing integrity vs frozen failure +38/-0

Add regression test for recomputing missing integrity vs frozen failure

• Adds a test that simulates a lockfile missing integrity for a registry tarball. Verifies frozen installs fail, while non-frozen installs recompute integrity and persist it back into the lockfile.

installing/deps-installer/test/brokenLockfileIntegrity.ts

index.tsTest integrity recomputation when store already has the package +61/-0

Test integrity recomputation when store already has the package

• Adds a test that seeds the store with a normal request, then resolves the same package with missing integrity. Ensures the requester refetches and returns a resolution with computed sha512 integrity despite the cache hit.

installing/package-requester/test/index.ts

Other (3) +7 / -0
package.jsonAdd lockfile.utils dependency for shared integrity logic +1/-0

Add lockfile.utils dependency for shared integrity logic

• Declares @pnpm/lockfile.utils as a workspace dependency so package-requester can use the centralized integrity predicate.

installing/package-requester/package.json

tsconfig.jsonWire TypeScript project reference to lockfile/utils +3/-0

Wire TypeScript project reference to lockfile/utils

• Adds a TS project reference so package-requester can compile against @pnpm/lockfile.utils in the workspace build graph.

installing/package-requester/tsconfig.json

pnpm-lock.yamlUpdate workspace lockfile for new internal dependency +3/-0

Update workspace lockfile for new internal dependency

• Updates the repository lockfile to include @pnpm/lockfile.utils as a dependency of installing/package-requester.

pnpm-lock.yaml

Copilot AI 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.

Pull request overview

This PR fixes installs against registries that can’t provide dist.integrity by computing the tarball integrity during fetch and persisting it back into the lockfile (TypeScript implementation only, with pacquet follow-up noted in the PR description).

Changes:

  • Introduces resolutionNeedsIntegrity() in @pnpm/lockfile.utils to centralize the “tarball integrity is required” decision.
  • Allows the deps resolution path (non-frozen installs) to carry integrity-less resolutions so the fetch pipeline can download the tarball, compute integrity, and write it back.
  • Adds tests covering integrity computation (including the “already in store but missing integrity in resolver output” case) and verifies frozen installs still fail closed.

Reviewed changes

Copilot reviewed 10 out of 11 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
pnpm-lock.yaml Adds @pnpm/lockfile.utils workspace dependency linkage.
lockfile/utils/src/toLockfileResolution.ts Adds resolutionNeedsIntegrity() helper to consolidate integrity requirement logic.
lockfile/utils/src/pkgSnapshotToResolution.ts Adds allowMissingIntegrity option to permit repair flows to proceed without throwing.
lockfile/utils/src/index.ts Exports the new helper (and isGitHostedTarballUrl) from @pnpm/lockfile.utils.
installing/package-requester/tsconfig.json Adds TS project reference to lockfile/utils.
installing/package-requester/test/index.ts Adds coverage for computing integrity when the package is already in the store but resolver omits integrity.
installing/package-requester/src/packageRequester.ts Forces fetch + writes computed integrity back into the tarball resolution; adds integrity-missing enforcement and refetch behavior changes.
installing/package-requester/package.json Adds dependency on @pnpm/lockfile.utils.
installing/deps-resolver/src/resolveDependencies.ts Reads lockfile resolutions with allowMissingIntegrity: true for repair flows.
installing/deps-installer/test/brokenLockfileIntegrity.ts Adds an end-to-end test for repairing missing integrity on non-frozen installs and failing on frozen installs.
installing/deps-installer/src/install/index.ts Forces full resolution on non-frozen installs when the wanted lockfile contains missing tarball integrity.
Files not reviewed (1)
  • pnpm-lock.yaml: Generated file

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

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

qodo-free-for-open-source-projects Bot commented Jun 18, 2026 •

Copy link
Copy Markdown

Code Review by Qodo

🐞 Bugs (13) 📘 Rule violations (0) 📎 Requirement gaps (1) 📜 Skill insights (0)

Context used

Grey Divider


Action required

1. Git tarball overmatch 🐞 Bug ⛨ Security
Description
isGitHostedTarballUrl() treats any URL on the allowlisted hosts as git-hosted if it merely
contains the substring tar.gz, and that classification is used to exempt the resolution from the
npm lockfile verifier’s integrity-required checks. A crafted lockfile can therefore bypass the new
fail-closed integrity gate by using a non-archive or mutable URL (or a ref/branch-based archive)
under those hosts, leading to unverified bytes being accepted for installation.
Code

pnpm11/resolving/resolver-base/src/index.ts[R86-104]

+const GIT_HOSTED_TARBALL_HOSTS = [
+  'https://codeload.github.com/',
+  'https://bitbucket.org/',
+  'https://gitlab.com/',
+]
+
+/**
+ * A tarball URL is git-hosted when it points at a known git provider's archive
+ * endpoint (GitHub/GitLab/Bitbucket). Schemes and hostnames are case-insensitive,
+ * so the match runs against a lowercased copy: a tampered
+ * `https://CODELOAD.GITHUB.COM/...` must not slip past as a registry-trusted
+ * tarball. Only the lowercased copy is inspected; the original URL is never rewritten.
+ */
+export function isGitHostedTarballUrl (url: string): boolean {
+  // Guard untrusted lockfile input before calling string methods.
+  if (typeof url !== 'string') return false
+  const lowerUrl = url.toLowerCase()
+  return GIT_HOSTED_TARBALL_HOSTS.some((host) => lowerUrl.startsWith(host)) && lowerUrl.includes('tar.gz')
+}
Evidence
The permissive includes('tar.gz') check can match URLs where tar.gz is not part of a real git
archive endpoint. The npm lockfile verifier uses isGitHostedTarballUrl() to exempt such entries
from registry tarball verification, so false positives here directly translate into
missing-integrity enforcement bypasses.

pnpm11/resolving/resolver-base/src/index.ts[86-104]
pnpm11/resolving/npm-resolver/src/createNpmResolutionVerifier.ts[952-965]

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

## Issue description
`isGitHostedTarballUrl()` currently matches on `startsWith(allowedHost)` and `includes('tar.gz')`. This is too permissive because it can classify non-archive URLs (or mutable ref/branch archives) as “git-hosted”, which then exempts them from integrity-required verification in `createNpmResolutionVerifier`.
### Issue Context
The PR moves enforcement of missing tarball integrity into the npm resolver’s lockfile verifier and uses `isGitHostedTarballUrl()` as part of the exemption logic for “git-hosted” tarballs. If the predicate has false positives, a tampered lockfile can bypass the new fail-closed integrity requirement.
### Fix Focus Areas
- pnpm11/resolving/resolver-base/src/index.ts[86-104]
### How to fix
1. Parse the URL (`new URL(url)`) and match **hostname + pathname**, not a substring over the full URL string.
2. Require the pathname to end with `.tar.gz` (or otherwise match known archive endpoint path shapes) so query-string occurrences of `tar.gz` don’t qualify.
3. Consider additionally constraining the “ref” segment for these archive URLs to an immutable form (e.g. full 40-hex SHA) if the security model depends on commit anchoring; otherwise require integrity for non-SHA refs.
4. Add unit tests for false-positive cases (e.g. `https://gitlab.com/...?...=tar.gz`, or non-archive paths containing `tar.gz`) to ensure they do **not** classify as git-hosted.

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


2. Non-semver skips origin checks 🐞 Bug ⛨ Security
Description
createNpmResolutionVerifier() returns ok:true when version is not valid semver, which skips
registry-origin checks (tarball URL binding / trust / minimum age) even for registry-tarball-shaped
resolutions. Because nameVerFromPkgSnapshot prefers pkgSnapshot.version, a tampered lockfile can
set a non-semver version to evade these registry checks while keeping a registry-style
depPath/resolution.
Code

pnpm11/resolving/npm-resolver/src/createNpmResolutionVerifier.ts[R206-212]

if (nonSemverVersion != null) return { ok: true }
+
+    // The registry policy checks below query the registry by version, so they need a
+    // valid semver. A registry entry with a non-semver version still carries a verified
+    // integrity (checked above), so it isn't rejected here — just not policed further.
if (!semver.valid(version)) return { ok: true }
-    const tarballUrl = (resolution as { tarball?: string }).tarball
Evidence
The verifier explicitly short-circuits on non-semver version before running runTarballUrlCheck,
which is the mechanism that binds a lockfile tarball URL to registry metadata. Because
nameVerFromPkgSnapshot() prefers pkgSnapshot.version, a lockfile edit can feed a non-semver
version into the verifier without changing the depPath shape, thereby skipping these registry-origin
checks.

pnpm11/resolving/npm-resolver/src/createNpmResolutionVerifier.ts[182-238]
pnpm11/lockfile/utils/src/nameVerFromPkgSnapshot.ts[12-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
`createNpmResolutionVerifier()` treats a registry tarball resolution as verified once it has a non-empty `integrity`, but then returns `{ ok: true }` when `semver.valid(version)` is false. This skips the registry-origin policy checks (tarball URL binding / trust / minimum age), enabling a lockfile-tampering bypass by altering only the snapshot’s `version` field.
### Issue Context
The verifier already documents that tarball URL binding prevents a `name@version` identity from fronting bytes from an attacker-chosen URL (even with a matching integrity). However, that protection is currently conditional on the `version` being semver-valid.
### Fix Focus Areas
- pnpm11/resolving/npm-resolver/src/createNpmResolutionVerifier.ts[182-242]
- pnpm11/lockfile/utils/src/nameVerFromPkgSnapshot.ts[12-22]
### Recommended fix
- In `createNpmResolutionVerifier.verify()`, when `isRegistryTarballResolution(resolution)` is true AND `nonSemverVersion == null` AND `!semver.valid(version)`, **fail closed** with a dedicated violation (new code) or an existing appropriate code, instead of returning `{ ok: true }`.
- Alternatively (or additionally), harden `nameVerFromPkgSnapshot()` / candidate collection so a registry-style depPath cannot be paired with a non-semver `pkgSnapshot.version` (ignore the snapshot override or surface a structural violation).

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


3. Non-string integrity persists 🐞 Bug ⛨ Security
Description
When a remote-tarball resolution has a tampered non-string truthy integrity (e.g. true), the new
resolutionNeedsFetch path triggers a download but the computed integrity is not written back
because the code uses a truthiness check (!(resolution as TarballResolution).integrity). This can
keep an invalid integrity type alive (and potentially forward it into checksum verification),
causing install-time crashes/DoS or a still-unverifiable lockfile snapshot.
Code

pnpm11/installing/package-requester/src/packageRequester.ts[R358-361]

+      populating ??= fetchResult.fetching().then((fetchedResult) => {
+        if (fetchedResult.integrity != null && !(resolution as TarballResolution).integrity) {
+          (resolution as TarballResolution).integrity = fetchedResult.integrity
+        }
Evidence
The remote-tarball fetcher explicitly classifies non-string integrity as “missing” (triggering the
fetch/compute path), but resolveAndFetch() only writes the computed integrity when the existing
integrity is falsy, so a truthy non-string (e.g. true) prevents overwrite. Separately, the tarball
fetcher forwards resolution.integrity to the downloader, and fetchToStore() prefers
opts.pkg.resolution.integrity ?? fetchedPackage.integrity, so a non-nullish non-string integrity
can override the computed checksum and propagate invalid types downstream.

pnpm11/fetching/tarball-fetcher/src/index.ts[63-73]
pnpm11/fetching/tarball-fetcher/src/index.ts[82-114]
pnpm11/installing/package-requester/src/packageRequester.ts[269-372]
pnpm11/installing/package-requester/src/packageRequester.ts[667-683]

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

## Issue description
The new missing-integrity repair flow correctly *detects* non-string/empty `integrity` as “missing”, but later stages still treat any truthy `resolution.integrity` as “present”, so a tampered non-string value (e.g. YAML `integrity: true`) blocks repair and can be forwarded into checksum handling.
### Issue Context
- `remoteTarballFetcher.resolutionNeedsFetch` intentionally treats non-string integrity as missing.
- However, the write-back logic in `packageRequester.resolveAndFetch()` only overwrites when `resolution.integrity` is falsy, and `fetchToStore()` prefers `opts.pkg.resolution.integrity` via `??`, so a boolean/object integrity can persist and/or override the computed string integrity.
### Fix Focus Areas
- pnpm11/installing/package-requester/src/packageRequester.ts[269-372]
- pnpm11/installing/package-requester/src/packageRequester.ts[667-683]
- pnpm11/fetching/tarball-fetcher/src/index.ts[70-115]
### What to change
1. Treat “integrity present” as **non-empty string only** everywhere in this repair path.
- Replace checks like `!(resolution as TarballResolution).integrity` with something like:
- `const hasValidIntegrity = typeof (resolution as any).integrity === 'string' && (resolution as any).integrity.length > 0`
- overwrite when `!hasValidIntegrity`.
2. Ensure the value passed down to the tarball downloader is either a valid string integrity or `undefined`.
- For the `mustComputeIntegrity` / `resolutionNeedsFetch` path, force `expected integrity` to `undefined` (so the downloader computes from bytes) rather than passing through a non-string.
3. Ensure the returned `integrity` from fetch prefers the computed string integrity when the resolution’s integrity is not a valid non-empty string (avoid `??` preferring booleans/objects).

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


View more (9)
4. Forged gitHosted bypass 🐞 Bug ⛨ Security
Description
createNpmResolutionVerifier() and classifyResolution() treat lockfile-provided gitHosted: true
as sufficient to exempt a tarball-shaped resolution from the new missing-integrity enforcement. A
tampered lockfile can set gitHosted: true on an arbitrary http(s) tarball and bypass
MISSING_TARBALL_INTEGRITY, causing pnpm (and pacquet’s analogous path) to fetch bytes without an
expected integrity hash.
Code

pnpm11/resolving/npm-resolver/src/createNpmResolutionVerifier.ts[R964-973]

+function isRegistryTarballResolution (resolution: Resolution | unknown): boolean {
if (resolution == null || typeof resolution !== 'object') return false
-  // Only plain tarball resolutions (npm registry / named registries) have no
-  // `type` field. Git / directory / binary / custom resolutions all carry one.
if ('type' in resolution && (resolution as { type?: unknown }).type != null) return false
-  // Git-hosted tarballs (codeload/gitlab/bitbucket) are special-cased in
-  // the resolver and aren't subject to release-age policy.
if ('gitHosted' in resolution && (resolution as { gitHosted?: boolean }).gitHosted) return false
const tarball = (resolution as { tarball?: unknown }).tarball
if (typeof tarball === 'string') {
-    // Local/non-registry tarballs (for example `file:`) have no packument
-    // metadata, so minimumReleaseAge/trustPolicy verification cannot apply.
+    // A git-hosted archive URL (codeload/gitlab/bitbucket) is commit-anchored and carries no
+    // integrity. The `gitHosted` flag is the primary signal, but legacy lockfiles record
+    // these without it, so detect them by URL too — matching `classifyResolution`.
+    if (isGitHostedTarballUrl(tarball)) return false
Evidence
The verifier skips registry-tarball enforcement when gitHosted is truthy, and resolution
classification likewise treats gitHosted: true as sufficient to classify a tarball as git-hosted;
assertFetchableResolution then exempts non-remoteTarball kinds from integrity checks. Pacquet’s
new fill-missing-integrity logic similarly treats the git_hosted flag as primary when deciding
whether to compute integrity.

pnpm11/resolving/npm-resolver/src/createNpmResolutionVerifier.ts[958-977]
pnpm11/resolving/resolver-base/src/index.ts[86-141]
pnpm11/lockfile/utils/src/pkgSnapshotToResolution.ts[78-98]
pacquet/crates/package-manager/src/prefetching_resolver.rs[168-193]

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

## Issue description
Lockfiles are untrusted input, but `gitHosted: true` currently causes registry/http(s) tarball resolutions to be treated as “git-hosted” and exempt from integrity-required verification. This allows a tampered lockfile to mark any arbitrary tarball as git-hosted and skip the new missing-integrity gate.
## Issue Context
The verifier’s `isRegistryTarballResolution()` excludes entries when `gitHosted` is truthy, and fetch gating (`classifyResolution` → `assertFetchableResolution`) also treats `gitHosted: true` as authoritative.
## Fix Focus Areas
- pnpm11/resolving/npm-resolver/src/createNpmResolutionVerifier.ts[958-977]
- pnpm11/resolving/resolver-base/src/index.ts[99-150]
- pnpm11/lockfile/utils/src/pkgSnapshotToResolution.ts[78-99]
## Suggested fix
1. Treat `gitHosted: true` as a *hint*, not an exemption, unless the `tarball` URL matches the known git-hosted archive patterns (`isGitHostedTarballUrl`).
2. If `gitHosted: true` is present but `tarball` is missing or does not match `isGitHostedTarballUrl`, either:
- classify/verify it as a normal remote tarball (thus requiring integrity), or
- fail closed with a dedicated violation (preferred: clearer diagnostics) saying the lockfile claims `gitHosted` but the URL is not a recognized git-hosted archive.
3. Mirror the same rule in the pacquet port if needed to keep parity.

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


5. TarballExtractMessage missing pkgId 📎 Requirement gap ➹ Performance
Description
The tarball worker message does not include pkgId on the integrity-computation path, so the worker
cannot write store-index entries under storeIndexKey(computedIntegrity, pkgId) without parsing it
from fallback key strings. This breaks the compliance requirement needed to support correct
post-computation store-index writes (and can contribute to avoidable re-downloads).
Code

pnpm11/store/controller-types/src/index.ts[R81-98]

+  /**
+   * The resolution can't be completed without a fresh download (e.g. a registry tarball
+   * whose integrity must be computed from the bytes), so the store copy must not be
+   * reused. Determined by the fetcher's `resolutionNeedsFetch`.
+   */
+  mustComputeIntegrity?: boolean
+  /**
+   * The fetcher already selected for this resolution by the caller, so the fetch path can
+   * reuse it instead of running `pickFetcher` (and a custom fetcher's async `canFetch`) a
+   * second time. Local-only optimization: set by `package-requester` for non-`variations`
+   * resolutions; absent for `variations` (the variant is picked at fetch time) and for
+   * callers reached over the store server (functions don't cross the IPC boundary), where
+   * the fetch path falls back to selecting the fetcher itself.
+   */
+  pickedFetcher?: PickedFetcher
ignoreScripts?: boolean
lockfileDir: string
pkg: PkgNameVersion & {
Evidence
Compliance ID 3 requires threading pkgId into the tarball worker message so the worker can write
store-index entries under the integrity-based key without deriving pkgId from fallback key
strings. However, TarballExtractMessage contains no pkgId field, and the worker emits index
writes only for the provided filesIndexFile, while the integrity-based key format explicitly
requires pkgId.

Tarball worker must receive pkgId explicitly when computing integrity to support correct store-index writes
pnpm11/worker/src/types.ts[14-29]
pnpm11/worker/src/start.ts[223-232]
pnpm11/store/index/src/index.ts[60-98]
pnpm11/store/controller-types/src/index.ts[77-104]

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

## Issue description
`TarballExtractMessage` lacks an explicit `pkgId` field, so when integrity is computed from downloaded bytes the tarball worker cannot reliably emit an additional store-index write under `storeIndexKey(computedIntegrity, pkgId)`.
## Issue Context
- The PR introduces an explicit integrity-computation path (`mustComputeIntegrity`) but does not propagate `pkgId` into the worker message.
- The worker currently writes index rows keyed only by `filesIndexFile`, and the integrity-based key format needs both `integrity` and `pkgId`.
## Fix Focus Areas
- pnpm11/store/controller-types/src/index.ts[77-104]
- pnpm11/worker/src/types.ts[14-29]
- pnpm11/worker/src/index.ts[172-213]
- pnpm11/worker/src/start.ts[207-233]
- pnpm11/store/index/src/index.ts[60-98]

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


6. Git tarballs misclassified 🐞 Bug ≡ Correctness
Description
createNpmResolutionVerifier() classifies type-less http(s) tarball resolutions as “registry
tarballs” unless gitHosted: true is present, so git-hosted tarball lockfile entries that omit this
flag are rejected with MISSING_TARBALL_INTEGRITY. This breaks installs from existing/legacy
lockfiles (including this repo’s with-git-protocol-dep fixture) where git-hosted tarballs
intentionally have no integrity.
Code

pnpm11/resolving/npm-resolver/src/createNpmResolutionVerifier.ts[R957-972]

+// A plain registry/named-registry tarball: no `type` (git/directory/binary/custom all
+// carry one), not git-hosted (codeload/gitlab/bitbucket — special-cased in the resolver),
+// and not a non-http tarball such as `file:` (no packument to verify against). Unlike a
+// "has a fetchable artifact" check, this does NOT require a `tarball` or `integrity`
+// field to be present: a canonical entry whose integrity was stripped down to `{}` is
+// still a registry tarball that must carry one, and the integrity check needs to catch it.
+function isRegistryTarballResolution (resolution: Resolution | unknown): boolean {
if (resolution == null || typeof resolution !== 'object') return false
-  // Only plain tarball resolutions (npm registry / named registries) have no
-  // `type` field. Git / directory / binary / custom resolutions all carry one.
if ('type' in resolution && (resolution as { type?: unknown }).type != null) return false
-  // Git-hosted tarballs (codeload/gitlab/bitbucket) are special-cased in
-  // the resolver and aren't subject to release-age policy.
if ('gitHosted' in resolution && (resolution as { gitHosted?: boolean }).gitHosted) return false
const tarball = (resolution as { tarball?: unknown }).tarball
if (typeof tarball === 'string') {
-    // Local/non-registry tarballs (for example `file:`) have no packument
-    // metadata, so minimumReleaseAge/trustPolicy verification cannot apply.
const protocol = tryParseUrl(tarball)?.protocol
if (protocol != null && protocol !== 'http:' && protocol !== 'https:') return false
}
-  return 'tarball' in resolution || 'integrity' in resolution
+  return true
Evidence
The verifier’s isRegistryTarballResolution() does not exclude git-hosted URLs unless the
gitHosted flag is present, so a lockfile entry like the fixture’s
https://codeload.github.com/.../tar.gz/... (no integrity, no gitHosted) will be treated as a
registry tarball and rejected by the new missing-integrity rule. The repo also contains
tests/fixtures that rely on such lockfile shapes being installable.

pnpm11/resolving/npm-resolver/src/createNpmResolutionVerifier.ts[957-972]
pnpm11/fixtures/with-git-protocol-dep/pnpm-lock.yaml[13-20]
pnpm11/installing/deps-installer/test/install/fromRepo.ts[331-360]
pnpm11/resolving/resolver-base/src/index.ts[86-105]

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

## Issue description
`isRegistryTarballResolution()` only exempts entries with an explicit `gitHosted: true` field, but git-hosted tarball URLs can exist in lockfiles without that flag (legacy / fixtures). Those entries are now treated as registry tarballs and fail the new missing-integrity check, even though git-hosted tarballs are intended to remain integrity-exempt.
### Issue Context
A repo fixture already contains a `codeload.github.com/.../tar.gz/...` tarball resolution without `integrity` and without `gitHosted: true`. The verifier currently does not use URL-based git-hosted detection, despite the repo having `isGitHostedTarballUrl()` for exactly this purpose.
### Fix Focus Areas
- pnpm11/resolving/npm-resolver/src/createNpmResolutionVerifier.ts[957-972]
- pnpm11/resolving/npm-resolver/test/createNpmResolutionVerifier.test.ts[303-387]
- pnpm11/resolving/resolver-base/src/index.ts[86-105]
### Suggested fix
1. Import `isGitHostedTarballUrl` from `@pnpm/resolving.resolver-base` in `createNpmResolutionVerifier.ts`.
2. Update `isRegistryTarballResolution()` to return `false` (exempt) when `tarball` is a string and `isGitHostedTarballUrl(tarball)` is `true` (in addition to the existing `gitHosted` flag check).
3. Add a unit test ensuring a git-hosted tarball URL without `gitHosted: true` is **not** rejected for missing integrity (and does not undergo registry policy checks).

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


7. Fetch before integrity enforcement 🐞 Bug ⛨ Security
Description
pkgSnapshotToResolution() no longer rejects integrity-less registry tarball snapshots, but
lockfileToDepGraph() can call storeController.fetchPackage() using that resolution before
headlessInstall() awaits verifyLockfile, allowing downloads to start from an integrity-less
(tampered/invalid) lockfile entry. This weakens the intended “fail-closed” invariant for missing
integrity and can lead to unverified bytes being fetched (or at least network attempts) prior to
verification rejection, and some callers (e.g. self-updater) don’t pass verifyLockfile at all.
Code

pnpm11/lockfile/utils/src/pkgSnapshotToResolution.ts[R12-29]

+// A registry tarball entry that lacks an `integrity` is rejected by the npm
+// resolver's lockfile verifier (`MISSING_TARBALL_INTEGRITY`), so the read-side
+// enforcement lives there rather than in this pure snapshot→resolution conversion.
export function pkgSnapshotToResolution (
depPath: string,
pkgSnapshot: PackageSnapshot,
registries: Registries
): Resolution {
const resolution = pkgSnapshot.resolution as TarballResolution
-  // Tarball-shaped resolutions (no `type` field) must carry `integrity`,
-  // except where the URL itself anchors the bytes:
-  //   - `file:` tarballs (local file on the user's machine; integrity
-  //     adds nothing the user doesn't already control).
-  //   - Git-hosted tarballs (URL contains the commit SHA; git's content-
-  //     addressed model binds the bytes to the commit). The `gitHosted`
-  //     flag may be absent on legacy lockfiles, so fall back to a URL
-  //     match — same logic as `toLockfileResolution`.
-  // For any other tarball entry a missing integrity is what a tampered
-  // lockfile looks like: the worker would mint a fresh integrity from
-  // whatever bytes the URL returned, so we fail closed here. Pacquet
-  // enforces the same invariant via
-  // `pacquet_package_manager::missing_tarball_integrity`.
-  if (
-    resolution.type == null &&
-    resolution.integrity == null &&
-    !resolution.tarball?.startsWith('file:') &&
-    !(resolution.gitHosted === true || (resolution.tarball != null && isGitHostedTarballUrl(resolution.tarball)))
-  ) {
-    throw new PnpmError('MISSING_TARBALL_INTEGRITY',
-      `Cannot install package "${depPath}": its lockfile entry has no "integrity" field, so pnpm cannot verify the downloaded tarball.`,
-      { hint: 'The lockfile may be corrupted or have been tampered with. Restore it from a trusted source, or delete it and re-run installation without --frozen-lockfile to regenerate.' }
-    )
+  if (resolution.tarball != null && typeof resolution.tarball !== 'string') {
+    // Lockfiles are untrusted; a non-string `tarball` (e.g. a YAML array) would otherwise be
+    // string-coerced into an attacker-controlled URL by `new url.URL(...)`, and crash the
+    // string checks below. Fail closed.
+    throw new PnpmError('INVALID_TARBALL_RESOLUTION',
+      `Cannot install package "${depPath}": its lockfile entry has a non-string "tarball" field.`)
}
if (
Boolean(resolution.type) ||
Evidence
The conversion helper explicitly documents that missing-integrity enforcement was moved to the
verifier, but fetches from lockfile snapshots can happen earlier via lockfileToDepGraph() and
storeController.fetchPackage(), while headlessInstall() only awaits verifyLockfile later (and
some callers don’t provide it).

pnpm11/lockfile/utils/src/pkgSnapshotToResolution.ts[12-34]
pnpm11/deps/graph-builder/src/lockfileToDepGraph.ts[282-295]
pnpm11/installing/deps-restorer/src/index.ts[626-628]
pnpm11/engine/pm/commands/src/self-updater/installPnpm.ts[241-301]

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

## Issue description
`pkgSnapshotToResolution()` no longer enforces that registry/http(s) tarball entries have a non-empty string `integrity`, relying on the npm resolver verifier instead. However, some flows begin fetching packages from lockfile-derived resolutions before (or without) awaiting lockfile verification, which can allow integrity-less lockfile entries to trigger network fetches (and potentially accept bytes without an expected checksum), undermining the intended fail-closed behavior.
## Issue Context
- `headlessInstall()` only awaits `verifyLockfile?.()` at specific gates (before lifecycle scripts/builds), while package fetching from the lockfile can happen earlier during dep graph materialization.
- At least one caller (`installFromLockfile()` in the self-updater) calls `headlessInstall()` without providing `verifyLockfile`, so the verifier-based enforcement won’t run.
## Fix Focus Areas
- pnpm11/installing/package-requester/src/packageRequester.ts[580-607]
- pnpm11/deps/graph-builder/src/lockfileToDepGraph.ts[282-295]
- pnpm11/installing/deps-restorer/src/index.ts[626-628]
- pnpm11/engine/pm/commands/src/self-updater/installPnpm.ts[241-301]
## Suggested fix direction
Implement a **fetch-boundary fail-closed guard**:
- In the store fetch path (e.g. `fetchToStore()` / `doFetchToStore()`), if the resolved package is a registry/http(s) tarball and `integrity` is missing/empty/non-string, then **throw** `MISSING_TARBALL_INTEGRITY` **unless** `opts.mustComputeIntegrity === true` (the explicit “write-side compute” path).
- This keeps the new feature (compute integrity during resolution when explicitly requested) while guaranteeing that integrity-less lockfile materialization cannot start downloads even if lockfile verification is deferred/omitted.
- Optionally, ensure headlessInstall/self-updater passes a verifier hook, but the fetch-boundary guard is the robust defense-in-depth.

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


8. Scoped auth not applied 🐞 Bug ☼ Reliability
Description
pacquet’s PrefetchingResolver::fill_missing_integrity() computes integrity by downloading the
tarball via FetchTarballForResolution, but that helper uses the tarball URL as the “package id”
for auth-header selection. This can skip scope-specific credentials (or pick the wrong one) and make
integrity computation fail for private/scoped packages even when the install-time fetch would
succeed.
Code

pacquet/crates/package-manager/src/prefetching_resolver.rs[R195-217]

+        let package_url = tarball.tarball.clone();
+
+        // Singleflight per URL: the same integrity-less tarball can arrive on many edges,
+        // so compute its integrity once and share it. Clone the cell's `Arc` out of the map
+        // before awaiting so the shard lock isn't held across the download.
+        let cell = Arc::clone(&self.ctx.integrity_cache.entry(package_url.clone()).or_default());
+        let integrity = cell
+            .get_or_try_init(|| async {
+                // Claim the URL so `maybe_kickoff_download` doesn't spawn a second fetch:
+                // this one already warms the mem cache.
+                self.ctx.spawned_urls.insert(package_url.clone());
+                let resolved = FetchTarballForResolution {
+                    http_client: &self.ctx.http_client,
+                    store_dir: self.ctx.store_dir,
+                    store_index_writer: self.ctx.store_index_writer.clone(),
+                    package_url: &package_url,
+                    auth_headers: &self.ctx.auth_headers,
+                    retry_opts: self.ctx.retry_opts,
+                }
+                .run::<SilentReporter>(Some(&self.ctx.mem_cache))
+                .await
+                .map_err(|err| Box::new(err) as ResolveError)?;
+                Ok::<_, ResolveError>(resolved.integrity)
Evidence
FetchTarballForResolution::run() passes package_url as the package_id argument, and the
tarball downloader uses that argument to choose auth headers via
AuthHeaders::for_url_with_package. Since AuthHeaders::for_url_with_package only activates
scope-specific credential lookup when the provided pkg name is scoped, using a URL string prevents
scope matching and can break scoped-private tarball downloads during integrity fill.

pacquet/crates/package-manager/src/prefetching_resolver.rs[180-217]
pacquet/crates/tarball/src/lib.rs[2320-2328]
pacquet/crates/tarball/src/lib.rs[1517-1555]
pacquet/crates/network/src/auth.rs[197-229]

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

## Issue description
`fill_missing_integrity()` fetches integrity-less tarballs using `FetchTarballForResolution`, but `FetchTarballForResolution` currently feeds `auth_headers.for_url_with_package()` with `package_id = package_url`. `AuthHeaders::for_url_with_package()` only prefers scope credentials when the provided `pkg_name` is scoped (e.g. `@org/pkg`), so this resolve-time fetch can miss required scoped auth and fail.
### Issue Context
- `fill_missing_integrity()` runs during resolution (before the install pass) and blocks resolution for integrity-less tarballs, so any auth failure here prevents lockfile generation.
- `FetchTarballForResolution::run()` passes `package_url` as the `package_id` argument into the tarball download routine.
### Fix Focus Areas
- pacquet/crates/package-manager/src/prefetching_resolver.rs[180-224]
- pacquet/crates/tarball/src/lib.rs[2289-2333]
- pacquet/crates/tarball/src/lib.rs[1517-1555]
- pacquet/crates/network/src/auth.rs[197-229]
### Suggested fix
- Thread an explicit package name (or `name@version`) into `FetchTarballForResolution` (or into its `run()` call) and use that value for `auth_headers.for_url_with_package(url, Some(pkg_name))`.
- In `fill_missing_integrity()`, when `result.name_ver` is present (expected for registry resolutions), pass `name_ver.name` (scoped when applicable). Fall back to the current URL placeholder only when the package name is genuinely unknown (direct URL tarball deps).

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


9. Integrity store key mismatch 🐞 Bug ➹ Performance
Description
When resolutionNeedsFetch is true, resolveAndFetch() defers populating resolution.integrity
until fetching() is awaited, but fetchToStore() computes filesIndexFile before the fetch using
pickStoreIndexKey() (which falls back to the git-hosted key when integrity is missing). The worker
then writes the index under that fallback key, so subsequent installs that now have integrity
compute a different filesIndexFile and miss the stored package, triggering unnecessary
re-downloads and duplicated store index entries.
Code

pnpm11/installing/package-requester/src/packageRequester.ts[R338-352]

+  // Fill in the computed integrity when the fetch is awaited instead of blocking resolution
+  // on the download here. The resolver awaits these (flagged by `resolutionNeedsFetch` on
+  // the response) before building the lockfile snapshot and virtual-store paths.
+  let fetching = fetchResult.fetching
+  if (resolutionNeedsFetch) {
+    let populating: Promise<PkgRequestFetchResult> | undefined
+    fetching = () => {
+      populating ??= fetchResult.fetching().then((fetchedResult) => {
+        if (fetchedResult.integrity != null && !(resolution as TarballResolution).integrity) {
+          (resolution as TarballResolution).integrity = fetchedResult.integrity
+        }
+        return fetchedResult
+      })
+      return populating
+    }
Evidence
The requester computes filesIndexFile before fetching based on whether resolution.integrity is
present; when missing, it falls back to a pkgId-based key. The worker always persists the index
under the filesIndexFile key it was given, even if it computed integrity itself, so later installs
(with integrity present) will compute a different key and fail to reuse the previously stored entry.

pnpm11/installing/package-requester/src/packageRequester.ts[241-353]
pnpm11/installing/package-requester/src/packageRequester.ts[397-417]
pnpm11/store/index/src/index.ts[61-98]
pnpm11/worker/src/start.ts[186-233]

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

## Issue description
Packages whose tarball integrity is computed during fetch are stored/indexed under a pre-fetch fallback `filesIndexFile` (git-hosted key) because integrity is not yet present when `pickStoreIndexKey()` runs. After the lockfile is repaired with the computed integrity, subsequent installs compute an integrity-based `filesIndexFile` and cannot find the previously stored index entry, causing repeated downloads and store-index duplication.
### Issue Context
- `getFilesIndexFilePath()` computes `filesIndexFile` up front from `pickStoreIndexKey(resolution, pkgId)`.
- `pickStoreIndexKey()` uses `gitHostedStoreIndexKey(pkgId, built)` whenever `!resolution.integrity`.
- The tarball worker writes the store index under the provided `filesIndexFile` key even when it computes integrity from bytes.
- In this PR, `resolution.integrity` is populated only after awaiting `fetching()` for `resolutionNeedsFetch` cases.
### Fix Focus Areas
- pnpm11/installing/package-requester/src/packageRequester.ts[241-353]
- pnpm11/installing/package-requester/src/packageRequester.ts[397-417]
- pnpm11/store/index/src/index.ts[61-98]
- pnpm11/worker/src/start.ts[186-233]
### Suggested fix approach
Ensure that when integrity is computed from the downloaded bytes, the store index is also written under the *integrity-based* key (`storeIndexKey(computedIntegrity, pkgId)`), so future installs can reuse the store. A practical place to do this without changing higher-level APIs is in the tarball worker:
- When `integrity` is not provided and the worker computes `calcIntegrity(buffer)`, additionally emit a second `indexWrites` entry keyed by `${computedIntegrity}\t${pkgId}`.
- `pkgId` can be derived from the fallback `filesIndexFile` format (it is `${pkgId}\t(built|not-built)` when `pickStoreIndexKey()` fell back).
- Keep the original write for backward compatibility (or add a deletion mechanism if available) but make sure the integrity-keyed write exists.

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


10. NonSemver skips integrity check 🐞 Bug ⛨ Security
Description
In createNpmResolutionVerifier(), the verifier returns ok:true when ctx.nonSemverVersion is set
before running the new MISSING_TARBALL_INTEGRITY check, so URL-keyed tarball lockfile entries (or a
tampered lockfile key) can bypass integrity-required verification. This undermines the intended
fail-closed behavior and allows proceeding to fetch/compute integrity later instead of rejecting the
untrusted lockfile entry up front.
Code

pnpm11/resolving/npm-resolver/src/createNpmResolutionVerifier.ts[R182-201]

+    // URL/git-keyed entries are deliberate non-registry deps. They anchor their bytes
+    // another way and a registry lookup would 404, so they're exempt.
if (nonSemverVersion != null) return { ok: true }
+    // Git / directory / binary / custom / file: / git-hosted resolutions anchor their
+    // bytes another way and are exempt from the registry-tarball checks too.
+    if (!isRegistryTarballResolution(resolution)) return { ok: true }
+
+    // A registry tarball is only verifiable against its integrity, so reject any entry
+    // whose integrity isn't a non-empty string: missing, `""`, or a non-string truthy value
+    // from a tampered YAML lockfile (which would otherwise pass a truthiness check, then
+    // crash in the worker's `parseIntegrity`). Checked before the semver guard so a
+    // non-semver `version` can't dodge it. Pacquet enforces the same invariant.
+    const integrity = (resolution as { integrity?: unknown }).integrity
+    if (typeof integrity !== 'string' || integrity.length === 0) {
+      return {
+        ok: false,
+        code: MISSING_TARBALL_INTEGRITY_VIOLATION_CODE,
+        reason: 'has no "integrity" field, so its downloaded tarball cannot be verified',
+      }
+    }
Evidence
The verifier currently returns early for nonSemverVersion before reaching the integrity-required
check; the lockfile verification gate passes nonSemverVersion from depPath into the verifier; and
the package requester later computes/populates integrity during fetching, meaning a lockfile entry
can bypass fail-closed verification and be “healed” by download instead of being rejected.

pnpm11/resolving/npm-resolver/src/createNpmResolutionVerifier.ts[181-201]
pnpm11/installing/deps-installer/src/install/verifyLockfileResolutions.ts[357-365]
pnpm11/installing/deps-installer/src/install/verifyLockfileResolutions.ts[379-401]
pnpm11/installing/deps-installer/src/install/verifyLockfileResolutions.ts[427-437]
pnpm11/installing/package-requester/src/packageRequester.ts[268-282]
pnpm11/installing/package-requester/src/packageRequester.ts[338-352]

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

## Issue description
`createNpmResolutionVerifier.verify()` short-circuits on `nonSemverVersion` before enforcing the new missing-tarball-integrity rule, so URL-/git-keyed lockfile entries can avoid the integrity-required gate.
## Issue Context
Even when an entry is URL-keyed, an HTTP(S) tarball resolution still needs a non-empty `integrity` to be verifiable. The verifier can enforce integrity without doing any registry lookup.
## Fix Focus Areas
- pnpm11/resolving/npm-resolver/src/createNpmResolutionVerifier.ts[181-207]
### Implementation guidance
- Reorder logic so that for any `isRegistryTarballResolution(resolution) === true`, you first validate `integrity` is a non-empty string and emit `MISSING_TARBALL_INTEGRITY_VIOLATION_CODE` when missing/invalid.
- Only after the integrity check, apply the `nonSemverVersion` short-circuit to skip the registry-backed policy checks (tarball URL binding, age, trust) that would 404 for non-registry deps.
- Add/adjust tests to cover a URL-keyed tarball entry missing integrity being rejected by the verifier (or otherwise explicitly document and enforce the intended behavior).

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


11. Non-string tarball crashes 🐞 Bug ⛨ Security
Description
classifyResolution() calls startsWith() and toLowerCase() on resolution.tarball without
validating it’s a string, so a tampered lockfile (e.g. YAML tarball: []/{}) can throw a
TypeError during fetcher selection. This turns attacker-controlled lockfile data into an
install-time crash (DoS) instead of a controlled lockfile verification failure.
Code

pnpm11/resolving/resolver-base/src/index.ts[R124-132]

+export function classifyResolution (resolution: Resolution): ResolutionKind {
+  // `== null` so a tarball entry deserialized from YAML with `type: null` is treated the
+  // same as an absent `type`, instead of falling through to `custom`.
+  if (resolution.type == null) {
+    if (resolution.tarball?.startsWith('file:')) return 'localTarball'
+    if (resolution.gitHosted === true || (resolution.tarball != null && isGitHostedTarballUrl(resolution.tarball))) {
+      return 'gitHostedTarball'
+    }
+    return 'remoteTarball'
Evidence
The new shared classifyResolution() is now used by pickFetcher() for fetcher selection, but it
invokes string methods on resolution.tarball without a typeof guard. A malformed/tampered
lockfile can therefore crash pnpm before policy verification runs; the verifier code in this PR
explicitly guards against non-string tarball, highlighting the expectation that such malformed
values may occur.

pnpm11/resolving/resolver-base/src/index.ts[99-102]
pnpm11/resolving/resolver-base/src/index.ts[124-133]
pnpm11/fetching/pick-fetcher/src/index.ts[40-55]
pnpm11/resolving/npm-resolver/src/createNpmResolutionVerifier.ts[215-220]
REVIEW_GUIDE.md[32-35]

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

## Issue description
`classifyResolution()` assumes `resolution.tarball` is a string when `resolution.type == null` and uses string methods (`startsWith`, `toLowerCase` via `isGitHostedTarballUrl`). If a lockfile contains a non-string `tarball` value (possible in YAML), pnpm can crash during fetcher selection.
## Issue Context
- Lockfiles are attacker-controlled input and should not be able to trigger uncaught runtime type errors.
- `createNpmResolutionVerifier()` already defensively treats non-string `tarball` as absent to avoid deep URL parsing crashes; `classifyResolution()` should be similarly defensive.
## Fix Focus Areas
- pnpm11/resolving/resolver-base/src/index.ts[99-102]
- pnpm11/resolving/resolver-base/src/index.ts[124-133]
## Suggested approach
- In `classifyResolution()`, normalize `tarball` to `string | undefined` before calling string APIs:
- `const tarball = typeof (resolution as any).tarball === 'string' ? (resolution as any).tarball : undefined`
- Use `tarball?.startsWith('file:')` and `tarball != null && isGitHostedTarballUrl(tarball)`.
- Optionally harden `isGitHostedTarballUrl()` by accepting `unknown` (or adding a small wrapper) and returning `false` for non-strings, to make callers safer by default.

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


12. Tarball type bypasses binding 🐞 Bug ⛨ Security
Description
createNpmResolutionVerifier() treats a non-string resolution.tarball as absent and therefore
skips the tarball-URL binding check, but pkgSnapshotToResolution() later passes whatever is in
pkgSnapshot.resolution.tarball into new URL(...), which string-coerces non-strings. A tampered
lockfile can use a YAML array value for tarball (stringifies to an attacker-controlled URL) plus a
matching integrity to bypass verifier URL binding and fetch attacker-chosen bytes under a registry
name@version identity.
Code

pnpm11/resolving/npm-resolver/src/createNpmResolutionVerifier.ts[R215-220]

+    // A tampered lockfile could carry a non-string `tarball`; treat anything that isn't a
+    // string as absent so the registry routing falls back to the scope-derived default
+    // instead of throwing deep inside URL parsing.
+    const rawTarball = (resolution as { tarball?: unknown }).tarball
+    const tarballUrl = typeof rawTarball === 'string' ? rawTarball : undefined
const registry = pickRegistryForVersion(opts.registries, namedRegistryPrefixes, name, tarballUrl)
Evidence
The verifier explicitly drops non-string tarballs from consideration (skipping URL binding), while
the lockfile snapshot conversion later passes tarball into new URL(...) without a type check,
which will coerce arrays/objects to strings and can yield an attacker-controlled URL for fetching.

pnpm11/resolving/npm-resolver/src/createNpmResolutionVerifier.ts[215-233]
pnpm11/lockfile/utils/src/pkgSnapshotToResolution.ts[48-58]
pnpm11/installing/deps-resolver/src/resolveDependencies.ts[1651-1662]

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

## Issue description
The npm lockfile verifier skips tarball-URL binding when `resolution.tarball` is not a string, but later lockfile→resolution conversion may still coerce and use that value as a URL. This creates a type-confusion bypass where malformed lockfile shapes can avoid URL binding.
## Issue Context
Lockfiles are attacker-controlled input. YAML allows non-string scalars/collections (e.g. arrays) for fields like `tarball`, and JS URL constructors coerce inputs to strings.
## Fix Focus Areas
- pnpm11/resolving/npm-resolver/src/createNpmResolutionVerifier.ts[215-220]
- pnpm11/lockfile/utils/src/pkgSnapshotToResolution.ts[47-58]
### Proposed fix
1) In `createNpmResolutionVerifier.verify`, if the `tarball` key exists and is not `undefined`/`null`, require `typeof tarball === 'string'`; otherwise return `{ ok: false, code: TARBALL_URL_MISMATCH_VIOLATION_CODE (or a new INVALID_LOCKFILE_RESOLUTION/TARBALL_FIELD_TYPE code), reason: 'tarball must be a string' }`.
2) In `pkgSnapshotToResolution`, before calling `new URL(...)`, validate that `pkgSnapshot.resolution.tarball` is either absent or a string; if present and not a string, throw a structured `PnpmError` (fail closed) rather than coercing.
3) Add a regression test with a YAML-crafted snapshot where `tarball` is an array that stringifies to a URL, asserting verification fails closed.

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



Remediation recommended

13. canFetch runs under skipFetch 🐞 Bug ➹ Performance ⭐ New
Description
resolveAndFetch() calls pickFetcher() (which awaits each custom fetcher’s async canFetch)
before it checks the skipFetch/not-installable early return, so --lockfile-only/skipFetch
installs still pay custom fetcher selection cost for every dependency even when no fetch will occur.
Code

pnpm11/installing/package-requester/src/packageRequester.ts[R269-281]

+  const fetcherForResolution = resolution.type === 'variations'
+    ? undefined
+    : await pickFetcher(ctx.fetchers, resolution as AtomicResolution, {
+      customFetchers: ctx.customFetchers,
+      packageId: id,
+    })
+  const resolutionNeedsFetchHook = fetcherForResolution?.resolutionNeedsFetch
+  const resolutionNeedsFetch = typeof resolutionNeedsFetchHook === 'function'
+    ? resolutionNeedsFetchHook(resolution)
+    : false
+  // Fetching can be skipped only when the manifest is available, the package content
+  // did not change, and the resolution does not need fetch-derived data.
+  if ((options.skipFetch === true || isInstallable === false) && !resolutionNeedsFetch && !integrityChanged && (manifest != null)) {
Evidence
The early-return skipFetch check happens after pickFetcher() is awaited. pickFetcher()
iterates custom fetchers and awaits canFetch sequentially, so this work is incurred even when
resolveAndFetch() would otherwise return without fetching.

[pnpm11/installing/package-requester/src/packageRequester.ts[255-298]](https://github.com...

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

Actionable comments posted: 1

🧹 Nitpick comments (1)
installing/package-requester/src/packageRequester.ts (1)

313-326: ⚡ Quick win

Narrow the eager fetch to only resolutions that actually need integrity repair

Line 315 currently waits on fetchResult.fetching() for any tarball without integrity, but the hard requirement is only for resolutionNeedsIntegrity(resolution). This broad await can unnecessarily serialize part of the install hot path.

Suggested patch
-  // A tarball resolution missing its integrity gets the integrity the worker computed
-  // from the tarball bytes.
-  if (!resolution.type && !(resolution as TarballResolution).integrity) {
-    const fetchedResult = await fetchResult.fetching()
-    if (fetchedResult.integrity) {
-      (resolution as TarballResolution).integrity = fetchedResult.integrity
-    }
-  }
-  if (resolutionNeedsIntegrity(resolution)) {
+  const needsIntegrity = resolutionNeedsIntegrity(resolution)
+  if (needsIntegrity) {
+    const fetchedResult = await fetchResult.fetching()
+    if (fetchedResult.integrity) {
+      (resolution as TarballResolution).integrity = fetchedResult.integrity
+    }
+  }
+  if (needsIntegrity && !(resolution as TarballResolution).integrity) {
     throw new PnpmError('MISSING_TARBALL_INTEGRITY',
       `Cannot compute the integrity of package "${id}": its registry metadata had no integrity and the tarball could not be downloaded to compute one.`,
       { hint: 'Ensure the tarball is reachable from the registry, then re-run installation.' }
     )
   }

As per coding guidelines, performance regressions in pnpm install paths are a prioritized review target.

🤖 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 `@installing/package-requester/src/packageRequester.ts` around lines 313 - 326,
The current code eagerly fetches the tarball result for any resolution missing
integrity, but the actual requirement is only for resolutions that satisfy
resolutionNeedsIntegrity(resolution). Move the await fetchResult.fetching() call
and its integrity assignment into the second if block (the one checking
resolutionNeedsIntegrity) so that the fetch only happens when it's truly needed.
This prevents unnecessary serialization in the install hot path by avoiding the
fetch when the resolution ultimately won't require integrity anyway.

Source: Coding guidelines

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

Inline comments:
In `@installing/deps-installer/src/install/index.ts`:
- Around line 1153-1157: The lockfileHasMissingTarballIntegrity function
incorrectly flags legacy file: snapshots as missing integrity, causing
unnecessary re-resolution work. In the some() callback within
lockfileHasMissingTarballIntegrity, add a check to skip resolutions that are
file: type (those without a tarball) before calling resolutionNeedsIntegrity,
ensuring only actual tarball-based resolutions are evaluated for integrity
requirements.

---

Nitpick comments:
In `@installing/package-requester/src/packageRequester.ts`:
- Around line 313-326: The current code eagerly fetches the tarball result for
any resolution missing integrity, but the actual requirement is only for
resolutions that satisfy resolutionNeedsIntegrity(resolution). Move the await
fetchResult.fetching() call and its integrity assignment into the second if
block (the one checking resolutionNeedsIntegrity) so that the fetch only happens
when it's truly needed. This prevents unnecessary serialization in the install
hot path by avoiding the fetch when the resolution ultimately won't require
integrity anyway.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: c0c3ec27-9189-478d-9a5b-67f3af642ed2

📥 Commits

Reviewing files that changed from the base of the PR and between fe66535 and 00ec993.

⛔ Files ignored due to path filters (1)
  • pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml, !pnpm-lock.yaml
📒 Files selected for processing (10)
  • installing/deps-installer/src/install/index.ts
  • installing/deps-installer/test/brokenLockfileIntegrity.ts
  • installing/deps-resolver/src/resolveDependencies.ts
  • installing/package-requester/package.json
  • installing/package-requester/src/packageRequester.ts
  • installing/package-requester/test/index.ts
  • installing/package-requester/tsconfig.json
  • lockfile/utils/src/index.ts
  • lockfile/utils/src/pkgSnapshotToResolution.ts
  • lockfile/utils/src/toLockfileResolution.ts

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

Copy link
Copy Markdown

Code review by qodo was updated up to the latest commit 00ec993

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

qodo-free-for-open-source-projects Bot commented Jun 18, 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

Copilot AI review requested due to automatic review settings June 18, 2026 10:30
@qodo-free-for-open-source-projects

Copy link
Copy Markdown

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

Copilot AI 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.

Pull request overview

Copilot reviewed 11 out of 12 changed files in this pull request and generated 3 comments.

Files not reviewed (1)
  • pnpm-lock.yaml: Generated file

@github-actions

github-actions Bot commented Jun 18, 2026 •

Copy link
Copy Markdown
Contributor

Integrated-Benchmark Report (Linux)

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.963 ± 0.184 3.712 4.245 1.91 ± 0.12
pacquet@main 3.761 ± 0.092 3.680 3.966 1.82 ± 0.09
pnpr@HEAD 2.070 ± 0.090 1.968 2.233 1.00
pnpr@main 2.185 ± 0.166 1.988 2.441 1.06 ± 0.09
BENCHMARK_REPORT.json
{
  "results": [
    {
      "command": "pacquet@HEAD",
      "mean": 3.9626944922600003,
      "stddev": 0.18429995346333922,
      "median": 3.91723690266,
      "user": 3.74945514,
      "system": 3.3532322999999997,
      "min": 3.71235945416,
      "max": 4.24527719716,
      "times": [
        4.24527719716,
        4.04693827816,
        3.86633828616,
        3.71762578716,
        3.71235945416,
        3.91770958016,
        3.90520111916,
        3.91676422516,
        4.080059701160001,
        4.21867129416
      ]
    },
    {
      "command": "pacquet@main",
      "mean": 3.76084096286,
      "stddev": 0.0922393021337193,
      "median": 3.7398955031599996,
      "user": 3.73901204,
      "system": 3.3424704999999997,
      "min": 3.6796193971599997,
      "max": 3.96598395816,
      "times": [
        3.77631282716,
        3.7506722091599998,
        3.68888992316,
        3.6796193971599997,
        3.72911879716,
        3.75922122316,
        3.96598395816,
        3.8710419741599997,
        3.70434617616,
        3.6832031431599996
      ]
    },
    {
      "command": "pnpr@HEAD",
      "mean": 2.07012380136,
      "stddev": 0.08969273632965694,
      "median": 2.05581507366,
      "user": 2.80000304,
      "system": 2.9453935999999996,
      "min": 1.9676236851600002,
      "max": 2.23312219816,
      "times": [
        1.97474747516,
        2.23312219816,
        1.9676236851600002,
        2.0382307591599997,
        2.18903884516,
        1.98602798316,
        2.0301592231599996,
        2.10008837116,
        2.10880008516,
        2.07339938816
      ]
    },
    {
      "command": "pnpr@main",
      "mean": 2.1852376464599996,
      "stddev": 0.16594537200751014,
      "median": 2.1040764186599996,
      "user": 2.7776288399999998,
      "system": 2.9414873999999993,
      "min": 1.98795521416,
      "max": 2.4405319681599997,
      "times": [
        2.03274981616,
        2.3636090621599997,
        1.98795521416,
        2.08247272716,
        2.1185226981599996,
        2.37603671716,
        2.06195704516,
        2.2989110771599996,
        2.0896301391599996,
        2.4405319681599997
      ]
    }
  ]
}

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

Command Mean [ms] Min [ms] Max [ms] Relative
pacquet@HEAD 668.8 ± 41.6 638.1 766.5 1.00 ± 0.09
pacquet@main 666.1 ± 44.7 639.4 790.1 1.00
pnpr@HEAD 716.5 ± 33.8 683.8 792.5 1.08 ± 0.09
pnpr@main 723.1 ± 33.0 685.5 800.0 1.09 ± 0.09
BENCHMARK_REPORT.json
{
  "results": [
    {
      "command": "pacquet@HEAD",
      "mean": 0.6687839211,
      "stddev": 0.041553818445710024,
      "median": 0.6515618527,
      "user": 0.41929602,
      "system": 1.36109424,
      "min": 0.6381231547,
      "max": 0.7665101077,
      "times": [
        0.6552863977000001,
        0.6575573637000001,
        0.7088469437,
        0.7665101077,
        0.6894117677,
        0.6387964767000001,
        0.6478373077,
        0.6398976247,
        0.6381231547,
        0.6455720667
      ]
    },
    {
      "command": "pacquet@main",
      "mean": 0.6661382732999999,
      "stddev": 0.04474713053561802,
      "median": 0.6544941847,
      "user": 0.39289572,
      "system": 1.33483344,
      "min": 0.6393881877,
      "max": 0.7900658987,
      "times": [
        0.6704312467,
        0.6505616887,
        0.6592114227,
        0.6627811707,
        0.6584266807,
        0.6393881877,
        0.6480056337,
        0.6409083277000001,
        0.6416024757000001,
        0.7900658987
      ]
    },
    {
      "command": "pnpr@HEAD",
      "mean": 0.716527801,
      "stddev": 0.03382829695923304,
      "median": 0.7081268172,
      "user": 0.41698062,
      "system": 1.3640522399999997,
      "min": 0.6837653257,
      "max": 0.7925401237,
      "times": [
        0.7524935957000001,
        0.7107050717000001,
        0.7090109157000001,
        0.6837653257,
        0.6883221477,
        0.7072427187,
        0.6938546847,
        0.6956186297,
        0.7317247967,
        0.7925401237
      ]
    },
    {
      "command": "pnpr@main",
      "mean": 0.7231251554,
      "stddev": 0.032952571787889025,
      "median": 0.7144706412,
      "user": 0.41679291999999996,
      "system": 1.3668686399999996,
      "min": 0.6854905407,
      "max": 0.7999635077,
      "times": [
        0.7478984927000001,
        0.7078171467000001,
        0.7177360977,
        0.7161525727,
        0.7008797977000001,
        0.6998380487,
        0.7999635077,
        0.7426866397,
        0.7127887097000001,
        0.6854905407
      ]
    }
  ]
}

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

Command Mean [s] Min [s] Max [s] Relative
pacquet@HEAD 4.332 ± 0.047 4.257 4.421 1.97 ± 0.12
pacquet@main 4.372 ± 0.033 4.317 4.415 1.99 ± 0.12
pnpr@HEAD 2.200 ± 0.118 2.059 2.399 1.00 ± 0.08
pnpr@main 2.199 ± 0.136 2.031 2.396 1.00
BENCHMARK_REPORT.json
{
  "results": [
    {
      "command": "pacquet@HEAD",
      "mean": 4.331943087800001,
      "stddev": 0.04748451213579612,
      "median": 4.3136153648,
      "user": 3.9390767,
      "system": 3.35630146,
      "min": 4.2574814413,
      "max": 4.4205694123,
      "times": [
        4.4205694123,
        4.3094072113,
        4.3113847953,
        4.3158459343,
        4.3609302113,
        4.3852230793,
        4.3517540663,
        4.3017893643,
        4.2574814413,
        4.3050453623000005
      ]
    },
    {
      "command": "pacquet@main",
      "mean": 4.3723599256,
      "stddev": 0.03260418293400025,
      "median": 4.3608513608,
      "user": 3.9241397,
      "system": 3.3609482599999994,
      "min": 4.3169534753,
      "max": 4.4150481553,
      "times": [
        4.405215392300001,
        4.3613932513,
        4.3507619923,
        4.3543489263,
        4.3169534753,
        4.3517804923000005,
        4.3959256763,
        4.4150481553,
        4.3603094703,
        4.4118624243
      ]
    },
    {
      "command": "pnpr@HEAD",
      "mean": 2.1998197577,
      "stddev": 0.11798734601028082,
      "median": 2.2153715858,
      "user": 2.6027175,
      "system": 2.8494864599999996,
      "min": 2.0592898203,
      "max": 2.3991180603,
      "times": [
        2.2907741483,
        2.3189537613000004,
        2.2352421403,
        2.2397110713000004,
        2.0684952813,
        2.1229641273,
        2.3991180603,
        2.1955010313,
        2.0681481353,
        2.0592898203
      ]
    },
    {
      "command": "pnpr@main",
      "mean": 2.1987570816,
      "stddev": 0.1363506140115176,
      "median": 2.1267941103,
      "user": 2.5821096,
      "system": 2.8657875600000002,
      "min": 2.0306084593000002,
      "max": 2.3958948403,
      "times": [
        2.3710340603000004,
        2.1272036053,
        2.0865670433,
        2.0917803093000003,
        2.3423933063,
        2.1203260693000003,
        2.1263846153,
        2.2953785073,
        2.0306084593000002,
        2.3958948403
      ]
    }
  ]
}

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

Command Mean [s] Min [s] Max [s] Relative
pacquet@HEAD 1.429 ± 0.015 1.403 1.455 2.10 ± 0.03
pacquet@main 1.454 ± 0.049 1.427 1.592 2.13 ± 0.08
pnpr@HEAD 0.682 ± 0.008 0.673 0.694 1.00
pnpr@main 0.754 ± 0.013 0.742 0.786 1.11 ± 0.02
BENCHMARK_REPORT.json
{
  "results": [
    {
      "command": "pacquet@HEAD",
      "mean": 1.42853418456,
      "stddev": 0.015237290741956002,
      "median": 1.42965932676,
      "user": 1.40730732,
      "system": 1.7579154,
      "min": 1.40297379226,
      "max": 1.45532002126,
      "times": [
        1.4230317752600001,
        1.41926368226,
        1.40297379226,
        1.41238090726,
        1.42966547026,
        1.4384417312600002,
        1.44390280426,
        1.4296531832600001,
        1.45532002126,
        1.4307084782600001
      ]
    },
    {
      "command": "pacquet@main",
      "mean": 1.45398048136,
      "stddev": 0.04919246660923868,
      "median": 1.4401119072600002,
      "user": 1.41315932,
      "system": 1.7618164999999997,
      "min": 1.4269810392600002,
      "max": 1.59173240426,
      "times": [
        1.59173240426,
        1.45227264126,
        1.4427428822600001,
        1.43321728826,
        1.4374809322600002,
        1.43305962826,
        1.44546055526,
        1.4272932952600001,
        1.44956414726,
        1.4269810392600002
      ]
    },
    {
      "command": "pnpr@HEAD",
      "mean": 0.6816471826600001,
      "stddev": 0.008078683261437732,
      "median": 0.68002261076,
      "user": 0.35431061999999997,
      "system": 1.2964683,
      "min": 0.6732226242600001,
      "max": 0.69424689526,
      "times": [
        0.6903178942600001,
        0.6732985572600001,
        0.69424689526,
        0.6911510322600001,
        0.6847934332600001,
        0.6732485482600001,
        0.68182491726,
        0.6782203042600001,
        0.6732226242600001,
        0.6761476202600001
      ]
    },
    {
      "command": "pnpr@main",
      "mean": 0.75433961626,
      "stddev": 0.012900509355370203,
      "median": 0.7506628092600001,
      "user": 0.36606651999999995,
      "system": 1.3624728999999998,
      "min": 0.7423502112600001,
      "max": 0.78568396626,
      "times": [
        0.7658672092600001,
        0.7438031412600001,
        0.7504374342600001,
        0.74581519626,
        0.75515089826,
        0.7542780002600001,
        0.7491219212600001,
        0.7423502112600001,
        0.78568396626,
        0.75088818426
      ]
    }
  ]
}

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

Command Mean [s] Min [s] Max [s] Relative
pacquet@HEAD 3.138 ± 0.028 3.105 3.206 4.57 ± 0.09
pacquet@main 3.190 ± 0.059 3.132 3.310 4.65 ± 0.12
pnpr@HEAD 0.686 ± 0.012 0.667 0.708 1.00
pnpr@main 0.718 ± 0.069 0.677 0.907 1.05 ± 0.10
BENCHMARK_REPORT.json
{
  "results": [
    {
      "command": "pacquet@HEAD",
      "mean": 3.13767341152,
      "stddev": 0.02800342513637192,
      "median": 3.13595534082,
      "user": 1.8481134999999997,
      "system": 2.0449363,
      "min": 3.10484863032,
      "max": 3.20601455632,
      "times": [
        3.14337785032,
        3.14073580532,
        3.1321358673199997,
        3.1507125653199997,
        3.13977481432,
        3.10484863032,
        3.12614096532,
        3.20601455632,
        3.1124461333199998,
        3.12054692732
      ]
    },
    {
      "command": "pacquet@main",
      "mean": 3.18955351402,
      "stddev": 0.05863558310652617,
      "median": 3.17283531332,
      "user": 1.8483101999999998,
      "system": 2.0818791000000005,
      "min": 3.13232083132,
      "max": 3.30965694532,
      "times": [
        3.1381081093199996,
        3.13232083132,
        3.1790978433199997,
        3.15723014232,
        3.16475565432,
        3.16758060532,
        3.2801725073199997,
        3.30965694532,
        3.1885224803199996,
        3.1780900213199996
      ]
    },
    {
      "command": "pnpr@HEAD",
      "mean": 0.6860203313200001,
      "stddev": 0.01227951074794985,
      "median": 0.68638334882,
      "user": 0.357857,
      "system": 1.3257487,
      "min": 0.66741326032,
      "max": 0.70787228932,
      "times": [
        0.68430886132,
        0.66973041532,
        0.66741326032,
        0.70787228932,
        0.6837471233200001,
        0.68845783632,
        0.6926286233200001,
        0.6777080533200001,
        0.69211896932,
        0.6962178813200001
      ]
    },
    {
      "command": "pnpr@main",
      "mean": 0.71755889882,
      "stddev": 0.06850436486311745,
      "median": 0.69827635882,
      "user": 0.3580264,
      "system": 1.3214644,
      "min": 0.6769574633200001,
      "max": 0.90737342032,
      "times": [
        0.6769574633200001,
        0.70975372232,
        0.7006301113200001,
        0.6809815233200001,
        0.7265368323200001,
        0.67938463932,
        0.7084881403200001,
        0.69592260632,
        0.68956052932,
        0.90737342032
      ]
    }
  ]
}

@github-actions

github-actions Bot commented Jun 18, 2026 •

Copy link
Copy Markdown
Contributor

🐰 Bencher Report

Branchpr/12491
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,331.94 ms
(+2.72%)Baseline: 4,217.25 ms
5,060.70 ms
(85.60%)
isolated-linker.fresh-install.cold-cache.hot-store📈 view plot
🚷 view threshold
3,137.67 ms
(+4.36%)Baseline: 3,006.54 ms
3,607.85 ms
(86.97%)
isolated-linker.fresh-install.hot-cache.hot-store📈 view plot
🚷 view threshold
1,428.53 ms
(+7.66%)Baseline: 1,326.93 ms
1,592.32 ms
(89.71%)
isolated-linker.fresh-restore.cold-cache.cold-store📈 view plot
🚷 view threshold
3,962.69 ms
(-0.03%)Baseline: 3,963.76 ms
4,756.52 ms
(83.31%)
isolated-linker.fresh-restore.hot-cache.hot-store📈 view plot
🚷 view threshold
668.78 ms
(+7.40%)Baseline: 622.68 ms
747.22 ms
(89.50%)
🐰 View full continuous benchmarking report in Bencher

@github-actions

github-actions Bot commented Jun 18, 2026 •

Copy link
Copy Markdown
Contributor

🐰 Bencher Report

Branchpr/12491
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,199.82 ms
isolated-linker.fresh-install.cold-cache.hot-store📈 view plot
⚠️ NO THRESHOLD
686.02 ms
isolated-linker.fresh-install.hot-cache.hot-store📈 view plot
⚠️ NO THRESHOLD
681.65 ms
isolated-linker.fresh-restore.cold-cache.cold-store📈 view plot
⚠️ NO THRESHOLD
2,070.12 ms
isolated-linker.fresh-restore.hot-cache.hot-store📈 view plot
⚠️ NO THRESHOLD
716.53 ms
🐰 View full continuous benchmarking report in Bencher

@zkochan zkochan left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

any changes should be in pacquet too

@ajeetdsouza

Copy link
Copy Markdown
Contributor Author

@zkochan does the approach look good? If yes, I can do the same for Rust as well.

ajeetdsouza and others added 2 commits June 21, 2026 11:30
…leading refetch warning

Address review feedback on the missing-tarball-integrity recovery path:

- Reword the MISSING_TARBALL_INTEGRITY error so it no longer assumes the
  cause was an unreachable registry tarball; it now states that no integrity
  was provided by the resolution nor computed during fetch, and hints at
  custom fetchers.
- Only emit the "Refetching ... to store" warning once a store read confirms
  the package was actually present. Initializing the flag from
  resolutionNeedsIntegrity made the warning fire on genuine first-time
  downloads from registries that omit integrity.
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 11.4+ breaks custom npm registries that generate packages on-demand

4 participants