← Back to Pull requests

fix(real-hoist): bound transitive peer traversal costs #18183

Closed
unknown closed this pull request without merging on Nov 17, 2026 14:29 UTC
View on GitHub
unknown unknown commented on Nov 17, 2026 11:25 UTC
Author

Summary

The transitive peer walk added in pnpm/pnpm#18176 can overflow the stack on deep graphs and compare large provider sets quadratically. Use an explicit worklist, retain parent edges through shared nodes and cycles, and compare sets of the existing canonical package locators. This addresses the two findings in Qodo's review.

Validation: the new 20,000-node chain reproduces the stack overflow before the change. All 49 hoister tests, 67 hoisted-linker tests, 23 CLI smoke tests, and an unchanged application's 1,249 tests pass. The synthetic 512-provider/512-comparison case drops from 897–920 ms to 87–92 ms. On two application lockfiles, hoisting medians remain about 7 ms and 25–27 ms; these measurements exclude parsing and filesystem installation. Temporary benchmark code is excluded.

Squash Commit Body

Walk transitive peer edges with an explicit worklist and retain parent
edges when revisiting shared nodes or cycles. Add a deep-chain regression
that overflows the recursive collector's stack.

Use canonical package locators in sets to remove quadratic provider
membership and equality scans. Read bindings from the current graph for
each decision rather than caching across hoist mutations.

Follow-up to pnpm/pnpm#18176.

Checklist

  • Verified the review findings and checked for an existing follow-up.

  • The affected traversal was added only to the Rust pnpm CLI.

  • Added a regression test and retained the cycle and generated-graph coverage.

  • No additional changeset: this hardens the unreleased fix in pnpm/pnpm#18176, whose changeset is still pending.

  • No documentation changes are needed for this internal implementation change.
  • Code Owner Approvals

    Pending maintainer review.

    ---
    Written by an agent (Codex, GPT-6).

    <!-- codesmith:footer -->
    ---
    <a href="https://backend.blacksmith.sh/track/enable-autofix?expires=1797506719&installation_model_id=426870&pr_number=18183&ref=codesmith_pr_footer&repository=pnpm%2Fpnpm&return_to=https%3A%2F%2Fgithub.com%2Fpnpm%2Fpnpm%2Fpull%2F18183&signature=b84ebc112b03dc8ab4f44ee03846b89b423d19adee745dad9fe6add9acdc627f"><picture><source media="(prefers-color-scheme: dark)" srcset="https://pr-comments-assets.blacksmith.sh/codesmith/autofix-with-codesmith-dark.svg"><source media="(prefers-color-scheme: light)" srcset="https://pr-comments-assets.blacksmith.sh/codesmith/autofix-with-codesmith-light.svg"><img alt="Autofix with [code]smith" src="https://pr-comments-assets.blacksmith.sh/codesmith/autofix-with-codesmith-dark-3x.png" width="190" height="28"></picture></a>
    <sup><a href="https://app.blacksmith.sh/pnpm/codesmith/pnpm/pr/18183?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
    Improved peer-provider resolution in deeply nested dependency chains, helping inherited providers be identified and bound correctly.
    * Verified provider handling across a 20,000-level dependency chain, including correct identification of the provider and inherited-provider status.
    <!-- end of auto-generated comment: release notes by coderabbit.ai -->

    Diff: 431 lines (+323 / -108) across 5 files Reviewer: zkochan Review duration: 184m
    All Vouch review confidence checks passed
    Residual risk 0.18 = Change Risk (0.45) × (1 − Review Confidence (0.60)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.45 · 431 lines diff across 5 files
    0.45
    Model 2 · Review Depth (DistilBERT)
    Depth Score: 0.17 · 1 substantive comment(s)
    0.17
    Model 3 · Review Timing & Attention
    Session adequacy: 100% · Reviewer familiarity: 35%
    60%
    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.363
    Shallow Review Depth shallow_review_depth
    0.289
    Real PR Conversation Timeline
    1 comments
    "Review active on #18183"
    general weight: 0.35
    Reviewers
    Assignees
    Unassigned
    Labels
    risk: low confidence: 60.5% 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.2% (MEDIUM) · Higher = larger blast radius
    45.2%
    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: 60.5% · Lower = rushed or shallow review
    60.5%
    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: 17.8% · Safe to merge
    17.8%
    Repository