Skip to content

test(pacquet): speed up the yaml scalar-budget lockfile test - #13876

Merged
zkochan merged 4 commits into
pnpm:mainfrom
jibin7jose:fix-allow-build-config
Aug 20, 2026
Merged

zkochan merged 4 commits into
pnpm:mainfrom
jibin7jose:fix-allow-build-config

Conversation

@jibin7jose

@jibin7jose jibin7jose commented Aug 12, 2026 •

Copy link
Copy Markdown
Contributor

Summary

This PR started as a fix for pnpm add --allow-build replacing the existing allowBuilds config (pnpm/pnpm#13872). That fix landed on main via pnpm/pnpm#13873 while this PR was open, so after rebasing, the production TypeScript change is gone and what remains is the still-useful rest:

  • Speed up pacquet's yaml scalar-budget lockfile test. The test built a 96 MB document out of a million importer lines, so parsing allocated a million AST nodes — on a dev machine it runs for over 10 minutes (measured: killed at 10 minutes, unfinished). A single 65 MiB scalar crosses the same 64 MiB scalar budget the test guards, and passes in 0.7 s.
  • Two Windows-only cleanups, validated by Windows CI: drop a needless return in pnpm-fs's is_symlink_or_junction, and use .cast() instead of as _ for the raw handle passed to GetFileInformationByHandle in the injected-deps syncer.
  • Extend the --allow-build merge test (added by fix(add): add to the existing allowBuilds instead of replacing it #13873) to also cover a string-valued allowBuilds entry surviving the merge.

No changeset: nothing here is user-visible (the original changeset was dropped as a duplicate of the one that landed with #13873).

Squash Commit Body

The scalar-budget regression test built a 96 MB lockfile out of a
million importer lines, so parsing allocated a million AST nodes and
the test ran for many minutes (or timed out) instead of exercising the
one thing it guards: that a document larger than the parser's 64 MiB
default scalar budget still parses. A single 65 MiB scalar crosses the
same budget and parses in under a second.

Also drops a needless `return` in pnpm-fs's is_symlink_or_junction,
uses `.cast()` instead of `as _` for the raw handle passed to
GetFileInformationByHandle in the injected-deps syncer, and extends
the --allow-build merge test with a string-valued allowBuilds entry.

The allowBuilds fix this PR originally carried was superseded by
pnpm/pnpm#13873 (Closes pnpm/pnpm#13872 there).

Checklist

  • I checked the referenced issue and verified that none of the PRs
    already linked to it solves it.
  • The change is implemented in both the TypeScript CLI and the Rust
    pnpm/ port, or the description notes what still needs porting. (Test-only
    and internal changes; nothing user-visible to mirror.)
  • Added a changeset (pnpm changeset) if this PR changes any published
    package. Keep it short and written for pnpm users — it becomes a release note.
    (Not needed: no user-visible change.)
  • Added or updated tests.

Written by an agent (Claude Code, claude-fable-5).

@jibin7jose
jibin7jose requested a review from zkochan as a code owner August 12, 2026 17:40
@qodo-code-review

Copy link
Copy Markdown

Qodo reviews are paused for this user.

Troubleshooting steps vary by plan Learn more →

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

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

@coderabbitai

coderabbitai Bot commented Aug 12, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: 3090ad60-fd78-4df9-9ec1-28aaa9a2a8a5

📥 Commits

Reviewing files that changed from the base of the PR and between 8680ece and 7bcc5b2.

📒 Files selected for processing (4)
  • pnpm/crates/fs/src/symlink_dir.rs
  • pnpm/crates/injected-deps-syncer/src/dir_patcher.rs
  • pnpm/crates/lockfile/src/load_lockfile/tests.rs
  • pnpm11/pnpm/test/install/lifecycleScripts.ts
🚧 Files skipped from review as they are similar to previous changes (4)
  • pnpm/crates/fs/src/symlink_dir.rs
  • pnpm11/pnpm/test/install/lifecycleScripts.ts
  • pnpm/crates/lockfile/src/load_lockfile/tests.rs
  • pnpm/crates/injected-deps-syncer/src/dir_patcher.rs

Included review availability: Your plan provides up to 10 included reviews per hour; 0 remain after this review.


📝 Walkthrough

Walkthrough

The PR verifies preservation of existing allowBuilds entries, updates two Windows Rust expressions without behavior changes, and simplifies the oversized lockfile parser regression fixture.

Changes

allowBuilds preservation

Layer / File(s) Summary
Validate workspace preservation
pnpm11/pnpm/test/install/lifecycleScripts.ts
The end-to-end test verifies that existing boolean and string allowBuilds entries remain alongside a newly approved package.

Windows Rust maintenance

Layer / File(s) Summary
Apply Windows Rust maintenance edits
pnpm/crates/fs/src/symlink_dir.rs, pnpm/crates/injected-deps-syncer/src/dir_patcher.rs
Windows junction detection uses a direct match expression. The Windows API call converts the file handle with .cast().

Lockfile parser test coverage

Layer / File(s) Summary
Update oversized scalar fixture
pnpm/crates/lockfile/src/load_lockfile/tests.rs
The regression test uses one 65 MiB pnpmfileChecksum scalar and verifies its parsed length.

Estimated code review effort: 2 (Simple) | ~10 minutes

Merge Risk: ⚪ Minimal · up to 7bcc5

No actionable merge-blocking risk remains; the PR is merge-ready after normal checks and review.

Assessment against linked issues

Objective Addressed Explanation
Preserve existing allowBuilds entries when pnpm add --allow-build adds a new approval [#13872] ✅

Out-of-scope changes

Code Change Explanation
Update Windows junction detection expression (pnpm/crates/fs/src/symlink_dir.rs:97-101) The linked issue concerns allowBuilds configuration.
Update Windows file-handle conversion (pnpm/crates/injected-deps-syncer/src/dir_patcher.rs:330) The linked issue does not mention Windows handle conversion.
Replace the oversized lockfile parser fixture (pnpm/crates/lockfile/src/load_lockfile/tests.rs:142-157) The change is unrelated to allowBuilds configuration preservation.

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

Suggested reviewers: zkochan

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

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

❤️ Share

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

@greptile-apps

greptile-apps Bot commented Aug 12, 2026 •

Copy link
Copy Markdown
Contributor

Confidence Score: 5/5

The PR appears safe to merge.

No blocking failure remains.

Reviews (6): Last reviewed commit: "chore: drop changeset superseded by pnpm..." | Re-trigger Greptile

use std::{
collections::{BTreeMap, HashMap},
fs::{self, File},
fs::File,

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

P1 Restore the Unix fs binding

When this crate is built for Unix, open_lockfile_no_follow still calls fs::OpenOptions, but this import no longer brings fs into scope, causing compilation to fail with an unresolved module.

Suggested change
fs::File,
fs::{self, File},

@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)
pnpm11/pnpm/test/install/lifecycleScripts.ts (1)

186-200: 🗄️ Data Integrity & Integration | 🔵 Trivial | ⚡ Quick win

Cover string-valued allowBuilds entries.

add.ts now preserves both boolean and string values from opts.allowBuilds, but this test only preserves true. Add a valid string-valued entry and assert that its exact value remains after pnpm add --allow-build. This protects the full configuration contract.

🤖 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 `@pnpm11/pnpm/test/install/lifecycleScripts.ts` around lines 186 - 200, Update
the test “pnpm add --allow-build should merge with existing allowBuilds in
pnpm-workspace.yaml” to include an existing string-valued allowBuilds entry
alongside the boolean entry, then assert that the exact string value is
preserved after execPnpmSync. Keep the existing boolean and newly added package
assertions unchanged.
🤖 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 `@pnpm/crates/lockfile/src/env_lockfile.rs`:
- Line 26: Update the imports used by the Unix-only function so the `fs` module
is available for its `fs::OpenOptions` reference, while retaining `File`; use
the existing `fs::{self, File}` form or qualify the call with
`std::fs::OpenOptions`.

---

Nitpick comments:
In `@pnpm11/pnpm/test/install/lifecycleScripts.ts`:
- Around line 186-200: Update the test “pnpm add --allow-build should merge with
existing allowBuilds in pnpm-workspace.yaml” to include an existing
string-valued allowBuilds entry alongside the boolean entry, then assert that
the exact string value is preserved after execPnpmSync. Keep the existing
boolean and newly added package assertions unchanged.
🪄 Autofix

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: 1c4f3742-b969-4bbe-a3c7-d0bd328ccae8

📥 Commits

Reviewing files that changed from the base of the PR and between e6f2249 and fecee76.

📒 Files selected for processing (7)
  • .changeset/fix-allow-build.md
  • pnpm/crates/fs/src/symlink_dir.rs
  • pnpm/crates/injected-deps-syncer/src/dir_patcher.rs
  • pnpm/crates/lockfile/src/env_lockfile.rs
  • pnpm/crates/patching/src/commit/tests.rs
  • pnpm11/installing/commands/src/add.ts
  • pnpm11/pnpm/test/install/lifecycleScripts.ts

use std::{
collections::{BTreeMap, HashMap},
fs::{self, File},
fs::File,

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.

🎯 Functional Correctness | 🔴 Critical | ⚡ Quick win

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
set -euo pipefail
rg -n -C 2 'fs::OpenOptions|fs::File' pnpm/crates/lockfile/src/env_lockfile.rs

Repository: pnpm/pnpm

Length of output: 664


🏁 Script executed:

#!/bin/bash
set -euo pipefail

python3 - <<'PY'
from pathlib import Path

path = Path("pnpm/crates/lockfile/src/env_lockfile.rs")
text = path.read_text()
print("module_import_present:", "fs::{self, File}" in text or "use std::fs;" in text)
print("file_import_present:", "fs::File" in text)
for number, line in enumerate(text.splitlines(), 1):
    if "fs::OpenOptions" in line or "use std::fs" in line:
        print(f"{number}:{line}")
PY

cat > /tmp/rust_fs_resolution.rs <<'RS'
use std::fs::File;

#[cfg(unix)]
fn open_lockfile_no_follow() -> std::io::Result<File> {
    fs::OpenOptions::new().read(true).open("/dev/null")
}

fn main() {}
RS

if command -v rustc >/dev/null 2>&1; then
    if rustc --edition=2021 --emit=metadata /tmp/rust_fs_resolution.rs -o /tmp/rust_fs_resolution.rmeta 2>&1; then
        echo "standalone_resolution: unexpectedly succeeded"
    else
        echo "standalone_resolution: fs::OpenOptions is unresolved without a module import"
    fi
else
    echo "rustc: unavailable"
fi

Repository: pnpm/pnpm

Length of output: 1169


Restore the fs module import.

The Unix-only function uses fs::OpenOptions, but the import binds only File. Restore fs::{self, File} or qualify the call as std::fs::OpenOptions.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@pnpm/crates/lockfile/src/env_lockfile.rs` at line 26, Update the imports used
by the Unix-only function so the `fs` module is available for its
`fs::OpenOptions` reference, while retaining `File`; use the existing
`fs::{self, File}` form or qualify the call with `std::fs::OpenOptions`.

@jibin7jose
jibin7jose force-pushed the fix-allow-build-config branch from fecee76 to c7081b2 Compare August 12, 2026 17:47
greptile-apps[bot]
greptile-apps Bot previously approved these changes Aug 12, 2026
@codecov-commenter

codecov-commenter commented Aug 12, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 88.17%. Comparing base (bb57938) to head (7bcc5b2).
⚠️ Report is 2 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main   #13876      +/-   ##
==========================================
- Coverage   88.19%   88.17%   -0.03%     
==========================================
  Files         646      646              
  Lines      107162   107281     +119     
==========================================
+ Hits        94509    94591      +82     
- Misses      12653    12690      +37     

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

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

@jibin7jose
jibin7jose force-pushed the fix-allow-build-config branch from c7081b2 to 9acf1cc Compare August 12, 2026 18:03
@greptile-apps
greptile-apps Bot dismissed their stale review August 12, 2026 18:03

Dismissed because a newer commit was pushed; Greptile will re-review the current head.

greptile-apps[bot]
greptile-apps Bot previously approved these changes Aug 12, 2026
@github-actions github-actions Bot added the reviewed: coderabbit CodeRabbit submitted an approving review label Aug 12, 2026
@github-actions

github-actions Bot commented Aug 12, 2026 •

Copy link
Copy Markdown
Contributor

Integrated-Benchmark Report (Linux)

Commit: 7bcc5b21c828

Regular scenarios report direct and pnpr installs. The peer-heavy resolver scenario compares current Rust, main Rust, and TypeScript pnpm. Bencher consumes pacquet@HEAD and pnpr@HEAD.

The tables below show mean ± σ; Bencher thresholds on the minimum latency, which is far less perturbed by shared-runner contention (noise only adds time).

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

Command Mean [s] Min [s] Max [s] Relative
pacquet@HEAD 2.425 ± 0.099 2.323 2.598 1.59 ± 0.16
pacquet@main 2.487 ± 0.114 2.338 2.683 1.63 ± 0.17
pnpr@HEAD 1.521 ± 0.138 1.382 1.756 1.00
pnpr@main 1.570 ± 0.151 1.385 1.803 1.03 ± 0.14
BENCHMARK_REPORT.json
{
  "results": [
    {
      "command": "pacquet@HEAD",
      "mean": 2.4246534548800005,
      "stddev": 0.09881068079939773,
      "median": 2.38270914478,
      "user": 1.68763094,
      "system": 1.6862468999999998,
      "min": 2.32277023578,
      "max": 2.59831136878
    },
    {
      "command": "pacquet@main",
      "mean": 2.48664130138,
      "stddev": 0.11446203632188928,
      "median": 2.48552996028,
      "user": 1.76219404,
      "system": 1.7321703,
      "min": 2.33780810378,
      "max": 2.6833608247800003
    },
    {
      "command": "pnpr@HEAD",
      "mean": 1.52091421948,
      "stddev": 0.1381425074913566,
      "median": 1.4750501912799998,
      "user": 1.6927894399999999,
      "system": 1.7495987,
      "min": 1.38177637378,
      "max": 1.75633938678
    },
    {
      "command": "pnpr@main",
      "mean": 1.56966059218,
      "stddev": 0.15067681075554973,
      "median": 1.6093233517799999,
      "user": 1.84657944,
      "system": 1.7724992999999998,
      "min": 1.38539571678,
      "max": 1.8032888067800001
    }
  ]
}

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

Command Mean [ms] Min [ms] Max [ms] Relative
pacquet@HEAD 373.9 ± 23.0 323.7 399.1 1.00
pacquet@main 390.0 ± 32.7 340.2 449.5 1.04 ± 0.11
pnpr@HEAD 390.0 ± 21.9 362.8 427.2 1.04 ± 0.09
pnpr@main 426.0 ± 52.5 377.0 538.5 1.14 ± 0.16
BENCHMARK_REPORT.json
{
  "results": [
    {
      "command": "pacquet@HEAD",
      "mean": 0.3738849133,
      "stddev": 0.0230285293553418,
      "median": 0.37706693150000004,
      "user": 0.30851182,
      "system": 0.67522474,
      "min": 0.323665785,
      "max": 0.399103665
    },
    {
      "command": "pacquet@main",
      "mean": 0.38999906939999995,
      "stddev": 0.032729576016680466,
      "median": 0.3927364425,
      "user": 0.3266808200000001,
      "system": 0.70801894,
      "min": 0.340171008,
      "max": 0.449472663
    },
    {
      "command": "pnpr@HEAD",
      "mean": 0.3900372296,
      "stddev": 0.02191183832592219,
      "median": 0.387020028,
      "user": 0.33784242,
      "system": 0.6665780399999999,
      "min": 0.362803132,
      "max": 0.427177965
    },
    {
      "command": "pnpr@main",
      "mean": 0.4260223596,
      "stddev": 0.05245168622377878,
      "median": 0.4111764005,
      "user": 0.35439782000000003,
      "system": 0.7038766399999999,
      "min": 0.376952985,
      "max": 0.538473707
    }
  ]
}

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

Command Mean [ms] Min [ms] Max [ms] Relative
pacquet@HEAD 12.7 ± 2.4 9.0 22.2 1.01 ± 0.23
pacquet@main 14.4 ± 3.4 9.4 26.9 1.15 ± 0.30
pnpr@HEAD 12.5 ± 1.5 8.6 15.9 1.00
pnpr@main 12.9 ± 1.7 8.6 16.5 1.03 ± 0.18
BENCHMARK_REPORT.json
{
  "results": [
    {
      "command": "pacquet@HEAD",
      "mean": 0.01270963190169884,
      "stddev": 0.0024054580400776505,
      "median": 0.012288099060000002,
      "user": 0.008003023088803091,
      "system": 0.0047212581467181445,
      "min": 0.00897298706,
      "max": 0.02222981706
    },
    {
      "command": "pacquet@main",
      "mean": 0.0143804914032836,
      "stddev": 0.003369336668000201,
      "median": 0.014021087060000001,
      "user": 0.008643067014925369,
      "system": 0.005739020373134328,
      "min": 0.00938974406,
      "max": 0.02688617606
    },
    {
      "command": "pnpr@HEAD",
      "mean": 0.01252898371020576,
      "stddev": 0.0014665833690493514,
      "median": 0.012445576060000001,
      "user": 0.007810553333333338,
      "system": 0.004727826337448558,
      "min": 0.00856668206,
      "max": 0.01593717006
    },
    {
      "command": "pnpr@main",
      "mean": 0.012930639789411764,
      "stddev": 0.001652431866702788,
      "median": 0.01302083606,
      "user": 0.008157137647058825,
      "system": 0.0047863275294117635,
      "min": 0.008587270059999999,
      "max": 0.01649346906
    }
  ]
}

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

Command Mean [ms] Min [ms] Max [ms] Relative
pacquet@HEAD 13.1 ± 1.5 9.9 16.5 1.06 ± 0.20
pacquet@main 12.8 ± 6.4 8.7 72.1 1.03 ± 0.54
pnpr@HEAD 12.4 ± 1.8 9.3 16.8 1.00
pnpr@main 13.1 ± 1.7 9.4 17.2 1.05 ± 0.21
BENCHMARK_REPORT.json
{
  "results": [
    {
      "command": "pacquet@HEAD",
      "mean": 0.013130518139999993,
      "stddev": 0.001478050903251225,
      "median": 0.013003738220000002,
      "user": 0.00844502,
      "system": 0.004706678133333332,
      "min": 0.009930568720000001,
      "max": 0.01651172872
    },
    {
      "command": "pacquet@main",
      "mean": 0.012768372908679248,
      "stddev": 0.006449834626990089,
      "median": 0.012143260720000002,
      "user": 0.007377247547169813,
      "system": 0.005411890566037736,
      "min": 0.008671324720000002,
      "max": 0.07208174872
    },
    {
      "command": "pnpr@HEAD",
      "mean": 0.012422450598453044,
      "stddev": 0.0018355808889643195,
      "median": 0.012206910720000002,
      "user": 0.007557570165745855,
      "system": 0.0048812355801104955,
      "min": 0.00930494972,
      "max": 0.01681340772
    },
    {
      "command": "pnpr@main",
      "mean": 0.013103719105620918,
      "stddev": 0.0016565202126757991,
      "median": 0.013341770720000002,
      "user": 0.008273249150326801,
      "system": 0.004862917647058825,
      "min": 0.009429594720000002,
      "max": 0.01719103672
    }
  ]
}

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

Command Mean [s] Min [s] Max [s] Relative
pacquet@HEAD 2.936 ± 0.047 2.884 3.020 1.86 ± 0.12
pacquet@main 2.907 ± 0.037 2.841 2.957 1.84 ± 0.11
pnpr@HEAD 1.577 ± 0.095 1.473 1.783 1.00
pnpr@main 1.578 ± 0.119 1.437 1.788 1.00 ± 0.10
BENCHMARK_REPORT.json
{
  "results": [
    {
      "command": "pacquet@HEAD",
      "mean": 2.9356945900799998,
      "stddev": 0.04650375038132855,
      "median": 2.92652441058,
      "user": 2.2976751399999995,
      "system": 1.7220682,
      "min": 2.88357728558,
      "max": 3.01997675658
    },
    {
      "command": "pacquet@main",
      "mean": 2.90736099068,
      "stddev": 0.03664242351874607,
      "median": 2.91524060308,
      "user": 2.2983770399999996,
      "system": 1.6535753,
      "min": 2.84116225358,
      "max": 2.95661217858
    },
    {
      "command": "pnpr@HEAD",
      "mean": 1.57696708238,
      "stddev": 0.09451527037427784,
      "median": 1.5677148655800002,
      "user": 1.5588056399999999,
      "system": 1.6587908000000002,
      "min": 1.47283090158,
      "max": 1.78337910658
    },
    {
      "command": "pnpr@main",
      "mean": 1.5781656171799998,
      "stddev": 0.11854938648221097,
      "median": 1.61407569958,
      "user": 1.3872926399999999,
      "system": 1.503199,
      "min": 1.43670619658,
      "max": 1.78820716558
    }
  ]
}

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

Command Mean [ms] Min [ms] Max [ms] Relative
pacquet@HEAD 429.5 ± 19.5 399.8 459.0 1.08 ± 0.08
pacquet@main 465.4 ± 27.0 421.3 505.1 1.17 ± 0.10
pnpr@HEAD 419.3 ± 22.3 390.0 455.2 1.05 ± 0.08
pnpr@main 397.5 ± 23.8 361.2 431.4 1.00
BENCHMARK_REPORT.json
{
  "results": [
    {
      "command": "pacquet@HEAD",
      "mean": 0.42951915752000003,
      "stddev": 0.01950660519338924,
      "median": 0.42984218262,
      "user": 0.49102527999999995,
      "system": 0.6426904200000001,
      "min": 0.39978484562,
      "max": 0.45904519862
    },
    {
      "command": "pacquet@main",
      "mean": 0.46540452302,
      "stddev": 0.027025992114418456,
      "median": 0.46346965362000003,
      "user": 0.56815818,
      "system": 0.7080127200000002,
      "min": 0.42125391962000003,
      "max": 0.50513197462
    },
    {
      "command": "pnpr@HEAD",
      "mean": 0.41933990462,
      "stddev": 0.022276159713456773,
      "median": 0.41880712661999997,
      "user": 0.29119547999999995,
      "system": 0.62616952,
      "min": 0.39000923362,
      "max": 0.45518431262000003
    },
    {
      "command": "pnpr@main",
      "mean": 0.39749221432,
      "stddev": 0.02383301620622691,
      "median": 0.39673498411999997,
      "user": 0.26051578000000003,
      "system": 0.5943089200000001,
      "min": 0.36115519362,
      "max": 0.43140019662
    }
  ]
}

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

Command Mean [s] Min [s] Max [s] Relative
pacquet@HEAD 1.983 ± 0.036 1.941 2.058 5.84 ± 0.25
pacquet@main 1.893 ± 0.016 1.868 1.911 5.57 ± 0.22
pnpr@HEAD 0.340 ± 0.013 0.318 0.358 1.00
pnpr@main 0.345 ± 0.024 0.319 0.387 1.02 ± 0.08
BENCHMARK_REPORT.json
{
  "results": [
    {
      "command": "pacquet@HEAD",
      "mean": 1.9832573193200003,
      "stddev": 0.035632505398948314,
      "median": 1.9851954117200001,
      "user": 0.8657133400000001,
      "system": 0.8287999199999998,
      "min": 1.94117917922,
      "max": 2.0575036562199998
    },
    {
      "command": "pacquet@main",
      "mean": 1.8926837337200002,
      "stddev": 0.01557644228234686,
      "median": 1.89542554972,
      "user": 0.75798054,
      "system": 0.71396502,
      "min": 1.8681403972200001,
      "max": 1.91126987822
    },
    {
      "command": "pnpr@HEAD",
      "mean": 0.33953090162,
      "stddev": 0.01298008849030967,
      "median": 0.34170364822,
      "user": 0.21403363999999997,
      "system": 0.5145385200000001,
      "min": 0.31789407422,
      "max": 0.35817742622000004
    },
    {
      "command": "pnpr@main",
      "mean": 0.34487786402,
      "stddev": 0.024397473293353462,
      "median": 0.34008336822,
      "user": 0.22606234,
      "system": 0.5085229200000001,
      "min": 0.31857212322,
      "max": 0.38694161022
    }
  ]
}

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

Command Mean [ms] Min [ms] Max [ms] Relative
pacquet@HEAD 218.0 ± 17.2 189.4 249.3 2.20 ± 0.18
pacquet@main 229.5 ± 13.6 207.5 252.5 2.31 ± 0.15
pnpr@HEAD 100.2 ± 3.7 96.3 112.3 1.01 ± 0.05
pnpr@main 99.2 ± 2.8 95.7 107.8 1.00
BENCHMARK_REPORT.json
{
  "results": [
    {
      "command": "pacquet@HEAD",
      "mean": 0.21798320186461537,
      "stddev": 0.01716147910062146,
      "median": 0.21947294948,
      "user": 0.1685837092307692,
      "system": 0.06349840769230769,
      "min": 0.18941445348,
      "max": 0.24930713248
    },
    {
      "command": "pacquet@main",
      "mean": 0.22951387123,
      "stddev": 0.01357462766178058,
      "median": 0.22448726248,
      "user": 0.18714819000000002,
      "system": 0.0594341,
      "min": 0.20752748848,
      "max": 0.25250755948000003
    },
    {
      "command": "pnpr@HEAD",
      "mean": 0.10021040660000002,
      "stddev": 0.0036878325049728667,
      "median": 0.10021812448,
      "user": 0.031058140000000005,
      "system": 0.011028979999999999,
      "min": 0.09625180148,
      "max": 0.11229155648
    },
    {
      "command": "pnpr@main",
      "mean": 0.09920811799724141,
      "stddev": 0.0027599014502812614,
      "median": 0.09860575248,
      "user": 0.029227112413793107,
      "system": 0.012388786206896553,
      "min": 0.09569212648,
      "max": 0.10782535148
    }
  ]
}

Scenario: Isolated linker: peer-heavy resolve, hot cache, offline

Command Mean [ms] Min [ms] Max [ms] Relative
pacquet@HEAD 642.0 ± 86.7 546.5 813.7 1.00
pacquet@main 673.8 ± 123.2 572.7 888.9 1.05 ± 0.24
pnpm@HEAD 3374.4 ± 241.0 3066.3 3675.8 5.26 ± 0.80
BENCHMARK_REPORT.json
{
  "results": [
    {
      "command": "pacquet@HEAD",
      "mean": 0.6419902837733333,
      "stddev": 0.08667931479976743,
      "median": 0.63427286644,
      "user": 0.6318872577777778,
      "system": 0.11625511333333333,
      "min": 0.54652606244,
      "max": 0.81365714144
    },
    {
      "command": "pacquet@main",
      "mean": 0.6737545822177777,
      "stddev": 0.12320863085044238,
      "median": 0.60336090844,
      "user": 0.66049348,
      "system": 0.12836411333333334,
      "min": 0.57269012544,
      "max": 0.8889049624400001
    },
    {
      "command": "pnpm@HEAD",
      "mean": 3.3743671775511115,
      "stddev": 0.24100199686499302,
      "median": 3.36425402644,
      "user": 5.104176813333333,
      "system": 0.3183558911111111,
      "min": 3.06628894744,
      "max": 3.67584370144
    }
  ]
}

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

Command Mean [s] Min [s] Max [s] Relative
pacquet@HEAD 4.421 ± 0.056 4.351 4.511 1.24 ± 0.06
pacquet@main 4.504 ± 0.164 4.321 4.728 1.26 ± 0.07
pnpr@HEAD 3.573 ± 0.123 3.399 3.802 1.00 ± 0.06
pnpr@main 3.561 ± 0.157 3.409 3.906 1.00
BENCHMARK_REPORT.json
{
  "results": [
    {
      "command": "pacquet@HEAD",
      "mean": 4.42119778158,
      "stddev": 0.05614160651635056,
      "median": 4.408354510780001,
      "user": 1.6981297999999998,
      "system": 1.6356189799999998,
      "min": 4.35099625428,
      "max": 4.51110029228
    },
    {
      "command": "pacquet@main",
      "mean": 4.50411183058,
      "stddev": 0.16446967467488513,
      "median": 4.42827888028,
      "user": 1.5953136999999997,
      "system": 1.52734898,
      "min": 4.32069574628,
      "max": 4.72787434428
    },
    {
      "command": "pnpr@HEAD",
      "mean": 3.5726556644800005,
      "stddev": 0.12284288415513109,
      "median": 3.5611040887799996,
      "user": 1.6271744,
      "system": 1.63042578,
      "min": 3.3992698992799997,
      "max": 3.80194286428
    },
    {
      "command": "pnpr@main",
      "mean": 3.56098172188,
      "stddev": 0.15666974155973515,
      "median": 3.52730458828,
      "user": 1.6288542,
      "system": 1.61661958,
      "min": 3.4093689812799997,
      "max": 3.90608300328
    }
  ]
}

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

Same install as the isolated fresh-restore hot/hot scenario, into the shared virtual store — the layout pnpm 12 installs into by default. Comparable to that scenario head-to-head.

Command Mean [ms] Min [ms] Max [ms] Relative
pacquet@HEAD 182.8 ± 14.7 170.9 220.3 1.00
pacquet@main 220.8 ± 8.5 210.2 237.5 1.21 ± 0.11
pnpr@HEAD 209.4 ± 21.4 183.6 252.0 1.15 ± 0.15
pnpr@main 195.9 ± 10.2 183.9 224.1 1.07 ± 0.10
BENCHMARK_REPORT.json
{
  "results": [
    {
      "command": "pacquet@HEAD",
      "mean": 0.18281259832,
      "stddev": 0.014749753831543684,
      "median": 0.17725236212,
      "user": 0.21035198,
      "system": 0.20157590666666664,
      "min": 0.17086965412,
      "max": 0.22025638212
    },
    {
      "command": "pacquet@main",
      "mean": 0.2208168137866667,
      "stddev": 0.00849513758901698,
      "median": 0.22155096862,
      "user": 0.26325603000000003,
      "system": 0.22293420666666666,
      "min": 0.21018145312,
      "max": 0.23752601012000002
    },
    {
      "command": "pnpr@HEAD",
      "mean": 0.20943417539272727,
      "stddev": 0.021436835438971794,
      "median": 0.20569001112000002,
      "user": 0.25082423454545455,
      "system": 0.19432549454545453,
      "min": 0.18356910412,
      "max": 0.25203138612000003
    },
    {
      "command": "pnpr@main",
      "mean": 0.19591723797714286,
      "stddev": 0.010218946129836579,
      "median": 0.19233028212000003,
      "user": 0.22330185142857142,
      "system": 0.18914082571428573,
      "min": 0.18393695912,
      "max": 0.22405090712
    }
  ]
}

@github-actions

github-actions Bot commented Aug 12, 2026 •

Copy link
Copy Markdown
Contributor

🐰 Bencher Report

Projectpnpm's project
Branchpr/13876
Testbedpacquet

🚨 2 Alerts

BenchmarkMeasure
Units
ViewBenchmark Result
(Result Δ%)
Upper Boundary
(Limit %)
isolated-linker.repeat-install.cold-cache.hot-storeLatency
milliseconds (ms)
📈 plot
🚷 threshold
🚨 alert (🔔)
9.93 ms
(+50.19%)Baseline: 6.61 ms
7.93 ms
(125.16%)

isolated-linker.repeat-install.hot-cache.hot-storeLatency
milliseconds (ms)
📈 plot
🚷 threshold
🚨 alert (🔔)
8.97 ms
(+40.84%)Baseline: 6.37 ms
7.65 ms
(117.36%)

Click to view all benchmark results
BenchmarkLatencyBenchmark Result
milliseconds (ms)
(Result Δ%)
Upper Boundary
milliseconds (ms)
(Limit %)
gvs-linker.fresh-restore.hot-cache.hot-store📈 view plot
🚷 view threshold
170.87 ms
(-4.78%)Baseline: 179.44 ms
215.33 ms
(79.35%)
isolated-linker.fresh-install.cold-cache.cold-store📈 view plot
🚷 view threshold
2,883.58 ms
(+3.33%)Baseline: 2,790.65 ms
3,348.78 ms
(86.11%)
isolated-linker.fresh-install.cold-cache.hot-store📈 view plot
🚷 view threshold
1,941.18 ms
(+0.77%)Baseline: 1,926.28 ms
2,311.54 ms
(83.98%)
isolated-linker.fresh-install.hot-cache.hot-store📈 view plot
🚷 view threshold
399.78 ms
(-12.75%)Baseline: 458.18 ms
549.82 ms
(72.71%)
isolated-linker.fresh-resolve.hot-cache.offline📈 view plot
🚷 view threshold
189.41 ms
(-12.34%)Baseline: 216.08 ms
259.30 ms
(73.05%)
isolated-linker.fresh-restore.cold-cache.cold-store📈 view plot
🚷 view threshold
2,322.77 ms
(+0.72%)Baseline: 2,306.07 ms
2,767.29 ms
(83.94%)
isolated-linker.fresh-restore.cold-cache.cold-store.cold-pnpr📈 view plot
🚷 view threshold
4,351.00 ms
(+0.03%)Baseline: 4,349.90 ms
5,219.88 ms
(83.35%)
isolated-linker.fresh-restore.hot-cache.hot-store📈 view plot
🚷 view threshold
323.67 ms
(+16.25%)Baseline: 278.42 ms
334.11 ms
(96.87%)
isolated-linker.peer-heavy-resolve.hot-cache.offline📈 view plot
🚷 view threshold
546.53 ms
(+10.65%)Baseline: 493.91 ms
592.69 ms
(92.21%)
isolated-linker.repeat-install.cold-cache.hot-store📈 view plot
🚷 view threshold
🚨 view alert (🔔)
9.93 ms
(+50.19%)Baseline: 6.61 ms
7.93 ms
(125.16%)

isolated-linker.repeat-install.hot-cache.hot-store📈 view plot
🚷 view threshold
🚨 view alert (🔔)
8.97 ms
(+40.84%)Baseline: 6.37 ms
7.65 ms
(117.36%)

🐰 View full continuous benchmarking report in Bencher

@github-actions

Copy link
Copy Markdown
Contributor

🐰 Bencher Report

Projectpnpm's project
Branchpr/13876
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
1,489.04 ms
isolated-linker.fresh-install.cold-cache.hot-store📈 view plot
⚠️ NO THRESHOLD
358.15 ms
isolated-linker.fresh-install.hot-cache.hot-store📈 view plot
⚠️ NO THRESHOLD
322.95 ms
isolated-linker.fresh-resolve.hot-cache.offline📈 view plot
⚠️ NO THRESHOLD
90.55 ms
isolated-linker.fresh-restore.cold-cache.cold-store📈 view plot
⚠️ NO THRESHOLD
1,420.96 ms
isolated-linker.fresh-restore.cold-cache.cold-store.cold-pnpr📈 view plot
⚠️ NO THRESHOLD
3,496.57 ms
isolated-linker.fresh-restore.hot-cache.hot-store📈 view plot
⚠️ NO THRESHOLD
282.45 ms
🐰 View full continuous benchmarking report in Bencher

@qodo-code-review

Copy link
Copy Markdown

Qodo reviews are paused for this user.

Troubleshooting steps vary by plan Learn more →

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

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

@greptile-apps
greptile-apps Bot dismissed their stale review August 13, 2026 12:38

Dismissed because a newer commit was pushed; Greptile will re-review the current head.

@karlhorky

karlhorky commented Aug 17, 2026 •

Copy link
Copy Markdown
Member

@zkochan what do you think of this PR? Can you review it?

btea mentioned in #13872 (comment) that it's "basically reasonable"


edit: oh, maybe the PR #13873 is better, if the Rust port doesn't need to be changed after all:

@zkochan
zkochan force-pushed the fix-allow-build-config branch from 7c86f92 to 88f26b0 Compare August 20, 2026 16:04
greptile-apps[bot]
greptile-apps Bot previously approved these changes Aug 20, 2026
@qodo-code-review

Copy link
Copy Markdown

Code Review by Qodo

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

Grey Divider


Remediation recommended

1. Unrelated Rust refactors included 📘 Rule violation ⚙ Maintainability
Description
This bug-fix PR for pnpm add --allow-build also includes unrelated Rust changes (filesystem
symlink handling, Windows handle casting, and lockfile parsing tests), increasing review/merge risk
and obscuring the core fix.
Code

pnpm/crates/fs/src/symlink_dir.rs[R97-100]

+        match junction::exists(link) {
            Ok(is_junction) => Ok(is_junction),
            Err(error) if error.raw_os_error() == Some(ERROR_NOT_A_REPARSE_POINT) => Ok(false),
            Err(error) => Err(error),
-        };
Relevance

●●● Strong

Bug-fix scope rule directly applies; reviewers have accepted maintainability cleanup findings in
nearby Rust changes.

PR-#13960
PR-#13306

ⓘ Recommendations generated based on similar findings in past PRs

Evidence
PR Compliance ID 2255067 requires bug-fix PRs to avoid unrelated refactors/reformatting. The diff
shows additional Rust changes in pnpm/crates/fs and pnpm/crates/injected-deps-syncer, plus a
significant rewrite of a lockfile parsing test fixture, none of which are part of the
--allow-build/allowBuilds bug described in the PR.

Rule 2255067: Bug fix changes must not include unrelated refactors or reformatting
pnpm/crates/fs/src/symlink_dir.rs[94-102]
pnpm/crates/injected-deps-syncer/src/dir_patcher.rs[321-333]
pnpm/crates/lockfile/src/load_lockfile/tests.rs[140-158]

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

## Issue description
This PR is scoped as a bug fix for `pnpm add --allow-build`, but it also contains unrelated Rust-only refactors/changes, which violates the repo’s scope-discipline expectations for bug-fix PRs.

## Issue Context
The PR description and changeset are about preserving/merging `allowBuilds` config, but additional diffs touch unrelated crates/tests.

## Fix Focus Areas
- pnpm/crates/fs/src/symlink_dir.rs[97-101]
- pnpm/crates/injected-deps-syncer/src/dir_patcher.rs[330-332]
- pnpm/crates/lockfile/src/load_lockfile/tests.rs[142-158]

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


2. Test double-allocates huge scalar 🐞 Bug ➹ Performance
Description
The updated large-scalar lockfile test builds a 65MiB temporary string via "a".repeat(...) and then
copies it into the main buffer, roughly doubling peak memory for this test and increasing risk of CI
OOM/flakiness when tests run concurrently.
Code

pnpm/crates/lockfile/src/load_lockfile/tests.rs[R145-148]

+    let huge_string_len = 65 * 1024 * 1024;
+    content.reserve(huge_string_len + 100);
+    content.push_str(&"a".repeat(huge_string_len));
+    content.push_str("\n\nimporters:\n  .: {}\n");
Relevance

●●● Strong

Close lockfile allocation precedent was accepted; this deterministic temporary-buffer duplication is
similarly actionable.

PR-#13417

ⓘ Recommendations generated based on similar findings in past PRs

Evidence
The test explicitly creates a 65MiB temporary string with repeat and then copies it into
content, which means both buffers exist at once during the append, raising peak memory use.

pnpm/crates/lockfile/src/load_lockfile/tests.rs[140-158]

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 test `parses_lockfile_larger_than_default_yaml_scalar_byte_budget` currently calls `"a".repeat(huge_string_len)` and then `push_str` into `content`. This creates a second ~65MiB allocation and then copies it, increasing peak memory (~2x for that section) and potentially making CI unstable under parallel test execution.

### Issue Context
This is test-only code, but it runs in unit test suites where parallelism can amplify peak RSS.

### Fix Focus Areas
- pnpm/crates/lockfile/src/load_lockfile/tests.rs[142-148]

### Suggested fix
Append the large scalar without allocating an intermediate 65MiB `String`.

One practical approach is chunked appends:
- Predefine a reasonably-sized chunk (e.g., 1MiB of `'a'`).
- Loop `huge_string_len / chunk.len()` times pushing that chunk.
- Append the remainder.

This keeps `content` as the only large buffer while remaining reasonably fast.

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


Grey Divider

Context sources
✅ Compliance rules (platform): 27 rules

Grey Divider

Tip of the day
💡 Did you know, you can copy the agent prompt from any finding and feed it to your IDE agent

More tips ↗ | Customize Qodo ↗ | Qodo docs ↗

Grey Divider

Qodo Logo

@qodo-code-review

Copy link
Copy Markdown

PR Code Suggestions ✨

Warning

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

No code suggestions found for the PR.

The allowBuilds merge fix already landed on main with its own changeset,
so this one would duplicate the release note. The remaining PR content is
internal/test-only and needs no changeset.

Co-Authored-By: Claude Fable 5 <[email protected]>
@greptile-apps
greptile-apps Bot dismissed their stale review August 20, 2026 16:21

Dismissed because a newer commit was pushed; Greptile will re-review the current head.

@qodo-code-review

qodo-code-review Bot commented Aug 20, 2026 •

Copy link
Copy Markdown

No code changes since the last review — review skipped

Qodo Logo

@coderabbitai

coderabbitai Bot commented Aug 20, 2026

Copy link
Copy Markdown
Contributor

Note

GitHub couldn't provide a complete incremental comparison for this pull request, so CodeRabbit is performing a full review instead. This review may take a little longer.

@qodo-code-review

Copy link
Copy Markdown

PR Code Suggestions ✨

Warning

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

No code suggestions found for the PR.

@zkochan zkochan changed the title fix(add): preserve existing allowBuilds config with --allow-build test(pacquet): speed up the yaml scalar-budget lockfile test Aug 20, 2026
@zkochan
zkochan merged commit cd1b42d into pnpm:main Aug 20, 2026
36 of 39 checks passed
@welcome

welcome Bot commented Aug 20, 2026

Copy link
Copy Markdown

Congrats on merging your first pull request! 🎉🎉🎉

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

Labels

product: pacquet product: pnpm@11 reviewed: coderabbit CodeRabbit submitted an approving review

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants