fix(reify): report added count for fresh linked installs#9667
Merged
Conversation
Under `install-strategy=linked`, a fresh `npm install` that actually creates `.store` entries and symlinks printed `up to date, audited N packages` instead of `added N packages`, misleading users and CI into thinking nothing changed. `reify-output` counts adds with `actualTree.inventory.has(d.ideal)`. Under the linked strategy the diff's `ideal` nodes belong to the isolated store tree (locations under `node_modules/.store/<key>/node_modules/<name>`), while the `actualTree` returned after reify is the logical hoisted-layout tree. The two never share node identity, so the lookup always failed and `added` stayed `0`. The ADD branch now also counts a node when it is a real store package node (`isInStore && !isLink`), which maps 1:1 to a hoisted package add. This excludes the internal store symlinks and the top-level consumer symlink, so the count matches hoisted for registry dependencies (verified: `minimatch` 4/4, `rimraf` 12/12, `express` 69/69). Omitted/incompatible optional deps have no store entry and are still not counted, and hoisted behavior is unchanged. Known limitations (tracked separately): workspace and `file:`/`npm link` additions are represented as links rather than store nodes under linked, so they are not yet counted here — counting them is entangled with the self-link bug (#9398) and the undeclared-workspaces bug (#9618). The `--json` `add[].path` for a counted store package points to its `.store` realpath rather than a logical `node_modules/<name>` path. ## References Fixes #9623 (cherry picked from commit 0c33947)
The `ls --install-strategy=linked` tests for undeclared and declared-but-missing workspaces passed without ever entering the undeclared-workspace branch of `filterLinkedStrategyEdges` in lib/commands/ls.js, because their mock filesystems omitted the hidden `node_modules/.package-lock.json` that a real linked install writes. Without that hidden lockfile, loadActual resolves the workspace root edges via the workspace globs instead of marking them missing, so the `edge.missing` guard is never satisfied and the branch stays uncovered. This surfaced as a global coverage gate failure (ls.js branch below 100%) on the first PR after the actual-tree workspace changes in #9666, because the Test matrix only runs on PRs and not on direct pushes to release/v11. Add the hidden lockfile to both tests so they reproduce a real linked install: the undeclared workspace now resolves as a missing root edge and is correctly skipped, and the declared-but-missing workspace resolves as missing and is still reported as UNMET DEPENDENCY. This exercises both branches and restores 100% coverage. No production code changes.
dhei
approved these changes
Jun 25, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Backport of #9661 to
release/v11.