feat(rules): add pnpm store and Yarn cache rules - #175
Muawiya-contact merged 3 commits into
Conversation
pnpm and Yarn keep regenerable package caches alongside npm's, but the embedded database only classified _cacache, so their caches scanned as unknown and never reached the report. pnpm-store covers the store under the pnpm home directory on all three platforms (**/pnpm/store/**) plus the legacy and configured ~/.pnpm-store. yarn-cache covers the Yarn 1 global caches (Linux, macOS, Windows) and Yarn Berry's per-project .yarn/cache and global ~/.yarn/berry/cache. Both are safe on the npm-cache reasoning: removing them only makes the next install re-download packages. The patterns name the cache directories, not their parents, so the pnpm binary and global installs under the pnpm home, and Yarn's release binaries, plugins and SDKs under .yarn, remain unknown. Fixture rows in EMBEDDED_RULE_FIXTURES pin a canonical path per rule, and dedicated tests cover each platform default plus the non-cache neighbours.
Muawiya-contact
left a comment
There was a problem hiding this comment.
Thanks for contributing again, Louis! This is useful package-manager coverage, but the Yarn verdict needs a safety adjustment before approval. Please account for Plug’n’Play dependencies as described inline and update the regression tests; current CI is green.
| "id": "yarn-cache", | ||
| "patterns": ["**/.cache/yarn/**", "**/library/caches/yarn/**", "**/appdata/local/yarn/cache/**", "**/.yarn/cache/**", "**/.yarn/berry/cache/**"], | ||
| "category": "package_manager_cache", | ||
| "verdict": "safe", |
There was a problem hiding this comment.
[P1] Use a conservative verdict for Yarn PnP caches. The PnP loader reads installed packages directly from their cache paths (https://yarnpkg.com/features/pnp), including .yarn/cache and the global Berry cache. Quarantining these ZIPs breaks application imports immediately, even without a committed zero-install cache; it does more than slow the next install. Please use review for paths that can back PnP installs, consistent with the existing node-modules rule, explain the reinstall/restore requirement, and add local/global PnP fixtures that must not classify as Safe. Retain Safe only where the cache is demonstrably separate from runtime dependencies.
There was a problem hiding this comment.
Done — d95bcc4 splits **/.yarn/cache/** and the global **/.yarn/berry/cache/** out of yarn-cache into a new yarn-pnp-cache rule at review, mirroring the node-modules treatment. The description calls out the PnP loader reading packages straight from the archives and that yarn install must restore them. Yarn 1's global download caches stay safe. Local and global PnP fixtures now assert Review in yarn_pnp_caches_are_review_not_safe, plus a yarn-pnp-cache row in the embedded-rule fixture table.
The PnP loader reads installed packages directly from the cache archives — a project's .yarn/cache and the global .yarn/berry/cache — so quarantining them breaks imports until yarn install restores the cache, not just slows the next install. Split them out of yarn-cache into yarn-pnp-cache (verdict: review); the Yarn 1 global caches stay safe since they only back downloads. Adds local and global PnP fixtures.
|
Addressed in Split the Berry caches out of Regression coverage: |
|
@LouisDeconinck can review some Open Prs a trigger you to review it. |
@LouisDeconinck Are you there? |
|
@Muawiya-contact done — reviewed #177 (approved; clean guarded render, label fallback is right) and #178 (approved; verified |
Muawiya-contact
left a comment
There was a problem hiding this comment.
Thanks for the update, Louis! The separate yarn-pnp-cache rule now uses review, and the local/global fixtures cover the safety concern; current CI passes, so approved. Also, thank you @LouisDeconinck for reviewing #177 and #178—your careful checks are helping the project move forward. If you’d like, please star Diskern, explore our other projects, and follow Coding Moves.
What & why
Closes #155
The embedded database classified npm's
_cacachebut nothing for pnpm or Yarn, so their caches scanned asunknownand never reached the report. This adds twopackage_manager_cache/saferules modeled onnpm-cache— regenerable downloads whose removal only makes the next install fetch packages again.pnpm-storecovers pnpm's content-addressable store at its real locations:**/pnpm/store/**— the store under the pnpm home directory, which is the default on all three platforms (~/.local/share/pnpm/store,~/Library/pnpm/store,%LOCALAPPDATA%\pnpm\store) and whereverPNPM_HOMEpoints.**/.pnpm-store/**— the pre-v7 default that a configuredstore-dirstill commonly uses.yarn-cachecovers both Yarn generations:**/.cache/yarn/**(Linux),**/library/caches/yarn/**(macOS),**/appdata/local/yarn/cache/**(Windows).**/.yarn/cache/**(per-project) and**/.yarn/berry/cache/**(global).The patterns name the cache directories, not their parents, so the non-cache neighbours stay
unknown: the pnpm binary and global installs under the pnpm home (pnpm/pnpm,pnpm/global/), and Yarn Berry's release binaries, plugins and SDKs under.yarn(.yarn/releases,.yarn/sdks). Dedicated tests pin that distinction in both directions, andEMBEDDED_RULE_FIXTURESgains a row per rule so the completeness guard keeps holding.One judgement call worth flagging: a committed
.yarn/cacheis the zero-installs pattern, so a minority of projects intentionally keep it in git — but its contents are still pure registry downloads thatyarn installre-fetches, sosafeis consistent with the npm-cache semantics rather than a new class of claim.Verdicts change only by gaining coverage: previously-
unknownpaths now classifysafe; no existing rule or verdict is altered. The db version stays at 3, matching thenpm-cacheprecedent of bumping at release time rather than per rule.Checklist
cargo fmt --allandcargo clippy -p diskern-core --all-targets -- -D warningsare cleancargo test -p diskern-corepasses: 101/101 (4 new tests)over deletion, deterministic verdicts)
changelog.d/