feat: project-defined side-effects cache keys #18584
All Vouch review confidence checks passed
Residual risk 0.21 = Change Risk (0.52) × (1 − Review Confidence (0.60)).
Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.52 · 650 lines diff across 8 files
Model 2 · Review Depth (DistilBERT)
Depth Score: 0.17 · 1 substantive comment(s)
Model 3 · Review Timing & Attention
Session adequacy: 100% · Reviewer familiarity: 35%
Bedrock Claude 3 · Risk Narration
(disconnected)
Groq Risk Narration
AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
Model 1 · Change Risk Attribution
SHAP Weights
Diff Size
diff_size
0.388
Shallow Review Depth
shallow_review_depth
0.289
Real PR Conversation Timeline
1 comments
"Review active on #18584"
general
weight: 0.35
zkochan
<!-- A maintainer will only start reviewing once CodeRabbit has approved and
CI is green. Please wait for those to pass before expecting human review. -->
Summary
Implements the RFC Project-defined side-effects cache keys.
key.env: pnpm hashes the listed names and values (pnpm's environment withextraEnvapplied) and appends;env=<hash>to the local key and the remote input key. Built packages and their dependents also get the hash in their global virtual store slot.key.excludeNodeVersion: the host part becomes<platform>;<arch>, with no Node.js detection. A package's ownnode@runtime:pin no longer replaces it (unresolved question 2). The remote tier presents and publishes compatibility tags without the Node.js dimension, such aspnpm:v1:linux-x64-glibc2.44.Where it lives
pnpm-graph-hasher: theenv_hashargument ofcalc_dep_state,calc_dep_state_input_keyandcalc_graph_node_hash(onBuildRequired). The hash is kept separate from the host part, because the slot hash replaces the host part with a package's own runtime pin. Alsocalc_env_hashandengine_name_without_node.pnpm-shared-artifact-protocol:node_major: Option<u32>in the platform structs. Tags with three dimensions parse and rank, and their scope keys are<os>-<arch>. pnpr reads this vocabulary from the same crate.pnpm-executor:is_script_reserved_env_name, which lists the names pnpm sets or removes for a script, andconfigured_env_value, anextraEnv-over-process lookup that is case-insensitive on Windows. Of twoextraEnvspellings of one name, the one that sorts last wins, in the script environment and in the key alike. The pipeline task cache'senvnow uses the same lookup, which fixes its case-sensitiveextraEnvmatch on Windows.pnpm-config:SideEffectsCacheKeySettings, whose fields overlay one by one.ForEveryPackage<T>rejects the per-package map form with a clear error.SideEffectsCacheSettinggets a hand-written deserializer so that the error is not hidden by "did not match any variant". The hook input keeps the object form whenkeyis set.pnpm-deps-restorer:SideEffectsCacheKey::from_configis the single place the key is computed. The engine-name resolvers, the build phase, cached builds,VirtualStoreLayoutand its fingerprint, the directory-clone cache and the remote tier all read it.pnpm-package-manager: the workspace state recordssideEffectsCacheExcludeNodeVersionandsideEffectsCacheEnvHash, both only when set. A change is drift: it skips the up-to-date shortcut and becomesPresentBuilds::Replaced, so the hoisted linker imports present packages that build again before it restores or builds them. An install that does not rebuild every project under today's key records one the next install sees as a change: a filtered install records amixedmarker, and an install under--ignore-scriptskeeps the recorded key (the hoisted linker then also keeps its present builds). Install and rebuild reject a reserved name withERR_PNPM_SIDE_EFFECTS_CACHE_KEY_RESERVED_ENV.pnpm-cli:pnpm store statusappliesupdateConfig(separate patch changeset).pnpm dlxand pnpm's own engine install drop the key.Unresolved questions of the RFC
| Question | Decision here |
|---|---|
| 1. Omitted
read/writein hook output or the env object | Keeps the current value. An omitted gate inpnpm-workspace.yamlis stilltrue. || 2.
excludeNodeVersionvs a package's own runtime pin | The pin is ignored as well. || 3. Which slots get the env hash | The build-required set, which includes dependents. |
| 4. Unset variable | Hashed as unset, no failure. |
| 5. Project-local
node_modules| The isolated linker already restores or re-runs the build once the drift forces a full install (covered by a test). The hoisted linker imports a present package that builds again (PresentBuilds::Replaced). || 6.
pnpm dlx| Ignores both fields. || 7.
--side-effects-cacheflags | Set onlyread/write. A hook'skeystill applies. || 8. pnpr without the new tags | Not implemented. A rejected lookup is a cache miss, as before. Warning once and skipping publication is left as a follow-up. |
| 9.
excludeNodeVersionwithoutenv| Allowed. The docs warn about it. || 11. Reserved names | Fail. This includes
NODE_OPTIONSandNODE_PATH, which the install rewrites for its build scripts. |Verification
<platform>;<arch>;format=2;…;env=<hash>and the layout-cache fingerprint) and package-manager.side_effects_cache_key.rs:- Two projects that differ in a listed variable build their own, with and without the global virtual store.
- Equal values share a build.
- A value set by an
updateConfighook takes part in the key.- A changed variable replaces the linked build under the isolated linker, the hoisted linker and the global virtual store.
-
store statusagrees withinstallon a value a hook sets.- A filtered install leaves the change to the next full install, including a round trip back to the first key.
- An install under
--ignore-scriptskeeps the build until one with scripts.- A reserved name is rejected.
--ignore-scriptsandstore statustests fail without their fixes.repeat_install_read_set/repeat_install_records::openstests could not run locally because the machine has no inotify instances left (inotify_init1: Too many open filesbefore pnpm starts). CI will run them.Checklist
pnpm changeset) if this PR changes any publishedpackage. Keep it short and written for pnpm users — it becomes a release note.
---
Written by an agent (Claude Code, claude-opus-5-5).
🤖 Generated with Claude Code
<!-- This is an auto-generated comment: release notes by coderabbit.ai -->
<!-- coderabbit-ai-generated:v1 -->
Summary by CodeRabbit
New Features
Configure side-effects cache keys with selected environment variables, so builds with different values use separate cache entries.
Optionally exclude the Node.js major version from cache compatibility while retaining platform and architecture checks.
Bug Fixes
pnpm store statusnow applies configuration hooks before checking store status.Installs recognize cache-key changes and update builds and cache entries accordingly.
Pipeline environment inputs match
extraEnvnames regardless of case on Windows.Omitted
readorwritesettings in environment or hook configuration preserve their current values.Documentation
Added guidance on cache-key settings, compatibility tags, and Nix development shells.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->