Skip to content

ci(release): gate releases on a publishable manifest, a real upgrade, and pnpm doctor - #13072

Merged
zkochan merged 12 commits into
mainfrom
release-guard-published-manifest
Jul 17, 2026
Merged

zkochan merged 12 commits into
mainfrom
release-guard-published-manifest

Conversation

@zkochan

@zkochan zkochan commented Jul 16, 2026 •

Copy link
Copy Markdown
Member

Summary

Two published v11 releases were broken in ways nothing in the release pipeline checked, and both only surfaced once users upgraded onto them:

Neither wrapper's failure would have caught the other's, and neither was caught before latest moved. This adds two gates.

Preflight assert (release.yml, verify-ts-release): on the packed tarball, the published pnpm manifest must declare no dependencies/devDependencies. It asserts on the artifact rather than trusting either stripper — bundle-deps.ts's on-disk strip is explicitly marked temporary ("Remove this once the release runs a pnpm that applies the hook"), so removing it while the hook still isn't honored would silently reintroduce #12955. npm publishes are immutable, so this has to fail before the first upload.

Upgrade gate (update-latest.yml, before dist-tag add): upgrade from the release line's current version onto the new one, for both the pnpm and @pnpm/exe wrappers, and then run the resulting binary. The release workflow has already published under next-<major> at that point, so this exercises the real registry artifact instead of a local reproduction of it, and it runs before the dist-tags move — the last gate before a version reaches everyone. It runs the binary rather than trusting self-update's exit code, because an @pnpm/exe self-update onto a release with missing natives still exits 0.

Both were verified against the real registry rather than only reasoned about:

check result
assert vs [email protected] rejected
assert vs [email protected], [email protected] accepted
gate: pnpm 11.13.0 → 11.13.1 passes
gate: pnpm 11.11.0 → 11.12.0 caught
gate: @pnpm/exe 11.13.1 → 11.11.0 passes
gate: @pnpm/exe 11.11.0 → 11.12.0 caught
gate: @pnpm/exe 11.13.1 → 11.13.0 caught

Related to #12959. The latent buildLockfileFromEnvLockfile bug that made the bad manifest fatal is addressed separately in #12960; this PR stops a broken artifact from being published or promoted in the first place.

Squash Commit Body

Two published v11 releases were broken in ways nothing in the pipeline
checked, and both only surfaced once users upgraded onto them.

11.12.0 was packed by a pnpm that ignores the .pnpmfile.cjs beforePacking
hook, so the bundled dependency fields survived into the published
manifest. Resolving node-gyp then pulled a peer-suffixed snapshot into the
env lockfile, and every upgrade onto 11.12.0 died in
buildLockfileFromEnvLockfile (pnpm/pnpm#12955, pnpm/pnpm#12959).
11.12.0 and 11.13.0 also shipped `@pnpm/exe` platform packages with no
native binary; setup.js exits 0 when the binary is missing, so the
placeholder bin survived and only a real invocation caught it.

Assert on the packed tarball that the published pnpm manifest declares no
dependency fields, rather than trusting either stripper, since npm
publishes are immutable. Then, in the Tag workflow, upgrade from the
release line's current version onto the new one for both the `pnpm` and
`@pnpm/exe` wrappers and run the resulting binary. The release workflow has
already published under next-<major> at that point, so this reads the real
registry artifact, and it runs before the dist-tags move — the last gate
before a version reaches everyone.

Verified against the registry: the assert rejects [email protected] and accepts
11.11.0/11.13.1; the upgrade gate passes 11.13.0 -> 11.13.1 and catches
both `[email protected]` and `@pnpm/[email protected]`/11.13.0.

Related to pnpm/pnpm#12959.

pnpm doctor

The gate above reproduced what a user does — install the release, then exercise
it — in shell only CI ran. A reproduction drifts from the thing it stands in
for, and it could assert only what shell can see: that the binary prints a
version.

So the gate now calls a real command. pnpm doctor reports the versions and
install method, whether the global bin directory is on PATH, whether the store
and cache are writable, which link strategies the store's filesystem supports,
registry reachability, and — the part the gate turns on — an offline file:
install
that drives the resolve/store/link path end to end in ~600ms. That is
the path a manifest declaring its bundled dependencies breaks. verify-upgrade
runs pnpm doctor --offline on the upgraded binary, so what gates a release is
what ships, and every check the command gains is one releases are verified
against. --json makes it machine-readable and --benchmark times it; it exits
non-zero when any check fails.

The command postdates the release lines this workflow can still tag, so the gate
probes for it and reports when it ran --version alone instead, rather than
failing a v10 promotion on a v11 command.

Verified by running it, not only by typechecking — which caught three real bugs:
the global-bin check was reading the local node_modules/.bin (never on PATH);
the reflink probe used Node's COPYFILE_FICLONE_FORCE, which returns ENOSYS on
macOS and Windows, so it told every Mac user their installs would copy and
advised moving the store — it now clones the way the importer does, via
@reflink/reflink; and pacquet's smoke test passed flags that CLI does not have.
Both stacks now report identically on the same machine.

The Tag workflow runs on pnpm

The workflow drove pnpm's own registry with npm — reading pnpm's dist-tags,
installing pnpm, moving pnpm's tags — which left view, add and dist-tag
unexercised by the pipeline that depends on them. npm was only ever there
because the job installs no pnpm and npm arrives free with Node. It now
installs pnpm with pnpm/setup (the action the rest of the release already
uses) and runs the pnpm CLI.

Tagging uses the version being released. It is published under
next-<major> by then and verify-upgrade has just exercised it, so every tag
is one more thing the release had to do correctly — an authenticated registry
write — before it reaches anyone. This cannot deadlock the way tagging with
latest would: a release that fails here blocks only itself, and its successor
carries its own tagger. The jobs that set up the comparison stay on a pinned
pnpm, since letting the version under test build its own starting point would
let a bug in it be blamed on the version it replaces.

Two details are load-bearing and were measured rather than assumed:

npm_config_registry pnpm ignores it — the registry is pinned per command with --registry
npm_config_userconfig pnpm honors it — this is the half that keeps a runner-level .npmrc out
npm_config_//…/:_authToken pnpm does not act on it, so auth goes through pn config set (as release.yml's publish steps already do)
pn add needs --allow-build=@pnpm/exe: pnpm blocks dependency build scripts, and @pnpm/exe's setup.js is what replaces its placeholder bin with the native. Without it the starting point reproduces the exact breakage this gate exists to catch, and blames the release for it.

Checklist

  • The change is implemented in both the TypeScript CLI and the Rust
    pnpm/ port, or the description notes what still needs porting.
  • Added a changeset (pnpm changeset) if this PR changes any published
    package. Keep it short and written for pnpm users — it becomes a release note.
  • Added or updated tests.

Written by an agent (Claude Code, claude-opus-4-8).


View with Codesmith Autofix with Codesmith
Need help on this PR? Tag /codesmith with what you need. Autofix is disabled.

Summary by CodeRabbit

  • Bug Fixes
    • Strengthened release verification by rejecting packed TypeScript artifacts that include dependency-related manifest fields (dependencies, devDependencies, optionalDependencies, or peerDependencies).
    • Added an upgrade verification step to ensure self-update produces the requested pnpm version before tags are published.
    • Updated the release/tag workflow so dist-tag updates only occur after successful upgrade verification.
  • New Features
    • Added a workflow input to skip the upgrade check when manually dispatching a run.

Copilot AI review requested due to automatic review settings July 16, 2026 09:08

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@coderabbitai

coderabbitai Bot commented Jul 16, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review
📝 Walkthrough

Walkthrough

Release workflows now reject dependency fields in packed TypeScript manifests and verify self-upgrades for both pnpm and @pnpm/exe before registry tags are updated.

Changes

Release verification

Layer / File(s) Summary
TypeScript tarball manifest verification
.github/workflows/release.yml
The release smoke test extracts package/package.json and fails when dependencies, devDependencies, optionalDependencies, or peerDependencies are present.
Self-update upgrade verification
.github/workflows/update-latest.yml
The workflow adds an optional skip input, resolves a source version with fallback handling, installs both package variants in isolation, verifies their starting versions, runs self-update to the target version, checks upgraded versions, and gates tag updates on success.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Sequence Diagram(s)

sequenceDiagram
  participant GitHubActions
  participant npmRegistry
  participant TempPnpmEnvironment
  participant pnpm
  participant PnpmExe
  GitHubActions->>npmRegistry: Resolve source version
  GitHubActions->>TempPnpmEnvironment: Install source packages
  GitHubActions->>pnpm: Verify source version
  GitHubActions->>PnpmExe: Verify source version
  GitHubActions->>pnpm: Self-update to target version
  GitHubActions->>PnpmExe: Self-update to target version
  GitHubActions->>pnpm: Verify target version
  GitHubActions->>PnpmExe: Verify target version
  GitHubActions->>GitHubActions: Update registry tags after verification
Loading

Possibly related PRs

  • pnpm/pnpm#13061: Updates related packed tarball handling in the release verification workflow.
  • pnpm/pnpm#13063: Adjusts related TypeScript release tarball verification logic.
  • pnpm/pnpm#13066: Modifies related TypeScript release tarball verification logic.

Suggested reviewers: copilot

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch release-guard-published-manifest

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@qodo-code-review

Copy link
Copy Markdown

PR Summary by Qodo

Gate releases on publishable pnpm manifest and real upgrade verification

✨ Enhancement ⚙️ Configuration changes 🕐 20-40 Minutes

Grey Divider

AI Description

• Add a preflight check that packed pnpm tarballs publish no dependency fields.
• Add an upgrade smoke gate that self-updates from current release-line version.
• Block dist-tag promotion until both pnpm and @pnpm/exe binaries run successfully.
Diagram

graph TD
  A["Release workflow"] --> B["Packed pnpm.tgz"] --> C{"Manifest clean?"} --> D["Publish to next-<major>"]
  E["Update-latest workflow"] --> F["Resolve FROM version"] --> G["Install+Self-update (pnpm & @pnpm/exe)"] --> H{"Upgraded binary runs?"} --> I["Move dist-tags (latest)"]
  D --> J[("npm registry")]
  J --> G

  subgraph Legend
    direction LR
    _job["Workflow job/step"] ~~~ _art["Artifact"] ~~~ _dec{"Gate"} ~~~ _reg[("Registry")]
  end
Loading
High-Level Assessment

The following are alternative approaches to this PR:

1. Extract gates into versioned repo scripts (e.g., scripts/release-guards/*)
  • ➕ Easier to unit-test locally and reuse across workflows
  • ➕ Less YAML-embedded logic; improves maintainability
  • ➖ More moving parts (Node runtime, script packaging) for what is currently self-contained
  • ➖ Still needs careful env isolation and registry interactions in CI
2. Validate via npm view only (metadata-based) instead of upgrading and running
  • ➕ Faster and avoids executing downloaded binaries in CI
  • ➕ Still catches some manifest-related regressions
  • ➖ Would not catch missing native binaries or runtime wrapper failures
  • ➖ Less representative than exercising actual self-update and invocation paths

Recommendation: Keep the PR’s approach: asserting directly on the packed tarball prevents immutable bad publishes, and the real upgrade-and-run gate is the most reliable way to catch wrapper- and native-binary regressions before dist-tag promotion. If the YAML grows further, consider later refactoring the gate logic into repo scripts for maintainability.

Files changed (2) +69 / -0

Other (2) +69 / -0
release.ymlPreflight: assert packed pnpm manifest declares no dependency fields +16/-0

Preflight: assert packed pnpm manifest declares no dependency fields

• Adds a tarball-level verification step that parses package/package.json from the built pnpm .tgz and fails if dependencies or devDependencies are present. This prevents publishing artifacts whose manifests incorrectly declare bundled runtime dependencies.

.github/workflows/release.yml

update-latest.ymlPre-tag gate: upgrade from current release-line version and run binaries +53/-0

Pre-tag gate: upgrade from current release-line version and run binaries

• Adds a verification step before dist-tag updates that installs the current release-line version, self-updates to the candidate version for both pnpm and @pnpm/exe, and then runs the resulting binary to confirm it works. Uses isolated PNPM_HOME/XDG dirs to ensure the upgrade exercises real registry artifacts and not cached state.

.github/workflows/update-latest.yml

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🧹 Nitpick comments (1)
.github/workflows/update-latest.yml (1)

63-66: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

Silence the zizmor warning for ad-hoc package installation.

The static analysis tool zizmor flags the npm install on line 87 for installing a package outside of a lockfile. Since this step dynamically resolves and installs the previous release version for testing, you can add an ignore directive to the step to suppress this false positive, matching the convention used in .github/workflows/release.yml.

♻️ Proposed refactor to add the ignore directive
     - name: Verify upgrading onto the new version
+      # zizmor: ignore[adhoc-packages] -- This step intentionally installs a dynamic older version from the registry to verify upgrades.
       env:
         VERSION: ${{ github.event.inputs.version }}
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In @.github/workflows/update-latest.yml around lines 63 - 66, Add the
repository’s established zizmor ignore directive to the “Verify upgrading onto
the new version” workflow step, matching the convention used in release.yml, so
the dynamic npm install is excluded from the lockfile warning. Keep the step’s
existing version environment and upgrade verification commands unchanged.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Nitpick comments:
In @.github/workflows/update-latest.yml:
- Around line 63-66: Add the repository’s established zizmor ignore directive to
the “Verify upgrading onto the new version” workflow step, matching the
convention used in release.yml, so the dynamic npm install is excluded from the
lockfile warning. Keep the step’s existing version environment and upgrade
verification commands unchanged.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: 537cdca1-a7f9-4640-8dae-7180d7451d89

📥 Commits

Reviewing files that changed from the base of the PR and between 6d2030e and 426a37f.

📒 Files selected for processing (2)
  • .github/workflows/release.yml
  • .github/workflows/update-latest.yml

@github-actions github-actions Bot added the reviewed: coderabbit CodeRabbit submitted an approving review label Jul 16, 2026
@qodo-code-review

qodo-code-review Bot commented Jul 16, 2026 •

Copy link
Copy Markdown

Code Review by Qodo

🐞 Bugs (4) 📘 Rule violations (1) 📎 Requirement gaps (0) 📜 Skill insights (0)

Context used
✅ Compliance rules (platform): 18 rules

Grey Divider


Action required

1. Release runs with NPM_TOKEN ✓ Resolved 🐞 Bug ⛨ Security
Description
tag-in-registry installs and then executes the exact ${{ github.event.inputs.version }} pn
binary in the same job step where NPM_TOKEN is injected, so a compromised/malicious published
release can read/exfiltrate the token while performing pn config set/pn dist-tag add. This makes
the dist-tag promotion step a high-value credential exposure point tied directly to the artifact
being promoted.
Code

.github/workflows/update-latest.yml[R224-248]

+    - name: Install pnpm and Node
+      uses: pnpm/setup@77cf06832101b3ac8c65caaf76a21643936d07a4
+      with:
+        version: ${{ github.event.inputs.version }}
+        runtime: [email protected]
+        install: false
    - name: Update tag
      env:
-        "npm_config_//registry.npmjs.org/:_authToken": ${{ secrets.NPM_TOKEN }}
+        # Written to pnpm's config rather than passed as
+        # `npm_config_//registry.npmjs.org/:_authToken`, which pnpm does not act
+        # on — the same reason release.yml's publish steps do this.
+        NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
        VERSION: ${{ github.event.inputs.version }}
        TAG: ${{ github.event.inputs.tag }}
      run: |
+        set -euo pipefail
+        trap 'pn config delete "//registry.npmjs.org/:_authToken" || true' EXIT
+        pn config set "//registry.npmjs.org/:_authToken" "${NPM_TOKEN}"
+
        MAJOR="${VERSION%%.*}"
-        npm dist-tag add "pnpm@${VERSION}" "latest-${MAJOR}"
-        npm dist-tag add "@pnpm/exe@${VERSION}" "latest-${MAJOR}"
+        pn dist-tag add "pnpm@${VERSION}" "latest-${MAJOR}" --registry="$REGISTRY"
+        pn dist-tag add "@pnpm/exe@${VERSION}" "latest-${MAJOR}" --registry="$REGISTRY"
        if [ "$TAG" != "latest-${MAJOR}" ]; then
-          npm dist-tag add "pnpm@${VERSION}" "${TAG}"
-          npm dist-tag add "@pnpm/exe@${VERSION}" "${TAG}"
+          pn dist-tag add "pnpm@${VERSION}" "${TAG}" --registry="$REGISTRY"
+          pn dist-tag add "@pnpm/exe@${VERSION}" "${TAG}" --registry="$REGISTRY"
Evidence
The workflow installs the input version, then later exports NPM_TOKEN and runs pn ... commands
that will execute that installed binary while the token is present.

.github/workflows/update-latest.yml[224-229]
.github/workflows/update-latest.yml[231-248]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

### Issue description
`tag-in-registry` installs the release version (`${{ github.event.inputs.version }}`) and later (with `NPM_TOKEN` present) invokes `pn` to write auth config and mutate dist-tags. If that release artifact is compromised, it can exfiltrate `NPM_TOKEN` during these invocations.

### Issue Context
This job is intentionally the only one with secrets, but it still executes the version being promoted after secrets are loaded.

### Fix Focus Areas
- .github/workflows/update-latest.yml[222-248]

### Suggested fix
- Do **not** use the promoted version’s `pn`/`pnpm` binary for authenticated tagging.
- Instead, install and use a pinned, trusted pnpm (e.g. `RELEASE_TOOL_PNPM_VERSION`) in `tag-in-registry` and perform all `dist-tag add` operations with that tool.
- If you must keep “self-tagging”, ensure secrets are only exposed to a minimal, isolated invocation (e.g., run tagging in a separate job/runner that does not execute arbitrary registry-installed code before the secreted step, and avoid persisting auth to default user config by using an isolated `npm_config_userconfig` file that you delete at the end).

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


2. Comments cite past broken releases ✓ Resolved 📘 Rule violation ⚙ Maintainability
Description
The newly added workflow comment blocks describe historical release incidents (e.g., what happened
when 11.12.0/11.13.0 were packed) instead of documenting the current, timeless contract/invariant of
the gate. This violates the requirement that inline comments describe current behavior rather than
past implementations/incidents and risks becoming stale or misleading.
Code

.github/workflows/update-latest.yml[R55-62]

+    # The release workflow has already published this version under
+    # next-<major>; moving the dist-tags below is what makes `pnpm self-update`
+    # and the devEngines/packageManager download path resolve it. Upgrading onto
+    # a version reads its published manifest, so a bad one only fails here, on
+    # the real registry artifact — 11.12.0 published its bundled dependencies as
+    # real dependencies and every upgrade onto it crashed
+    # (pnpm/pnpm#12955, pnpm/pnpm#12959). This is the last gate before `latest`
+    # exposes the version to everyone.
Evidence
PR Compliance ID 772199 disallows historical/temporal framing in source comments and requires
comments to describe current behavior. The cited workflow lines include explicitly historical
phrasing (e.g., "When 11.12.0 was packed...") and references to specific past releases
(11.12.0/11.13.0), demonstrating that the comments are narrating past events rather than stating the
present workflow intent/constraints in a timeless way, which matches the rule’s failure mode.

Rule 772199: Comments must describe current behavior, not historical implementations
.github/workflows/update-latest.yml[55-62]
.github/workflows/update-latest.yml[99-103]
.github/workflows/release.yml[239-246]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
The workflow comments currently narrate specific past release incidents (historical version-specific behavior) rather than describing the current, stable contract/invariant of the workflow gate.

## Issue Context
Per compliance (PR Compliance ID 772199), historical context should be kept in PR/issue history (PR descriptions, commit messages, or linked issues), while inline comments must focus on current behavior, constraints, and rationale without temporal/historical framing to avoid staleness or misleading documentation.

## Fix Focus Areas
- .github/workflows/update-latest.yml[55-62]
- .github/workflows/update-latest.yml[99-103]
- .github/workflows/release.yml[239-246]

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


3. Scripts can steal NPM_TOKEN ✓ Resolved 🐞 Bug ⛨ Security
Description
update-latest.yml now runs npm install --ignore-scripts=false on registry artifacts (pnpm and
@pnpm/exe) in the same job that later exports secrets.NPM_TOKEN for npm dist-tag add. A
compromised package’s lifecycle script can persistently alter later steps (e.g., via
$GITHUB_PATH/$GITHUB_ENV to shadow npm) and then capture/exfiltrate the token when the tagging
step runs.
Code

.github/workflows/update-latest.yml[R63-110]

+    - name: Verify upgrading onto the new version
+      env:
+        VERSION: ${{ github.event.inputs.version }}
+      run: |
+        set -eu
+        MAJOR="${VERSION%%.*}"
+        # Upgrade from what users on this release line are running today. A new
+        # major has no latest-<major> yet, so fall back to the current latest.
+        if ! FROM=$(npm view "pnpm@latest-${MAJOR}" version 2>/dev/null) || [ -z "$FROM" ]; then
+          FROM=$(npm view pnpm dist-tags.latest)
+        fi
+        echo "Upgrading from v${FROM} to v${VERSION}"
+
+        # Both wrappers are exercised: self-update reinstalls the package it is
+        # running from, so `pnpm` and `@pnpm/exe` resolve different published
+        # manifests and a broken one surfaces on only that wrapper.
+        for package in pnpm @pnpm/exe; do
+          work=$(mktemp -d)
+          # Isolate the whole pnpm environment so the upgrade resolves and
+          # installs for real instead of reusing a warm store or global dir.
+          export PNPM_HOME="$work/home"
+          export XDG_DATA_HOME="$work/data"
+          export XDG_CACHE_HOME="$work/cache"
+
+          npm install --prefix "$work/from" --ignore-scripts=false "${package}@${FROM}"
+          case "$package" in
+            pnpm) from_bin=(node "$work/from/node_modules/pnpm/bin/pnpm.mjs") ;;
+            @pnpm/exe) from_bin=("$work/from/node_modules/@pnpm/exe/pnpm") ;;
+          esac
+
+          # Check the starting point separately so a previous release that is
+          # itself broken fails here, with its own version in the message,
+          # instead of looking like a fault in $VERSION.
+          test "$("${from_bin[@]}" --version)" = "$FROM"
+
+          ( cd "$work" && "${from_bin[@]}" self-update "$VERSION" )
+          # Run the upgraded binary, not just the exit code: @pnpm/exe's
+          # preinstall leaves its placeholder bin in place when the platform
+          # package ships without a native, so a self-update onto a release with
+          # missing natives (11.12.0, 11.13.0) still "succeeds" and only a real
+          # invocation catches it.
+          test "$("$PNPM_HOME/bin/pnpm" --version)" = "$VERSION"
+          echo "OK: ${package}@${FROM} self-updated to v${VERSION}"
+        done
+
    - name: Update tag
      env:
        "npm_config_//registry.npmjs.org/:_authToken": ${{ secrets.NPM_TOKEN }}
Evidence
The workflow explicitly enables lifecycle scripts while installing registry packages in the new
verification step, and later injects NPM_TOKEN for tagging in the same job. The repo’s security
guide calls out CI/workflow changes as requiring tight secret scoping and treating registry/tarball
inputs as attacker-controlled, which makes this combined design a concrete credential-exposure risk
if a resolved artifact is compromised.

.github/workflows/update-latest.yml[55-120]
.github/workflows/update-latest.yml[14-20]
REVIEW_GUIDE.md[30-104]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
The new upgrade-verification step executes npm lifecycle scripts from registry-resolved packages (`npm install --ignore-scripts=false`) before a later step in the *same job* injects `secrets.NPM_TOKEN` for `npm dist-tag add`. Registry artifacts must be treated as attacker-controlled; lifecycle scripts can persist runner changes that affect later steps and potentially capture the token.

## Issue Context
This is a release pipeline. The workflow already follows the repo’s security guidance to scope secrets to only the step that needs them, but running untrusted code earlier in the same job can still modify the environment/command resolution used by the later secret-bearing step.

## Fix Focus Areas
- .github/workflows/update-latest.yml[55-120]

### Suggested remediation approach
- Split the workflow into two jobs:
 - A **verify** job (no `environment: release`, no secrets) that performs the upgrade gate.
 - A **tag** job (with `environment: release` and `NPM_TOKEN`) that runs `npm dist-tag add`, depending on the verify job via `needs`.
- If splitting jobs is not feasible, ensure the verify step cannot influence subsequent steps that use `NPM_TOKEN` (job-level isolation is the most reliable option).

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools



Remediation recommended

4. Weak version validation 🐞 Bug ⛨ Security ⭐ New
Description
The Validate version and tag step validates VERSION via line-based grep, so a multi-line
VERSION can pass if any line matches, and the regex also accepts non-canonical numeric identifiers
with leading zeros despite claiming “exact semver”. This weakens the workflow’s release-integrity
guard and can let malformed inputs reach later tagging/upgrade logic (likely failing later, but
after bypassing the intended invariant).
Code

.github/workflows/update-latest.yml[R61-70]

+        set -euo pipefail
+        # Stable versions only, no prerelease suffix. Every dispatch moves
+        # latest-<major> whatever `tag` says, so there is no way to tag a
+        # prerelease here without promoting it to a channel that `pnpm
+        # self-update` and a bare `npm install pnpm` resolve — and the release
+        # lines that publish prereleases (`X.Y.Z-alpha.N` under next-<major>)
+        # are exactly the ones a typo here would leak to everyone.
+        if ! printf '%s\n' "$VERSION" | grep -Eq '^[0-9]+\.[0-9]+\.[0-9]+$'; then
+          echo "::error::Version must be an exact, stable semver version like 11.2.0 (prereleases cannot be tagged). Got: ${VERSION}"
          exit 1
Evidence
VERSION is a workflow_dispatch input and is validated only by a line-oriented grep check;
grep anchors apply per-line, so multi-line inputs can satisfy the pattern on one line. The regex
used also permits leading-zero numeric components, which is looser than the “exact semver” contract
implied by the error message and comment.

.github/workflows/update-latest.yml[3-9]
.github/workflows/update-latest.yml[61-72]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
The workflow’s VERSION validation uses `printf ... | grep -Eq '^...$'`, which matches per-line. If `VERSION` contains newlines, the check can succeed even though the overall input is malformed. The regex also permits leading zeros in numeric components (`01.02.03`), which contradicts the “exact semver” wording and can allow unintended/malformed values to pass the guard.

## Issue Context
This value is a `workflow_dispatch` input and is later used to derive `MAJOR` and to drive promotion logic; the intent of this guard is to prevent unsafe/accidental promotion.

## Fix Focus Areas
- .github/workflows/update-latest.yml[61-70]

## Suggested fix
Replace the `grep` check with a single-string validation that:
1) Rejects multi-line input explicitly.
2) Enforces canonical SemVer numeric identifiers (no leading zeros except `0`).

Example (bash):
```bash
case "$VERSION" in
 *$'\n'*|*$'\r'*)
   echo "::error::Version must be a single-line stable semver. Got: ${VERSION}"
   exit 1
   ;;
esac

if ! [[ "$VERSION" =~ ^(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)$ ]]; then
 echo "::error::Version must be an exact, stable semver version like 11.2.0. Got: ${VERSION}"
 exit 1
fi
```
(Or equivalent `grep` logic that guarantees single-line input before matching, but `[[ ... =~ ... ]]` avoids line-based pitfalls.)

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


5. Smoke test uses ambient cache 🐞 Bug ☼ Reliability
Description
The Rust doctor install smoke test isolates --store-dir but does not isolate the cache directory
for the child install, so it may write to or depend on the user’s real cache state. This makes the
diagnostic less reproducible and violates the “scratch” expectation implied by the test’s temp
workspace.
Code

pnpm/crates/cli/src/cli_args/doctor.rs[R348-371]

+fn run_install_smoke_test(base: &Path) -> Result<(), String> {
+    let provider = base.join("provider");
+    let consumer = base.join("consumer");
+    let store = base.join("store");
+    fs::create_dir_all(&provider).map_err(|error| error.to_string())?;
+    fs::create_dir_all(&consumer).map_err(|error| error.to_string())?;
+    fs::write(provider.join("package.json"), r#"{"name":"pnpm-doctor-fixture","version":"0.0.0"}"#)
+        .map_err(|error| error.to_string())?;
+    fs::write(
+        consumer.join("package.json"),
+        r#"{"name":"pnpm-doctor-consumer","version":"0.0.0","private":true,"dependencies":{"pnpm-doctor-fixture":"file:../provider"}}"#,
+    )
+    .map_err(|error| error.to_string())?;
+
+    // A throwaway store keeps the probe from writing into the real one. The
+    // fixture is a temp directory with no lockfile and no workspace above it,
+    // so nothing here depends on the lockfile or workspace flags.
+    let current_exe = std::env::current_exe().map_err(|error| error.to_string())?;
+    let output = Command::new(current_exe)
+        .current_dir(&consumer)
+        .args(["install", "--offline", "--ignore-scripts"])
+        .arg(format!("--store-dir={}", store.display()))
+        .output()
+        .map_err(|error| error.to_string())?;
Evidence
The Rust smoke test only passes --store-dir to the child process, while the config system supports
cache-dir via env overlay; the TS doctor implementation explicitly isolates both store and cache
for the same smoke-test concept.

pnpm/crates/cli/src/cli_args/doctor.rs[348-371]
pnpm/crates/config/src/env_overlay.rs[191-197]
pnpm11/pnpm/src/cmd/doctor.ts[286-296]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

### Issue description
`run_install_smoke_test()` spawns `pnpm install` with a temporary `--store-dir`, but the subprocess inherits the ambient cache directory (from config/env), so the smoke test can read/write user cache state.

### Issue Context
`cache-dir` is a supported config key and can be overridden via env overlay (e.g. `PNPM_CONFIG_CACHE_DIR`). The TypeScript doctor smoke test already passes an isolated `--cache-dir`.

### Fix Focus Areas
- pnpm/crates/cli/src/cli_args/doctor.rs[348-371]
- pnpm/crates/config/src/env_overlay.rs[191-197]
- pnpm11/pnpm/src/cmd/doctor.ts[286-296]

### Suggested fix
- Create a temp cache directory alongside `store` (e.g. `let cache = base.join("cache")`).
- Override the spawned command’s cache via env overlay, e.g. `.env("PNPM_CONFIG_CACHE_DIR", &cache)` (and/or the lowercase variant if needed by your env reader).
- Optionally also set `XDG_CACHE_HOME` for the subprocess to keep all XDG-derived paths inside the temp base.

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


6. Doctor leaks registry URL 🐞 Bug ⛨ Security
Description
pacquet doctor prints config.registry verbatim in the connectivity check result, which can leak
inline URL credentials (userinfo) into terminal/CI logs. This bypasses the existing
redact_and_sanitize pattern used by pacquet ping for the same data.
Code

pnpm/crates/cli/src/cli_args/doctor.rs[R149-165]

+    async fn check_connectivity(&self, config: &Config) -> CheckResult {
+        let title = "Registry connectivity";
+        if self.offline {
+            return CheckResult::pass(title, "skipped (--offline)");
+        }
+        let started = Instant::now();
+        match (PingArgs { registry: None }).run(config).await {
+            Ok(_) => CheckResult::pass(
+                title,
+                format!("{} ({}ms)", config.registry, started.elapsed().as_millis()),
+            ),
+            Err(error) => CheckResult::fail(
+                title,
+                format!("could not reach {}: {error}", config.registry),
+                "Check your network, proxy, and registry configuration.",
+            ),
+        }
Evidence
pacquet ping explicitly redacts/sanitizes registry URLs before printing, but doctor prints
config.registry directly in its pass/fail detail, so inline credentials would be exposed.

pnpm/crates/cli/src/cli_args/doctor.rs[149-165]
pnpm/crates/cli/src/cli_args/ping.rs[35-63]
pnpm/crates/network/src/auth.rs[767-777]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

### Issue description
`pacquet doctor` formats connectivity results using `config.registry` directly. If the registry URL contains inline credentials (e.g. `https://user:pass@host/`), those credentials will be printed.

### Issue Context
The codebase already has a safe formatter for this class of output: `pacquet_network::redact_and_sanitize` is used by `pacquet ping`.

### Fix Focus Areas
- pnpm/crates/cli/src/cli_args/doctor.rs[149-165]
- pnpm/crates/cli/src/cli_args/ping.rs[35-63]

### Suggested fix
- Use `pacquet_network::redact_and_sanitize(&config.registry)` (or `redact_url_credentials` + control-char stripping) when constructing the `detail` string for pass/fail.
- Consider applying the same sanitization to any other user/config-derived strings included in the doctor report.

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


View more (2)
7. Missing trailing commas in doctor.ts 📘 Rule violation ⚙ Maintainability
Description
Multi-line parameter and argument lists in pnpm11/pnpm/src/cmd/doctor.ts omit trailing commas on
the last item, violating the repo’s TypeScript trailing-comma requirement and creating noisier diffs
on future edits.
Code

pnpm11/pnpm/src/cmd/doctor.ts[R260-284]

+export async function checkInstallSmokeTest (
+  pnpmCommand: string[],
+  opts: Pick<DoctorCommandOptions, 'benchmark'>
+): Promise<CheckResult> {
+  const title = 'Install smoke test'
+  const base = await fs.promises.mkdtemp(path.join(os.tmpdir(), 'pnpm-doctor-install-'))
+  const started = Date.now()
+  try {
+    const provider = path.join(base, 'provider')
+    const consumer = path.join(base, 'consumer')
+    await fs.promises.mkdir(provider, { recursive: true })
+    await fs.promises.mkdir(consumer, { recursive: true })
+    await fs.promises.writeFile(
+      path.join(provider, 'package.json'),
+      JSON.stringify({ name: 'pnpm-doctor-fixture', version: '0.0.0' })
+    )
+    await fs.promises.writeFile(
+      path.join(consumer, 'package.json'),
+      JSON.stringify({
+        name: 'pnpm-doctor-consumer',
+        version: '0.0.0',
+        private: true,
+        dependencies: { 'pnpm-doctor-fixture': 'file:../provider' },
+      })
+    )
Evidence
PR Compliance ID 713434 requires trailing commas in multi-line TypeScript constructs. In
checkInstallSmokeTest, the last parameter opts: Pick<DoctorCommandOptions, 'benchmark'> has no
trailing comma, and the multi-line fs.promises.writeFile( calls similarly omit a trailing comma
after the final argument.

Rule 713434: Require trailing commas in TypeScript collections and multi-line constructs
pnpm11/pnpm/src/cmd/doctor.ts[260-284]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
TypeScript multi-line constructs should include a trailing comma after the last item. In `checkInstallSmokeTest`, both the multi-line parameter list and some multi-line call argument lists are missing the trailing comma on the last entry.

## Issue Context
This repo’s compliance rule requires trailing commas in multi-line TypeScript parameter/argument lists to keep formatting consistent and reduce diff churn.

## Fix Focus Areas
- pnpm11/pnpm/src/cmd/doctor.ts[260-284]

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


8. TS doctor ignores registry auth 🐞 Bug ⛨ Security
Description
The TypeScript pnpm doctor connectivity check uses a bare fetch() without pnpm’s configByUri
auth-header resolution or registry dispatcher options, so it can fail on registries that require
auth/proxy/TLS config even when pnpm would otherwise work. It also echoes the registry URL verbatim,
which can leak inline URL credentials in output.
Code

pnpm11/pnpm/src/cmd/doctor.ts[R224-250]

+async function checkConnectivity (opts: DoctorCommandOptions): Promise<CheckResult> {
+  const title = 'Registry connectivity'
+  if (opts.offline) {
+    return { title, status: 'pass', detail: 'skipped (--offline)' }
+  }
+  const registry = opts.registries?.default ?? DEFAULT_REGISTRY
+  const pingUrl = new URL('./-/ping?write=true', registry.endsWith('/') ? registry : `${registry}/`)
+  const started = Date.now()
+  try {
+    const response = await fetch(pingUrl, { signal: AbortSignal.timeout(15_000) })
+    if (!response.ok) {
+      return {
+        title,
+        status: 'fail',
+        detail: `${registry} responded ${response.status} ${response.statusText}`.trimEnd(),
+        fix: 'Check your registry, proxy, and auth configuration.',
+      }
+    }
+    return { title, status: 'pass', detail: `${registry} (${Date.now() - started}ms)` }
+  } catch (err: unknown) {
+    return {
+      title,
+      status: 'fail',
+      detail: `could not reach ${registry}: ${util.types.isNativeError(err) ? err.message : String(err)}`,
+      fix: 'Check your network, proxy, and registry configuration.',
+    }
+  }
Evidence
Doctor uses a direct fetch() to /-/ping?write=true and does not compute or pass
authHeaderValue, while the existing ping command does; the repo also already provides
URL-credential redaction utilities for output safety.

pnpm11/pnpm/src/cmd/doctor.ts[224-250]
pnpm11/registry-access/commands/src/ping.ts[48-66]
pnpm11/core/error/src/index.ts[65-102]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

### Issue description
`pnpm doctor` implements its own connectivity check with `fetch(pingUrl)` and prints the registry URL directly. This diverges from pnpm’s existing ping behavior that resolves auth headers and uses the configured fetch stack.

### Issue Context
There is an existing ping implementation in `pnpm11/registry-access/commands/src/ping.ts` that:
- resolves auth via `createGetAuthHeaderByURI(configByUri)`
- uses `createFetchFromRegistry(opts)`
Doctor can either call into that implementation or replicate its approach, but it needs access to `configByUri` / dispatcher options.

### Fix Focus Areas
- pnpm11/pnpm/src/cmd/doctor.ts[224-250]
- pnpm11/registry-access/commands/src/ping.ts[48-66]
- pnpm11/core/error/src/index.ts[65-102]

### Suggested fix
- Extend `DoctorCommandOptions` so the CLI passes through the same network-related options that `ping` expects (e.g. `configByUri`, proxy/TLS dispatcher options), then use `createGetAuthHeaderByURI` + `createFetchFromRegistry` (or directly call the ping handler).
- Redact inline credentials in any printed registry URL using `redactUrlCredentials()` before interpolating into `detail` strings.

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


Grey Divider

Qodo Logo

Comment thread .github/workflows/update-latest.yml Resolved
Comment thread .github/workflows/update-latest.yml Resolved
@qodo-code-review

qodo-code-review Bot commented Jul 16, 2026 •

Copy link
Copy Markdown

PR Code Suggestions ✨

Latest suggestions up to 2c22ff2

Warning

/improve is deprecated. Use /agentic_review instead (removal date not yet scheduled).

CategorySuggestion                                                                                                                                    Impact
General
Test actual cross-filesystem link support

Test filesystem capabilities by linking from the store to the project directory
instead of testing entirely within the store. This ensures the check accurately
reflects whether cross-filesystem hardlinks or reflinks will work during actual
package installations.

pnpm11/pnpm/src/cmd/doctor.ts [196-207]

 async function checkFilesystemCapabilities (opts: DoctorCommandOptions): Promise<CheckResult> {
   const title = 'Filesystem'
-  const probeParent = opts.storeDir ?? opts.cacheDir
-  let probeDir: string
+  const sourceParent = opts.storeDir ?? opts.cacheDir
+  let sourceDir: string
+  let destinationDir: string
   try {
-    probeDir = await fs.promises.mkdtemp(path.join(probeParent, '.pnpm-doctor-'))
+    sourceDir = await fs.promises.mkdtemp(path.join(sourceParent, '.pnpm-doctor-source-'))
+    destinationDir = await fs.promises.mkdtemp(path.join(opts.dir, '.pnpm-doctor-destination-'))
   } catch {
-    probeDir = await fs.promises.mkdtemp(path.join(os.tmpdir(), 'pnpm-doctor-'))
+    return {
+      title,
+      status: 'warn',
+      detail: 'could not create filesystem probe directories',
+      fix: 'Check that the store and project directories are writable.',
+    }
   }
   const started = Date.now()
   try {
-    const capabilities = await probeLinkCapabilities(probeDir)
+    const capabilities = await probeLinkCapabilities(sourceDir, destinationDir)
     ...
+  } finally {
+    await Promise.all([
+      fs.promises.rm(sourceDir, { recursive: true, force: true }),
+      fs.promises.rm(destinationDir, { recursive: true, force: true }),
+    ])
   }
 }

[To ensure code accuracy, apply this suggestion manually]

Suggestion importance[1-10]: 9

__

Why: Identifies a major logical flaw where the diagnostic currently tests intra-store link capabilities rather than the actual cross-filesystem link support between the store and the opts.dir project directory.

High
Security
Prevent symlink-based file truncation

Use the wx flag and a random filename suffix when testing directory writability.
This prevents symlink-based file truncation attacks by ensuring the probe file
is exclusively created.

pnpm11/pnpm/src/cmd/doctor.ts [421-430]

 function canWriteToDir (dir: string): boolean {
-  const probe = path.join(dir, `.pnpm-doctor-write-${process.pid}`)
+  const probe = path.join(
+    dir,
+    `.pnpm-doctor-write-${process.pid}-${crypto.randomUUID()}`
+  )
+  let created = false
   try {
-    fs.writeFileSync(probe, '')
-    fs.rmSync(probe, { force: true })
+    fs.writeFileSync(probe, '', { flag: 'wx' })
+    created = true
     return true
   } catch {
     return false
+  } finally {
+    if (created) fs.rmSync(probe, { force: true })
   }
 }
  • Apply / Chat
Suggestion importance[1-10]: 7

__

Why: Addresses a valid security risk (symlink attack) by using the wx flag for atomic creation, although the suggested code misses the required crypto import for randomUUID().

Medium
  • More

Previous suggestions

Suggestions up to commit 4a08e61
CategorySuggestion                                                                                                                                    Impact
Possible issue
Accept creatable configured directories

Update canWriteToDir to attempt creating the directory if it's missing, avoiding
false failures on fresh installations.

pnpm11/pnpm/src/cmd/doctor.ts [421-430]

 function canWriteToDir (dir: string): boolean {
+  const existed = fs.existsSync(dir)
   const probe = path.join(dir, `.pnpm-doctor-write-${process.pid}`)
   try {
+    fs.mkdirSync(dir, { recursive: true })
     fs.writeFileSync(probe, '')
     fs.rmSync(probe, { force: true })
+    if (!existed) fs.rmSync(dir, { recursive: true, force: true })
     return true
   } catch {
+    fs.rmSync(probe, { force: true })
+    if (!existed) fs.rmSync(dir, { recursive: true, force: true })
     return false
   }
 }
Suggestion importance[1-10]: 7

__

Why: This addresses a valid edge case where pnpm doctor might fail incorrectly on fresh installations if the cache or store directories don't exist yet but can be successfully created.

Medium
Require a strictly newer release

Add a Node.js script step to ensure the target VERSION is strictly newer than
the FROM version before performing the upgrade test.

.github/workflows/update-latest.yml [139-142]

 if ! FROM=$(pn view "pnpm@latest-${MAJOR}" version --registry="$REGISTRY" 2>/dev/null) || [ -z "$FROM" ]; then
   FROM=$(pn view pnpm dist-tags.latest --registry="$REGISTRY")
 fi
+FROM="$FROM" VERSION="$VERSION" node -e '
+  const from = process.env.FROM.split(".").map(Number)
+  const target = process.env.VERSION.split(".").map(Number)
+  const comparison = target.findIndex((part, index) => part !== from[index])
+  if (comparison === -1 || target[comparison] < from[comparison]) {
+    throw new Error(`Refusing to promote ${process.env.VERSION}: it is not newer than ${process.env.FROM}`)
+  }
+'
 echo "Upgrading from v${FROM} to v${VERSION}"
Suggestion importance[1-10]: 5

__

Why: Adding a strict version check helps prevent accidental downgrades or redundant self-updates during the release tagging process, though it's a minor defensive addition.

Low
General
Probe actual cross-filesystem linking

Test filesystem linking capabilities across the store and the current project
directory (opts.dir) instead of internally within the store.

pnpm11/pnpm/src/cmd/doctor.ts [198-207]

-const probeParent = opts.storeDir ?? opts.cacheDir
-let probeDir: string
+const storeParent = opts.storeDir ?? opts.cacheDir
+let sourceDir: string
 try {
-  probeDir = await fs.promises.mkdtemp(path.join(probeParent, '.pnpm-doctor-'))
+  sourceDir = await fs.promises.mkdtemp(path.join(storeParent, '.pnpm-doctor-source-'))
 } catch {
-  probeDir = await fs.promises.mkdtemp(path.join(os.tmpdir(), 'pnpm-doctor-'))
+  sourceDir = await fs.promises.mkdtemp(path.join(os.tmpdir(), 'pnpm-doctor-source-'))
 }
+const destinationDir = await fs.promises.mkdtemp(path.join(opts.dir, '.pnpm-doctor-destination-'))
 ...
-const capabilities = await probeLinkCapabilities(probeDir)
+const capabilities = await probeLinkCapabilities(sourceDir, destinationDir)
Suggestion importance[1-10]: 6

__

Why: The suggestion catches an excellent logical flaw regarding cross-filesystem link testing, but the provided code snippet is incomplete and would cause a TypeScript error because probeLinkCapabilities still only accepts one argument.

Low
Suggestions up to commit 7c15b4e
CategorySuggestion                                                                                                                                    Impact
Possible issue
Probe cross-filesystem link support

Modify the link capability check to create the destination probe in opts.dir
rather than the store directory. This accurately tests if cross-filesystem
hardlinks/reflinks are supported between the store and the project.

pnpm11/pnpm/src/cmd/doctor.ts [198-207]

-const probeParent = opts.storeDir ?? opts.cacheDir
-let probeDir: string
-try {
-  probeDir = await fs.promises.mkdtemp(path.join(probeParent, '.pnpm-doctor-'))
-} catch {
-  probeDir = await fs.promises.mkdtemp(path.join(os.tmpdir(), 'pnpm-doctor-'))
-}
+const sourceParent = opts.storeDir ?? opts.cacheDir
+const sourceDir = await fs.promises.mkdtemp(path.join(sourceParent, '.pnpm-doctor-source-'))
+const destinationDir = await fs.promises.mkdtemp(path.join(opts.dir, '.pnpm-doctor-destination-'))
 const started = Date.now()
 try {
-  const capabilities = await probeLinkCapabilities(probeDir)
+  const capabilities = await probeLinkCapabilities(sourceDir, destinationDir)
+  ...
+} finally {
+  await Promise.all([
+    fs.promises.rm(sourceDir, { recursive: true, force: true }),
+    fs.promises.rm(destinationDir, { recursive: true, force: true }),
+  ])
+}
Suggestion importance[1-10]: 9

__

Why: This addresses a critical flaw in the diagnostic logic, ensuring it correctly evaluates cross-filesystem link capabilities between the store and the actual project directory instead of just testing links locally within the store.

High
Accept creatable diagnostic directories

Update canWriteToDir to recursively create the target directory if it's missing,
perform the write test, and clean up afterwards. This ensures missing
directories aren't incorrectly reported as unwritable.

pnpm11/pnpm/src/cmd/doctor.ts [421-430]

 function canWriteToDir (dir: string): boolean {
+  const existed = fs.existsSync(dir)
   const probe = path.join(dir, `.pnpm-doctor-write-${process.pid}`)
   try {
+    fs.mkdirSync(dir, { recursive: true })
     fs.writeFileSync(probe, '')
     fs.rmSync(probe, { force: true })
+    if (!existed) fs.rmSync(dir, { recursive: true })
     return true
   } catch {
+    if (!existed) fs.rmSync(dir, { recursive: true, force: true })
     return false
   }
 }
Suggestion importance[1-10]: 8

__

Why: This prevents false negative failures on fresh setups where the store or cache directories haven't been created yet, correctly mirroring pnpm's ability to create these directories automatically.

Medium
Reject unsupported release tags

Add a catch-all fallback to the tag validation case statement. This ensures that
only latest or latest- tags are accepted, preventing typos from being published.

.github/workflows/update-latest.yml [73-94]

 case "$TAG" in
   latest-*)
     if [ "$TAG" != "latest-${MAJOR}" ]; then
       echo "::error::Tag ${TAG} does not match the major version of ${VERSION}. Expected latest-${MAJOR}."
       exit 1
     fi
     ;;
   latest)
     ...
     ;;
+  *)
+    echo "::error::Tag must be latest or latest-${MAJOR}. Got: ${TAG}"
+    exit 1
+    ;;
 esac
Suggestion importance[1-10]: 7

__

Why: Adding a fallback to the case statement prevents invalid or misspelled tags from silently bypassing validation and being deployed to the registry.

Medium
Suggestions up to commit cc627e5
CategorySuggestion                                                                                                                                    Impact
General
Probe the actual filesystem boundary

Test hardlink and reflink capabilities across the store-to-project filesystem
boundary instead of doing it internally inside the store directory.

pnpm11/pnpm/src/cmd/doctor.ts [198-207]

-const probeParent = opts.storeDir ?? opts.cacheDir
-let probeDir: string
-try {
-  probeDir = await fs.promises.mkdtemp(path.join(probeParent, '.pnpm-doctor-'))
-} catch {
-  probeDir = await fs.promises.mkdtemp(path.join(os.tmpdir(), 'pnpm-doctor-'))
-}
+const storeProbeDir = await fs.promises.mkdtemp(path.join(probeParent, '.pnpm-doctor-store-'))
+const projectProbeDir = await fs.promises.mkdtemp(path.join(opts.dir, '.pnpm-doctor-project-'))
 const started = Date.now()
 try {
-  const capabilities = await probeLinkCapabilities(probeDir)
+  const capabilities = await probeLinkCapabilities(storeProbeDir, projectProbeDir)
+  ...
+} finally {
+  await Promise.all([
+    fs.promises.rm(storeProbeDir, { recursive: true, force: true }),
+    fs.promises.rm(projectProbeDir, { recursive: true, force: true }),
+  ])
+}
Suggestion importance[1-10]: 9

__

Why: Testing link capabilities within a single directory fails to accurately represent pnpm's real behavior, missing failures that occur when the store and project are on different filesystems.

High
Security
Prevent probe symlink truncation

Use exclusive file creation (fs.openSync with wx) instead of fs.writeFileSync to
prevent symlink attacks.

pnpm11/pnpm/src/cmd/doctor.ts [421-430]

 function canWriteToDir (dir: string): boolean {
   const probe = path.join(dir, `.pnpm-doctor-write-${process.pid}`)
   try {
-    fs.writeFileSync(probe, '')
+    const fd = fs.openSync(probe, 'wx')
+    fs.closeSync(fd)
     fs.rmSync(probe, { force: true })
     return true
   } catch {
     return false
   }
 }
Suggestion importance[1-10]: 8

__

Why: Using exclusive file creation (wx flag) is a secure practice that prevents potential symlink-based arbitrary file overwrite vulnerabilities.

Medium
Possible issue
Honor configured registry networking

Replace the raw fetch call with pnpm's built-in registry ping mechanism. This
ensures proxy, authentication, and certificates are properly utilized.

pnpm11/pnpm/src/cmd/doctor.ts [233]

-const response = await fetch(pingUrl, { signal: AbortSignal.timeout(15_000) })
+const response = await pingConfiguredRegistry({
+  registry,
+  signal: AbortSignal.timeout(15_000),
+  ...opts.registryRequestOptions,
+})
Suggestion importance[1-10]: 8

__

Why: Raw fetch fails to utilize pnpm's proxy and authentication configurations, which can cause false-positive failures on environments that require them.

Medium
Suggestions up to commit a6932db
CategorySuggestion                                                                                                                                    Impact
Possible issue
Accept creatable configured directories

Modify canWriteToDir to recursively create the directory before attempting to
write the probe file, avoiding false failures.

pnpm11/pnpm/src/cmd/doctor.ts [421-430]

 function canWriteToDir (dir: string): boolean {
   const probe = path.join(dir, `.pnpm-doctor-write-${process.pid}`)
   try {
+    fs.mkdirSync(dir, { recursive: true })
     fs.writeFileSync(probe, '')
     fs.rmSync(probe, { force: true })
     return true
   } catch {
     return false
   }
 }
Suggestion importance[1-10]: 8

__

Why: Creating the directories recursively prevents false negative results on fresh installations where these directories do not yet exist, accurately reflecting pnpm's behavior.

Medium
General
Probe cross-filesystem link support

Test link capabilities between the store directory and the project directory
rather than within the same directory to accurately detect cross-filesystem
linking issues.

pnpm11/pnpm/src/cmd/doctor.ts [198-207]

-const probeParent = opts.storeDir ?? opts.cacheDir
-let probeDir: string
-try {
-  probeDir = await fs.promises.mkdtemp(path.join(probeParent, '.pnpm-doctor-'))
-} catch {
-  probeDir = await fs.promises.mkdtemp(path.join(os.tmpdir(), 'pnpm-doctor-'))
-}
+const sourceDir = await fs.promises.mkdtemp(path.join(opts.storeDir ?? opts.cacheDir, '.pnpm-doctor-source-'))
+const destinationDir = await fs.promises.mkdtemp(path.join(opts.dir, '.pnpm-doctor-destination-'))
 const started = Date.now()
 try {
-  const capabilities = await probeLinkCapabilities(probeDir)
+  const capabilities = await probeLinkCapabilities(sourceDir, destinationDir)
+  ...
+} finally {
+  await Promise.all([
+    fs.promises.rm(sourceDir, { recursive: true, force: true }),
+    fs.promises.rm(destinationDir, { recursive: true, force: true }),
+  ])
+}
Suggestion importance[1-10]: 8

__

Why: Testing hardlinks and reflinks between the store and the actual project directory accurately catches cross-device (EXDEV) limitations, aligning with the check's actual purpose and warning message.

Medium
✅ Suggestions up to commit 426a37f
CategorySuggestion                                                                                                                                    Impact
Possible issue
✅ Change global executable path to $PNPM_HOME/pnpm
Suggestion Impact:The commit addressed the path issue with a compatibility fallback, using "$PNPM_HOME/bin/pnpm" when present and otherwise "$PNPM_HOME/pnpm" because different pnpm versions use different global executable layouts.

code diff:

+          # self-update installs the target using the layout of the version
+          # doing the installing: v11 links global bins into $PNPM_HOME/bin,
+          # v10 links them directly into $PNPM_HOME.
+          if [ -x "$PNPM_HOME/bin/pnpm" ]; then
+            upgraded="$PNPM_HOME/bin/pnpm"
+          else
+            upgraded="$PNPM_HOME/pnpm"
+          fi
+          # Run the upgraded binary rather than trust self-update's exit code:
+          # `@pnpm/exe`'s preinstall leaves its placeholder bin in place when the
+          # platform package ships no native, so that failure is invisible until
+          # the binary is actually invoked.
+          test "$("$upgraded" --version)" = "$VERSION"

Update the path to the upgraded pnpm binary to use $PNPM_HOME/pnpm instead of
$PNPM_HOME/bin/pnpm.

.github/workflows/update-latest.yml [99-105]

 # Run the upgraded binary, not just the exit code: @pnpm/exe's
 # preinstall leaves its placeholder bin in place when the platform
 # package ships without a native, so a self-update onto a release with
 # missing natives (11.12.0, 11.13.0) still "succeeds" and only a real
 # invocation catches it.
-test "$("$PNPM_HOME/bin/pnpm" --version)" = "$VERSION"
+test "$("$PNPM_HOME/pnpm" --version)" = "$VERSION"
 echo "OK: ${package}@${FROM} self-updated to v${VERSION}"

[Suggestion processed]

Suggestion importance[1-10]: 8

__

Why: pnpm installs global executables directly into PNPM_HOME rather than a bin subdirectory, so the current path will likely cause the workflow to fail.

Medium

@greptile-apps

greptile-apps Bot commented Jul 16, 2026 •

Copy link
Copy Markdown
Contributor

Confidence Score: 4/5

Safe to merge with one targeted fix: the Rust smoke test is missing --no-frozen-lockfile, which will cause pacquet doctor to fail on any CI runner where CI=true.

The workflow additions and the TypeScript pnpm doctor implementation are solid and well-tested. The Rust run_install_smoke_test omits --no-frozen-lockfile: pnpm (and pacquet for parity) defaults to frozen-lockfile=true in CI environments, so running the smoke install into a fresh temp directory with no lockfile will fail exactly there. The TypeScript version adds the flag explicitly for this reason. The render_report duration-rendering divergence is a minor output parity gap that does not affect the gate's correctness.

pnpm/crates/cli/src/cli_args/doctor.rs — run_install_smoke_test needs --no-frozen-lockfile and render_report omits duration for non-pass checks with fixes, unlike the TypeScript version.

Reviews (10): Last reviewed commit: "ci(release): stop re-deriving the same r..." | Re-trigger Greptile

Comment thread .github/workflows/update-latest.yml Resolved
Comment thread .github/workflows/update-latest.yml Resolved
Copilot AI review requested due to automatic review settings July 16, 2026 09:27

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@zkochan

zkochan commented Jul 16, 2026 •

Copy link
Copy Markdown
Member Author

Re: "Change global executable path to $PNPM_HOME/pnpm"

Updated — I was half wrong here. Leaving the original reasoning below for the record, but the conclusion has changed.

$PNPM_HOME/bin/pnpm is correct for v11, which is what I checked:

// selfUpdate.ts
await linkBins(path.join(baseDir, 'node_modules'), path.join(opts.pnpmHomeDir, 'bin'), { warn: globalWarn })

$PNPM_HOME/pnpm is the v10 layout, and hasLegacyHomeDirShim exists to refresh those older shims. So swapping the path outright, as suggested, would have broken the v11 case — the v11 runs could not have passed if it were wrong.

What I missed is that this workflow can tag any release line via latest-<major>, and self-update installs the target using the layout of the version doing the installing. CodeRabbit raised that at #discussion_r3594237765 and it's correct — verified after a real [email protected] self-update:

$PNPM_HOME/bin/pnpm : missing
$PNPM_HOME/pnpm     : EXISTS

Fixed in f7b7957 by accepting either layout rather than swapping to one. There was a second v10 break neither suggestion reached — the driver was invoked as bin/pnpm.mjs, which v10 doesn't ship — so the step now drives through npm's .bin/pnpm shim instead.

So: the suggestion as written would have been wrong, but it was pointing at a real defect. Thanks for the nudge.


Written by an agent (Claude Code, claude-opus-4-8).

@qodo-code-review

qodo-code-review Bot commented Jul 16, 2026 •

Copy link
Copy Markdown

Code Review by Qodo

🐞 Bugs (1) 📘 Rule violations (1) 📎 Requirement gaps (0) 📜 Skill insights (0)

Context used
✅ Compliance rules (platform): 18 rules

Grey Divider


Action required

1. Prerelease can be tagged ✓ Resolved 🐞 Bug ≡ Correctness ⭐ New
Description
The validate step says the version must be an exact stable semver like 11.2.0, but its regex
explicitly permits prerelease suffixes, allowing TAG=latest with VERSION=12.0.0-rc.1 to pass
validation and proceed to dist-tag updates. This can accidentally promote a prerelease to
latest/latest-<major> and ship it to all default consumers.
Code

.github/workflows/update-latest.yml[R44-47]

+        set -euo pipefail
        if ! printf '%s\n' "$VERSION" | grep -Eq '^[0-9]+\.[0-9]+\.[0-9]+(-[.0-9A-Za-z-]+)?$'; then
          echo "::error::Version must be an exact semver version like 11.2.0. Got: ${VERSION}"
          exit 1
Evidence
The validation regex explicitly allows -<prerelease> while the workflow later uses TAG to add
dist-tags, meaning a prerelease can be assigned to latest/latest-<major> if dispatched that way.

.github/workflows/update-latest.yml[32-48]
.github/workflows/update-latest.yml[173-185]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

### Issue description
The VERSION validator allows prereleases even when tagging to `latest`/`latest-<major>`, contradicting the stated contract and allowing an operator mistake to promote a prerelease to public stable dist-tags.

### Issue Context
- `grep -Eq '...(-[.0-9A-Za-z-]+)?$'` accepts prereleases.
- Later steps apply the requested tag(s) via `npm dist-tag add`.

### Fix Focus Areas
- .github/workflows/update-latest.yml[44-71]
- .github/workflows/update-latest.yml[173-185]

### Suggested fix
Add a stable-only requirement when TAG is `latest` or `latest-*`:
- Either tighten the regex to `^[0-9]+\.[0-9]+\.[0-9]+$` for those tags, or
- Keep the current regex but add:
 - `if [[ "$TAG" == latest* && "$VERSION" == *-* ]]; then echo "::error::Refusing to tag prerelease $VERSION as $TAG"; exit 1; fi`
This preserves prerelease support for non-latest tags (if desired) while preventing accidental promotion to stable channels.

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools



Remediation recommended

2. Ambient pnpm config read 🐞 Bug ⛨ Security ⭐ New
Description
verify-upgrade isolates PNPM_HOME/XDG_{DATA,CACHE}_HOME but leaves pnpm’s config location ambient,
so pnpm self-update can read runner user config (e.g. global config.yaml) and change
registries/auth/store behavior, weakening the intended “pin registry / no ambient config” guarantee.
This can make the gate validate against settings users don’t have and can unintentionally expose any
pre-existing runner creds/config to the just-installed CLI.
Code

.github/workflows/update-latest.yml[R124-145]

+          work=$(mktemp -d)
+          # Isolate the whole pnpm environment so the upgrade resolves and
+          # installs for real instead of reusing a warm store or global dir.
+          export PNPM_HOME="$work/home"
+          export XDG_DATA_HOME="$work/data"
+          export XDG_CACHE_HOME="$work/cache"
+
+          cd "$work"
+          npm install --prefix "$work/from" --ignore-scripts=false "${package}@${FROM}"
+          # Drive through npm's bin shim rather than a path into the package:
+          # the entry point differs by major (pnpm.cjs in v10, pnpm.mjs in v11)
+          # and between the two wrappers, and the shim is what a user gets.
+          from_bin="$work/from/node_modules/.bin/pnpm"
+
+          # Check the starting point separately so a broken current release
+          # fails naming its own version rather than looking like a fault in
+          # $VERSION. When the current release is the broken one, it also blocks
+          # its own fix — dispatch with skip_upgrade_check to promote that.
+          test "$("$from_bin" --version)" = "$FROM"
+
+          "$from_bin" self-update "$VERSION"
+
Evidence
The workflow only sets PNPM_HOME and XDG data/cache homes, but pnpm’s config dir is derived from
XDG_CONFIG_HOME or os.homedir(), and pnpm reads global config.yaml from that location early during
config resolution.

.github/workflows/update-latest.yml[123-160]
pnpm11/config/reader/src/dirs.ts[73-91]
pnpm11/config/reader/src/index.ts[224-241]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

### Issue description
`verify-upgrade` aims to validate the real npmjs artifact in an isolated environment, but it only isolates PNPM_HOME and XDG data/cache directories. pnpm’s config directory defaults under the runner user’s home (or XDG_CONFIG_HOME if set), so `pnpm self-update` can still consume ambient config.yaml and any associated registry/auth settings.

### Issue Context
- This job intentionally executes published artifacts.
- It already pins `npm_config_registry`/`npm_config_userconfig`, but pnpm also reads global config.yaml from its config directory.

### Fix Focus Areas
- .github/workflows/update-latest.yml[123-160]

### Suggested fix
In the loop before invoking `pnpm`:
- Set and create an isolated config dir, e.g.:
 - `export HOME="$work/home"`
 - `export XDG_CONFIG_HOME="$work/config"`
 - `mkdir -p "$HOME" "$XDG_CONFIG_HOME"`
- (Optional) also set `XDG_STATE_HOME` to a temp dir for completeness.
This prevents reading `~/.config/pnpm/config.yaml` (or equivalent) from the runner user and keeps the upgrade gate’s registry/config behavior reproducible.

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


3. Writable npm userconfig path ✓ Resolved 🐞 Bug ⛨ Security
Description
verify-upgrade sets npm_config_userconfig to a filesystem path while also enabling lifecycle
scripts (--ignore-scripts=false), so those scripts can create/modify that userconfig file and
influence later npm invocations in the same step (e.g., proxy/CA settings), weakening the intended
“no ambient npm config” isolation boundary.
Code

.github/workflows/update-latest.yml[R79-87]

+        VERSION: ${{ github.event.inputs.version }}
+        # This gate is only meaningful if it resolves the artifact users
+        # resolve, so pin the registry and read no ambient npm config: a
+        # runner-level .npmrc could otherwise redirect it to a different
+        # registry, and its contents would reach the lifecycle scripts run
+        # below. RUNNER_TEMP is emptied per job, so this path stays absent.
+        npm_config_registry: https://registry.npmjs.org/
+        npm_config_userconfig: ${{ runner.temp }}/absent-npmrc
+      # zizmor: ignore[adhoc-packages] -- Installing a published release from
Evidence
The workflow explicitly enables lifecycle scripts during npm install, and the configured
npm_config_userconfig points at a writable on-disk path; since multiple npm commands run in the
same step, a script can persist config via that path for later invocations. The repo’s review guide
highlights .npmrc/proxy/auth as a key security surface.

.github/workflows/update-latest.yml[64-67]
.github/workflows/update-latest.yml[79-87]
.github/workflows/update-latest.yml[108-118]
REVIEW_GUIDE.md[63-66]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

### Issue description
`verify-upgrade` attempts to avoid ambient npm config by pointing `npm_config_userconfig` at a path that is expected not to exist. But because the job intentionally runs lifecycle scripts, those scripts can write to that known path and thereby affect subsequent `npm` commands in the same step.

### Issue Context
The workflow itself notes that lifecycle scripts can persist data across steps via filesystem/env mechanisms; the same risk applies within a single step across multiple npm invocations.

### Fix
Prefer a non-persistent config sink instead of an “absent file” path:
- Set `npm_config_userconfig: /dev/null`
- (recommended) also set `npm_config_globalconfig: /dev/null`
This keeps npm from reading any on-disk config that a lifecycle script could populate for later commands.

### Fix Focus Areas
- .github/workflows/update-latest.yml[79-87]
- .github/workflows/update-latest.yml[108-118]

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


4. Unpinned registry in tagging ✓ Resolved 🐞 Bug ⛨ Security
Description
tag-in-registry runs npm dist-tag add with secrets.NPM_TOKEN but does not pin
npm_config_registry or isolate npm config, so runner/global npm config (registry/proxy/CA) can
change where/how the credentialed request is sent and make tagging non-reproducible or route traffic
through an unintended network path.
Code

.github/workflows/update-latest.yml[R158-160]

    - name: Update tag
      env:
        "npm_config_//registry.npmjs.org/:_authToken": ${{ secrets.NPM_TOKEN }}
Evidence
The step injects an npmjs-scoped auth token but does not set
npm_config_registry/npm_config_userconfig, so npm will consult ambient config for
registry/proxy/TLS behavior; the repo’s review guide explicitly calls out .npmrc/proxy/auth and CI
secret scoping as security-sensitive.

.github/workflows/update-latest.yml[158-170]
REVIEW_GUIDE.md[63-66]
REVIEW_GUIDE.md[98-103]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

### Issue description
`tag-in-registry` performs credentialed `npm dist-tag add` operations but does not explicitly pin the registry nor neutralize ambient npm config sources. This leaves the tagging request behavior dependent on runner/global npm configuration (e.g., registry/proxy/CA), which is undesirable for a release-critical, token-bearing step.

### Issue Context
- npm config is security-sensitive in this repo’s review guide, especially around registries/auth/proxies.
- The workflow already pins registry/userconfig for `verify-upgrade`, but the token-bearing tagging step does not.

### Fix
- In `tag-in-registry` → `Update tag` step, add:
 - `npm_config_registry: https://registry.npmjs.org/`
 - `npm_config_userconfig: /dev/null`
 - (recommended) `npm_config_globalconfig: /dev/null`
 - (optional hardening) explicitly clear proxy/CA-related npm env vars if you want to guarantee no proxy/CA injection (e.g. `npm_config_proxy`, `npm_config_https_proxy`, `npm_config_cafile`).

### Fix Focus Areas
- .github/workflows/update-latest.yml[158-170]

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


View more (2)
5. npm view errors suppressed 📘 Rule violation ☼ Reliability
Description
The upgrade gate silences all npm view failures with 2>/dev/null and falls back to
dist-tags.latest, which can hide unexpected errors (e.g. network/registry issues) and make the
gate validate against an unintended baseline version. This violates the requirement to avoid
swallowing errors and to handle only the specific expected failure case (missing latest-<major>
tag).
Code

.github/workflows/update-latest.yml[R100-102]

+        if ! FROM=$(npm view "pnpm@latest-${MAJOR}" version 2>/dev/null) || [ -z "$FROM" ]; then
+          FROM=$(npm view pnpm dist-tags.latest)
+        fi
Evidence
PR Compliance ID 9 requires not swallowing errors and only handling specific expected error cases.
The new code redirects npm view stderr to /dev/null and treats any failure as “tag absent”,
which can mask real problems and change behavior silently.

CLAUDE.md: Do Not Swallow Errors; Catch Only Specific Expected Error Cases
.github/workflows/update-latest.yml[97-102]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
In `verify-upgrade`, the workflow runs `npm view "pnpm@latest-${MAJOR}" version 2>/dev/null` and falls back on any failure. This suppresses unexpected errors (network, registry outages, malformed responses) and may cause the upgrade check to run from the wrong `FROM` version.

## Issue Context
The intended behavior is: fall back only when the `latest-<major>` dist-tag does not exist (typically an `E404` case for a new major). Other failures should fail the job with a useful error.

## Fix Focus Areas
- .github/workflows/update-latest.yml[97-102]

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


6. Npm config not isolated ✓ Resolved 🐞 Bug ⛨ Security
Description
verify-upgrade runs npm view/npm install on registry artifacts with lifecycle scripts enabled,
but it does not isolate npm’s user/global config or force the npmjs registry, so any pre-existing
runner npm config/credentials (e.g. a user .npmrc) are exposed to those scripts and the check may
validate the wrong registry artifact. This undermines the intended “real registry artifact” gate and
creates conditional credential-exfiltration risk if the runner image has any persisted npm
auth/config.
Code

.github/workflows/update-latest.yml[R82-110]

+      run: |
+        set -eu
+        # npm and pnpm both enforce the devEngines of whatever manifest they
+        # find by walking up from the working directory, and this repo's pins a
+        # pnpm — so every command here runs from a scratch dir instead of the
+        # caller's cwd, which would otherwise fail or switch versions.
+        cd "$(mktemp -d)"
+
+        MAJOR="${VERSION%%.*}"
+        # Upgrade from what users on this release line are running today. A new
+        # major has no latest-<major> yet, so fall back to the current latest.
+        if ! FROM=$(npm view "pnpm@latest-${MAJOR}" version 2>/dev/null) || [ -z "$FROM" ]; then
+          FROM=$(npm view pnpm dist-tags.latest)
+        fi
+        echo "Upgrading from v${FROM} to v${VERSION}"
+
+        # Both wrappers are exercised: self-update reinstalls the package it is
+        # running from, so `pnpm` and `@pnpm/exe` resolve different published
+        # manifests and a broken one surfaces on only that wrapper.
+        for package in pnpm @pnpm/exe; do
+          work=$(mktemp -d)
+          # Isolate the whole pnpm environment so the upgrade resolves and
+          # installs for real instead of reusing a warm store or global dir.
+          export PNPM_HOME="$work/home"
+          export XDG_DATA_HOME="$work/data"
+          export XDG_CACHE_HOME="$work/cache"
+
+          cd "$work"
+          npm install --prefix "$work/from" --ignore-scripts=false "${package}@${FROM}"
Evidence
The new verify-upgrade job explicitly installs and runs packages from the registry (including
lifecycle scripts) but only changes the working directory; it does not set HOME,
NPM_CONFIG_USERCONFIG, or an explicit registry, so npm will still consult runner/user config
sources. The repo’s review guide requires treating registry metadata and environment/config as
attacker-controlled and recommends minimum-privilege workflow design for CI that touches untrusted
artifacts.

.github/workflows/update-latest.yml[57-129]
REVIEW_GUIDE.md[30-36]
REVIEW_GUIDE.md[101-103]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

### Issue description
`verify-upgrade` executes `npm view` and `npm install` (with scripts enabled) without constraining npm’s config sources or registry. If the runner has any pre-existing npm configuration (user/global `.npmrc`, env-based npm config, registry mirror, etc.), lifecycle scripts can read it and exfiltrate credentials, and the gate may unintentionally validate a non-npmjs artifact.

### Issue Context
This job intentionally avoids *workflow* secrets, but npm can still pick up implicit credentials/config from the runner environment/home directory. The workflow comments already call out lifecycle-script persistence risks; this change tightens the job to be self-contained and ensures it truly tests the public npmjs artifact.

### Fix Focus Areas
- .github/workflows/update-latest.yml[57-129]

### Suggested fix
In the `verify-upgrade` step script, before any `npm view`/`npm install` calls:
- Set a temporary `HOME` (or `NPM_CONFIG_USERCONFIG`) pointing to an empty, job-controlled `.npmrc`.
- Force npm to use the public npmjs registry via `npm_config_registry=https://registry.npmjs.org/` (and optionally `npm_config_always_auth=false`).

Example (one possible approach):
```bash
export HOME="$(mktemp -d)"
export NPM_CONFIG_USERCONFIG="$HOME/.npmrc"
: > "$NPM_CONFIG_USERCONFIG"
export npm_config_registry="https://registry.npmjs.org/"
```
This keeps the smoke test deterministic and prevents accidental credential/config inheritance.

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools



Informational

7. npm install does avoidable work ✓ Resolved 🐞 Bug ➹ Performance
Description
verify-upgrade uses npm install without disabling audit/fund or lockfile generation, which can
add extra network calls and I/O unrelated to validating the upgrade and make the release gate
slower/flakier. This is especially noticeable because the job performs multiple installs (two
wrappers) per run.
Code

.github/workflows/update-latest.yml[117]

+          npm install --prefix "$work/from" --ignore-scripts=false "${package}@${FROM}"
Evidence
The workflow runs npm install with scripts enabled and no flags to disable audit/fund/lockfile
behavior, so npm may do additional work beyond what the gate needs.

.github/workflows/update-latest.yml[108-118]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

### Issue description
`npm install` in the upgrade gate may perform extra work (audit/fund) and write a package-lock, increasing runtime and potential flakiness.

### Issue Context
The gate’s purpose is to install + execute the binaries to validate upgrade behavior; audit/fund/lockfile outputs don’t contribute to that.

### Fix
Add flags such as `--no-audit --no-fund --package-lock=false` (and optionally `--loglevel=error`) to the `npm install` command.

### Fix Focus Areas
- .github/workflows/update-latest.yml[116-118]

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


Grey Divider

Previous review results

Review updated until commit 2c22ff2

Results up to commit 99198a8


🐞 Bugs (0) 📘 Rule violations (0) 📎 Requirement gaps (0) 🎨 UX issues (0) 🔗 Cross-repo conflicts (0) 📜 Skill insights (0)


Remediation recommended
1. Npm config not isolated ✓ Resolved 🐞 Bug ⛨ Security
Description
verify-upgrade runs npm view/npm install on registry artifacts with lifecycle scripts enabled,
but it does not isolate npm’s user/global config or force the npmjs registry, so any pre-existing
runner npm config/credentials (e.g. a user .npmrc) are exposed to those scripts and the check may
validate the wrong registry artifact. This undermines the intended “real registry artifact” gate and
creates conditional credential-exfiltration risk if the runner image has any persisted npm
auth/config.
Code

.github/workflows/update-latest.yml[R82-110]

+      run: |
+        set -eu
+        # npm and pnpm both enforce the devEngines of whatever manifest they
+        # find by walking up from the working directory, and this repo's pins a
+        # pnpm — so every command here runs from a scratch dir instead of the
+        # caller's cwd, which would otherwise fail or switch versions.
+        cd "$(mktemp -d)"
+
+        MAJOR="${VERSION%%.*}"
+        # Upgrade from what users on this release line are running today. A new
+        # major has no latest-<major> yet, so fall back to the current latest.
+        if ! FROM=$(npm view "pnpm@latest-${MAJOR}" version 2>/dev/null) || [ -z "$FROM" ]; then
+          FROM=$(npm view pnpm dist-tags.latest)
+        fi
+        echo "Upgrading from v${FROM} to v${VERSION}"
+
+        # Both wrappers are exercised: self-update reinstalls the package it is
+        # running from, so `pnpm` and `@pnpm/exe` resolve different published
+        # manifests and a broken one surfaces on only that wrapper.
+        for package in pnpm @pnpm/exe; do
+          work=$(mktemp -d)
+          # Isolate the whole pnpm environment so the upgrade resolves and
+          # installs for real instead of reusing a warm store or global dir.
+          export PNPM_HOME="$work/home"
+          export XDG_DATA_HOME="$work/data"
+          export XDG_CACHE_HOME="$work/cache"
+
+          cd "$work"
+          npm install --prefix "$work/from" --ignore-scripts=false "${package}@${FROM}"
Evidence
The new verify-upgrade job explicitly installs and runs packages from the registry (including
lifecycle scripts) but only changes the working directory; it does not set HOME,
NPM_CONFIG_USERCONFIG, or an explicit registry, so npm will still consult runner/user config
sources. The repo’s review guide requires treating registry metadata and environment/config as
attacker-controlled and recommends minimum-privilege workflow design for CI that touches untrusted
artifacts.

.github/workflows/update-latest.yml[57-129]
REVIEW_GUIDE.md[30-36]
REVIEW_GUIDE.md[101-103]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

### Issue description
`verify-upgrade` executes `npm view` and `npm install` (with scripts enabled) without constraining npm’s config sources or registry. If the runner has any pre-existing npm configuration (user/global `.npmrc`, env-based npm config, registry mirror, etc.), lifecycle scripts can read it and exfiltrate credentials, and the gate may unintentionally validate a non-npmjs artifact.

### Issue Context
This job intentionally avoids *workflow* secrets, but npm can still pick up implicit credentials/config from the runner environment/home directory. The workflow comments already call out lifecycle-script persistence risks; this change tightens the job to be self-contained and ensures it truly tests the public npmjs artifact.

### Fix Focus Areas
- .github/workflows/update-latest.yml[57-129]

### Suggested fix
In the `verify-upgrade` step script, before any `npm view`/`npm install` calls:
- Set a temporary `HOME` (or `NPM_CONFIG_USERCONFIG`) pointing to an empty, job-controlled `.npmrc`.
- Force npm to use the public npmjs registry via `npm_config_registry=https://registry.npmjs.org/` (and optionally `npm_config_always_auth=false`).

Example (one possible approach):
```bash
export HOME="$(mktemp -d)"
export NPM_CONFIG_USERCONFIG="$HOME/.npmrc"
: > "$NPM_CONFIG_USERCONFIG"
export npm_config_registry="https://registry.npmjs.org/"
```
This keeps the smoke test deterministic and prevents accidental credential/config inheritance.

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


Results up to commit 57119ea


🐞 Bugs (0) 📘 Rule violations (1) 📎 Requirement gaps (0) 🎨 UX issues (0) 🔗 Cross-repo conflicts (0) 📜 Skill insights (0)


Remediation recommended
1. npm view errors suppressed 📘 Rule violation ☼ Reliability
Description
The upgrade gate silences all npm view failures with 2>/dev/null and falls back to
dist-tags.latest, which can hide unexpected errors (e.g. network/registry issues) and make the
gate validate against an unintended baseline version. This violates the requirement to avoid
swallowing errors and to handle only the specific expected failure case (missing latest-<major>
tag).
Code

.github/workflows/update-latest.yml[R100-102]

+        if ! FROM=$(npm view "pnpm@latest-${MAJOR}" version 2>/dev/null) || [ -z "$FROM" ]; then
+          FROM=$(npm view pnpm dist-tags.latest)
+        fi
Evidence
PR Compliance ID 9 requires not swallowing errors and only handling specific expected error cases.
The new code redirects npm view stderr to /dev/null and treats any failure as “tag absent”,
which can mask real problems and change behavior silently.

CLAUDE.md: Do Not Swallow Errors; Catch Only Specific Expected Error Cases
.github/workflows/update-latest.yml[97-102]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
In `verify-upgrade`, the workflow runs `npm view "pnpm@latest-${MAJOR}" version 2>/dev/null` and falls back on any failure. This suppresses unexpected errors (network, registry outages, malformed responses) and may cause the upgrade check to run from the wrong `FROM` version.

## Issue Context
The intended behavior is: fall back only when the `latest-<major>` dist-tag does not exist (typically an `E404` case for a new major). Other failures should fail the job with a useful error.

## Fix Focus Areas
- .github/workflows/update-latest.yml[97-102]

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


2. Writable npm userconfig path ✓ Resolved 🐞 Bug ⛨ Security
Description
verify-upgrade sets npm_config_userconfig to a filesystem path while also enabling lifecycle
scripts (--ignore-scripts=false), so those scripts can create/modify that userconfig file and
influence later npm invocations in the same step (e.g., proxy/CA settings), weakening the intended
“no ambient npm config” isolation boundary.
Code

.github/workflows/update-latest.yml[R79-87]

+        VERSION: ${{ github.event.inputs.version }}
+        # This gate is only meaningful if it resolves the artifact users
+        # resolve, so pin the registry and read no ambient npm config: a
+        # runner-level .npmrc could otherwise redirect it to a different
+        # registry, and its contents would reach the lifecycle scripts run
+        # below. RUNNER_TEMP is emptied per job, so this path stays absent.
+        npm_config_registry: https://registry.npmjs.org/
+        npm_config_userconfig: ${{ runner.temp }}/absent-npmrc
+      # zizmor: ignore[adhoc-packages] -- Installing a published release from
Evidence
The workflow explicitly enables lifecycle scripts during npm install, and the configured
npm_config_userconfig points at a writable on-disk path; since multiple npm commands run in the
same step, a script can persist config via that path for later invocations. The repo’s review guide
highlights .npmrc/proxy/auth as a key security surface.

.github/workflows/update-latest.yml[64-67]
.github/workflows/update-latest.yml[79-87]
.github/workflows/update-latest.yml[108-118]
REVIEW_GUIDE.md[63-66]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

### Issue description
`verify-upgrade` attempts to avoid ambient npm config by pointing `npm_config_userconfig` at a path that is expected not to exist. But because the job intentionally runs lifecycle scripts, those scripts can write to that known path and thereby affect subsequent `npm` commands in the same step.

### Issue Context
The workflow itself notes that lifecycle scripts can persist data across steps via filesystem/env mechanisms; the same risk applies within a single step across multiple npm invocations.

### Fix
Prefer a non-persistent config sink instead of an “absent file” path:
- Set `npm_config_userconfig: /dev/null`
- (recommended) also set `npm_config_globalconfig: /dev/null`
This keeps npm from reading any on-disk config that a lifecycle script could populate for later commands.

### Fix Focus Areas
- .github/workflows/update-latest.yml[79-87]
- .github/workflows/update-latest.yml[108-118]

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


3. Unpinned registry in tagging ✓ Resolved 🐞 Bug ⛨ Security
Description
tag-in-registry runs npm dist-tag add with secrets.NPM_TOKEN but does not pin
npm_config_registry or isolate npm config, so runner/global npm config (registry/proxy/CA) can
change where/how the credentialed request is sent and make tagging non-reproducible or route traffic
through an unintended network path.
Code

.github/workflows/update-latest.yml[R158-160]

    - name: Update tag
      env:
        "npm_config_//registry.npmjs.org/:_authToken": ${{ secrets.NPM_TOKEN }}
Evidence
The step injects an npmjs-scoped auth token but does not set
npm_config_registry/npm_config_userconfig, so npm will consult ambient config for
registry/proxy/TLS behavior; the repo’s review guide explicitly calls out .npmrc/proxy/auth and CI
secret scoping as security-sensitive.

.github/workflows/update-latest.yml[158-170]
REVIEW_GUIDE.md[63-66]
REVIEW_GUIDE.md[98-103]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

### Issue description
`tag-in-registry` performs credentialed `npm dist-tag add` operations but does not explicitly pin the registry nor neutralize ambient npm config sources. This leaves the tagging request behavior dependent on runner/global npm configuration (e.g., registry/proxy/CA), which is undesirable for a release-critical, token-bearing step.

### Issue Context
- npm config is security-sensitive in this repo’s review guide, especially around registries/auth/proxies.
- The workflow already pins registry/userconfig for `verify-upgrade`, but the token-bearing tagging step does not.

### Fix
- In `tag-in-registry` → `Update tag` step, add:
 - `npm_config_registry: https://registry.npmjs.org/`
 - `npm_config_userconfig: /dev/null`
 - (recommended) `npm_config_globalconfig: /dev/null`
 - (optional hardening) explicitly clear proxy/CA-related npm env vars if you want to guarantee no proxy/CA injection (e.g. `npm_config_proxy`, `npm_config_https_proxy`, `npm_config_cafile`).

### Fix Focus Areas
- .github/workflows/update-latest.yml[158-170]

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


Results up to commit cb2135d


🐞 Bugs (0) 📘 Rule violations (0) 📎 Requirement gaps (0) 🎨 UX issues (0) 🔗 Cross-repo conflicts (0) 📜 Skill insights (0)


Informational
1. npm install does avoidable work ✓ Resolved 🐞 Bug ➹ Performance
Description
verify-upgrade uses npm install without disabling audit/fund or lockfile generation, which can
add extra network calls and I/O unrelated to validating the upgrade and make the release gate
slower/flakier. This is especially noticeable because the job performs multiple installs (two
wrappers) per run.
Code

.github/workflows/update-latest.yml[117]

+          npm install --prefix "$work/from" --ignore-scripts=false "${package}@${FROM}"
Evidence
The workflow runs npm install with scripts enabled and no flags to disable audit/fund/lockfile
behavior, so npm may do additional work beyond what the gate needs.

.github/workflows/update-latest.yml[108-118]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

### Issue description
`npm install` in the upgrade gate may perform extra work (audit/fund) and write a package-lock, increasing runtime and potential flakiness.

### Issue Context
The gate’s purpose is to install + execute the binaries to validate upgrade behavior; audit/fund/lockfile outputs don’t contribute to that.

### Fix
Add flags such as `--no-audit --no-fund --package-lock=false` (and optionally `--loglevel=error`) to the `npm install` command.

### Fix Focus Areas
- .github/workflows/update-latest.yml[116-118]

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


Qodo Logo

@qodo-code-review

Copy link
Copy Markdown

PR Code Suggestions ✨

Warning

/improve is deprecated. Use /agentic_review instead (removal date not yet scheduled).

No code suggestions found for the PR.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In @.github/workflows/update-latest.yml:
- Line 127: Update the pnpm version verification command in the workflow to
locate and invoke pnpm from either the v11+ path, $PNPM_HOME/bin/pnpm, or the
v10 path, $PNPM_HOME/pnpm. Preserve the existing comparison against $VERSION and
ensure verification succeeds when either executable location is present.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: 07b89d64-7586-4f89-bc46-cea43dca9911

📥 Commits

Reviewing files that changed from the base of the PR and between 426a37f and 99198a8.

📒 Files selected for processing (2)
  • .github/workflows/release.yml
  • .github/workflows/update-latest.yml
🚧 Files skipped from review as they are similar to previous changes (1)
  • .github/workflows/release.yml

Comment thread .github/workflows/update-latest.yml Resolved
Copilot AI review requested due to automatic review settings July 16, 2026 09:49

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

Copilot AI review requested due to automatic review settings July 16, 2026 09:53

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@qodo-code-review

Copy link
Copy Markdown

PR Code Suggestions ✨

Warning

/improve is deprecated. Use /agentic_review instead (removal date not yet scheduled).

No code suggestions found for the PR.

@zkochan

zkochan commented Jul 16, 2026

Copy link
Copy Markdown
Member Author

Re: "Npm config not isolated"

Addressed in 57119ea, though I'd split your two concerns — they don't carry equal weight here.

Wrong-artifact risk: valid, and fixed. This gate's entire premise is that it resolves what users will resolve. Reading ambient npm config meant a runner-level .npmrc could redirect it, and the gate would then pass on an artifact nobody installs. That's a silent false-negative on a release gate, which is the worst failure mode it could have. Now pinned:

npm_config_registry: https://registry.npmjs.org/
npm_config_userconfig: ${{ runner.temp }}/absent-npmrc

This isn't hypothetical — it reproduces locally. My ~/.npmrc was demonstrably being read by the step, and the isolation removes it:

before: 'Unknown user config' warnings: 2
after:  'Unknown user config' warnings: 0

Credential exfiltration: largely already closed. As of 99198a8 this runs in verify-upgrade, which has no environment: and references no secrets — that was the fix for the token-theft path you raised earlier. The runner is ephemeral and nothing in the workflow writes an .npmrc, so there is no npm auth to capture. Pinning userconfig is still worth having as defense in depth, but I don't want to overstate it as closing a live hole.

Registry results are unchanged after the isolation: 11.13.1 and 10.34.4 pass; 11.12.0 and 11.13.0 are rejected.


Written by an agent (Claude Code, claude-opus-4-8).

Comment thread .github/workflows/release.yml Resolved
@qodo-code-review

Copy link
Copy Markdown

Code review by qodo was updated up to the latest commit 57119ea

@qodo-code-review

Copy link
Copy Markdown

PR Code Suggestions ✨

Warning

/improve is deprecated. Use /agentic_review instead (removal date not yet scheduled).

No code suggestions found for the PR.

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

Labels

reviewed: coderabbit CodeRabbit submitted an approving review

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants