Skip to content

Dependency graphs lead with direct changes: churn folds into the dependency it came with - #343

Open
agorischek wants to merge 19 commits into
mainfrom
dependencies-fold-churn
Open

agorischek wants to merge 19 commits into
mainfrom
dependencies-fold-churn

Conversation

@agorischek

@agorischek agorischek commented Dec 4, 2026 •

Copy link
Copy Markdown
Collaborator

What changed

Fixes the workspace-dependencies image from the Projections setup trials. On a webpack-to-Rspack migration, the default PNG showed transitive packages and left out the workspace and its direct changes. --focus changes and --entity workspace:<name> didn't help. A mass-removal pull request was unreadable in the same way. Both reproduce on main 49d66f0 with the new scenarios below.

Previously, the dependencies presentation showed every changed package and the path that pulls it in. Adding or removing a direct dependency also adds or removes every transitive package only it depended on: about 150 for webpack, webpack-cli, webpack-dev-server and their loaders against Rspack. Because all of them counted as changed, the renderer drew them all and buried the direct changes.

  • Fold churn into the card of the package that brings it. A changed transitive package is churn (churn.ts) when, in each revision it's in, the graph reaches it only through changed direct dependencies, whether they arrive, leave or move to another version. It is also churn when it only moved to another version itself: a bump, or npm installing it under another key (pkg@1.2) while a package of its name is in the other revision. Churn collapses into summary cards like unchanged packages do. A transitive package new to the dependency tree, or gone from it, under an unchanged direct dependency still shows. On one real Webpack-to-Rspack pull request that also refreshed its lockfile, the whole-PR comparison fell from 447 cards to 159, close to the 146 for its single bundler commit. Its height fell from 10864 px to 5695 px, and what's left is mostly unchanged direct dependencies, which are always shown. The npm-express-5 and npm-react-update scenarios now fold the packages Express 5 and React DOM bring.
  • Counted per revision, one step per card. Each revision counts its hidden packages on the card of the shown package that pulls them in there, expanded cards included. A summary card whose count differs between the revisions is modified. A card joins its owner's step, or else the step of the change that causes it, chosen by ID so a comparison and its reverse agree. Its edge joins the same step.
  • The owner's card presents its churn. The card of the visible package that pulls a folded package in lists it in data-entity-aliases, the same way a NuGet project folds onto its framework's card. Host selection, hover, filter and focus requests for a folded package land on that card.
  • diff-changes honours aliases. Previously the built-in check required each changed entity to have its own element. It now also accepts a visible entity element that lists the entity in data-entity-aliases. EntitySample adds an optional aliases field, documented in the check description and the testing README.
  • Scenarios. make-bundler-migration.mjs generates three synthetic revisions of an npm workspace for two scenarios: npm-bundler-migration (webpack to Rspack in the web app) and npm-mass-removal (the admin app leaves the workspace along with the packages only it used).

Before and after

webpack to Rspack, before (main, clipped at 4096 px):

webpack to Rspack on main: hundreds of transitive package cards, no workspace in view

After:

webpack to Rspack with this change: the web app with three added and five removed direct dependencies, each with its summary card

A workspace member removed, before and after:

The admin app removed, on main

The admin app removed, with this change: the removed member and its four removed direct dependencies

Known issues the new scenarios expose

checks.spec.ts lists two known failures for the new scenarios. Both come from how the existing renderer counts dependents and sizes cards, which this change doesn't touch. I didn't run the checks against main for these scenarios.

  • neutral-endpoints (both scenarios) and diff-neutral (migration): a package's "+N dependents" note counts the dependents of both revisions whose edges aren't drawn, so at an endpoint it can differ from that revision alone.
  • neutral-endpoints (removal): cards share one width over both revisions, so @rspack/plugin-react-refresh wraps at a different dot than After alone draws it, like the existing database/prisma-licensing entry.

Evidence

  • npm run tools -- test packages/renderers/graph: 49 pass, including the new packages that come and go only with a direct dependency that comes or goes fold into its summary card, which fails on main.

  • npm run tools -- test packages/renderers/testing: 29 pass, including the new diff-changes counts a change drawn on a card that presents it in data-entity-aliases.

  • Harness on Chromium desktop, all specs filtered to npm- and nuget (npx playwright test --project=chromium-desktop --grep "npm-|nuget" --timeout=300000), with checks.spec.ts run locally on Chromium desktop for every scenario instead of its usual project: 64 passed. On this two-core machine the checks needed more than the default 90 s.

  • PNGs from projections compare HEAD~1..HEAD -p deps --png … in a scratch repository whose extractor replays the fixtures, built from main and from this branch.

  • npm run tools -- check --fast passes, apart from the format check on docs/guides/host-core.md and tools/scripts/check-styles.mjs, which this PR doesn't touch and which fail the same way on main.

  • Documentation that this change affects is updated, and generated reference
    pages are regenerated (npm run docs:generate). The graph renderer's built-in page and README, the workspace-dependencies page and the testing README describe the fold.

  • Fixes include a regression test.

  • A changelog fragment at changelog.d/<this PR's number>.md describes what
    users will notice, or the PR has the no changelog label (see
    changelog.d/README.md).

  • No credentials, private source or machine-specific paths are included.

agorischek and others added 3 commits December 4, 2026 08:15
… diff-changes honours aliases

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

Active issues can hide packages under revision-absent owners, let alias-based visual regressions pass checks, and leave summaries visible after their owners disappear.

3 open issues
What changed in this PR

This PR makes Projections dependency graphs emphasize direct changes by folding related transitive churn into summary cards.

Changes:

  • Adds revision-aware churn detection, summary updates, and folded-package aliases.
  • Extends diff-changes checks to recognize aliases.
  • Adds migration/removal scenarios, regression coverage, documentation, and changelog entries.
File Description
packages/​renderers/​testing/​test/​helpers.test.mjs Adds alias-check coverage.
packages/​renderers/​testing/​src/​types.ts Adds optional sample aliases.
packages/​renderers/​testing/​src/​measure/​entities.ts Reads entity aliases.
packages/​renderers/​testing/​src/​checks/​comparison/​diff.ts Recognizes aliased changes.
packages/​renderers/​testing/​src/​checks/​catalog.ts Documents alias-aware checks.
packages/​renderers/​testing/​README.md Explains alias support.
packages/​renderers/​harness/​browser/​checks.spec.ts Records known scenario failures.
packages/​renderers/​graph/​test/​dependencies.test.mjs Tests churn folding.
packages/​renderers/​graph/​src/​dependencies/​view.tsx Clarifies folded-card behavior in comments.
packages/​renderers/​graph/​src/​dependencies/​model.ts Maps folded entities into summaries and steps.
packages/​renderers/​graph/​src/​dependencies/​graph.ts Adds per-revision adjacency.
packages/​renderers/​graph/​src/​dependencies/​collapse.ts Folds churn and updates summary status.
packages/​renderers/​graph/​src/​dependencies/​churn.ts Identifies transitive churn.
packages/​renderers/​graph/​scenarios.json Registers two dependency scenarios.
packages/​renderers/​graph/​README.md Documents folding behavior.
packages/​renderers/​graph/​fixtures/​make-bundler-migration.mjs Generates synthetic workspace revisions.
docs/​builtins/​renderers/​graph.md Explains churn summaries.
docs/​builtins/​extractors/​workspace-dependencies.md Describes dependency presentation changes.
changelog.d/​343.md Announces graph improvements.
changelog.d/​343-renderer-authors.md Announces alias-aware checks.

Review effort: Balanced

…ges matches references by alias

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

Ownership changes can leave summary counts stale and remove collapse controls, while incomplete alias handling causes comparison checks to reject valid highlighting or miss unmarked changes.

4 open issues
3 resolved since last review

Review effort: Balanced

…aliased cards count as touched in every check

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

Summary scheduling remains order-dependent and omits synthetic edges, causing reverse-comparison count mismatches and edge highlights that are out of sync with their cards.

2 open issues
4 resolved since last review

Review effort: Balanced

agorischek and others added 3 commits December 4, 2026 02:22
…e summary steps by cause, with their edges

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

Dependency folding can hide transitive-only version changes, and expanded-card membership incorrectly carries ownership across revisions, producing inaccurate summaries.

2 open issues
2 resolved since last review

Review effort: Balanced

agorischek and others added 3 commits December 4, 2026 11:25
…vision

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
agorischek and others added 2 commits December 4, 2026 21:43
Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
agorischek and others added 2 commits December 4, 2026 23:45
Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
agorischek and others added 3 commits December 5, 2026 00:34
With churn folded, the first summary card is express's; expanding it
reveals packages whose own summary cards can come first, so re-resolving
.first() after the click found a different, collapsed card.

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants