Skip to content

fix(fix): read pnpm lockfiles with a package installed once per target version - #100

Merged
lucasbraum merged 2 commits into
mainfrom
fix/pnpm-lockfile-peer-dup-keys
Oct 13, 2026
Merged

lucasbraum merged 2 commits into
mainfrom
fix/pnpm-lockfile-peer-dup-keys

Conversation

@lucasbraum

@lucasbraum lucasbraum commented Oct 13, 2026 •

Copy link
Copy Markdown
Collaborator

Fixes UPT-28.

Problem

fix zod --no-llm on band-ai/band-sdk-typescript (zod ground truth, 5d9a66a) failed with Map keys must be unique … '@modelcontextprotocol/[email protected](@cfworker/[email protected])(zod@*)'. The repo installs zod 3.25.76, 4.3.6 and 4.4.3 side by side, so pnpm writes one snapshot per zod version (x@1([email protected]), x@1([email protected])). pnpmGraph rewrote (zod@<version>) to (zod@*) in the raw text before parsing, so those keys collapsed into duplicates and the YAML parser rejected the file.

Fix

pnpmGraph (packages/core/src/fix/managers/text-lock.ts) now parses the raw lockfile first, then strips the target's peer version from each entry:

  • Variants of one package that differ only by the target version are merged into one record under the (zod@*) key. The merged record's dependencies (dependencies, optionalDependencies) are the union of the variants' dependencies, and so are its edges.
  • If the same dependency resolves to different versions in two variants, they are not merged. They also stay separate if they differ in anything else (identity, execution fields, other metadata). Each separate variant keeps its own key and is compared as written, so a change in one of them still trips the guard.
  • Dependency versions are compared without the target's peer version (3.25.1(zod@*)). The target's own edge is left out of that comparison: each variant points at its own zod version, and every zod entry is in scope anyway.
  • Dependency edges resolve to the written key first, then to the peerless key.

stable is exported from lock-guard.ts so the variant comparison reuses it.

Tests

  • New fixture fixtures/lockfiles/peer-variants/pnpm-lock.yaml with the real band-sdk shape: two importers on different zod majors, plus @modelcontextprotocol/sdk and zod-to-json-schema present once per zod version. Package names and the shape are taken from the public lockfile; integrity values are placeholders.

  • Three tests in text-lock.test.ts:

    • the zod bump passes and only the zod entries move;
    • variants are merged by the union of their dependencies (only one has cross-spawn), and dropping it later is caught as outside zod;
    • variants where the same dependency (ajv) resolves to different versions stay separate, and a change to one of them is caught.

    On main, all three fail with the production error.

  • pnpm typecheck && pnpm lint && pnpm test pass.

Verified on band-sdk (scratch clone, 5d9a66a)

  • uptide fix zod --no-llm now completes the whole migration (check, upgrade, fixes, verification). Verification still fails for migration reasons: 4 type errors are left for manual work without the LLM, and one test was already failing before the upgrade. The lockfile is no longer the problem.
  • uptide pack test zod runs against band-sdk again: PASS, verified. Overall precision is 100% and recall 85%; on breaking sites it is 100% and 74%, which matches the README.

🤖 Generated with Claude Code

lucasbraum and others added 2 commits October 12, 2026 21:40
…t version

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: Lucas Braum <[email protected]>
Variants that differ only by the target's peer version are merged with
their dependencies unioned. A dependency resolved to different versions
across variants, or any other difference, keeps them apart.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: Lucas Braum <[email protected]>
@lucasbraum
lucasbraum merged commit 53f9f7d into main Oct 13, 2026
10 checks passed
@lucasbraum
lucasbraum deleted the fix/pnpm-lockfile-peer-dup-keys branch October 13, 2026 05:35
@uptide-release uptide-release Bot mentioned this pull request Oct 13, 2026
lucasbraum pushed a commit that referenced this pull request Oct 13, 2026
This PR was opened by the [Changesets
release](https://github.com/changesets/action) GitHub action. When
you're ready to do a release, you can merge this and publish to npm
yourself or [setup this action to publish
automatically](https://github.com/changesets/action#with-publishing). If
you're not ready to do a release yet, that's fine, whenever you add more
changesets to main, this PR will be updated.


# Releases
## [email protected]

### Minor Changes

- [#108](#108)
[`38dcd4b`](38dcd4b)
Thanks [@lucasbraum](https://github.com/lucasbraum)! - The Uptide Action
now requires the Anthropic API key. Without `anthropic-api-key` (or with
it
empty), in any mode, it stops before doing anything: the job summary
says to add the
repository secret `ANTHROPIC_API_KEY` (Settings → Secrets and variables
→ Actions), the run
report has no upgrades and an error starting with `LLM_KEY_MISSING`, and
the job fails.
`uptide.run/v1` gains `llmKey` (`present` or `missing`; never the key).
`uptide init` no longer
writes `llm.enabled`, and refuses an existing `uptide.yml` that sets it
to `false`, which the
  Action rejects. The CLI on your own machine still runs without a key.

- [#101](#101)
[`8452329`](8452329)
Thanks [@lucasbraum](https://github.com/lucasbraum)! - `list`, `check`,
`fix`, `plan` and the Action never target a release younger than the
repository's release-age policy: npm `min-release-age` (`.npmrc`), pnpm
`minimumReleaseAge`
with `minimumReleaseAgeExclude` (`pnpm-workspace.yaml`), or Yarn
`npmMinimalAgeGate` with
`npmPreapprovedPackages` (`.yarnrc.yml`). When none is set, the default
of the pinned package
manager version applies (pnpm 11 and 12, Yarn 4.15 and later: one day),
labelled as such.
When the newest release is too young, the newest one old enough is the
target and the output
says why (`4.6.7 is 2 days old; your policy is 7 days (min-release-age
in .npmrc); targeting
4.6.5`). When nothing newer than the installed version qualifies, the
package is skipped with
that reason, shown as `status: skipped` in `uptide.run/v1` and in the
HTML list report.
Companions and peers follow the same policy. `minReleaseAgeDays` in
`uptide.yml` applies when
the repository sets no policy itself. See `docs/config.md#release-age`.

### Patch Changes

- [#107](#107)
[`008f84a`](008f84a)
Thanks [@lucasbraum](https://github.com/lucasbraum)! - The Action's
commits are authored by the Uptide App's own bot account,
`<app slug>[bot] <<bot user id>+<app
slug>[bot]@users.noreply.github.com>`, resolved with the
installation token, so GitHub links them to the App. When it cannot be
resolved they keep
  `uptide[bot] <[email protected]>` and the job log warns.

- [#107](#107)
[`008f84a`](008f84a)
Thanks [@lucasbraum](https://github.com/lucasbraum)! - `uptide.run/v1`
gains `verification.baselineHealth`: the repository before the upgrade
in
counts only (type errors, failing test runs, and missing-module errors
under its own paths and
in packages), so the dashboard can tell a run that could only compare
from one that proved.
No module or alias name leaves the fix report. Optional; absent in older
reports.

- [#107](#107)
[`008f84a`](008f84a)
Thanks [@lucasbraum](https://github.com/lucasbraum)! - `check` analyzes
a package's companions at the versions its upgrade moves them to, even
when
nothing imports them or they only carry types: `check react` in a Next
app used to report
`react-dom` and `@types/react` on their own at their installed versions,
while `react` moved
to 19. They are now members of `react`'s group, linked into the compile
at 19, and the
  Action's job summary shows each one moving with `react`.

- [#102](#102)
[`78f1f7a`](78f1f7a)
Thanks [@lucasbraum](https://github.com/lucasbraum)! - `uptide init`
writes a workflow that runs the released Uptide Action,
`uptide-dev/uptide@2045c7d # v0.9.0`,
and no longer notes that the action is not released yet.

- [#100](#100)
[`53f9f7d`](53f9f7d)
Thanks [@lucasbraum](https://github.com/lucasbraum)! - `fix` reads pnpm
lockfiles that install a package once per version of the upgraded one
(`x@1([email protected])` next to `x@1([email protected])`) instead of failing with
"Map keys must be unique". Variants that differ only by that version are
compared as one entry; variants that differ in anything else are still
checked one by one.

- [#107](#107)
[`008f84a`](008f84a)
Thanks [@lucasbraum](https://github.com/lucasbraum)! - When Uptide
refuses to publish a migration that did not verify, it words the reason
as the
run's verdict does: `1 type error introduced by the upgrade, 2
pre-existing` instead of
`1 new type error`, and a test run that was already failing before the
upgrade is named as
  such instead of as a failure of the migration.

- [#104](#104)
[`8fd120e`](8fd120e)
Thanks [@lucasbraum](https://github.com/lucasbraum)! - Reports no longer
show a breaking count of 0 for a package without a migration pack: the
terminal, the HTML report and the Action's job summary say `not
analyzed: no pack yet`
instead, and `uptide.run/v1` gains `analysis` (`pack` or `none`, absent
when nothing was
analyzed). A companion that `check` reports at its installed version
(`react-dom` or
`@types/react` with `react`) shows the versions it moves to and `moves
with react`, carried as
`movesWith`, instead of `up to date`; no upgrade kind is printed when
nothing moves. The job
summary lists breaking sites per package by path and line, and has no
breaking-sites section
when there are none. The generated workflow runs on `ubuntu-24.04`
instead of `ubuntu-latest`.

- [#107](#107)
[`008f84a`](008f84a)
Thanks [@lucasbraum](https://github.com/lucasbraum)! - Reports say what
the upgrade broke and what the migration left. `uptide.run/v1` gains
`verification.typecheck.afterUpgrade`, the type errors right after the
version bump and before
any fix, next to `before` and `after` (optional; absent in older
reports). The job summary
prints `types 0 → 4 with the upgrade → 0 after Uptide`, and the pull
request body and the
  terminal say `the upgrade broke 4 · Uptide left 0`.

Co-authored-by: uptide-release[bot] <338861287+uptide-release[bot]@users.noreply.github.com>
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