Skip to content

Add experimental pnpm lockfile invalidation - #1173

Draft
Christian Gonzalez (christiango) wants to merge 4 commits into
mainfrom
christiango-smarter-lockfile-invalidation
Draft

Add experimental pnpm lockfile invalidation#1173
Christian Gonzalez (christiango) wants to merge 4 commits into
mainfrom
christiango-smarter-lockfile-invalidation

Conversation

@christiango

@christiango Christian Gonzalez (christiango) commented Jul 8, 2026

Copy link
Copy Markdown
Member

Summary

Adds an experimental opt-in config option for smarter pnpm lockfile invalidation:

experimentalLockfileInvalidation: { packageManager: "pnpm" }

When enabled, Lage analyzes pnpm-lock.yaml (lockfileVersion 9.x) and computes per-package external dependency closure signatures. This makes both cache hashing and --since filtering invalidate only the workspace packages whose lockfile closure actually changed, instead of treating every lockfile edit as a full-repo invalidation.

Details

  • Adds @lage-run/lockfile for strict pnpm v9 schema validation and stable importer closure signatures.
  • Uses iterative SCC condensation and leaf-to-parent hashing to handle cycles and very deep lockfiles without recursive stack growth.
  • Includes package/snapshot artifact metadata, peer/patch-resolved metadata, importer metadata, and top-level pnpm installation settings.
  • Threads the option through run, affected, watch, info, server, and cache paths.
  • Shares one committed/staged/unstaged/untracked changed-file set and precisely handles local lockfile edits under --since.
  • Automatically owns pnpm-lock.yaml matches from repo-wide and environment globs while precise analysis succeeds.
  • Conservatively falls back on missing, added, deleted, malformed, unsupported, unresolved, or incompletely mapped lockfiles: --since selects all packages and cache keys include the complete raw lockfile.
  • Refreshes signatures cheaply in long-lived server mode when the lockfile stat changes.
  • Documents pnpm-only support and adds regression coverage for fallback, global/root inputs, aliases, peer/patch keys, merge-base failures, local changes, wildcard globs, cycles, and a 20,000-node chain.
  • Adds grouped Beachball metadata.

Validation

  • yarn checkchange
  • yarn syncpack:check
  • yarn format:check
  • yarn lage test --to @lage-run/lockfile --to @lage-run/hasher --to @lage-run/cli
  • yarn ci

Christian Gonzalez and others added 2 commits July 8, 2026 14:23
Add an experimental, opt-in config option
`experimentalLockfileInvalidation: { packageManager: "pnpm" }` that makes
lage precisely determine which workspace packages are actually affected by a
pnpm lockfile change, instead of treating any `pnpm-lock.yaml` change as a
repo-wide invalidation.

- New `@lage-run/lockfile` package: Merkle-hashes the pnpm lockfile snapshot
  DAG (lockfileVersion 9.x) to compute a stable per-package closure signature
  in ~O(nodes + edges) once per run.
- `@lage-run/hasher`: `TargetHasher` uses the closure signature for cache-key
  invalidation when enabled, so only affected packages get a new hash.
- `@lage-run/cli`: `--since` filtering diffs old vs new lockfile and only marks
  affected packages as changed instead of the whole graph.
- `workspace-tools`: new `getMergeBase` git helper.
- Unsupported package managers / lockfile versions fall back safely to today's
  blanket behavior (never under-invalidate).
- Docs + tests + beachball change file.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Address adversarial review findings for the experimental pnpm lockfile invalidation path:

- Treat root/unmapped pnpm importers as global invalidation inputs for cache hashing and force safe blanket fallback for --since when they change.
- Include pnpm package artifact and snapshot metadata in Merkle node hashes so integrity/tarball/patch metadata changes are not missed.
- Replace placeholder cycle handling with SCC-based hashing so changes within cyclic dependency components propagate to all importers entering the component.
- Pass experimental lockfile invalidation through the info command target graph path.
- Add regression coverage for root importer changes, metadata-only lockfile changes, and cycle propagation.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
@christiango

Copy link
Copy Markdown
Member Author

Not ready for review yet, this is the LLM's crack at it

Christian Gonzalez added 2 commits July 11, 2026 10:22
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>

Copilot-Session: 48bff3c0-aa2a-4ffe-a638-160026f2c2d0
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>

Copilot-Session: 48bff3c0-aa2a-4ffe-a638-160026f2c2d0
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.

1 participant