Repository navigation
fix: honor trustPolicy in pnpm self-update, and recover from unusable cached engine slots - #12838
Conversation
PR Summary by Qodofix(pacquet-cli): skip trust check when resolving pnpm engine version
AI Description
Diagram
High-Level Assessment
Files changed (2)
|
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (3)
🚧 Files skipped from review as they are similar to previous changes (1)
📝 WalkthroughWalkthroughThe PR updates self-update resolution to use full metadata when needed, removes trust-policy gating from the Rust probe, forwards trust-policy inputs in the pnpm self-updater, and changes cached pnpm reuse so native slots are reused only when relinking succeeds. ChangesSelf-update resolution and reuse
Estimated code review effort: 4 (Complex) | ~45 minutes Possibly related PRs
Suggested labels: ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Warning There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure. 🔧 ESLint
ESLint install failed. For unrecoverable errors, disable the tool in CodeRabbit configuration. 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. Comment |
Micro-Benchmark ResultsLinux |
Code Review by Qodo
1. No-downgrade can miss trust
|
Code Review by Qodo
Context used✅ Compliance rules (platform):
51 rules 1.
|
PR Code Suggestions ✨Latest suggestions up to ba5234a Warning
Previous suggestionsSuggestions up to commit 117e24e
Suggestions up to commit f9cf80b
|
|||||||||||||||||||||||||||||||
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #12838 +/- ##
==========================================
+ Coverage 85.80% 85.82% +0.01%
==========================================
Files 448 448
Lines 69402 69415 +13
==========================================
+ Hits 59552 59575 +23
+ Misses 9850 9840 -10 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
|
Code review by qodo was updated up to the latest commit f9cf80b |
Integrated-Benchmark Report (Linux)Commit: Each scenario reports direct installs and pnpr installs. Bencher consumes pacquet@HEAD and pnpr@HEAD. Scenario: Isolated linker: fresh restore, cold cache + cold store
BENCHMARK_REPORT.json{
"results": [
{
"command": "pacquet@HEAD",
"mean": 4.06586162206,
"stddev": 0.125982355271281,
"median": 4.04707061346,
"user": 3.9178871599999994,
"system": 3.40018442,
"min": 3.91213405046,
"max": 4.31137130146,
"times": [
4.17658962446,
4.14263586946,
3.98598513446,
3.93198621046,
4.01581294046,
3.96994721946,
4.13382558346,
4.07832828646,
3.91213405046,
4.31137130146
]
},
{
"command": "pacquet@main",
"mean": 4.09641589346,
"stddev": 0.15997308657144915,
"median": 4.06867726496,
"user": 3.94253156,
"system": 3.41087572,
"min": 3.93578447846,
"max": 4.40330334446,
"times": [
3.95805712946,
4.15209099946,
3.98526353046,
3.96319012246,
3.95040188646,
4.40330334446,
4.21410434846,
3.93578447846,
4.17913316946,
4.22282992546
]
},
{
"command": "pnpr@HEAD",
"mean": 2.08882299086,
"stddev": 0.10700174920133913,
"median": 2.0461062959599996,
"user": 2.73610966,
"system": 2.91414632,
"min": 1.97760552446,
"max": 2.25074835546,
"times": [
2.07521213746,
2.0170004544599998,
1.97760552446,
2.10162013146,
2.24476158846,
2.00126515346,
2.20551708346,
2.25074835546,
2.00285663746,
2.01164284246
]
},
{
"command": "pnpr@main",
"mean": 2.0776696549600002,
"stddev": 0.062197095106126754,
"median": 2.06537869946,
"user": 2.7268348599999994,
"system": 2.9472400199999997,
"min": 1.99230418846,
"max": 2.21788323046,
"times": [
2.21788323046,
2.0898436184599998,
2.06493906046,
2.05448696946,
2.04787583646,
2.06581833846,
2.08449523346,
2.13402223446,
2.02502783946,
1.99230418846
]
}
]
}Scenario: Isolated linker: fresh restore, hot cache + hot store
BENCHMARK_REPORT.json{
"results": [
{
"command": "pacquet@HEAD",
"mean": 0.6537102620999999,
"stddev": 0.01792142708403315,
"median": 0.6541717146999999,
"user": 0.4039797399999999,
"system": 1.32991952,
"min": 0.6268850547,
"max": 0.6772599887,
"times": [
0.6715607017,
0.6350024877,
0.6772599887,
0.6553441227,
0.6425977467,
0.6363387766999999,
0.6724824597,
0.6666319757,
0.6268850547,
0.6529993067
]
},
{
"command": "pacquet@main",
"mean": 0.6910375616,
"stddev": 0.10733942488869277,
"median": 0.6568112257000001,
"user": 0.39542853999999994,
"system": 1.33397852,
"min": 0.6353627747,
"max": 0.9921962357,
"times": [
0.6500222807,
0.6532999887,
0.6582783337,
0.6668642167,
0.6360189367,
0.6634329587,
0.6995557727,
0.6353627747,
0.6553441177,
0.9921962357
]
},
{
"command": "pnpr@HEAD",
"mean": 0.7175578007000001,
"stddev": 0.042517408373944354,
"median": 0.7062471717000001,
"user": 0.4175645399999999,
"system": 1.35871452,
"min": 0.6932158147,
"max": 0.8361491517,
"times": [
0.7125222877,
0.7132542857,
0.6932158147,
0.6977958567,
0.7117341417,
0.6961405697,
0.7165194687,
0.6974862287,
0.8361491517,
0.7007602017
]
},
{
"command": "pnpr@main",
"mean": 0.7375032165000001,
"stddev": 0.05830786505659497,
"median": 0.7145740272,
"user": 0.4145084399999999,
"system": 1.36559852,
"min": 0.6988866277,
"max": 0.8930585217,
"times": [
0.7674061717,
0.7128286087,
0.7134768917,
0.7056332347,
0.7398718747,
0.6988866277,
0.8930585217,
0.7032396657,
0.7249594057,
0.7156711627
]
}
]
}Scenario: Isolated linker: fresh install, cold cache + cold store
BENCHMARK_REPORT.json{
"results": [
{
"command": "pacquet@HEAD",
"mean": 4.204961475500001,
"stddev": 0.04088301012367777,
"median": 4.2009659603,
"user": 3.79545058,
"system": 3.27286942,
"min": 4.1545004403,
"max": 4.2960811843,
"times": [
4.2368345603,
4.2010729453,
4.2136478953,
4.1555191843,
4.2960811843,
4.1545004403,
4.1919683853,
4.2008589753,
4.2136860913,
4.1854450933
]
},
{
"command": "pacquet@main",
"mean": 4.1893324009,
"stddev": 0.042355585494679895,
"median": 4.1989112303,
"user": 3.7789081800000006,
"system": 3.2639145199999993,
"min": 4.1071059863,
"max": 4.2599961883,
"times": [
4.2599961883,
4.2043174103,
4.1071059863,
4.1642353053,
4.1948316973,
4.2198085433,
4.2133993403,
4.2029907633,
4.1481729013,
4.1784658732999995
]
},
{
"command": "pnpr@HEAD",
"mean": 2.1494470711,
"stddev": 0.17401753682038193,
"median": 2.1048025143,
"user": 2.5452264799999993,
"system": 2.7917180200000002,
"min": 1.9640200853000003,
"max": 2.5635570813,
"times": [
2.0214588452999998,
2.1820812993,
2.0862164623,
2.0018453823,
2.2334581022999997,
2.0711591182999998,
2.5635570813,
2.2472857683,
1.9640200853000003,
2.1233885663
]
},
{
"command": "pnpr@main",
"mean": 2.0868335123999997,
"stddev": 0.09175458563207867,
"median": 2.0663089787999995,
"user": 2.59398458,
"system": 2.74770252,
"min": 2.0019638373,
"max": 2.3256946693,
"times": [
2.0716545752999997,
2.1135237313,
2.0019638373,
2.0898622893,
2.0609633822999998,
2.0192562483,
2.0606822172999997,
2.0208723403,
2.1038618333,
2.3256946693
]
}
]
}Scenario: Isolated linker: fresh install, hot cache + hot store
BENCHMARK_REPORT.json{
"results": [
{
"command": "pacquet@HEAD",
"mean": 1.372779129,
"stddev": 0.013573728412099735,
"median": 1.3726224429,
"user": 1.3280538200000003,
"system": 1.6970642599999999,
"min": 1.3543871589,
"max": 1.3952641849,
"times": [
1.3543871589,
1.3939266619000001,
1.3742244169,
1.3641974639,
1.3674192619,
1.3753277589000001,
1.3570254439,
1.3710204689,
1.3952641849,
1.3749984699
]
},
{
"command": "pacquet@main",
"mean": 1.3448204546,
"stddev": 0.013180361602811821,
"median": 1.3437945659000001,
"user": 1.28767442,
"system": 1.6723378600000003,
"min": 1.3272853359,
"max": 1.3645211209,
"times": [
1.3586580679,
1.3566906589,
1.3645211209,
1.3530644819000002,
1.3391762329,
1.3285771299,
1.3356543979,
1.3484128989,
1.3361642209,
1.3272853359
]
},
{
"command": "pnpr@HEAD",
"mean": 0.6461976376,
"stddev": 0.009237896194321433,
"median": 0.6454433654,
"user": 0.35008282,
"system": 1.22900906,
"min": 0.6316936769000001,
"max": 0.6575531139,
"times": [
0.6428898549000001,
0.6535378179000001,
0.6424378849000001,
0.6316936769000001,
0.6363330369000001,
0.6551123989000001,
0.6563680299000001,
0.6380536859000001,
0.6575531139,
0.6479968759000001
]
},
{
"command": "pnpr@main",
"mean": 0.6693546278,
"stddev": 0.07822851922471682,
"median": 0.6411754319,
"user": 0.33182232,
"system": 1.2545651599999998,
"min": 0.6316299959,
"max": 0.8883341759000001,
"times": [
0.6450681359,
0.6316299959,
0.6376380359,
0.6363181369,
0.6385867339000001,
0.6356006469000001,
0.6437641299000001,
0.6799619529,
0.8883341759000001,
0.6566443339000001
]
}
]
}Scenario: Isolated linker: fresh install, cold cache + hot store
BENCHMARK_REPORT.json{
"results": [
{
"command": "pacquet@HEAD",
"mean": 3.0990724697600003,
"stddev": 0.049969356260155244,
"median": 3.09307968536,
"user": 1.8257968999999996,
"system": 1.9719896600000002,
"min": 3.02550325286,
"max": 3.18655186186,
"times": [
3.18655186186,
3.09255827986,
3.14982796086,
3.09360109086,
3.05724358186,
3.02550325286,
3.07350630986,
3.11982501986,
3.05185703086,
3.14025030886
]
},
{
"command": "pacquet@main",
"mean": 3.03621299046,
"stddev": 0.030334381772600266,
"median": 3.04392122036,
"user": 1.7510197,
"system": 1.98277456,
"min": 2.97462389786,
"max": 3.06795214786,
"times": [
3.05484072886,
3.01953825486,
2.97462389786,
3.04197472386,
3.00617684186,
3.04586771686,
3.0218763968599998,
3.06632469486,
3.06795214786,
3.06295450086
]
},
{
"command": "pnpr@HEAD",
"mean": 0.6691020908599999,
"stddev": 0.009445930106421405,
"median": 0.6677585298600001,
"user": 0.3511463999999999,
"system": 1.28924216,
"min": 0.65513488586,
"max": 0.68362119986,
"times": [
0.68362119986,
0.68290296986,
0.65513488586,
0.66402664186,
0.66045424586,
0.67486470186,
0.6627282518600001,
0.6644747278600001,
0.6710423318600001,
0.67177095186
]
},
{
"command": "pnpr@main",
"mean": 0.6532680764600001,
"stddev": 0.010965460673887248,
"median": 0.6570279638600001,
"user": 0.32776869999999997,
"system": 1.2749804599999999,
"min": 0.63212870886,
"max": 0.6657034618600001,
"times": [
0.6657034618600001,
0.64925032486,
0.6564165818600001,
0.64309611586,
0.63212870886,
0.65880355086,
0.6624625228600001,
0.64318235286,
0.66399779886,
0.6576393458600001
]
}
]
}Scenario: Isolated linker: fresh resolve, hot cache, offline
BENCHMARK_REPORT.json{
"results": [
{
"command": "pacquet@HEAD",
"mean": 0.65954988444,
"stddev": 0.011992128590816829,
"median": 0.65651651734,
"user": 0.61947276,
"system": 0.14792487999999998,
"min": 0.64592466534,
"max": 0.68841086534,
"times": [
0.68841086534,
0.66704689134,
0.64592466534,
0.64713300234,
0.65601909734,
0.65701393734,
0.66207978634,
0.66134710734,
0.65519362334,
0.65532986834
]
},
{
"command": "pacquet@main",
"mean": 0.6599586253399999,
"stddev": 0.005969254078177028,
"median": 0.65851457334,
"user": 0.61728916,
"system": 0.15249108,
"min": 0.65288954534,
"max": 0.67012844734,
"times": [
0.6544615553400001,
0.66477233934,
0.65667638134,
0.65288954534,
0.66482156134,
0.65687620234,
0.67012844734,
0.66529111534,
0.66015294434,
0.65351616134
]
},
{
"command": "pnpr@HEAD",
"mean": 0.10753116606000003,
"stddev": 0.0005211713855071677,
"median": 0.10741075834000001,
"user": 0.02716454,
"system": 0.020566959999999995,
"min": 0.10676130334000002,
"max": 0.10966246234000002,
"times": [
0.10966246234000002,
0.10738833434000002,
0.10712284934,
0.10794530034000001,
0.10693821434,
0.10775471234,
0.10745048334000001,
0.10714555834000002,
0.10790176434000001,
0.10740431434000001,
0.10740167434,
0.10676130334000002,
0.10738794834000001,
0.10732683234000001,
0.10764475634000001,
0.10731900934000001,
0.10741075834000001,
0.10747282234000001,
0.10736814934000001,
0.10753533634000001,
0.10776985534000001,
0.10752161834000001,
0.10734638134,
0.10773403134000001,
0.10756468134000001
]
},
{
"command": "pnpr@main",
"mean": 0.10916617446,
"stddev": 0.0022608869681470588,
"median": 0.10788323634000001,
"user": 0.027376739999999997,
"system": 0.021189119999999995,
"min": 0.10621577434000001,
"max": 0.11309895434000002,
"times": [
0.10728895534,
0.10735049734,
0.10832014134000001,
0.10621577434000001,
0.10788323634000001,
0.10905002834000001,
0.11197326534000002,
0.10744645734000001,
0.10692990234000001,
0.10771428734,
0.10692633734000001,
0.10759127134000002,
0.10746589734,
0.11309895434000002,
0.11155402234000002,
0.10736560534,
0.10853887634,
0.11117985734000001,
0.11227516134000001,
0.11204679134000001,
0.11287116134000001,
0.11123515134,
0.10765482634000001,
0.11170693334000001,
0.10747096934000001
]
}
]
}Scenario: Isolated linker: fresh restore, cold cache + cold store + cold pnpr
BENCHMARK_REPORT.json{
"results": [
{
"command": "pacquet@HEAD",
"mean": 6.844423583300001,
"stddev": 0.17657928126218403,
"median": 6.782227355400001,
"user": 4.08910004,
"system": 3.6428145599999993,
"min": 6.6657322264,
"max": 7.2563375034,
"times": [
6.754292743400001,
6.900415969400001,
6.6657322264,
6.9949273814,
6.772984557400001,
6.778059698400001,
6.868572252400001,
6.6665184884,
6.786395012400001,
7.2563375034
]
},
{
"command": "pacquet@main",
"mean": 6.8180905890000005,
"stddev": 0.13261201380704468,
"median": 6.8357972559,
"user": 4.138535639999999,
"system": 3.67783306,
"min": 6.6471764144000005,
"max": 7.004961913400001,
"times": [
6.7128676004,
6.6599932374,
6.6998250354,
6.8551063784,
6.9625856694,
7.004961913400001,
6.8164881334,
6.9588568734,
6.8630446344000005,
6.6471764144000005
]
},
{
"command": "pnpr@HEAD",
"mean": 4.937600537600001,
"stddev": 0.15037465984401516,
"median": 4.898406216400001,
"user": 2.81105724,
"system": 3.09712806,
"min": 4.7630235004,
"max": 5.278133367400001,
"times": [
5.278133367400001,
4.884998337400001,
4.8232901834,
4.935852043400001,
4.9118140954000005,
4.9421822064,
4.7630235004,
4.8815112094,
5.1083753964000005,
4.8468250364
]
},
{
"command": "pnpr@main",
"mean": 4.9221657156,
"stddev": 0.10459489275537265,
"median": 4.8773127164000005,
"user": 2.8352564399999993,
"system": 3.1155261600000004,
"min": 4.803715283400001,
"max": 5.1026267694000005,
"times": [
4.891451125400001,
4.9473200654000005,
5.1026267694000005,
4.803715283400001,
4.8424108834,
4.8631743074000005,
4.8578944034000004,
5.0746303154,
4.8384285894,
5.0000054134
]
}
]
} |
|
| Branch | pr/12838 |
| Testbed | pnpr |
⚠️ 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-thresholdsflag.
Click to view all benchmark results
| Benchmark | Latency | milliseconds (ms) |
|---|---|---|
| isolated-linker.fresh-install.cold-cache.cold-store | 📈 view plot | 2,149.45 ms |
| isolated-linker.fresh-install.cold-cache.hot-store | 📈 view plot | 669.10 ms |
| isolated-linker.fresh-install.hot-cache.hot-store | 📈 view plot | 646.20 ms |
| isolated-linker.fresh-resolve.hot-cache.offline | 📈 view plot | 107.53 ms |
| isolated-linker.fresh-restore.cold-cache.cold-store | 📈 view plot | 2,088.82 ms |
| isolated-linker.fresh-restore.cold-cache.cold-store.cold-pnpr | 📈 view plot | 4,937.60 ms |
| isolated-linker.fresh-restore.hot-cache.hot-store | 📈 view plot | 717.56 ms |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
pacquet/crates/cli/src/cli_args/self_update/install_pnpm/tests.rs (1)
184-194: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winAdd coverage for the Windows relink path.
This positive reuse test is Unix-only, but
reuse_cached_enginenow callslink_exe_platform_binary, which has Windows-specific.exeand alias-linking behavior. Please add a Windows-specific regression test, or make the fixture exercise both executable names where CI supports it. As per path instructions, “tests must prove the changed behavior,” and pacquet tests should cover behavior changes at the right level.🤖 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 `@pacquet/crates/cli/src/cli_args/self_update/install_pnpm/tests.rs` around lines 184 - 194, The existing reuse_cached_engine regression test only covers the Unix relink path, but link_exe_platform_binary now has Windows-specific .exe and alias-linking behavior. Add a Windows-focused test alongside reuse_cached_engine_accepts_a_healthy_slot, or extend the fixture in install_pnpm/tests.rs to exercise both executable names when running on Windows, so the test proves the changed behavior for reuse_cached_engine and link_exe_platform_binary. Keep the coverage at the same integration level as the current pnpm install tests and verify the linked executable/alias state after relinking.Source: Path instructions
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Nitpick comments:
In `@pacquet/crates/cli/src/cli_args/self_update/install_pnpm/tests.rs`:
- Around line 184-194: The existing reuse_cached_engine regression test only
covers the Unix relink path, but link_exe_platform_binary now has
Windows-specific .exe and alias-linking behavior. Add a Windows-focused test
alongside reuse_cached_engine_accepts_a_healthy_slot, or extend the fixture in
install_pnpm/tests.rs to exercise both executable names when running on Windows,
so the test proves the changed behavior for reuse_cached_engine and
link_exe_platform_binary. Keep the coverage at the same integration level as the
current pnpm install tests and verify the linked executable/alias state after
relinking.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro Plus
Run ID: 3e94d2dc-b955-4028-ba88-781f628724ad
📒 Files selected for processing (3)
pacquet/crates/cli/src/cli_args/self_update/install_pnpm.rspacquet/crates/cli/src/cli_args/self_update/install_pnpm/tests.rspacquet/crates/cli/src/config_deps.rs
🚧 Files skipped from review as they are similar to previous changes (1)
- pacquet/crates/cli/src/config_deps.rs
|
Code review by qodo was updated up to the latest commit 117e24e |
|
Code review by qodo was updated up to the latest commit 117e24e |
1 similar comment
|
Code review by qodo was updated up to the latest commit 117e24e |
`pnpm self-update` (and, in pacquet, `pnpm with` / CLI auto-switching) resolved the target pnpm version with a self-update-specific resolver that fetched abbreviated registry metadata and — depending on the stack — either crashed or silently skipped the no-downgrade trust check: - pacquet passed `trustPolicy` into the resolve but the resolver was hard- wired to abbreviated metadata (no per-version `time`), so the check failed closed on every self-update with "trust check failed: missing time for version <version> of pnpm in metadata". - the TypeScript CLI never passed `trustPolicy` into its resolve at all, so `trustPolicy=no-downgrade` was not enforced when picking the pnpm version. Resolve the engine version the same way a regular install does instead of special-casing self-update: derive the metadata mode from config and pass the trust policy through. - pacquet: add `Config::requires_full_metadata_for_resolution` and use it in both `PickPolicy` (install path) and the env-installer resolver (`resolve_pnpm_version`), and restore `trust_policy*` on its resolve options. Under `resolutionMode=time-based` / `trustPolicy=no-downgrade` the probe now fetches the full packument the checks need. - TypeScript: compute `fullMetadata` in `selfUpdate.ts` (mirroring `dlx`) and pass `fullMetadata`/`filterMetadata` to `createResolver`, and pass `trustPolicy`/`trustPolicyExclude`/`trustPolicyIgnoreAfter` into the `resolve()` call (its resolve is the sole version selection, unlike `dlx`). Adds tests on both stacks: a trust-downgraded pnpm is rejected under no-downgrade, and a clean update still resolves. The pacquet test serves abbreviated metadata without `time` to the abbreviated `Accept` header, so it also proves the probe requests full metadata rather than failing closed.
`pnpm self-update <target <= v11>` aborted with "the installed pnpm wrapper at <slot>/node_modules/`@pnpm/exe` resolves outside <slot>" when an existing global `@pnpm/exe` slot left by an older layout symlinks its wrapper into a shared location outside the per-slot directory (e.g. the global virtual store). On a version cache-hit, `install_pnpm` relinks the engine's native platform binary; because the wrapper resolved outside the slot, `link_exe_platform_binary`'s containment guard rejected it and the `?` propagated the error, failing the whole self-update. Make the cache-hit relink best-effort: `reuse_cached_engine` reports a relink failure as "not reusable", so the caller falls through to a fresh, self-contained install instead of aborting. The containment guard is unchanged — it still refuses to link a wrapper that escapes the slot, and nothing from the rejected slot is linked or executed; the fresh install downloads and signature-verifies the engine into a new slot, then the old slot is orphaned and cleaned on a later run. Add unit tests: a healthy slot is reused (and relinked), a version mismatch is not reused, and a slot whose wrapper escapes the slot is not reused so the caller reinstalls.
|
Code review by qodo was updated up to the latest commit ba5234a |
|
Code review by qodo was updated up to the latest commit ba5234a |
1 similar comment
|
Code review by qodo was updated up to the latest commit ba5234a |
There was a problem hiding this comment.
Actionable comments posted: 1
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
pnpm11/engine/pm/commands/src/self-updater/selfUpdate.ts (1)
61-73: 🎯 Functional Correctness | 🟠 Major | ⚡ Quick winAdd the missing config fields to
SelfUpdateCommandOptions
SelfUpdateCommandOptionsonly inheritsCreateStoreControllerOptionsplus the currentPick<Config, ...>, but this function readsopts.resolutionMode,opts.trustPolicy,opts.trustPolicyExclude,opts.trustPolicyIgnoreAfter, andopts.registrySupportsTimeField. Those need to be included here, or this won’t type-check.🤖 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/engine/pm/commands/src/self-updater/selfUpdate.ts` around lines 61 - 73, `SelfUpdateCommandOptions` is missing several config properties that `selfUpdate` reads directly. Update the type definition to include `resolutionMode`, `trustPolicy`, `trustPolicyExclude`, `trustPolicyIgnoreAfter`, and `registrySupportsTimeField` in the existing `Pick<Config, ...>` for `SelfUpdateCommandOptions`, alongside the current fields, so `selfUpdate` type-checks correctly.
🤖 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 `@pacquet/crates/config/src/lib.rs`:
- Around line 1567-1573: The Config::requires_full_metadata_for_resolution
method is missing the minimumReleaseAge trigger, so Rust no longer matches the
TypeScript fullMetadata logic. Update this method to also return true when
minimumReleaseAge is configured, alongside ResolutionMode::TimeBased and
TrustPolicy::NoDowngrade, while still gating on registry_supports_time_field.
Keep the behavior aligned with the TS selfUpdate.ts equivalent and preserve the
existing method structure and symbols.
---
Outside diff comments:
In `@pnpm11/engine/pm/commands/src/self-updater/selfUpdate.ts`:
- Around line 61-73: `SelfUpdateCommandOptions` is missing several config
properties that `selfUpdate` reads directly. Update the type definition to
include `resolutionMode`, `trustPolicy`, `trustPolicyExclude`,
`trustPolicyIgnoreAfter`, and `registrySupportsTimeField` in the existing
`Pick<Config, ...>` for `SelfUpdateCommandOptions`, alongside the current
fields, so `selfUpdate` type-checks correctly.
🪄 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: 5411e07c-eb34-4408-a007-a81ad12fdf25
📒 Files selected for processing (9)
.changeset/self-update-trust-policy.mdpacquet/crates/cli/src/cli_args/self_update/install_pnpm.rspacquet/crates/cli/src/cli_args/self_update/install_pnpm/tests.rspacquet/crates/cli/src/config_deps.rspacquet/crates/cli/src/config_deps/tests.rspacquet/crates/config/src/lib.rspacquet/crates/package-manager/src/resolution_policy.rspnpm11/engine/pm/commands/src/self-updater/selfUpdate.tspnpm11/engine/pm/commands/test/self-updater/selfUpdate.test.ts
✅ Files skipped from review due to trivial changes (1)
- .changeset/self-update-trust-policy.md
🚧 Files skipped from review as they are similar to previous changes (2)
- pacquet/crates/cli/src/cli_args/self_update/install_pnpm.rs
- pacquet/crates/cli/src/cli_args/self_update/install_pnpm/tests.rs
The no-downgrade check reads per-version trust evidence (`_npmUser` / `dist.attestations`) that the abbreviated packument never carries — even a `registrySupportsTimeField` registry only adds `time`, not the evidence. So `Config::requires_full_metadata_for_resolution` and the TypeScript `selfUpdate.ts` formula must request full metadata for `trustPolicy=no-downgrade` regardless of `registrySupportsTimeField`; otherwise the check sees no evidence and silently misses a downgrade. `minimumReleaseAge` stays out of the up-front decision in both stacks: the resolver upgrades abbreviated metadata to full on demand for the maturity check, matching the install path (`PickPolicy` / `createNewStoreController`). This also aligns the Rust and TypeScript formulas, which had diverged on the `minimumReleaseAge` term. Add a pacquet regression test that serves abbreviated-with-`time`-but-no- evidence to the abbreviated `Accept` header under `registrySupportsTimeField=true` and asserts the downgrade is still rejected. The install-time lockfile verifier already fetches full metadata unconditionally for its trust check, so a downgrade was still blocked there; this makes the resolver-time and self-update probe checks sound too.
|
Code review by qodo was updated up to the latest commit 3271334 |
PR Code Suggestions ✨Warning
No code suggestions found for the PR.
|

Summary
Two
pnpm self-updatefixes. The first is cross-stack (TypeScript + pacquet); the second is pacquet-only.1. Honor
trustPolicy=no-downgradewhen resolving the pnpm enginepnpm self-updateresolved the target pnpm version with a self-update-specific resolver that fetched abbreviated registry metadata (which omits per-versiontime) and, depending on the stack, either crashed or silently skipped the no-downgrade trust check:trustPolicyinto the resolve but the resolver was hard-wired to abbreviated metadata, so the check failed closed on every self-update:trustPolicyinto its resolve at all, sotrustPolicy=no-downgradewas not enforced when picking the pnpm version.The fix resolves the engine version the same way a regular install does, instead of special-casing self-update — derive the metadata mode from config and pass the trust policy through:
Config::requires_full_metadata_for_resolutionand use it in bothPickPolicy(install path) and the env-installer resolver (resolve_pnpm_version); restoredtrust_policy*on the resolve options. UnderresolutionMode=time-based/trustPolicy=no-downgradethe probe now fetches the full packument the checks need.no-downgradealways fetches full metadata — even whenregistrySupportsTimeFieldis set — because abbreviated metadata omits the trust evidence (_npmUser/dist.attestations) the check reads, not justtime.fullMetadatainselfUpdate.ts(mirroringdlx) and passfullMetadata/filterMetadatatocreateResolver; passtrustPolicy/trustPolicyExclude/trustPolicyIgnoreAfterinto theresolve()call (self-update'sresolveis its sole version selection, unlikedlx, whose real install re-resolves through the store controller).Tests on both stacks: a trust-downgraded pnpm is rejected under
no-downgrade, and a clean update still resolves. The pacquet test serves abbreviated metadata (notime) to the abbreviatedAcceptheader, so it also proves the probe requests full metadata rather than failing closed.2. Recover when a cached engine slot is unusable (pacquet)
pnpm self-update <= v11aborted with:when an existing global
@pnpm/exeslot from an older layout symlinks its wrapper outside the per-slot directory (e.g. into the shared global virtual store). On a version cache-hit,link_exe_platform_binary's containment guard rejected the wrapper and the?aborted the whole self-update.The cache-hit relink is now best-effort:
reuse_cached_enginereports a relink failure as "not reusable", so the caller falls through to a fresh, self-contained, signature-verified install instead of aborting. The containment guard is unchanged — it still refuses to link a wrapper that escapes the slot, and nothing from the rejected slot is linked or executed.Both errors were reproduced with the built binary and confirmed fixed. A focused security review of the diff found no newly-introduced vulnerabilities (guards preserved; fresh-install fallback is signature-verified; the no-downgrade gate is now enforced more consistently, not less).
Squash Commit Body
Checklist
pacquet/port, or the description notes what still needs porting.Fix 1 lands in both stacks. Fix 2 addresses a pacquet-only mechanism
(the
@pnpm/exenative-binary relink guard) with no TypeScriptcounterpart.
@pnpm/engine.pm.commands+pnpm, patch) forthe user-visible self-update trust-policy change.
Written by an agent (Claude Code, claude-opus-4-8).