← Back to Pull requests

feat(lockfile): read `tool:` lockfile keys as `runtime:` #18589

Open
unknown opened this pull request with 445 lines diff across 5 files
View on GitHub
unknown unknown commented on Dec 01, 2026 00:23 UTC
Author

Summary

tool: replaces runtime: as the protocol for tools pnpm provisions itself, but lockfile keys and references still spell it runtime: (node@runtime:22.0.0). The plan is to switch the lockfile spelling to tool: in the next lockfile major. For that to be safe, the pnpm versions that will meet such a lockfile have to read it first.

Today node@tool:22.0.0 doesn't fail to parse. tool is a reserved version prefix, so the key falls through to an opaque non-semver version with no prefix. It round-trips byte for byte, but Prefix::is_tool() is false and none of the runtime handling (installability, frozen install, lockfile reuse, hoisting) applies to it.

This PR makes the lockfile parser (PkgVerPeer::from_str) accept tool: as a second spelling of Prefix::Runtime:

  • Keys normalize to runtime: on read. Code downstream and string checks such as @runtime: only ever see one spelling.

  • pnpm still writes runtime: in every format. Choosing the written spelling per lockfile format is a separate change.

  • tool:file:… is rejected the same way runtime:file:… is.
  • Tests:

  • pkg_ver_peer::tests::tool_prefix_reads_as_runtime: parsing, peer suffix, equality with the runtime: spelling, written form, and the conflicting-scheme error.

  • next_format::tests::tool_keys_read_as_runtime_keys_in_both_formats: a lockfile spelled with tool: keys and importer versions loads equal to its runtime: spelling, in both the 9.0 format and the 13.0 format.
  • Both tests fail without the parser change.

    Checklist

  • 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.
  • 🤖 Generated with Claude Code

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

    <!-- codesmith:footer -->
    ---
    <a href="https://dashboardbackend.blacksmith.sh/track/run-proof?expires=1798676600&installation_model_id=426870&pr_number=18589&ref=codesmith_pr_footer&repository=pnpm%2Fpnpm&return_to=https%3A%2F%2Fgithub.com%2Fpnpm%2Fpnpm%2Fpull%2F18589&variant=show_it_working&signature=efbf3a5ebb002475f3d3d9c33d5cd3fe34a98cd76c3001ca33f97825f94b0479"><picture><source media="(prefers-color-scheme: dark)" srcset="https://pr-comments-assets.blacksmith.sh/codesmith/proof-show-it-working-v2-dark.svg"><source media="(prefers-color-scheme: light)" srcset="https://pr-comments-assets.blacksmith.sh/codesmith/proof-show-it-working-v2-light.svg"><img alt="Show it working" src="https://pr-comments-assets.blacksmith.sh/codesmith/proof-show-it-working-v2-dark-3x.png" width="140" height="28"></picture></a>
    <sup><a href="https://app.blacksmith.sh/pnpm/codesmith/pnpm/pr/18589?autoLogin=true&ref=codesmith_pr_footer">Open in [code]smith</a> · Need help on this PR? Tag <code>@codesmith-bot</code> with what you need.</sup>

    <!-- codesmith:autofix:disabled -->
    <!-- /codesmith:footer -->

    <!-- This is an auto-generated comment: release notes by coderabbit.ai -->
    <!-- coderabbit-ai-generated:v1 -->

    Summary by CodeRabbit

    Bug Fixes
    pnpm now reads tool: lockfile version entries the same way as runtime: entries in both supported lockfile formats. Existing tool: entries are interpreted as runtime dependencies, preserving their version and peer information. When pnpm writes the lockfile, it continues to use the runtime: prefix. Combining tool: with a conflicting scheme such as file: remains invalid.
    <!-- end of auto-generated comment: release notes by coderabbit.ai -->

    Diff: 445 lines (+333 / -112) across 5 files Reviewer: zkochan Review duration: 344m
    All Vouch review confidence checks passed
    Residual risk 0.26 = Change Risk (0.45) × (1 − Review Confidence (0.43)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.45 · 445 lines diff across 5 files
    0.45
    Model 2 · Review Depth (DistilBERT)
    Depth Score: 0.02 · 1 substantive comment(s)
    0.02
    Model 3 · Review Timing & Attention
    Session adequacy: 100% · Reviewer familiarity: 35%
    42%
    Bedrock Claude 3 · Risk Narration
    (disconnected)
    Groq
    Groq Risk Narration
    AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
    Model 1 · Change Risk Attribution
    SHAP Weights
    Diff Size diff_size
    0.365
    Shallow Review Depth shallow_review_depth
    0.344
    Real PR Conversation Timeline
    1 comments
    "Review active on #18589"
    general weight: 0.35
    Reviewers
    Assignees
    Unassigned
    Labels
    risk: low confidence: 43.0% reviewed
    Vouch Risk Breakdown
    AI-powered review risk analysis
    Change Risk
    Change Risk · Model 1 (XGBoost)
    Predicted defect probability (0.00–1.00) based on diff churn, modified sensitive files, and author risk history.
    Score: 45.4% (MEDIUM) · Higher = larger blast radius
    45.4%
    Review Confidence
    Review Confidence · Models 2 & 3
    Scrutiny score (0.00–1.00) combining DistilBERT semantic review depth with reviewer familiarity and session dwell time.
    Score: 43.0% · Lower = rushed or shallow review
    43.0%
    Residual Risk
    Residual Risk · Core Equation
    Residual = Change × (1 − Confidence)
    Unmitigated risk surviving review. ≥ 0.65 triggers an automated re-queue to protect production.
    Score: 25.9% · Safe to merge
    25.9%
    Repository