Repository navigation
fix(package-manager): hold selected projects to the wanted lockfile after a filtered install - #17019
Conversation
…fter a filtered install A filtered install refreshes the workspace-wide lastValidatedTimestamp while materializing only the projects it selected. The verify-deps gate before run and exec then found no manifest or lockfile newer than that timestamp and reported the tree up to date, so a later filtered command that selected another project, installed earlier but behind the wanted lockfile since, ran its script without the new dependencies. The "error" and "warn" actions reported nothing for the same reason. After a filtered install the gate already required each selected project with dependencies to have a modules directory and an importer in the current lockfile. It now also requires the current lockfile to record what the wanted lockfile materializes for the selection: the materialization closure of the selected importers must match on both sides. The closures are taken in the dependency groups the workspace state recorded, so a production-only filtered install does not make the gate install before every script. Projects the command did not select stay exempt, so a stale unselected project cannot make the gate reinstall on every run either. The check only runs when the state records a filtered install and the selection includes a project with dependencies. It adds a parse of the wanted lockfile to that path, which already read the current lockfile. pnpm v11 has the same bug, but its filtered install writes the wanted importers of the unselected projects into the current lockfile, so the current lockfile cannot show which projects are stale there. That needs a different mechanism and is left out of this change. Closes pnpm#17011 Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info
📝 Walkthrough
Merge Risk: ⚪ Minimal · up to
|
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #17019 +/- ##
=======================================
Coverage 92.53% 92.54%
=======================================
Files 1775 1775
Lines 228495 228551 +56
=======================================
+ Hits 211441 211505 +64
+ Misses 17054 17046 -8 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Same-run regression checkHEAD and main are measured on the same runner. The tolerance is 5% of the main median or 2 ms, whichever is larger. A regression requires both the median slowdown and the gap between the fastest retained HEAD sample and slowest retained main sample to exceed this tolerance, after trimming up to 10% from each tail. Suspected regressions are rerun once with target order reversed and only fail if reproduced. This conservative noise guard is not a statistical confidence interval. Inconclusive rows do not fail the check. They remain visible for performance review. Bencher retains absolute minimum timings for historical tracking; historical alerts do not gate this PR. Sequential measurements can still be affected by runner drift.
Integrated-Benchmark Report (Linux)Commit: Regular scenarios report direct and pnpr installs. The peer-heavy resolver scenario compares current Rust, main Rust, and TypeScript pnpm; the linked and injected workspace scenarios compare current Rust against main Rust. Bencher consumes pacquet@HEAD and pnpr@HEAD. The tables below show mean ± σ. Bencher tracks absolute minimum latency; PR regression checks compare HEAD and main samples from the same runner. Historical timing alerts do not gate PRs. Scenario: Isolated linker: fresh restore, cold cache + cold store
BENCHMARK_REPORT.json{
"results": [
{
"command": "pacquet@HEAD",
"mean": 2.4249131825,
"stddev": 0.13462362819478088,
"median": 2.3873834117,
"user": 1.2783106,
"system": 1.3781280199999997,
"min": 2.2788634327,
"max": 2.6195678317
},
{
"command": "pacquet@main",
"mean": 2.3920002796,
"stddev": 0.12275533519388729,
"median": 2.3314144592,
"user": 1.2883250999999998,
"system": 1.3827637199999998,
"min": 2.2702976937,
"max": 2.5666579787
},
{
"command": "pnpr@HEAD",
"mean": 1.5100514246999999,
"stddev": 0.17014395760183434,
"median": 1.5774781922,
"user": 1.1928486999999999,
"system": 1.2389526199999998,
"min": 1.2883565397,
"max": 1.6888052757
},
{
"command": "pnpr@main",
"mean": 1.4155729276,
"stddev": 0.07374141863137432,
"median": 1.3971285582,
"user": 1.3952737000000002,
"system": 1.45574082,
"min": 1.3012979297,
"max": 1.5414869546999999
}
]
}Scenario: Isolated linker: fresh restore, hot cache + hot store
BENCHMARK_REPORT.json{
"results": [
{
"command": "pacquet@HEAD",
"mean": 0.23252149148,
"stddev": 0.012290537506897261,
"median": 0.22950360578,
"user": 0.25092375999999994,
"system": 0.5712558600000001,
"min": 0.21646782478,
"max": 0.24991281678
},
{
"command": "pacquet@main",
"mean": 0.3250224435800001,
"stddev": 0.08319020048245795,
"median": 0.34222024428000003,
"user": 0.37559515999999993,
"system": 0.7934986599999999,
"min": 0.22216724678000002,
"max": 0.42167829078
},
{
"command": "pnpr@HEAD",
"mean": 0.25002941628,
"stddev": 0.015143981610153835,
"median": 0.24802842628,
"user": 0.26135016,
"system": 0.60612796,
"min": 0.22205771478,
"max": 0.27675601578000003
},
{
"command": "pnpr@main",
"mean": 0.24438304798,
"stddev": 0.010513414987385167,
"median": 0.24778448028,
"user": 0.26615906,
"system": 0.55733616,
"min": 0.22437882178000002,
"max": 0.25640579378
}
]
}Scenario: Isolated linker: repeat install, hot cache + hot store
BENCHMARK_REPORT.json{
"results": [
{
"command": "pacquet@HEAD",
"mean": 0.010138177545645152,
"stddev": 0.000615770444206292,
"median": 0.01015475334,
"user": 0.00549832112903226,
"system": 0.0056639561290322575,
"min": 0.00847765784,
"max": 0.01249080984
},
{
"command": "pacquet@main",
"mean": 0.010096676727159535,
"stddev": 0.00045931302790806744,
"median": 0.01012951784,
"user": 0.0053332228015564205,
"system": 0.0057922639688716,
"min": 0.00856826784,
"max": 0.01181977884
},
{
"command": "pnpr@HEAD",
"mean": 0.01010286084389106,
"stddev": 0.000516240303177496,
"median": 0.01013644784,
"user": 0.005586203346303502,
"system": 0.005568031439688714,
"min": 0.00843434784,
"max": 0.01159585884
},
{
"command": "pnpr@main",
"mean": 0.010133202798015268,
"stddev": 0.0004791103719033977,
"median": 0.01016735384,
"user": 0.005839115114503817,
"system": 0.005354003053435114,
"min": 0.00832587784,
"max": 0.01224656984
}
]
}Scenario: Isolated linker: repeat install, cold cache + hot store
BENCHMARK_REPORT.json{
"results": [
{
"command": "pacquet@HEAD",
"mean": 0.00855330329760684,
"stddev": 0.0007986820643805059,
"median": 0.00839567246,
"user": 0.004481379230769226,
"system": 0.004837903675213679,
"min": 0.0072506244600000005,
"max": 0.01176138546
},
{
"command": "pacquet@main",
"mean": 0.008070046252253524,
"stddev": 0.0005613908695148243,
"median": 0.008023296959999999,
"user": 0.004766351197183101,
"system": 0.004008995985915491,
"min": 0.007207353460000001,
"max": 0.011582219460000001
},
{
"command": "pnpr@HEAD",
"mean": 0.007979037915830394,
"stddev": 0.0003428775228370003,
"median": 0.00794519046,
"user": 0.004798620989399293,
"system": 0.0040023347703180235,
"min": 0.00712358546,
"max": 0.00936936846
},
{
"command": "pnpr@main",
"mean": 0.007861774056551732,
"stddev": 0.0004570432354166398,
"median": 0.00781708946,
"user": 0.004713862758620686,
"system": 0.00388567455172414,
"min": 0.006851564460000001,
"max": 0.01029845546
}
]
}Scenario: Isolated linker: fresh install, cold cache + cold store
BENCHMARK_REPORT.json{
"results": [
{
"command": "pacquet@HEAD",
"mean": 2.53924231532,
"stddev": 0.09469456451887182,
"median": 2.50233111002,
"user": 1.9531512,
"system": 1.65228076,
"min": 2.48299574502,
"max": 2.77373365202
},
{
"command": "pacquet@main",
"mean": 2.52544229002,
"stddev": 0.02446606303837267,
"median": 2.52121587852,
"user": 1.9046134999999995,
"system": 1.59341526,
"min": 2.49746653502,
"max": 2.58381647102
},
{
"command": "pnpr@HEAD",
"mean": 1.58691054252,
"stddev": 0.11021378234284102,
"median": 1.58574772002,
"user": 1.239354,
"system": 1.3076777600000002,
"min": 1.41191081602,
"max": 1.7457315220200003
},
{
"command": "pnpr@main",
"mean": 1.62745560782,
"stddev": 0.138047654994021,
"median": 1.5961104000200002,
"user": 1.1981484999999998,
"system": 1.3264867599999999,
"min": 1.47681155202,
"max": 1.8704940410200002
}
]
}Scenario: Isolated linker: fresh install, hot cache + hot store
BENCHMARK_REPORT.json{
"results": [
{
"command": "pacquet@HEAD",
"mean": 0.42285421952,
"stddev": 0.020015945188618493,
"median": 0.42299752382,
"user": 0.5802924,
"system": 0.70804822,
"min": 0.39659294582,
"max": 0.45072915682
},
{
"command": "pacquet@main",
"mean": 0.43696666651999994,
"stddev": 0.018626787051032625,
"median": 0.43566582282,
"user": 0.6268812,
"system": 0.73951422,
"min": 0.41229070182,
"max": 0.46085186082
},
{
"command": "pnpr@HEAD",
"mean": 0.28798332091999995,
"stddev": 0.00902430287810605,
"median": 0.28656707732,
"user": 0.23629569999999997,
"system": 0.5724004199999999,
"min": 0.27561563282,
"max": 0.30625232182
},
{
"command": "pnpr@main",
"mean": 0.28088788072000004,
"stddev": 0.009045936000266966,
"median": 0.27954638032,
"user": 0.22466819999999998,
"system": 0.5439104199999999,
"min": 0.26733522781999997,
"max": 0.29416560782
}
]
}Scenario: Isolated linker: fresh install, cold cache + hot store
BENCHMARK_REPORT.json{
"results": [
{
"command": "pacquet@HEAD",
"mean": 1.6209350097600002,
"stddev": 0.0158838794536392,
"median": 1.61648530646,
"user": 0.8742757400000002,
"system": 0.9139475599999998,
"min": 1.59817183096,
"max": 1.65211569096
},
{
"command": "pacquet@main",
"mean": 1.61331329666,
"stddev": 0.011422756395026877,
"median": 1.61453412446,
"user": 0.8761702400000001,
"system": 0.88595056,
"min": 1.58953875396,
"max": 1.62726335296
},
{
"command": "pnpr@HEAD",
"mean": 0.29680687906,
"stddev": 0.009491590164194973,
"median": 0.29962730046,
"user": 0.24334414,
"system": 0.58611116,
"min": 0.28333548096000005,
"max": 0.30711955396
},
{
"command": "pnpr@main",
"mean": 0.29668068416000004,
"stddev": 0.008940544196858049,
"median": 0.30054395096000003,
"user": 0.24650873999999998,
"system": 0.59029906,
"min": 0.27897466596000003,
"max": 0.30638414396
}
]
}Scenario: Isolated linker: fresh resolve, hot cache, offline
BENCHMARK_REPORT.json{
"results": [
{
"command": "pacquet@HEAD",
"mean": 0.23858306352909092,
"stddev": 0.008761485874439654,
"median": 0.23501085562000001,
"user": 0.22631796363636364,
"system": 0.09537022909090909,
"min": 0.22806284062,
"max": 0.25287258062000006
},
{
"command": "pacquet@main",
"mean": 0.23041748652909091,
"stddev": 0.01139228434375831,
"median": 0.22556584962,
"user": 0.20849305454545455,
"system": 0.09312850181818182,
"min": 0.22112320162000001,
"max": 0.25291816562
},
{
"command": "pnpr@HEAD",
"mean": 0.09339424858774195,
"stddev": 0.0019241726416941466,
"median": 0.09277660362000001,
"user": 0.03232063225806451,
"system": 0.01667766451612903,
"min": 0.09158152362000001,
"max": 0.09852461862
},
{
"command": "pnpr@main",
"mean": 0.10770258498666667,
"stddev": 0.016270227949200057,
"median": 0.09799609912000001,
"user": 0.042342899999999996,
"system": 0.02192322,
"min": 0.09109113462,
"max": 0.13751474262000002
}
]
}Scenario: Isolated linker: peer-heavy resolve, hot cache, offline
BENCHMARK_REPORT.json{
"results": [
{
"command": "pacquet@HEAD",
"mean": 0.24242113781111113,
"stddev": 0.009836844798686224,
"median": 0.23714087170000003,
"user": 0.24859888666666663,
"system": 0.05428165777777778,
"min": 0.23191121270000004,
"max": 0.25791493870000004
},
{
"command": "pacquet@main",
"mean": 0.24366225036666667,
"stddev": 0.011919439008429681,
"median": 0.24462790970000003,
"user": 0.2531704422222222,
"system": 0.05172554666666666,
"min": 0.22999819170000002,
"max": 0.26882814070000005
},
{
"command": "pnpm@HEAD",
"mean": 3.651653769366666,
"stddev": 0.1123913941810724,
"median": 3.6590145087,
"user": 5.5429102199999996,
"system": 0.38001188,
"min": 3.4964473947,
"max": 3.8289300476999997
}
]
}Scenario: Isolated linker: linked-workspace resolve, hot cache, offline
BENCHMARK_REPORT.json{
"results": [
{
"command": "pacquet@HEAD",
"mean": 0.21488134174769233,
"stddev": 0.0046384203170463725,
"median": 0.21478218444000002,
"user": 0.17290750923076922,
"system": 0.08682258461538463,
"min": 0.20729740744000003,
"max": 0.22220041244000002
},
{
"command": "pacquet@main",
"mean": 0.21521993159384617,
"stddev": 0.004809090414384733,
"median": 0.21604834644000004,
"user": 0.1773141246153846,
"system": 0.0834501230769231,
"min": 0.20694089744000002,
"max": 0.22202736144000002
}
]
}Scenario: Isolated linker: injected workspace repeat install, hot cache + hot store
BENCHMARK_REPORT.json{
"results": [
{
"command": "pacquet@HEAD",
"mean": 0.07000263723052629,
"stddev": 0.001960526704632806,
"median": 0.06961452252,
"user": 0.02533191578947368,
"system": 0.049691727368421056,
"min": 0.06773794952,
"max": 0.07661997951999999
},
{
"command": "pacquet@main",
"mean": 0.07134270442476191,
"stddev": 0.0036433325950412138,
"median": 0.07069854102,
"user": 0.0257671,
"system": 0.05076637523809523,
"min": 0.06691046752,
"max": 0.08548470652
}
]
}Scenario: Isolated linker: fresh restore, cold cache + cold store + cold pnpr
BENCHMARK_REPORT.json{
"results": [
{
"command": "pacquet@HEAD",
"mean": 4.53905305354,
"stddev": 0.13975586390607986,
"median": 4.54464097894,
"user": 1.5558682400000001,
"system": 1.5555865,
"min": 4.32738751994,
"max": 4.8028777519400006
},
{
"command": "pacquet@main",
"mean": 4.42318172944,
"stddev": 0.110128552162899,
"median": 4.37999638344,
"user": 1.42577284,
"system": 1.4055514999999998,
"min": 4.32615248194,
"max": 4.68488294494
},
{
"command": "pnpr@HEAD",
"mean": 3.4470990421399996,
"stddev": 0.09068590283117692,
"median": 3.41536962844,
"user": 1.33458634,
"system": 1.3190075999999997,
"min": 3.38349234494,
"max": 3.67730657594
},
{
"command": "pnpr@main",
"mean": 3.5573272274399996,
"stddev": 0.12175628680544383,
"median": 3.5440815909400003,
"user": 1.32957224,
"system": 1.3565229,
"min": 3.39747982594,
"max": 3.71417961894
}
]
}Scenario: GVS linker: fresh restore, hot cache + hot storeSame install as the isolated fresh-restore hot/hot scenario, into the shared virtual store, the layout pnpm 12 installs into by default. Scenarios run on separate machines, so compare main and branch within each table.
BENCHMARK_REPORT.json{
"results": [
{
"command": "pacquet@HEAD",
"mean": 0.14796137254888886,
"stddev": 0.005209576650712406,
"median": 0.14639844716,
"user": 0.17866596222222222,
"system": 0.1770371288888889,
"min": 0.14154982716,
"max": 0.15862152516
},
{
"command": "pacquet@main",
"mean": 0.15477449234750001,
"stddev": 0.004705813084128723,
"median": 0.15380756516,
"user": 0.17964299,
"system": 0.19631092749999998,
"min": 0.14776795216000002,
"max": 0.16093595616
},
{
"command": "pnpr@HEAD",
"mean": 0.1679973768933333,
"stddev": 0.003928865337331295,
"median": 0.16893022516,
"user": 0.19837440666666664,
"system": 0.18486093999999997,
"min": 0.16122359816,
"max": 0.17502626116
},
{
"command": "pnpr@main",
"mean": 0.17059575669333332,
"stddev": 0.006084575846497306,
"median": 0.17009410716,
"user": 0.20506920666666667,
"system": 0.18111087333333334,
"min": 0.15972410616000002,
"max": 0.18041623516000002
}
]
}Scenario: Store only: unlocked direct deps, cold cache + hot storeStore-only install (
BENCHMARK_REPORT.json{
"results": [
{
"command": "pacquet@HEAD",
"mean": 1.15533718412,
"stddev": 0.01991187053457181,
"median": 1.15536083082,
"user": 0.53571114,
"system": 0.22235902,
"min": 1.13362327782,
"max": 1.19575405082
},
{
"command": "pacquet@main",
"mean": 1.2209594006200004,
"stddev": 0.09188373319030721,
"median": 1.18084485282,
"user": 0.6668830399999999,
"system": 0.28688782,
"min": 1.14091917682,
"max": 1.38733025882
}
]
} |
…d lockfile Without pnpm-lock.yaml the current lockfile stands in for it, so the selection check has nothing to compare and must not report the selected projects outdated. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Qodo reviews are paused for this user.Troubleshooting steps vary by plan Learn more → On a Teams plan? Using GitHub Enterprise Server, GitLab Self-Managed, or Bitbucket Data Center? |
There was a problem hiding this comment.
Your trial has ended. Reactivate Greptile to resume code reviews.
|
Reviewed the full change on c99f7f6. The rebase onto What I checked:
Status: all checks are green. CodeRabbit approved this head. Greptile (trial ended) and Qodo (paused for this user) did not review. Nothing is left to do in this PR. The v11 half is still open as pnpm/tasks#139, as the description says. Written by an agent (Claude Code, claude-opus-5-5). |
|
Congrats on merging your first pull request! 🎉🎉🎉 |
Summary
close #17011
After a filtered install for one project,
pnpm runandpnpm exectreated another selected project as up to date even when its dependencies had changed and were never installed. The script then ran without them, andverifyDepsBeforeRun: errorandwarnreported nothing.Root cause. A filtered install writes one workspace-wide
lastValidatedTimestampwhile materializing only the projects it selected. For a later filtered command, the gate checks that each selected project has a modules directory and an importer in the current lockfile. Both hold for a project installed earlier. No manifest or lockfile is newer than the refreshed timestamp, socheck_freshnessreturns early and never compares the current lockfile with the wanted one. The current lockfile still holds that project's importer from before the change.Fix. When the state records a filtered install, the gate now also requires the current lockfile to record what the wanted lockfile materializes for the selection. It builds
materialization_closurefor the selected importers from both lockfiles and compares their importers, snapshots, and packages. Two details:pnpm install --prod --filter …the current lockfile has no dev dependencies, so comparing all groups would make the gate install before every script.When it fails, the gate reports
the installed dependencies are not up to date with the lockfile. That is the same message it gives for this repro when no filtered install ran in between. The string now lives in one constant shared with the existing assertion.Cost. The extra work only runs after a filtered install and only for a selection that includes a project with dependencies. That path already read the current lockfile. It now also parses the wanted lockfile, which is loaded lazily and reused by the later freshness phase.
pnpm v11 is not fixed in this PR
The bug reproduces on 11.28.6 with the issue's script. v11 needs a different fix, so it is not included here. v11's filtered install writes the wanted importer of every unselected project into the current lockfile. After
pnpm --filter a run x,node_modules/.pnpm/lock.yamlalready listsmsunderbeven thoughb/node_moduleslacks it. With a shared dependency,msis also inpackages, so nothing in v11's current lockfile shows thatbis stale. Fixing v11 would need new state, such as recording which projects a filtered install materialized in the workspace state, or probingnode_modules. I'd like a maintainer's view on the approach before attempting it. I filed the follow-up as pnpm/tasks#139.Squash Commit Body
How I tested it
Reproduced first on published pnpm 12.14.0 and 11.28.6 with the issue's script. In both,
--config.verify-deps-before-run=error --filter b run xreported nothing and the script failed withCannot find module 'ms'. The control withoutpnpm --filter a run xreported the drift on both versions.Unit tests in
optimistic_repeat_install/tests.rs:a_filtered_state_requires_the_selected_projects_to_match_the_wanted_lockfile: a selected project behind the wanted lockfile is outdated even though nothing is newer than the timestamp. A stale unselected project does not affect the selection. This test fails without the fix.a_filtered_state_without_a_wanted_lockfile_accepts_the_selected_projects: withoutpnpm-lock.yamlthe current lockfile stands in for it, so the selection is not reported outdated. It fails if that branch is flipped.a_filtered_state_compares_the_selected_projects_in_the_recorded_groups: a production-only filtered install is not reported outdated for its missing dev dependencies. It passes with or without the fix. I confirmed it fails when the fix compares all groups.End-to-end test
verify_deps_before_run::exec_installs_the_changed_dependencies_of_a_project_a_filtered_install_left_behindmirrors the issue against the mocked registry:errorfails with the outdated message.installinstalls the new dependency for the selected project.errorrun passes, so the gate does not loop.This test fails without the fix.
The issue's script against a local debug build of the branch:
errorreports the drift,pnpm --filter b run xinstallsmsand printsb: ok, and latererrorruns for bothaandbpass without reinstalling.pnpm test:rust -p pnpm-package-manager: 996 passed. The one skipped test is skipped on main too.pnpm test:rust -p pnpm-cli -E 'test(/^verify_deps_before_run::/)': 46 passed.cargo clippy --locked --workspace --all-targets -- --deny warnings, the pinned rustfmt--check, andtyposon the changed files are clean.Not run locally:
cargo dylint, which isn't installed here. I kept the changed functions and files within the limits indylint.toml. CI runs it.Checklist
already linked to it solves it.
are implemented in every affected version. (v12 only. v11 is affected too, but needs a different mechanism. See "pnpm v11 is not fixed in this PR" above.)
pnpm changeset) if this PR changes any publishedpackage. Keep it short and written for pnpm users — it becomes a release note.
This PR was written with the help of an AI agent, and I reviewed and ran the tests described above.
Written by an agent (Claude Code, claude-opus-5-5).
🤖 Generated with Claude Code
Summary by CodeRabbit
pnpm runandpnpm execcommands now detect when a selected project’s dependencies are out of date, even after another filtered install.verifyDepsBeforeRun=error, these commands report outdated dependencies. In install mode, they install the selected project’s changed dependencies before running.