Skip to content

perf(resolver): cache cycle-truncated peer verdicts, scoped to their truncation - #13859

Merged
zkochan merged 4 commits into
mainfrom
fix-13681-cycle-cache-key
Aug 12, 2026
Merged

zkochan merged 4 commits into
mainfrom
fix-13681-cycle-cache-key

Conversation

@zkochan

@zkochan zkochan commented Aug 12, 2026 •

Copy link
Copy Markdown
Member

The third and largest piece of #13681, addressing what the first two PRs (#13844, #13855) deliberately left alone: the occurrence explosion itself.

The problem

A walk that re-enters a package already on its ancestor chain resolves against a truncated subtree, so its verdict has never been cached — reusing it where the subtree is intact drops transitivePeerDependencies depending on traversal order (#5108). On a peer-cyclic graph this rule makes the peers cache inert. Resolving bit's env packages:

full walks:            188,707   (91% end in a cycle)
peers-cache hits:          155   of 188,862 lookups  (0.08%)
occurrence nodes:    2,008,130   for a 6,133-node graph

The insight, measured before designed

The truncation is not arbitrary: realize_children_with drops exactly the edges forms_cycle finds in the occurrence's own ancestor ids. So a truncated verdict is a function of (package, peer context, the chain entries the gate actually weighs) — and everything else in the chain is noise. I instrumented the workload to check how much noise:

candidate key distinct keys / 171,508 cycle walks
full ancestor chain 68,184 (2.5×) — and implemented honestly, memory got worse
chain ∩ reachable-set 68,180 — useless, the cluster is one giant SCC
chain ∩ consulted ids ~1,900 (91×)

The mechanism

  • Every full walk keeps a ConsultedPkgs frame — a bitset over interned package ids. Realization marks the package whose children are realized plus every child edge target (precisely the forms_cycle arguments); reusing an already-realized children map marks the same ids, since the map embodies the same answers. Finished walks fold their frame into their parent's; a cache hit folds the stored entry's set in. An outer frame therefore covers the dependence of everything under it.
  • Cycle-resolved verdicts are now stored, tagged with a CycleTruncationKey: the consulted set plus the occurrence's ancestor ids restricted to it (base entries first — forms_cycle treats the halves differently, so the boundary is part of the key).
  • find_hit hands a tagged verdict only to an occurrence whose ancestors, restricted to the entry's consulted set, are exactly the recorded chain. Equal restrictions ⇒ every gate answer equal ⇒ same realization, same truncation, same verdict, by induction on the walk. Non-matching occurrences — in particular ones whose ancestors don't truncate the subtree at all, the not expected updates in lockfile #5108 shape — re-walk exactly as before.

Results

Same replayed install as the previous PRs (5 importers, 3,807 merged packages), alternating A/B:

peak RSS wall time
main 3043 / 3056 / 3042 MB 59 / 39 / 42 s
this branch 1405 / 1416 / 1415 MB 20 / 25 / 20 s

3047 → 1412 MB (−54%), roughly 2× faster. Walk counts: full walks 188,707 → 33,648; cycle walks 171,508 → 16,563; the keyed entries hit 44,999 times. Cumulative across the three PRs the install has gone 3670 → 1412 MB (−62%).

Correctness

This is the change #5108 exists to be afraid of, so I want to be explicit about the evidence and its limits.

  • 328 tests pass, including new ones that pin the key's semantics from both directions: unconsulted ancestors are noise (reuse happens), while order changes, extra occurrences, base/appended boundary moves, and — critically — an occurrence whose ancestors don't truncate the subtree all refuse reuse.
  • Repeat installs never churn. Fixed-point checked both ways: the unmodified engine, handed this branch's lockfile as wanted, preserves it byte for byte; this branch preserves main's lockfile byte for byte. Lockfile churn on repeat installs is the not expected updates in lockfile #5108 regression, and it cannot happen here.
  • Cold output is deterministic — three cold runs, byte-identical.
  • Cold output differs from main in 13 snapshot entries (52 diff lines of ~86k), all in the @teambit/component → command-bar/pubsub/ui cluster — the exact entries that already flip between identical stock runs (Lockfile is not reproducible: four identical installs produce four different lockfiles #13846, 96–197-line diffs). The branch picks a different valid peer variant there; the fixed-point check is what shows it is valid. I want to flag this honestly rather than bury it: if byte-identical cold output against current main is a hard requirement even inside the known-nondeterministic cluster, this needs a maintainer call.
  • cargo clippy --all-targets, cargo fmt, and cargo dylint clean across the workspace.

What I'd take a steer on

The one hole I know of and did not close: keyless (non-cycle) items whose subtrees contain cycle-resolved descendants re-entering ancestors above them embed chain-dependence today, on main, and are reused with ctx checks only. That is pre-existing behavior — this PR neither introduces nor widens it — and I suspect it is the root of #13846. Happy to attack it as a follow-up with the same consulted-set machinery (tagging any item whose frame intersects its chain).

Refs #13681


View with [code]smith Autofix with [code]smith
Need help on this PR? Tag @codesmith-bot with what you need. Autofix is disabled.

Summary by CodeRabbit

  • Performance Improvements
    • Improved peer-dependency resolution speed and reduced memory usage.
    • Added safe caching for reusable cycle-resolution results, including lazy resolution paths.
  • Bug Fixes
    • Prevented cached cycle results from being reused when dependency ancestry or consulted packages differ, improving resolution accuracy.
  • Tests
    • Added coverage for cache matching across dependency orders, duplicates, ancestry boundaries, and repeated cycle traversals.

…truncation

A walk that re-enters a package already on its ancestor chain resolves
against a truncated subtree, so its verdict was never cached (#5108:
reusing it where the subtree is intact drops transitivePeerDependencies
depending on traversal order). On a peer-cyclic graph that rule makes
the peers cache inert: resolving the bit monorepo's env packages, 91%
of 188,707 full walks ended in a cycle, the cache hit 155 times in
188,862 lookups, and the walk realized 2,008,130 occurrence nodes for a
6,133-node graph.

The truncation is not arbitrary, though. `realize_children_with` drops
exactly the edges `forms_cycle` finds in the occurrence's own ancestor
ids, so the verdict is a function of (package, peer context, the chain
entries the gate weighs). Everything else in the chain is noise. This
change makes that precise and caches on it:

- Every full walk keeps a `ConsultedPkgs` frame — a bitset over interned
  package ids — and realization marks the package whose children are
  being realized plus every child edge target: precisely the
  `forms_cycle` arguments. Reusing an already-realized children map
  marks the same ids, since the map embodies the same answers. Finished
  walks fold their frame into their parent's, and a cache hit folds the
  stored entry's set into the running frame, so an outer frame always
  covers the dependence of everything under it.
- A cycle-resolved verdict is now stored, tagged with a
  `CycleTruncationKey`: its consulted set plus the occurrence's ancestor
  ids restricted to it, base entries first. `forms_cycle` treats the
  base and appended halves differently, so the boundary is part of the
  key.
- `find_hit` hands a tagged verdict only to an occurrence whose ancestor
  ids, restricted to the entry's consulted set, are exactly the recorded
  chain. Equal restrictions mean every gate answer the walk depends on
  is equal, which by induction means the same realization, the same
  truncation, and the same verdict. Occurrences that don't match — in
  particular ones whose ancestors don't truncate the subtree at all —
  re-walk, exactly as before. The fast cache paths have no ancestor ids
  to compare and skip tagged entries entirely.
- The bit index and the interned consulted sets live in
  `PeerDiscoveryCaches`, since the cache items they interpret already
  persist across discovery and main walks.

On the workload above, full walks drop from 188,707 to 33,648 and
cycle-resolved walks from 171,508 to 16,563; the keyed entries are hit
44,999 times. Peak RSS falls from 3047 MB to 1412 MB (-54%, n=3 each,
alternating A/B, non-overlapping) and wall time roughly halves.

Output changes only within the resolver's existing order-sensitivity
envelope (#13846): 13 snapshot entries in the same @teambit cluster
that already flips between identical stock runs pick a different valid
peer variant. Both directions were checked as fixed points — the
unmodified engine, handed this branch's lockfile as wanted, preserves
it byte for byte, and this branch preserves the unmodified engine's
lockfile byte for byte — so repeat installs never churn, which is the
regression #5108 guards. Cold output is deterministic across runs.

Refs #13681
Copilot AI lite review requested due to automatic review settings August 12, 2026 11:18

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 Aug 12, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: b011c9e0-e663-4139-82b6-3f4564691eed

📥 Commits

Reviewing files that changed from the base of the PR and between 05e0b6d and f5020a4.

📒 Files selected for processing (1)
  • pnpm/crates/resolving-deps-resolver/src/resolve_peers/tests.rs
🚧 Files skipped from review as they are similar to previous changes (1)
  • pnpm/crates/resolving-deps-resolver/src/resolve_peers/tests.rs

📝 Walkthrough

Walkthrough

The resolver tracks consulted packages during peer walks and caches cycle-truncated resolutions with matching ancestor-chain context. Cache lookup rejects incompatible cycle verdicts, while reusable consulted-package sets persist through discovery caches.

Changes

Scoped cycle verdict caching

Layer / File(s) Summary
Cycle cache key and ancestor contracts
pnpm/crates/resolving-deps-resolver/src/resolve_peers/cache.rs, pnpm/crates/resolving-deps-resolver/src/resolve_peers/cache/tests.rs, pnpm/crates/resolving-deps-resolver/src/resolved_tree.rs
CycleTruncationKey records consulted packages and relevant ancestor IDs. Cache lookup validates matching truncation context. Tests cover ordering, duplication, boundaries, and consulted-set merging.
Walker consulted-package tracking
pnpm/crates/resolving-deps-resolver/src/resolve_peers/walker.rs, pnpm/crates/resolving-deps-resolver/src/resolve_peers/discovery.rs, .changeset/cycle-verdict-cache.md
Walker records consulted packages during child preview and realization, persists deduplicated sets, propagates context through cache hits, and stores scoped keys for eligible truncated results. The changeset records the cache behavior update.
Lazy cycle regression coverage
pnpm/crates/resolving-deps-resolver/src/resolve_peers/tests.rs
Tests construct lazy ring dependencies and verify distinct truncation contexts, peer preservation, and bounded repeated realization.

Estimated code review effort: 4 (Complex) | ~45 minutes

Sequence Diagram(s)

sequenceDiagram
  participant Walker
  participant AncestorIds
  participant PeerDiscoveryCaches
  participant PeersCache
  Walker->>AncestorIds: Read base and appended ancestor IDs
  Walker->>PeerDiscoveryCaches: Record consulted packages and intern sets
  Walker->>PeersCache: Look up resolution with cycle context
  PeersCache-->>Walker: Return a matching cached verdict
  Walker->>PeersCache: Store a cycle key on an eligible truncated result
Loading

Possibly related issues

  • pnpm/pnpm#13865: Adds the same CycleTruncationKey and consulted-package tracking for context-bound cycle verdict reuse.

Possibly related PRs

  • pnpm/pnpm#13491: Both changes modify peer-resolution discovery and walker caching.
  • pnpm/pnpm#13545: Both changes modify AncestorIds and peer-resolution cache infrastructure.
  • pnpm/pnpm#13551: Both changes modify the peer-resolution cache and Walker behavior.

Suggested labels: product: pacquet

Suggested reviewers: greptile-apps

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix-13681-cycle-cache-key

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

Cache cycle-truncated peer-resolution verdicts keyed by consulted ancestors

✨ Enhancement 🐞 Bug fix 🧪 Tests 📝 Documentation 🕐 40+ Minutes

Grey Divider

AI Description

• Cache peer-resolution results computed inside cycles, scoped to matching truncation context.
• Track packages consulted by the cycle gate to build a coarse, reusable cache key.
• Add unit tests ensuring truncated verdicts are reused only when provably valid.
Diagram

graph TD
  A["Peer walk (Walker)"] --> B{"Cache hit?"}
  B -->|"yes"| C[("Peers cache") ] --> D["Fold consulted set"]
  B -->|"no"| E["Realize children"] --> F["Mark consulted bits"] --> G["Build CycleTruncationKey"] --> C
  C --> H["Reuse only if key matches ancestors"]

  subgraph Legend
    direction LR
    _p["Process"] ~~~ _d{"Decision"} ~~~ _c[("Cache")]
  end
Loading
High-Level Assessment

The following are alternative approaches to this PR:

1. Key cache by full ancestor chain
  • ➕ Simpler correctness story: exact chain equality implies identical truncation
  • ➖ Explodes key cardinality on deep/cyclic graphs, increasing memory and reducing reuse
  • ➖ Still wastes entropy on ancestors that the cycle gate never consults
2. Keep current behavior (never cache cycle-truncated verdicts)
  • ➕ Avoids any risk of reusing a partial verdict in a non-truncated context
  • ➖ Makes peers cache effectively inert on peer-cyclic graphs; large CPU/memory blowups remain
3. SCC-level memoization (cache per strongly-connected component)
  • ➕ Could amortize work across many cycle re-entries without per-occurrence keys
  • ➖ Higher implementation complexity (needs graph/SCC identification and stable component identity)
  • ➖ Harder to prove equivalence with the cycle gate’s exact truncation semantics

Recommendation: The PR’s approach (scope cycle-truncated verdicts using a consulted-set-restricted ancestor chain) is the best balance: it preserves #5108 correctness by construction while drastically improving cache reuse on cyclic graphs. It also keeps key cardinality low (compared to full-chain keying) without requiring heavy graph analysis like SCC memoization.

Files changed (6) +397 / -18

Enhancement (1) +8 / -0
discovery.rsPersist consulted-bit index and deduped consulted sets across walks +8/-0

Persist consulted-bit index and deduped consulted sets across walks

• Extends 'PeerDiscoveryCaches' with 'consulted_bit_by_pkg' and 'consulted_sets' so cycle-truncation keys remain interpretable and memory-efficient across walker instances. Ensures the bit assignments outlive the cached items that reference them.

pnpm/crates/resolving-deps-resolver/src/resolve_peers/discovery.rs

Bug fix (2) +267 / -17
cache.rsIntroduce consulted-bitset and cycle truncation key for peers cache entries +139/-5

Introduce consulted-bitset and cycle truncation key for peers cache entries

• Adds 'ConsultedPkgs' (normalized bitset) and 'CycleTruncationKey' to represent when a cycle-truncated verdict is authoritative. Extends 'PeersCacheItem' with an optional 'cycle_key' and updates cache-hit logic to validate keys against the current ancestor chain before reusing truncated verdicts.

pnpm/crates/resolving-deps-resolver/src/resolve_peers/cache.rs

walker.rsTrack gate-consulted packages per walk and scope cached cycle verdicts +128/-12

Track gate-consulted packages per walk and scope cached cycle verdicts

• Adds a per-walk 'consulted_stack' frame and plumbs marking into child realization (including reuse of already-realized children maps). Builds and stores 'CycleTruncationKey' for cycle-truncated results, merges consulted sets on cache hits, and prevents fast-path cache use for cycle-scoped entries (no ancestors available there).

pnpm/crates/resolving-deps-resolver/src/resolve_peers/walker.rs

Refactor (1) +10 / -0
resolved_tree.rsExpose base/appended ancestor iterators for truncation-key matching +10/-0

Expose base/appended ancestor iterators for truncation-key matching

• Adds 'AncestorIds::base_ids()' and 'AncestorIds::appended_ids()' iterators to support constructing and matching cycle truncation keys without leaking internal representation details.

pnpm/crates/resolving-deps-resolver/src/resolved_tree.rs

Tests (1) +107 / -1
tests.rsAdd unit tests for cycle-key scoping and consulted-set normalization +107/-1

Add unit tests for cycle-key scoping and consulted-set normalization

• Introduces tests asserting that truncated verdicts are reused only when the current ancestors truncate identically (order- and base/appended-boundary sensitive). Adds coverage ensuring 'ConsultedPkgs' equality/hashing is stable regardless of insertion/capacity history and supports set union via 'or()'.

pnpm/crates/resolving-deps-resolver/src/resolve_peers/cache/tests.rs

Documentation (1) +5 / -0
cycle-verdict-cache.mdDocument perf win from caching cycle-scoped peer verdicts +5/-0

Document perf win from caching cycle-scoped peer verdicts

• Adds a changeset describing reduced memory usage and faster installs on peer-cyclic graphs. Explains that verdicts computed inside dependency cycles are now cached and reused when valid.

.changeset/cycle-verdict-cache.md

@greptile-apps

greptile-apps Bot commented Aug 12, 2026 •

Copy link
Copy Markdown
Contributor

Confidence Score: 4/5

The PR is not yet safe to merge because an already-realized provider preview can still produce an incompletely scoped cycle-cache verdict.

The realized preview branch returns before recording the package and child IDs, and the immediately following cache-hit path can exit without reaching the realization branch where those inputs are marked, leaving incorrect peer-verdict reuse reachable.

Files Needing Attention: pnpm/crates/resolving-deps-resolver/src/resolve_peers/cache.rs, pnpm/crates/resolving-deps-resolver/src/resolve_peers/walker.rs

Comments Outside Diff (1)

  1. pnpm/crates/resolving-deps-resolver/src/resolve_peers/cache.rs, line 666-680 (link)

    P1 Realized previews omit key inputs

    When a cycle re-entry previews a node whose children are already TreeChildren::Realized, this branch returns without recording the package and child IDs represented by the provider map. A subsequent cache hit bypasses realize_children_with, leaving the cycle key incomplete and allowing a truncated verdict to be reused under different ancestry, which drops resolved or transitive peer dependencies from the graph and lockfile.

    Knowledge Base Used: Resolving and Fetching Dependency Specifiers

Reviews (4): Last reviewed commit: "style(resolver): realign the fixture clo..." | Re-trigger Greptile

@codecov-commenter

codecov-commenter commented Aug 12, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 97.33333% with 4 lines in your changes missing coverage. Please review.
✅ Project coverage is 88.29%. Comparing base (260fb13) to head (f5020a4).
⚠️ Report is 5 commits behind head on main.

Files with missing lines Patch % Lines
...esolving-deps-resolver/src/resolve_peers/walker.rs 96.25% 3 Missing ⚠️
...resolving-deps-resolver/src/resolve_peers/cache.rs 98.43% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main   #13859      +/-   ##
==========================================
+ Coverage   88.26%   88.29%   +0.03%     
==========================================
  Files         627      627              
  Lines      103370   103689     +319     
==========================================
+ Hits        91235    91550     +315     
- Misses      12135    12139       +4     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@github-actions

github-actions Bot commented Aug 12, 2026 •

Copy link
Copy Markdown
Contributor

Micro-Benchmark Results

Linux

group                                            main                                   pr
-----                                            ----                                   --
lockfile/parse_pnpm_lock                         1.00     11.6±0.19ms    32.3 MB/sec    1.12     13.0±0.28ms    28.8 MB/sec
packument/parse                                  1.00     40.5±1.77µs  1638.6 MB/sec    1.08     43.8±0.96µs  1512.9 MB/sec
tarball/download_dependency                      1.02      3.4±0.26ms  1275.2 KB/sec    1.00      3.3±0.51ms  1300.9 KB/sec
tarball_batch/cold_store_many_medium_tarballs    1.08   210.0±13.23ms 76.2 KElem/sec    1.00   194.3±18.14ms 82.3 KElem/sec
workspace_resolution/hoist_heavy                 1.00    249.5±2.53ms        ? ?/sec    1.22   305.4±10.46ms        ? ?/sec

@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 (3)
pnpm/crates/resolving-deps-resolver/src/resolve_peers/cache.rs (1)

388-394: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

Correct the comment: this path does have an ancestor chain.

parent_ids is in scope from the enclosing signature, and find_fast_hit only calls this for a TreeChildren::Lazy node. So parent_ids is the same pre-realization chain that resolve_node captures as truncation_ids. The comment says no chain exists, which is not accurate.

Skipping keyed entries is sound, because it only loses hits. Two options:

  1. Minimum: reword the comment to state that the fast path deliberately stays on unkeyed entries.
  2. Optional follow-up: pass parent_ids to CycleTruncationKey::matches here. That would recover fast-path hits on the peer-cyclic graphs this PR targets. Keep it out of this PR if you want to limit scope.
♻️ Proposed comment correction
         self.peers_cache.get(pkg_id)?.iter().find(|item| {
-            // The fast paths have no ancestor chain to compare, so they
-            // stay on the entries that never needed one.
+            // The fast paths deliberately stay on entries that never needed
+            // an ancestor chain. `parent_ids` could validate a keyed entry,
+            // but the fast path is kept free of that comparison.
             item.cycle_key.is_none()

This follows the coding guideline: "Comments should document contracts, non-obvious invariants, workarounds, deliberate exceptions, or unavoidable technical constraints, and should describe current behavior rather than historical implementation details."

🤖 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 `@pnpm/crates/resolving-deps-resolver/src/resolve_peers/cache.rs` around lines
388 - 394, Correct the comment immediately above the cycle_key check in
find_fast_hit to state that the fast path deliberately considers only entries
without a cycle key, rather than claiming no ancestor chain exists. Keep the
existing matching behavior unchanged; do not add parent_ids to
CycleTruncationKey::matches unless expanding scope.

Source: Coding guidelines

pnpm/crates/resolving-deps-resolver/src/resolve_peers/cache/tests.rs (1)

110-160: 🎯 Functional Correctness | 🔵 Trivial | ⚡ Quick win

Add a boundary case with base_len > 0.

The assertions are behavioral and exercise find_hit on the production path. Coverage of matching and non-matching consulted chains is complete.

One boundary shape is missing. keyed_item hardcodes base_len = 0, so every recorded key holds its whole chain in the appended half. Line 152 therefore only tests one direction of the base_len check: recorded 0 against a current chain with two consulted base ids. A key with base_len > 0, and a mixed base-plus-appended key, stay unexercised. Walker::build_cycle_key produces base_len > 0 whenever a consulted id sits in the base half, so this shape occurs in real walks.

Let keyed_item take a base/appended split, then assert that a key recorded with base_len > 0 rejects the same ids moved into the appended half.

💚 Proposed test extension
 fn keyed_item(
     walker: &mut crate::resolve_peers::walker::Walker<'_>,
-    chain: &[&str],
+    base: &[&str],
+    appended: &[&str],
 ) -> PeersCacheItem {
     // Consulted set = exactly the ids in `chain`, registered through the
     // walker's bit index the way a real walk would.
     let mut bits = ConsultedPkgs::default();
-    for id in chain {
+    for id in base.iter().chain(appended) {
         let next = walker.consulted_bit_by_pkg.len() as u32;
         let bit = *walker.consulted_bit_by_pkg.entry(Arc::from(*id)).or_insert(next);
         bits.set(bit);
     }
     PeersCacheItem {
         dep_path: DepPath::from("[email protected]"),
         resolved_peers: Arc::new(HashMap::default()),
         missing_peers: Arc::new(HashMap::default()),
         missing_peers_of_children: Arc::new(HashMap::default()),
         subtree_missing_by_pkg: None,
         cycle_key: Some(CycleTruncationKey::new(
             Arc::new(bits),
-            chain.iter().map(|id| Arc::from(*id)).collect(),
-            0,
+            base.iter().chain(appended).map(|id| Arc::from(*id)).collect(),
+            u32::try_from(base.len()).expect("test chain fits in u32"),
         )),
     }
 }

Then add a test for the recorded-base direction:

/// A key recorded with consulted ids in the base half must reject the
/// same ids in the appended half: `forms_cycle` answers the two halves
/// differently, so `base_len` is part of the key in both directions.
#[test]
fn a_cycle_verdict_is_scoped_to_the_base_appended_boundary() {
    let mut tree = ResolvedTree::default();
    let mut walker = walker_for_tests(&mut tree);
    let item = keyed_item(&mut walker, &["[email protected]"], &["[email protected]"]);
    walker.peers_cache.insert("[email protected]".to_string(), vec![item]);
    let refs = HashMap::default();

    assert!(
        walker
            .find_hit(&refs, "[email protected]", Some(&ancestors(&["[email protected]"], &["[email protected]"])))
            .is_some(),
        "the same base/appended split reuses the verdict",
    );
    assert!(
        walker
            .find_hit(&refs, "[email protected]", Some(&ancestors(&[], &["[email protected]", "[email protected]"])))
            .is_none(),
        "moving a consulted id out of the base half is a different truncation",
    );
}

This follows the path instructions, which require "regression tests for matching and non-matching keys" and state "Add tests that cover the cache-key boundary cases and verify they fail without the fix."

🤖 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 `@pnpm/crates/resolving-deps-resolver/src/resolve_peers/cache/tests.rs` around
lines 110 - 160, Add coverage for the base/appended boundary in
`a_cycle_verdict_is_scoped_to_ancestors_that_truncate_identically`: change
`keyed_item` to accept separate base and appended ids, then add
`a_cycle_verdict_is_scoped_to_the_base_appended_boundary` using a non-empty
base. Assert the matching split reuses the verdict while moving the consulted
base id into the appended half returns no hit.

Source: Path instructions

pnpm/crates/resolving-deps-resolver/src/resolve_peers/walker.rs (1)

277-302: 🚀 Performance & Scalability | 🔵 Trivial | 💤 Low value

Optional: reuse the interned Arc<str> and cut one clone from the interning path.

The key construction is correct and mirrors CycleTruncationKey::matches in filter order and base_len accounting.

Two contained allocation nits on a hot path:

  1. Arc::from(id) at Lines 285 and 291 allocates a new Arc<str> for each consulted chain entry. consulted_bit_by_pkg already holds an Arc<str> for that id, and the consulted closure just looked it up. Switch the closure to get_key_value and clone the existing Arc.
  2. The interning block at Lines 294-300 clones frame twice on the miss path. The entry API needs one clone.
⚡ Proposed allocation reuse
     fn build_cycle_key(&mut self, ids: &AncestorIds, frame: &ConsultedPkgs) -> CycleTruncationKey {
-        let consulted = |bit_by_pkg: &HashMap<Arc<str>, u32>, id: &str| {
-            bit_by_pkg.get(id).is_some_and(|bit| frame.contains(*bit))
-        };
+        // Yields the interned key so the chain shares the bit map's
+        // allocation instead of making a new one per entry.
+        let consulted = |bit_by_pkg: &'_ HashMap<Arc<str>, u32>, id: &str| {
+            bit_by_pkg
+                .get_key_value(id)
+                .filter(|(_, bit)| frame.contains(**bit))
+                .map(|(interned, _)| Arc::clone(interned))
+        };
         let mut chain: Vec<Arc<str>> = Vec::new();
         let mut base_len = 0u32;
         for id in ids.base_ids() {
-            if consulted(&self.consulted_bit_by_pkg, id) {
-                chain.push(Arc::from(id));
+            if let Some(interned) = consulted(&self.consulted_bit_by_pkg, id) {
+                chain.push(interned);
                 base_len += 1;
             }
         }
         for id in ids.appended_ids() {
-            if consulted(&self.consulted_bit_by_pkg, id) {
-                chain.push(Arc::from(id));
+            if let Some(interned) = consulted(&self.consulted_bit_by_pkg, id) {
+                chain.push(interned);
             }
         }
-        let shared = if let Some(hit) = self.consulted_sets.get(frame) {
-            Arc::clone(hit)
-        } else {
-            let arc = Arc::new(frame.clone());
-            self.consulted_sets.insert(frame.clone(), Arc::clone(&arc));
-            arc
-        };
+        let shared = Arc::clone(
+            self.consulted_sets
+                .entry(frame.clone())
+                .or_insert_with(|| Arc::new(frame.clone())),
+        );
         CycleTruncationKey::new(shared, chain, base_len)
     }

The entry form still clones frame for the key on both paths, so if the hit rate is high, keep the current get-first shape and apply only change 1.

This follows the path instruction from pnpm/CODE_STYLE_GUIDE.md: "choose owned versus borrowed types to avoid unnecessary cloning" and "prefer Arc::clone for reference-counted values."

🤖 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 `@pnpm/crates/resolving-deps-resolver/src/resolve_peers/walker.rs` around lines
277 - 302, Update build_cycle_key so the consulted lookup returns the existing
Arc<str> via get_key_value, then push an Arc::clone of that key instead of
constructing Arc::from(id) for both base_ids and appended_ids. Preserve the
current filtering order and base_len accounting; leave the consulted_sets
interning block unchanged unless a one-clone entry-API change can be made
without cloning frame on cache hits.

Source: Path instructions

🤖 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 `@pnpm/crates/resolving-deps-resolver/src/resolve_peers/cache.rs`:
- Around line 388-394: Correct the comment immediately above the cycle_key check
in find_fast_hit to state that the fast path deliberately considers only entries
without a cycle key, rather than claiming no ancestor chain exists. Keep the
existing matching behavior unchanged; do not add parent_ids to
CycleTruncationKey::matches unless expanding scope.

In `@pnpm/crates/resolving-deps-resolver/src/resolve_peers/cache/tests.rs`:
- Around line 110-160: Add coverage for the base/appended boundary in
`a_cycle_verdict_is_scoped_to_ancestors_that_truncate_identically`: change
`keyed_item` to accept separate base and appended ids, then add
`a_cycle_verdict_is_scoped_to_the_base_appended_boundary` using a non-empty
base. Assert the matching split reuses the verdict while moving the consulted
base id into the appended half returns no hit.

In `@pnpm/crates/resolving-deps-resolver/src/resolve_peers/walker.rs`:
- Around line 277-302: Update build_cycle_key so the consulted lookup returns
the existing Arc<str> via get_key_value, then push an Arc::clone of that key
instead of constructing Arc::from(id) for both base_ids and appended_ids.
Preserve the current filtering order and base_len accounting; leave the
consulted_sets interning block unchanged unless a one-clone entry-API change can
be made without cloning frame on cache hits.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: bb0eadc7-b8b0-4dc3-94f1-0a8c74bd3362

📥 Commits

Reviewing files that changed from the base of the PR and between bfce662 and ae28bcd.

📒 Files selected for processing (6)
  • .changeset/cycle-verdict-cache.md
  • pnpm/crates/resolving-deps-resolver/src/resolve_peers/cache.rs
  • pnpm/crates/resolving-deps-resolver/src/resolve_peers/cache/tests.rs
  • pnpm/crates/resolving-deps-resolver/src/resolve_peers/discovery.rs
  • pnpm/crates/resolving-deps-resolver/src/resolve_peers/walker.rs
  • pnpm/crates/resolving-deps-resolver/src/resolved_tree.rs

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

qodo-code-review Bot commented Aug 12, 2026 •

Copy link
Copy Markdown

Code Review by Qodo

🐞 Bugs (5) 📘 Rule violations (1) 📜 Skill insights (0)

Grey Divider


Remediation recommended

1. Realized cycles skip caching 🐞 Bug ➹ Performance ⭐ New
Description
In Walker::resolve_node, if a walk is detected as cycle-traversing but cycle_key cannot be built
(missing truncation_ids), the code skips recording the verdict in both caches. This is
safety-preserving, but it means any cycle re-walk that lands on an already-Realized occurrence
node will always recompute peers, limiting the performance win in graphs that revisit realized cycle
occurrences.
Code

pnpm/crates/resolving-deps-resolver/src/resolve_peers/walker.rs[R964-966]

+        if resolved_through_cycle && cycle_key.is_none() {
+            // A truncated verdict with no scope must not be reused
+            // anywhere, so neither cache records it.
Relevance

●● Moderate

Perf tweak touches cycle-verdict scoping/correctness; no close precedent on caching keyless
realized-cycle walks.

PR-#13589
PR-#13855

ⓘ Recommendations generated based on similar findings in past PRs

Evidence
The walker only captures truncation_ids for Lazy nodes and later refuses to cache cycle results
when cycle_key is None. Because realization converts Lazy to Realized and drops
parent_ids, later cycle visits to already-realized occurrences cannot build a key and are
therefore uncached.

pnpm/crates/resolving-deps-resolver/src/resolve_peers/walker.rs[609-615]
pnpm/crates/resolving-deps-resolver/src/resolve_peers/walker.rs[958-966]
pnpm/crates/resolving-deps-resolver/src/resolve_peers/cache.rs[824-829]

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

## Issue description
Cycle-truncated verdicts are only cached when the occurrence’s `AncestorIds` (`truncation_ids`) are available to build a `CycleTruncationKey`. When `resolved_through_cycle` is true but `truncation_ids` is unavailable, the code currently skips caching entirely. This is correct for safety, but it can reduce cache hit rate if cycle re-walks revisit already-`Realized` occurrences.

## Issue Context
- `resolve_node` captures `truncation_ids` only when the node’s children are `TreeChildren::Lazy`.
- `realize_children_with` replaces `Lazy` with `Realized` and drops the stored `parent_ids`, so later visits cannot reconstruct `truncation_ids`.
- As a result, cycle walks that start from a `Realized` occurrence cannot build a `cycle_key` and are not cached.

## Fix Focus Areas
- pnpm/crates/resolving-deps-resolver/src/resolve_peers/walker.rs[609-615]
- pnpm/crates/resolving-deps-resolver/src/resolve_peers/walker.rs[958-966]
- pnpm/crates/resolving-deps-resolver/src/resolve_peers/cache.rs[723-830]

## Suggested approach
1. Preserve enough scope metadata across realization to allow safe `cycle_key` construction on later visits, without reintroducing incorrect reuse:
  - Option A: extend `TreeChildren::Realized` to also carry the `AncestorIds` (or a compact representation) used for its realization.
  - Option B (lower memory): store this scope only when realization actually *truncated* at least one edge (i.e., when `forms_cycle` caused any `continue`), since only those verdicts require scoping.
2. Update `resolve_node` to obtain `truncation_ids` for both `Lazy` and `Realized` nodes (when available), enabling `cycle_key` construction for cycle verdicts even after a node has been realized.
3. Keep the existing safety behavior (don’t cache when scope is unknown), but reduce the number of cases where scope is unknowable.

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


2. Comment says as before ✓ Resolved 📘 Rule violation ⚙ Maintainability
Description
Newly added comments use historical phrasing (e.g., as before, exactly as before, `used to
hold`) instead of clearly stating the current intended behavior and contract. This can become stale
over time and mislead maintainers, increasing the risk of drift and confusion during future
refactors.
Code

pnpm/crates/resolving-deps-resolver/src/resolve_peers/walker.rs[R949-957]

+        // Without the occurrence's ancestor ids there is nothing to scope
+        // a truncated verdict to, so it stays uncached exactly as before.
+        let cycle_key = match (resolved_through_cycle, truncation_ids.as_ref(), frame.as_ref()) {
+            (true, Some(ids), Some(frame)) => Some(self.build_cycle_key(ids, frame)),
+            _ => None,
+        };
+        if resolved_through_cycle && cycle_key.is_none() {
+            // Leave both caches untouched, as before.
+        } else if !resolved_through_cycle && is_pure {
Relevance

●●● Strong

Clear, repeated precedent to rewrite comments to avoid historical phrasing (“used to/as before”) per
style/compliance.

PR-#13594
PR-#13575

ⓘ Recommendations generated based on similar findings in past PRs

Evidence
PR Compliance ID 772199 forbids inline comments that reference past behavior using phrases like `as
before or used to`. The cited additions include exactly this kind of historical wording—one
comment uses as before/exactly as before, and another states that the cache used to hold only
full-subtree verdicts—directly matching the prohibited pattern and demonstrating the violation.

Rule 772199: Comments must describe current behavior, not historical implementations
pnpm/crates/resolving-deps-resolver/src/resolve_peers/walker.rs[949-957]
pnpm/crates/resolving-deps-resolver/src/resolve_peers/cache.rs[150-152]

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

## Issue description
Newly added inline comments describe behavior in terms of prior implementations (e.g., `as before`, `exactly as before`, `used to hold`) rather than documenting the current behavior and contract. Update these comments so they stand on their own, remain accurate over time, and only describe the present intended behavior.

## Issue Context
Inline comments should remain correct even if earlier implementations are forgotten or refactored; historical/migration details should be captured in PR descriptions or design docs, not embedded in code comments.

## Fix Focus Areas
- pnpm/crates/resolving-deps-resolver/src/resolve_peers/walker.rs[949-957]
- pnpm/crates/resolving-deps-resolver/src/resolve_peers/cache.rs[150-152]

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


3. Cycle hits skip fast-path 🐞 Bug ➹ Performance
Description
find_fast_hit_for_lazy filters out all cycle-keyed cache items, so even when a cycle-truncated
verdict is reusable it cannot hit the early has_no_locked_peers() fast path and instead pays extra
work before the later find_hit can return. In cycle-heavy graphs (this PR’s target), this
increases hot-path CPU and reduces the realized speedup from caching cycle verdicts.
Code

pnpm/crates/resolving-deps-resolver/src/resolve_peers/cache.rs[R388-391]

+            // Keyed entries are deliberately left to `find_hit`: this
+            // path could validate them against `parent_ids`, but it
+            // skips them to keep the fast path's matching unchanged.
+            // Skipping only loses hits, never correctness.
Relevance

●● Moderate

Perf win plausible, but author intentionally avoids keyed fast-path; change affects matching logic,
may be deferred.

PR-#13855
PR-#13844

ⓘ Recommendations generated based on similar findings in past PRs

Evidence
The new code explicitly excludes keyed entries from find_fast_hit_for_lazy, and resolve_node
invokes that fast-hit path before doing additional work and only later attempts the full find_hit
path where keyed entries can match.

pnpm/crates/resolving-deps-resolver/src/resolve_peers/cache.rs[381-397]
pnpm/crates/resolving-deps-resolver/src/resolve_peers/walker.rs[679-716]

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

### Issue description
`find_fast_hit_for_lazy` deliberately skips `PeersCacheItem`s with `cycle_key`, which prevents cycle-verdict reuse from benefiting from the early `has_no_locked_peers()` fast path. This means reusable cycle cache entries are only discovered later (via `find_hit`) after extra per-node work.

### Issue Context
A fast-hit happens before `resolve_node` pushes a consulted frame and before provider preview/ref building. When keyed entries are skipped, those steps are still executed even if the eventual result is a cache hit.

### Fix Focus Areas
- pnpm/crates/resolving-deps-resolver/src/resolve_peers/cache.rs[381-397]
- pnpm/crates/resolving-deps-resolver/src/resolve_peers/walker.rs[679-716]

### Suggested fix
- Teach `find_fast_hit_for_lazy` to consider `cycle_key` entries by validating the key against the available `parent_ids` (the node is `Lazy` here, so `parent_ids` exist).
- Keep the fast-path cheap by ordering checks as:
 1) do the existing fast parent-context matching (`fast_cache_item_matches`), then
 2) if `item.cycle_key.is_some()`, validate `key.matches(parent_ids, &self.consulted_bit_by_pkg)`.
- Add/adjust a unit test to cover a no-locked-peers node where only a cycle-keyed cache item matches, ensuring the fast path returns it.

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


View review recommended (2)
4. Changeset missing pnpm bump 📘 Rule violation § Compliance
Description
The new changeset only declares a pacquet release and omits a required pnpm bump entry. This can
cause the pnpm release tooling to miss or misclassify the change.
Code

.changeset/cycle-verdict-cache.md[R1-3]

+---
+"pacquet": patch
+---
Relevance

●● Moderate

Mixed precedent: some PRs add required pnpm entry; others reject it for Rust-only/irrelevant pnpm
changesets.

PR-#13748
PR-#13587
PR-#12996

ⓘ Recommendations generated based on similar findings in past PRs

Evidence
PR Compliance ID 713436 requires each changeset to include an explicit pnpm entry with a valid
bump type; the added changeset front-matter lists only pacquet and omits pnpm.

Rule 713436: Explicitly declare pnpm package and correct bump type in changesets
.changeset/cycle-verdict-cache.md[1-3]

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 changeset file is missing a required `pnpm` package bump entry.

## Issue Context
Compliance requires changesets to explicitly include the `pnpm` package with a valid bump type (`patch`/`minor`/`major`).

## Fix Focus Areas
- .changeset/cycle-verdict-cache.md[1-3]

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


5. Redundant consulted edge scans 🐞 Bug ➹ Performance
Description
The new consulted-set tracking adds extra full traversals of a package’s child edge list (and may
over-mark consulted ids during provider preview), increasing per-node work and potentially reducing
cache-key reuse by making keys more specific than necessary. This overhead sits on the dependency
resolution hot path and can partially offset the PR’s intended speed/memory win on high-fanout
packages.
Code

pnpm/crates/resolving-deps-resolver/src/resolve_peers/cache.rs[R775-778]

            // for this package id — defensive empty case.
            None => Arc::new(Vec::new()),
        };
+        self.mark_realization_consulted(&pkg_id);
Relevance

●● Moderate

Extra edge scans on hot path may matter, but changing consulted tracking is semantic/risky; similar
perf refactors are mixed.

PR-#13510
PR-#13388

ⓘ Recommendations generated based on similar findings in past PRs

Evidence
The PR introduces mark_realization_consulted, which iterates the package’s children edges to mark
consulted ids; the new calls in both provider preview and child realization cause additional passes
over the same edge lists (and preview can mark more ids than it actually consults).

pnpm/crates/resolving-deps-resolver/src/resolve_peers/walker.rs[252-272]
pnpm/crates/resolving-deps-resolver/src/resolve_peers/cache.rs[657-719]
pnpm/crates/resolving-deps-resolver/src/resolve_peers/cache.rs[745-828]

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

### Issue description
`mark_realization_consulted()` iterates all child edges for `pkg_id`, but it’s currently invoked in places that already iterate the same edges (or only consult a subset), adding extra O(out_degree) passes in a hot path and potentially over-approximating the consulted set.

### Issue Context
- `preview_peer_provider_children` calls `mark_realization_consulted(&pkg_id)` even though preview logic only consults `forms_cycle` for provider edges; on a later cache hit, that inflated consulted set can unnecessarily specialize ancestor restrictions and reduce reuse.
- `realize_children_with` calls `mark_realization_consulted(&pkg_id)` and then iterates `children_spec` again to realize children.

### Fix Focus Areas
- pnpm/crates/resolving-deps-resolver/src/resolve_peers/cache.rs[657-719]
- pnpm/crates/resolving-deps-resolver/src/resolve_peers/cache.rs[745-828]
- pnpm/crates/resolving-deps-resolver/src/resolve_peers/walker.rs[252-272]

### Suggested approach
- Avoid the extra traversal by marking consulted ids during the existing edge iteration in `realize_children_with` (mark `pkg_id` once, then mark each `edge.pkg_id` as you walk `children_spec`).
- For `preview_peer_provider_children`, either:
 - mark only the edges actually consulted in preview (the provider edges that run through `forms_cycle`), or
 - delay marking and rely on the consulted set from a cache hit (if the preview’s own consultations don’t need to contribute to truncation scoping).
- Consider adding a small micro-benchmark or debug counter (behind a feature) to ensure the new consulted tracking doesn’t add an extra full-edge pass per node in steady state.

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



Informational

6. Bitset interning is O(words) 🐞 Bug ➹ Performance
Description
build_cycle_key interns ConsultedPkgs via a HashSet, which hashes and compares the full
Vec<u64> bitset (and clones it on a miss) each time a new consulted set is inserted. This makes
cycle-key construction cost proportional to the bitset length, so it’s worth profiling/optimizing if
consulted bitsets can become large in real workloads.
Code

pnpm/crates/resolving-deps-resolver/src/resolve_peers/walker.rs[307]

+            self.consulted_sets.insert(Arc::clone(&arc));
Relevance

●● Moderate

Valid potential hotspot, but optimization is speculative/complex; team sometimes rejects micro-perf
refactors without data.

PR-#13589
PR-#13844

ⓘ Recommendations generated based on similar findings in past PRs

Evidence
consulted_sets is a HashSet<Arc<ConsultedPkgs>> and is populated by cloning/inserting frames;
ConsultedPkgs derives Hash, so hashing the set requires hashing the underlying Vec<u64>
representation.

pnpm/crates/resolving-deps-resolver/src/resolve_peers/walker.rs[141-146]
pnpm/crates/resolving-deps-resolver/src/resolve_peers/walker.rs[274-311]
pnpm/crates/resolving-deps-resolver/src/resolve_peers/cache.rs[48-53]

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

### Issue description
Interning `ConsultedPkgs` into `consulted_sets` uses derived `Hash`/`Eq` over `Vec<u64>`, so lookups and inserts hash/compare the entire bitset. On an insert miss, the bitset is also cloned before insertion.

### Issue Context
This is not a correctness bug. It’s an internal performance characteristic of the new interning step on the cycle-verdict caching path.

### Fix Focus Areas
- pnpm/crates/resolving-deps-resolver/src/resolve_peers/walker.rs[277-311]
- pnpm/crates/resolving-deps-resolver/src/resolve_peers/cache.rs[48-76]
- pnpm/crates/resolving-deps-resolver/src/resolve_peers/discovery.rs[114-121]

### Suggested fix
- Profile first to confirm this shows up in cycle-heavy installs.
- If it is hot, consider one of:
 - Store a cached 64-bit fingerprint in `ConsultedPkgs` (updated in `set()`/`or()`) and implement `Hash` using that fingerprint + length, with equality as a fallback.
 - Use an interner keyed by a cheap fingerprint (hash + last-nonzero index) to avoid repeatedly hashing the full `Vec<u64>` on lookup.
 - If acceptable for the project, use a faster hasher for `consulted_sets` (internal-only structure) while keeping correctness via `Eq`.

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


7. Early chain match in cache 🐞 Bug ➹ Performance
Description
In find_hit, cycle-key matching (ancestor-chain scan + pkg→bit lookups) is performed before
parent-context checks, which can add avoidable work for rejected cycle-keyed items. This is likely a
micro-optimization but sits on a frequent lookup path.
Code

pnpm/crates/resolving-deps-resolver/src/resolve_peers/cache.rs[R268-274]

+            // A truncated verdict is only valid for an occurrence whose
+            // ancestors truncate it the same way.
+            if let Some(key) = &item.cycle_key
+                && !ancestor_ids
+                    .is_some_and(|current| key.matches(current, &self.consulted_bit_by_pkg))
+            {
+                return false;
Relevance

●● Moderate

Perf micro-reorder on hot path; team sometimes accepts hot-path optimizations but unclear if worth
churn here.

PR-#13172
PR-#13473

ⓘ Recommendations generated based on similar findings in past PRs

Evidence
The newly-added cycle_key validation runs before the existing resolved/missing peers checks, and
matches is implemented as a scan of base/appended ids with per-id lookups.

pnpm/crates/resolving-deps-resolver/src/resolve_peers/cache.rs[260-290]
pnpm/crates/resolving-deps-resolver/src/resolve_peers/cache.rs[110-136]
pnpm/crates/resolving-deps-resolver/src/resolved_tree.rs[70-121]

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

### Issue description
`find_hit` checks `CycleTruncationKey::matches` before evaluating resolved/missing peer compatibility. For entries with `cycle_key`, this can add an O(chain_len) scan even when the entry would be rejected quickly by parent-context mismatch.

### Issue Context
`CycleTruncationKey::matches` iterates `AncestorIds` and does `bit_by_pkg` lookups per id, so it’s not free. In workloads with many cycle-keyed entries under a pkg id, doing this first may increase average lookup cost.

### Fix Focus Areas
- pnpm/crates/resolving-deps-resolver/src/resolve_peers/cache.rs[260-290]
- pnpm/crates/resolving-deps-resolver/src/resolve_peers/cache.rs[110-136]
- pnpm/crates/resolving-deps-resolver/src/resolved_tree.rs[70-121]

### Suggested approach
- Reorder predicates so cheap/likely-to-fail checks run first (e.g., resolved_peers/missing_peers), and only run `key.matches(...)` once the item is otherwise a match.
- If ordering matters for correctness reasoning, add a comment and (ideally) a small benchmark/counter to validate the change improves typical workloads.

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


8. Cycle key string allocations ✓ Resolved 🐞 Bug ➹ Performance
Description
build_cycle_key constructs CycleTruncationKey.chain by allocating fresh Arc<str> values from
&str ancestor ids for each cached cycle verdict. This adds allocation/memory pressure in the same
scenarios the PR targets (cycle-heavy graphs), and a more compact representation (e.g., u32 bit ids)
could reduce it.
Code

pnpm/crates/resolving-deps-resolver/src/resolve_peers/walker.rs[R283-286]

+        for id in ids.base_ids() {
+            if consulted(&self.consulted_bit_by_pkg, id) {
+                chain.push(Arc::from(id));
+                base_len += 1;
Relevance

●● Moderate

Team accepts avoiding allocations, but switching cycle key representation (Arc<str>→bit ids) is
larger redesign.

PR-#13855
PR-#13830

ⓘ Recommendations generated based on similar findings in past PRs

Evidence
The key stores an owned chain of Arc<str>, and build_cycle_key fills it by allocating Arc<str>
from ancestor &str values; this is new, allocation-heavy behavior for cycle caching scenarios.

pnpm/crates/resolving-deps-resolver/src/resolve_peers/cache.rs[88-99]
pnpm/crates/resolving-deps-resolver/src/resolve_peers/walker.rs[277-302]

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

### Issue description
`CycleTruncationKey` stores its restricted chain as `Box<[Arc<str>]>`, and `build_cycle_key` populates it using `Arc::from(id)` for each consulted ancestor id. This allocates new string storage per cached cycle verdict.

### Issue Context
Because `consulted_bit_by_pkg` already interns pkg ids to bits, the chain could be represented more compactly as an ordered list of those `u32` bits plus the `base_len` boundary, avoiding string allocations and potentially making `matches` cheaper.

### Fix Focus Areas
- pnpm/crates/resolving-deps-resolver/src/resolve_peers/cache.rs[88-99]
- pnpm/crates/resolving-deps-resolver/src/resolve_peers/walker.rs[277-302]

### Suggested approach
- Change `CycleTruncationKey.chain` to `Box<[u32]>` (or `Vec<u32>` boxed) storing the ordered restricted chain bits.
- In `build_cycle_key`, push the bit for each consulted id instead of allocating a new `Arc<str>`.
- In `matches`, produce the current restricted-bit sequence (base then appended) and compare to stored.
- Keep `base_len` semantics identical so base/appended boundary is still part of the key.

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


Grey Divider

Context
✅ Compliance rules (platform): 26 rules

Grey Divider

Tip of the day
💡 Did you know, you can enable the Remediation agent and Qodo fixes findings in a dedicated fix PR

More tips ↗ | Customize Qodo ↗ | Qodo docs ↗

Grey Divider

Previous review results

Review updated until commit f5020a4

Results up to commit ae28bcd ⚖️ Balanced


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


Remediation recommended
1. Comment says as before ✓ Resolved 📘 Rule violation ⚙ Maintainability
Description
Newly added comments use historical phrasing (e.g., as before, exactly as before, `used to
hold`) instead of clearly stating the current intended behavior and contract. This can become stale
over time and mislead maintainers, increasing the risk of drift and confusion during future
refactors.
Code

pnpm/crates/resolving-deps-resolver/src/resolve_peers/walker.rs[R949-957]

+        // Without the occurrence's ancestor ids there is nothing to scope
+        // a truncated verdict to, so it stays uncached exactly as before.
+        let cycle_key = match (resolved_through_cycle, truncation_ids.as_ref(), frame.as_ref()) {
+            (true, Some(ids), Some(frame)) => Some(self.build_cycle_key(ids, frame)),
+            _ => None,
+        };
+        if resolved_through_cycle && cycle_key.is_none() {
+            // Leave both caches untouched, as before.
+        } else if !resolved_through_cycle && is_pure {
Relevance

●●● Strong

Clear, repeated precedent to rewrite comments to avoid historical phrasing (“used to/as before”) per
style/compliance.

PR-#13594
PR-#13575

ⓘ Recommendations generated based on similar findings in past PRs

Evidence
PR Compliance ID 772199 forbids inline comments that reference past behavior using phrases like `as
before or used to`. The cited additions include exactly this kind of historical wording—one
comment uses as before/exactly as before, and another states that the cache used to hold only
full-subtree verdicts—directly matching the prohibited pattern and demonstrating the violation.

Rule 772199: Comments must describe current behavior, not historical implementations
pnpm/crates/resolving-deps-resolver/src/resolve_peers/walker.rs[949-957]
pnpm/crates/resolving-deps-resolver/src/resolve_peers/cache.rs[150-152]

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

## Issue description
Newly added inline comments describe behavior in terms of prior implementations (e.g., `as before`, `exactly as before`, `used to hold`) rather than documenting the current behavior and contract. Update these comments so they stand on their own, remain accurate over time, and only describe the present intended behavior.

## Issue Context
Inline comments should remain correct even if earlier implementations are forgotten or refactored; historical/migration details should be captured in PR descriptions or design docs, not embedded in code comments.

## Fix Focus Areas
- pnpm/crates/resolving-deps-resolver/src/resolve_peers/walker.rs[949-957]
- pnpm/crates/resolving-deps-resolver/src/resolve_peers/cache.rs[150-152]

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


2. Changeset missing pnpm bump 📘 Rule violation § Compliance
Description
The new changeset only declares a pacquet release and omits a required pnpm bump entry. This can
cause the pnpm release tooling to miss or misclassify the change.
Code

.changeset/cycle-verdict-cache.md[R1-3]

+---
+"pacquet": patch
+---
Relevance

●● Moderate

Mixed precedent: some PRs add required pnpm entry; others reject it for Rust-only/irrelevant pnpm
changesets.

PR-#13748
PR-#13587
PR-#12996

ⓘ Recommendations generated based on similar findings in past PRs

Evidence
PR Compliance ID 713436 requires each changeset to include an explicit pnpm entry with a valid
bump type; the added changeset front-matter lists only pacquet and omits pnpm.

Rule 713436: Explicitly declare pnpm package and correct bump type in changesets
.changeset/cycle-verdict-cache.md[1-3]

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 changeset file is missing a required `pnpm` package bump entry.

## Issue Context
Compliance requires changesets to explicitly include the `pnpm` package with a valid bump type (`patch`/`minor`/`major`).

## Fix Focus Areas
- .changeset/cycle-verdict-cache.md[1-3]

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


3. Redundant consulted edge scans 🐞 Bug ➹ Performance
Description
The new consulted-set tracking adds extra full traversals of a package’s child edge list (and may
over-mark consulted ids during provider preview), increasing per-node work and potentially reducing
cache-key reuse by making keys more specific than necessary. This overhead sits on the dependency
resolution hot path and can partially offset the PR’s intended speed/memory win on high-fanout
packages.
Code

pnpm/crates/resolving-deps-resolver/src/resolve_peers/cache.rs[R775-778]

            // for this package id — defensive empty case.
            None => Arc::new(Vec::new()),
        };
+        self.mark_realization_consulted(&pkg_id);
Relevance

●● Moderate

Extra edge scans on hot path may matter, but changing consulted tracking is semantic/risky; similar
perf refactors are mixed.

PR-#13510
PR-#13388

ⓘ Recommendations generated based on similar findings in past PRs

Evidence
The PR introduces mark_realization_consulted, which iterates the package’s children edges to mark
consulted ids; the new calls in both provider preview and child realization cause additional passes
over the same edge lists (and preview can mark more ids than it actually consults).

pnpm/crates/resolving-deps-resolver/src/resolve_peers/walker.rs[252-272]
pnpm/crates/resolving-deps-resolver/src/resolve_peers/cache.rs[657-719]
pnpm/crates/resolving-deps-resolver/src/resolve_peers/cache.rs[745-828]

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

### Issue description
`mark_realization_consulted()` iterates all child edges for `pkg_id`, but it’s currently invoked in places that already iterate the same edges (or only consult a subset), adding extra O(out_degree) passes in a hot path and potentially over-approximating the consulted set.

### Issue Context
- `preview_peer_provider_children` calls `mark_realization_consulted(&pkg_id)` even though preview logic only consults `forms_cycle` for provider edges; on a later cache hit, that inflated consulted set can unnecessarily specialize ancestor restrictions and reduce reuse.
- `realize_children_with` calls `mark_realization_consulted(&pkg_id)` and then iterates `children_spec` again to realize children.

### Fix Focus Areas
- pnpm/crates/resolving-deps-resolver/src/resolve_peers/cache.rs[657-719]
- pnpm/crates/resolving-deps-resolver/src/resolve_peers/cache.rs[745-828]
- pnpm/crates/resolving-deps-resolver/src/resolve_peers/walker.rs[252-272]

### Suggested approach
- Avoid the extra traversal by marking consulted ids during the existing edge iteration in `realize_children_with` (mark `pkg_id` once, then mark each `edge.pkg_id` as you walk `children_spec`).
- For `preview_peer_provider_children`, either:
 - mark only the edges actually consulted in preview (the provider edges that run through `forms_cycle`), or
 - delay marking and rely on the consulted set from a cache hit (if the preview’s own consultations don’t need to contribute to truncation scoping).
- Consider adding a small micro-benchmark or debug counter (behind a feature) to ensure the new consulted tracking doesn’t add an extra full-edge pass per node in steady state.

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



Informational
4. Early chain match in cache 🐞 Bug ➹ Performance
Description
In find_hit, cycle-key matching (ancestor-chain scan + pkg→bit lookups) is performed before
parent-context checks, which can add avoidable work for rejected cycle-keyed items. This is likely a
micro-optimization but sits on a frequent lookup path.
Code

pnpm/crates/resolving-deps-resolver/src/resolve_peers/cache.rs[R268-274]

+            // A truncated verdict is only valid for an occurrence whose
+            // ancestors truncate it the same way.
+            if let Some(key) = &item.cycle_key
+                && !ancestor_ids
+                    .is_some_and(|current| key.matches(current, &self.consulted_bit_by_pkg))
+            {
+                return false;
Relevance

●● Moderate

Perf micro-reorder on hot path; team sometimes accepts hot-path optimizations but unclear if worth
churn here.

PR-#13172
PR-#13473

ⓘ Recommendations generated based on similar findings in past PRs

Evidence
The newly-added cycle_key validation runs before the existing resolved/missing peers checks, and
matches is implemented as a scan of base/appended ids with per-id lookups.

pnpm/crates/resolving-deps-resolver/src/resolve_peers/cache.rs[260-290]
pnpm/crates/resolving-deps-resolver/src/resolve_peers/cache.rs[110-136]
pnpm/crates/resolving-deps-resolver/src/resolved_tree.rs[70-121]

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

### Issue description
`find_hit` checks `CycleTruncationKey::matches` before evaluating resolved/missing peer compatibility. For entries with `cycle_key`, this can add an O(chain_len) scan even when the entry would be rejected quickly by parent-context mismatch.

### Issue Context
`CycleTruncationKey::matches` iterates `AncestorIds` and does `bit_by_pkg` lookups per id, so it’s not free. In workloads with many cycle-keyed entries under a pkg id, doing this first may increase average lookup cost.

### Fix Focus Areas
- pnpm/crates/resolving-deps-resolver/src/resolve_peers/cache.rs[260-290]
- pnpm/crates/resolving-deps-resolver/src/resolve_peers/cache.rs[110-136]
- pnpm/crates/resolving-deps-resolver/src/resolved_tree.rs[70-121]

### Suggested approach
- Reorder predicates so cheap/likely-to-fail checks run first (e.g., resolved_peers/missing_peers), and only run `key.matches(...)` once the item is otherwise a match.
- If ordering matters for correctness reasoning, add a comment and (ideally) a small benchmark/counter to validate the change improves typical workloads.

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


5. Cycle key string allocations ✓ Resolved 🐞 Bug ➹ Performance
Description
build_cycle_key constructs CycleTruncationKey.chain by allocating fresh Arc<str> values from
&str ancestor ids for each cached cycle verdict. This adds allocation/memory pressure in the same
scenarios the PR targets (cycle-heavy graphs), and a more compact representation (e.g., u32 bit ids)
could reduce it.
Code

pnpm/crates/resolving-deps-resolver/src/resolve_peers/walker.rs[R283-286]

+        for id in ids.base_ids() {
+            if consulted(&self.consulted_bit_by_pkg, id) {
+                chain.push(Arc::from(id));
+                base_len += 1;
Relevance

●● Moderate

Team accepts avoiding allocations, but switching cycle key representation (Arc<str>→bit ids) is
larger redesign.

PR-#13855
PR-#13830

ⓘ Recommendations generated based on similar findings in past PRs

Evidence
The key stores an owned chain of Arc<str>, and build_cycle_key fills it by allocating Arc<str>
from ancestor &str values; this is new, allocation-heavy behavior for cycle caching scenarios.

pnpm/crates/resolving-deps-resolver/src/resolve_peers/cache.rs[88-99]
pnpm/crates/resolving-deps-resolver/src/resolve_peers/walker.rs[277-302]

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

### Issue description
`CycleTruncationKey` stores its restricted chain as `Box<[Arc<str>]>`, and `build_cycle_key` populates it using `Arc::from(id)` for each consulted ancestor id. This allocates new string storage per cached cycle verdict.

### Issue Context
Because `consulted_bit_by_pkg` already interns pkg ids to bits, the chain could be represented more compactly as an ordered list of those `u32` bits plus the `base_len` boundary, avoiding string allocations and potentially making `matches` cheaper.

### Fix Focus Areas
- pnpm/crates/resolving-deps-resolver/src/resolve_peers/cache.rs[88-99]
- pnpm/crates/resolving-deps-resolver/src/resolve_peers/walker.rs[277-302]

### Suggested approach
- Change `CycleTruncationKey.chain` to `Box<[u32]>` (or `Vec<u32>` boxed) storing the ordered restricted chain bits.
- In `build_cycle_key`, push the bit for each consulted id instead of allocating a new `Arc<str>`.
- In `matches`, produce the current restricted-bit sequence (base then appended) and compare to stored.
- Keep `base_len` semantics identical so base/appended boundary is still part of the key.

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


Results up to commit 8990508 ⚖️ Balanced


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


Remediation recommended
1. Cycle hits skip fast-path 🐞 Bug ➹ Performance
Description
find_fast_hit_for_lazy filters out all cycle-keyed cache items, so even when a cycle-truncated
verdict is reusable it cannot hit the early has_no_locked_peers() fast path and instead pays extra
work before the later find_hit can return. In cycle-heavy graphs (this PR’s target), this
increases hot-path CPU and reduces the realized speedup from caching cycle verdicts.
Code

pnpm/crates/resolving-deps-resolver/src/resolve_peers/cache.rs[R388-391]

+            // Keyed entries are deliberately left to `find_hit`: this
+            // path could validate them against `parent_ids`, but it
+            // skips them to keep the fast path's matching unchanged.
+            // Skipping only loses hits, never correctness.
Relevance

●● Moderate

Perf win plausible, but author intentionally avoids keyed fast-path; change affects matching logic,
may be deferred.

PR-#13855
PR-#13844

ⓘ Recommendations generated based on similar findings in past PRs

Evidence
The new code explicitly excludes keyed entries from find_fast_hit_for_lazy, and resolve_node
invokes that fast-hit path before doing additional work and only later attempts the full find_hit
path where keyed entries can match.

pnpm/crates/resolving-deps-resolver/src/resolve_peers/cache.rs[381-397]
pnpm/crates/resolving-deps-resolver/src/resolve_peers/walker.rs[679-716]

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

### Issue description
`find_fast_hit_for_lazy` deliberately skips `PeersCacheItem`s with `cycle_key`, which prevents cycle-verdict reuse from benefiting from the early `has_no_locked_peers()` fast path. This means reusable cycle cache entries are only discovered later (via `find_hit`) after extra per-node work.

### Issue Context
A fast-hit happens before `resolve_node` pushes a consulted frame and before provider preview/ref building. When keyed entries are skipped, those steps are still executed even if the eventual result is a cache hit.

### Fix Focus Areas
- pnpm/crates/resolving-deps-resolver/src/resolve_peers/cache.rs[381-397]
- pnpm/crates/resolving-deps-resolver/src/resolve_peers/walker.rs[679-716]

### Suggested fix
- Teach `find_fast_hit_for_lazy` to consider `cycle_key` entries by validating the key against the available `parent_ids` (the node is `Lazy` here, so `parent_ids` exist).
- Keep the fast-path cheap by ordering checks as:
 1) do the existing fast parent-context matching (`fast_cache_item_matches`), then
 2) if `item.cycle_key.is_some()`, validate `key.matches(parent_ids, &self.consulted_bit_by_pkg)`.
- Add/adjust a unit test to cover a no-locked-peers node where only a cycle-keyed cache item matches, ensuring the fast path returns it.

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



Informational
2. Bitset interning is O(words) 🐞 Bug ➹ Performance
Description
build_cycle_key interns ConsultedPkgs via a HashSet, which hashes and compares the full
Vec<u64> bitset (and clones it on a miss) each time a new consulted set is inserted. This makes
cycle-key construction cost proportional to the bitset length, so it’s worth profiling/optimizing if
consulted bitsets can become large in real workloads.
Code

pnpm/crates/resolving-deps-resolver/src/resolve_peers/walker.rs[307]

+            self.consulted_sets.insert(Arc::clone(&arc));
Relevance

●● Moderate

Valid potential hotspot, but optimization is speculative/complex; team sometimes rejects micro-perf
refactors without data.

PR-#13589
PR-#13844

ⓘ Recommendations generated based on similar findings in past PRs

Evidence
consulted_sets is a HashSet<Arc<ConsultedPkgs>> and is populated by cloning/inserting frames;
ConsultedPkgs derives Hash, so hashing the set requires hashing the underlying Vec<u64>
representation.

pnpm/crates/resolving-deps-resolver/src/resolve_peers/walker.rs[141-146]
pnpm/crates/resolving-deps-resolver/src/resolve_peers/walker.rs[274-311]
pnpm/crates/resolving-deps-resolver/src/resolve_peers/cache.rs[48-53]

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

### Issue description
Interning `ConsultedPkgs` into `consulted_sets` uses derived `Hash`/`Eq` over `Vec<u64>`, so lookups and inserts hash/compare the entire bitset. On an insert miss, the bitset is also cloned before insertion.

### Issue Context
This is not a correctness bug. It’s an internal performance characteristic of the new interning step on the cycle-verdict caching path.

### Fix Focus Areas
- pnpm/crates/resolving-deps-resolver/src/resolve_peers/walker.rs[277-311]
- pnpm/crates/resolving-deps-resolver/src/resolve_peers/cache.rs[48-76]
- pnpm/crates/resolving-deps-resolver/src/resolve_peers/discovery.rs[114-121]

### Suggested fix
- Profile first to confirm this shows up in cycle-heavy installs.
- If it is hot, consider one of:
 - Store a cached 64-bit fingerprint in `ConsultedPkgs` (updated in `set()`/`or()`) and implement `Hash` using that fingerprint + length, with equality as a fallback.
 - Use an interner keyed by a cheap fingerprint (hash + last-nonzero index) to avoid repeatedly hashing the full `Vec<u64>` on lookup.
 - If acceptable for the project, use a faster hasher for `consulted_sets` (internal-only structure) while keeping correctness via `Eq`.

ⓘ 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.

- The fast-path comment claimed no ancestor chain exists there; it does
  — `parent_ids` is the same pre-realization chain `resolve_node`
  captures. Skipping keyed entries is a deliberate scope choice that
  only loses hits, and the comment now says so.
- `build_cycle_key` allocated a fresh `Arc<str>` per consulted chain
  entry when the bit index already owns one — `get_key_value` shares it
  — and the set interner cloned the frame twice on a miss. Keying the
  interner as a `HashSet<Arc<ConsultedPkgs>>` (lookup through
  `Borrow<ConsultedPkgs>`) gets a miss down to one clone and a hit to
  none.
- `keyed_item` hardcoded `base_len = 0`, leaving mixed base/appended
  keys — which `build_cycle_key` produces whenever a consulted id sits
  in the dependency walk's base half — untested. The helper now takes
  the split, and `a_mixed_base_and_appended_key_pins_the_boundary`
  covers both directions of the boundary.
- Dropped the test doc comment that restated the assertions.

Output verified unchanged: same lockfile byte for byte, peak RSS still
~1.4 GB on the #13681 workload.
Copilot AI review requested due to automatic review settings August 12, 2026 11:39

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 Aug 12, 2026

Copy link
Copy Markdown
Member Author

All three review points addressed in 8990508:

Fast-path comment corrected. You are right that parent_ids is in scope and is exactly the pre-realization chain resolve_node captures as truncation_ids — the comment claimed no chain exists, which was false. It now states what is true: keyed entries are deliberately left to find_hit to keep this PR's fast-path matching unchanged, and skipping only loses hits. Extending the fast paths to validate keyed entries is the natural follow-up once this lands; agreed on keeping it out of scope here.

base_len > 0 boundary covered. keyed_item now takes the base/appended split, and a_mixed_base_and_appended_key_pins_the_boundary checks a mixed key matches the same split padded with unconsulted noise on both halves, and refuses the same ids entirely-appended and entirely-base.

Both allocation nits fixed. The chain now shares the bit index's Arc<str> via get_key_value instead of allocating per entry, and the interner became a HashSet<Arc<ConsultedPkgs>> — lookup borrows through Borrow<ConsultedPkgs>, so a hit clones nothing and a miss clones the frame once.

Verified unchanged behaviour: 329 tests pass, and the #13681 workload produces a byte-identical lockfile at the same ~1.4 GB peak.

greptile-apps[bot]
greptile-apps Bot previously approved these changes Aug 12, 2026
@qodo-code-review

Copy link
Copy Markdown

Code review by qodo was updated up to the latest commit 8990508

@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.

@github-actions

Copy link
Copy Markdown
Contributor

Integrated-Benchmark Report (Linux)

Commit: 8990508957f5

Regular scenarios report direct and pnpr installs. The peer-heavy resolver scenario compares current Rust, main Rust, and TypeScript pnpm. Bencher consumes pacquet@HEAD and pnpr@HEAD.

The tables below show mean ± σ; Bencher thresholds on the minimum latency, which is far less perturbed by shared-runner contention (noise only adds time).

Scenario: Isolated linker: fresh restore, cold cache + cold store

Command Mean [s] Min [s] Max [s] Relative
pacquet@HEAD 2.539 ± 0.177 2.355 2.781 1.72 ± 0.19
pacquet@main 2.482 ± 0.151 2.356 2.771 1.68 ± 0.17
pnpr@HEAD 1.479 ± 0.123 1.357 1.720 1.00
pnpr@main 1.506 ± 0.172 1.358 1.806 1.02 ± 0.14
BENCHMARK_REPORT.json
{
  "results": [
    {
      "command": "pacquet@HEAD",
      "mean": 2.5385175738399997,
      "stddev": 0.1769960046967517,
      "median": 2.47046723554,
      "user": 1.5704387199999998,
      "system": 1.3017284999999996,
      "min": 2.35457605104,
      "max": 2.78132338204,
      "times": [
        2.36846702004,
        2.41358473304,
        2.74665724304,
        2.66373005204,
        2.37717243204,
        2.52734973804,
        2.35457605104,
        2.78132338204,
        2.40786772704,
        2.74444736004
      ]
    },
    {
      "command": "pacquet@main",
      "mean": 2.4819060194399998,
      "stddev": 0.15116202855896227,
      "median": 2.4301380980400005,
      "user": 1.55086832,
      "system": 1.3431959,
      "min": 2.35638793604,
      "max": 2.77059522904,
      "times": [
        2.36871283204,
        2.38286028404,
        2.4445692930400003,
        2.36014399604,
        2.73158718704,
        2.77059522904,
        2.35638793604,
        2.51272708504,
        2.47576944904,
        2.4157069030400002
      ]
    },
    {
      "command": "pnpr@HEAD",
      "mean": 1.4793338228400001,
      "stddev": 0.12293143540640086,
      "median": 1.43325185554,
      "user": 1.04963062,
      "system": 1.1964244999999998,
      "min": 1.3571634870400002,
      "max": 1.7201813080400001,
      "times": [
        1.42248991704,
        1.3627466510400001,
        1.60173474204,
        1.3571634870400002,
        1.4034894430400002,
        1.51261782504,
        1.4440137940400002,
        1.3769556600400001,
        1.7201813080400001,
        1.5919454010400003
      ]
    },
    {
      "command": "pnpr@main",
      "mean": 1.5056082670400002,
      "stddev": 0.17237876472689678,
      "median": 1.4156702980400002,
      "user": 1.0823826200000002,
      "system": 1.1653497999999998,
      "min": 1.35841462904,
      "max": 1.80634556604,
      "times": [
        1.5647667150400002,
        1.80634556604,
        1.5440306990400001,
        1.39080355804,
        1.3911721000400001,
        1.3670140530400001,
        1.39670036204,
        1.4346402340400002,
        1.8021947540400003,
        1.35841462904
      ]
    }
  ]
}

Scenario: Isolated linker: fresh restore, hot cache + hot store

Command Mean [ms] Min [ms] Max [ms] Relative
pacquet@HEAD 263.1 ± 5.8 255.6 274.1 1.04 ± 0.04
pacquet@main 253.2 ± 7.2 243.0 265.1 1.00
pnpr@HEAD 269.6 ± 9.6 249.2 281.1 1.06 ± 0.05
pnpr@main 273.5 ± 11.6 259.4 302.0 1.08 ± 0.06
BENCHMARK_REPORT.json
{
  "results": [
    {
      "command": "pacquet@HEAD",
      "mean": 0.26309396726,
      "stddev": 0.005846213168925492,
      "median": 0.26256758666,
      "user": 0.22249433999999998,
      "system": 0.5261377,
      "min": 0.25558967716000003,
      "max": 0.27410553916,
      "times": [
        0.25558967716000003,
        0.26911584016,
        0.26430132016,
        0.26070282616,
        0.26647139916,
        0.25810180816,
        0.27410553916,
        0.25666543816000004,
        0.26083385316,
        0.26505197116
      ]
    },
    {
      "command": "pacquet@main",
      "mean": 0.25320863346,
      "stddev": 0.0071955499845934015,
      "median": 0.25305270766000004,
      "user": 0.21810944000000002,
      "system": 0.5167166,
      "min": 0.24300370916000003,
      "max": 0.26513795316000005,
      "times": [
        0.25677961216,
        0.25546170516000005,
        0.25802427116000004,
        0.26091777116000003,
        0.24300370916000003,
        0.25064371016000003,
        0.24475019116000002,
        0.24860989716000004,
        0.26513795316000005,
        0.24875751416000003
      ]
    },
    {
      "command": "pnpr@HEAD",
      "mean": 0.26962309926000005,
      "stddev": 0.009597963700450235,
      "median": 0.27104636816000005,
      "user": 0.22113724,
      "system": 0.5306225,
      "min": 0.24918368416000003,
      "max": 0.28106781516,
      "times": [
        0.28056445916,
        0.28106781516,
        0.24918368416000003,
        0.26507550616000003,
        0.26509488216000004,
        0.27618485716,
        0.27208879716,
        0.27000393916000004,
        0.27429556616,
        0.26267148616
      ]
    },
    {
      "command": "pnpr@main",
      "mean": 0.27348659176000006,
      "stddev": 0.01159092130781376,
      "median": 0.27018258066,
      "user": 0.21556084000000003,
      "system": 0.5526660999999999,
      "min": 0.25939055016,
      "max": 0.30202967616000004,
      "times": [
        0.25939055016,
        0.26953130116,
        0.26608730716,
        0.30202967616000004,
        0.27234091216,
        0.28281448916,
        0.27009848716,
        0.26968917816000004,
        0.27026667416000005,
        0.27261734216000005
      ]
    }
  ]
}

Scenario: Isolated linker: fresh install, cold cache + cold store

Command Mean [s] Min [s] Max [s] Relative
pacquet@HEAD 2.737 ± 0.025 2.702 2.783 1.73 ± 0.15
pacquet@main 2.720 ± 0.018 2.690 2.748 1.72 ± 0.15
pnpr@HEAD 1.630 ± 0.169 1.436 1.859 1.03 ± 0.14
pnpr@main 1.578 ± 0.135 1.426 1.857 1.00
BENCHMARK_REPORT.json
{
  "results": [
    {
      "command": "pacquet@HEAD",
      "mean": 2.7366620720600006,
      "stddev": 0.025116547474073006,
      "median": 2.7362657871600002,
      "user": 1.5529059799999998,
      "system": 1.3664157399999994,
      "min": 2.7016087191600002,
      "max": 2.7829187231600003,
      "times": [
        2.7465495321600004,
        2.7089749861600003,
        2.74404507416,
        2.7016087191600002,
        2.7350298491600005,
        2.7183814061600002,
        2.7668476541600002,
        2.7829187231600003,
        2.7247630511600005,
        2.73750172516
      ]
    },
    {
      "command": "pacquet@main",
      "mean": 2.72007410356,
      "stddev": 0.018050067192249067,
      "median": 2.7244677411600002,
      "user": 1.5564244799999998,
      "system": 1.3347261399999997,
      "min": 2.68969522616,
      "max": 2.7476005771600005,
      "times": [
        2.71678737016,
        2.7223773271600002,
        2.7346661551600002,
        2.7267730691600005,
        2.72655815516,
        2.73230399516,
        2.68969522616,
        2.7476005771600005,
        2.6938644131600005,
        2.71011474716
      ]
    },
    {
      "command": "pnpr@HEAD",
      "mean": 1.6302741390599997,
      "stddev": 0.16910685384950846,
      "median": 1.62291859016,
      "user": 1.0905812799999999,
      "system": 1.1243600399999998,
      "min": 1.43560668316,
      "max": 1.85864401116,
      "times": [
        1.43629800316,
        1.8371097701599999,
        1.67310521216,
        1.43560668316,
        1.73088534816,
        1.7920887971600001,
        1.57273196816,
        1.5160495651600001,
        1.45022203216,
        1.85864401116
      ]
    },
    {
      "command": "pnpr@main",
      "mean": 1.5780056247600003,
      "stddev": 0.13470574101842436,
      "median": 1.5675885536599998,
      "user": 1.03838808,
      "system": 1.1844312399999997,
      "min": 1.42586737116,
      "max": 1.8567461951600002,
      "times": [
        1.8567461951600002,
        1.46236994316,
        1.64523389416,
        1.5111480501599999,
        1.45209845616,
        1.62402905716,
        1.48584311516,
        1.67744950916,
        1.42586737116,
        1.6392706561600001
      ]
    }
  ]
}

Scenario: Isolated linker: fresh install, hot cache + hot store

Command Mean [ms] Min [ms] Max [ms] Relative
pacquet@HEAD 425.7 ± 11.5 412.4 445.9 1.39 ± 0.04
pacquet@main 426.4 ± 13.6 409.4 454.6 1.39 ± 0.05
pnpr@HEAD 307.2 ± 5.3 297.3 314.0 1.00
pnpr@main 310.0 ± 6.5 301.4 319.6 1.01 ± 0.03
BENCHMARK_REPORT.json
{
  "results": [
    {
      "command": "pacquet@HEAD",
      "mean": 0.42565864248,
      "stddev": 0.01147991390722532,
      "median": 0.42383690268,
      "user": 0.5466106,
      "system": 0.6659459,
      "min": 0.41236612618,
      "max": 0.44585502418,
      "times": [
        0.41855208318000003,
        0.42285063418,
        0.44585502418,
        0.41819657518000003,
        0.42598867218,
        0.42817179518000004,
        0.42482317118,
        0.44479903818000005,
        0.41236612618,
        0.41498330518000004
      ]
    },
    {
      "command": "pacquet@main",
      "mean": 0.42644536068,
      "stddev": 0.013580286094915206,
      "median": 0.42205570868000003,
      "user": 0.5382541,
      "system": 0.680856,
      "min": 0.40944832218000005,
      "max": 0.45461248418000005,
      "times": [
        0.42119455918000004,
        0.41403834818,
        0.41631441718,
        0.42178251518000004,
        0.43995767818000003,
        0.40944832218000005,
        0.43152623018,
        0.42232890218,
        0.43325015018,
        0.45461248418000005
      ]
    },
    {
      "command": "pnpr@HEAD",
      "mean": 0.30719950358000003,
      "stddev": 0.005306211920721491,
      "median": 0.30684354468,
      "user": 0.2070998,
      "system": 0.5399684,
      "min": 0.29725120918000003,
      "max": 0.31398241818,
      "times": [
        0.29725120918000003,
        0.30576615418,
        0.31294177218,
        0.30792093518,
        0.31098706718,
        0.30413997718,
        0.31398241818,
        0.30484905018,
        0.31174820918,
        0.30240824318000004
      ]
    },
    {
      "command": "pnpr@main",
      "mean": 0.31002024188,
      "stddev": 0.006542539392692355,
      "median": 0.30859812768000006,
      "user": 0.2139819,
      "system": 0.5387340999999999,
      "min": 0.30141486518,
      "max": 0.31960986618000004,
      "times": [
        0.30141486518,
        0.30739506518000004,
        0.30980119018,
        0.31195481818000004,
        0.30334390218,
        0.31731355918000004,
        0.31830207718000003,
        0.30455067018000004,
        0.31960986618000004,
        0.30651640518
      ]
    }
  ]
}

Scenario: Isolated linker: fresh install, cold cache + hot store

Command Mean [s] Min [s] Max [s] Relative
pacquet@HEAD 1.878 ± 0.006 1.867 1.888 6.22 ± 0.16
pacquet@main 1.873 ± 0.019 1.843 1.897 6.20 ± 0.17
pnpr@HEAD 0.302 ± 0.008 0.293 0.311 1.00
pnpr@main 0.306 ± 0.005 0.298 0.319 1.01 ± 0.03
BENCHMARK_REPORT.json
{
  "results": [
    {
      "command": "pacquet@HEAD",
      "mean": 1.87838966858,
      "stddev": 0.006473661737919479,
      "median": 1.87813605688,
      "user": 0.7276341599999998,
      "system": 0.80106262,
      "min": 1.8672732488800001,
      "max": 1.8883366598800002,
      "times": [
        1.87980530488,
        1.88054324188,
        1.8672732488800001,
        1.8847776508800003,
        1.87646680888,
        1.8742577268800003,
        1.8754182188800002,
        1.8883366598800002,
        1.87228072088,
        1.88473710388
      ]
    },
    {
      "command": "pacquet@main",
      "mean": 1.87282051938,
      "stddev": 0.018836301455814542,
      "median": 1.8755846358800001,
      "user": 0.7201130599999999,
      "system": 0.8172625200000001,
      "min": 1.8431961118800002,
      "max": 1.8966675888800002,
      "times": [
        1.85132248688,
        1.89236904988,
        1.8829583208800003,
        1.8735253898800002,
        1.86113793588,
        1.85690694388,
        1.8966675888800002,
        1.87764388188,
        1.8431961118800002,
        1.89247748388
      ]
    },
    {
      "command": "pnpr@HEAD",
      "mean": 0.30207450948000003,
      "stddev": 0.007543221277501779,
      "median": 0.30137531888,
      "user": 0.20842685999999996,
      "system": 0.52696842,
      "min": 0.29312401988000003,
      "max": 0.31148032488,
      "times": [
        0.29597390688,
        0.30909986988,
        0.31148032488,
        0.30804886388,
        0.31113752988000004,
        0.30478596188,
        0.29312401988000003,
        0.29796467588000003,
        0.29354327588,
        0.29558666588
      ]
    },
    {
      "command": "pnpr@main",
      "mean": 0.30644476758000005,
      "stddev": 0.00542185326151491,
      "median": 0.30633932188,
      "user": 0.19240696,
      "system": 0.5578378199999998,
      "min": 0.29788493488,
      "max": 0.31912003188000004,
      "times": [
        0.30273020288,
        0.30768001688,
        0.30613900988000003,
        0.29788493488,
        0.30572040388,
        0.30789220588,
        0.31912003188000004,
        0.30310327588,
        0.30763795988000003,
        0.30653963388
      ]
    }
  ]
}

Scenario: Isolated linker: fresh resolve, hot cache, offline

Command Mean [ms] Min [ms] Max [ms] Relative
pacquet@HEAD 212.9 ± 18.7 188.4 246.0 2.43 ± 0.22
pacquet@main 219.8 ± 11.2 199.0 237.3 2.51 ± 0.13
pnpr@HEAD 87.7 ± 1.8 84.7 92.0 1.00 ± 0.02
pnpr@main 87.6 ± 1.2 85.9 91.3 1.00
BENCHMARK_REPORT.json
{
  "results": [
    {
      "command": "pacquet@HEAD",
      "mean": 0.2128778216830769,
      "stddev": 0.018725215547827165,
      "median": 0.21422184876,
      "user": 0.1505569892307692,
      "system": 0.061038426153846144,
      "min": 0.18840970876000002,
      "max": 0.24596981476000002,
      "times": [
        0.21422184876,
        0.24596981476000002,
        0.24270900576,
        0.18840970876000002,
        0.19456916876000002,
        0.19001052976000002,
        0.19353741976000002,
        0.22526131876000002,
        0.21536056876,
        0.21724821676,
        0.21220055976000002,
        0.20374508576,
        0.22416843576
      ]
    },
    {
      "command": "pacquet@main",
      "mean": 0.21983257726,
      "stddev": 0.011247414638817026,
      "median": 0.22164036826,
      "user": 0.16096021999999996,
      "system": 0.05832850857142856,
      "min": 0.19898815476,
      "max": 0.23733527476000002,
      "times": [
        0.19898815476,
        0.21950466876000002,
        0.23123163176,
        0.22379021476000002,
        0.22377606776,
        0.23282086876000002,
        0.22795087476,
        0.21224160676,
        0.21442305676,
        0.22427171976000002,
        0.20237171376000002,
        0.23733527476000002,
        0.21888993276000002,
        0.21006029576000002
      ]
    },
    {
      "command": "pnpr@HEAD",
      "mean": 0.08773053539636363,
      "stddev": 0.001818260637874695,
      "median": 0.08749455176000001,
      "user": 0.02163858363636363,
      "system": 0.009120484242424245,
      "min": 0.08467020376,
      "max": 0.09195740076,
      "times": [
        0.08505840276,
        0.08698994376000001,
        0.08826463876,
        0.08688079876,
        0.08907160576,
        0.08500050376,
        0.08749455176000001,
        0.08575492276,
        0.08900793676,
        0.08873824976,
        0.08897259976,
        0.08753261376,
        0.08969689076000001,
        0.08594139276,
        0.08804142976,
        0.08589043776000001,
        0.08928181176000001,
        0.09099208776,
        0.08710027076,
        0.08500936076,
        0.08875021276,
        0.08718159376000001,
        0.08645730276000001,
        0.08710242476,
        0.08682524476,
        0.08851753476,
        0.08467020376,
        0.08715183776,
        0.09065628576000001,
        0.09024071376000001,
        0.08809699476,
        0.09195740076,
        0.08677946776
      ]
    },
    {
      "command": "pnpr@main",
      "mean": 0.08755373260848487,
      "stddev": 0.0012074230959532978,
      "median": 0.08732360076000001,
      "user": 0.02043894727272727,
      "system": 0.01033158,
      "min": 0.08585773576,
      "max": 0.09133233576000001,
      "times": [
        0.08653018876,
        0.08728402676000001,
        0.08647212076,
        0.08719121176,
        0.08744837576,
        0.08585773576,
        0.08806016576,
        0.08882173676,
        0.09133233576000001,
        0.08682911176000001,
        0.08816307876,
        0.09060021976,
        0.08728937676000001,
        0.08748974376,
        0.08726304676,
        0.08786985876,
        0.08723454276,
        0.09009543176000001,
        0.08709254576,
        0.08623490476000001,
        0.08637375476,
        0.08776096376,
        0.08694825576000001,
        0.08755589776,
        0.08630348376000001,
        0.08827987776,
        0.08735350776,
        0.08619699276000001,
        0.08746111976,
        0.08711487776,
        0.08743106276,
        0.08732360076000001,
        0.08801002176
      ]
    }
  ]
}

Scenario: Isolated linker: peer-heavy resolve, hot cache, offline

Command Mean [ms] Min [ms] Max [ms] Relative
pacquet@HEAD 545.9 ± 102.6 440.6 772.6 1.02 ± 0.23
pacquet@main 533.2 ± 67.8 412.2 614.3 1.00
pnpm@HEAD 3031.5 ± 85.2 2925.1 3215.9 5.69 ± 0.74
BENCHMARK_REPORT.json
{
  "results": [
    {
      "command": "pacquet@HEAD",
      "mean": 0.5458601094622222,
      "stddev": 0.1025732557702177,
      "median": 0.5168127912400001,
      "user": 0.5293109733333332,
      "system": 0.10435294222222222,
      "min": 0.44064430924000003,
      "max": 0.7725894902400001,
      "times": [
        0.48512500924,
        0.7725894902400001,
        0.5550679892400001,
        0.46087626924,
        0.5168127912400001,
        0.5774788852400001,
        0.6183193222400001,
        0.48582691924000004,
        0.44064430924000003
      ]
    },
    {
      "command": "pacquet@main",
      "mean": 0.5332349315733335,
      "stddev": 0.06777027790569688,
      "median": 0.5625376302400001,
      "user": 0.5005445288888888,
      "system": 0.11032894222222221,
      "min": 0.41223593224000005,
      "max": 0.6143277482400001,
      "times": [
        0.6143277482400001,
        0.41223593224000005,
        0.5775317432400001,
        0.45421366624000004,
        0.5047129092400001,
        0.5939402862400001,
        0.5625376302400001,
        0.50918510524,
        0.57042936324
      ]
    },
    {
      "command": "pnpm@HEAD",
      "mean": 3.0315460302399995,
      "stddev": 0.08524559235095318,
      "median": 3.01972519124,
      "user": 4.64174064,
      "system": 0.2827186088888889,
      "min": 2.92506723524,
      "max": 3.21593439124,
      "times": [
        3.21593439124,
        3.08809155724,
        3.06503402724,
        3.02859727724,
        2.92506723524,
        2.99081776424,
        2.96210108524,
        2.98854574324,
        3.01972519124
      ]
    }
  ]
}

Scenario: Isolated linker: fresh restore, cold cache + cold store + cold pnpr

Command Mean [s] Min [s] Max [s] Relative
pacquet@HEAD 4.524 ± 0.150 4.419 4.896 1.27 ± 0.05
pacquet@main 4.543 ± 0.134 4.435 4.836 1.28 ± 0.05
pnpr@HEAD 3.614 ± 0.147 3.442 3.847 1.02 ± 0.05
pnpr@main 3.550 ± 0.083 3.450 3.682 1.00
BENCHMARK_REPORT.json
{
  "results": [
    {
      "command": "pacquet@HEAD",
      "mean": 4.5235329567800004,
      "stddev": 0.15006935921902773,
      "median": 4.45719434708,
      "user": 1.7411064,
      "system": 1.40301744,
      "min": 4.4190135140799995,
      "max": 4.89589780208,
      "times": [
        4.45189982808,
        4.89589780208,
        4.62933689408,
        4.46248886608,
        4.42794286808,
        4.59923518708,
        4.48466525108,
        4.43854162208,
        4.4190135140799995,
        4.42630773508
      ]
    },
    {
      "command": "pacquet@main",
      "mean": 4.542940380279999,
      "stddev": 0.13433749317111787,
      "median": 4.47368437858,
      "user": 1.7896817999999999,
      "system": 1.3629667399999998,
      "min": 4.43546577808,
      "max": 4.83612366808,
      "times": [
        4.47239983408,
        4.59534857108,
        4.60590398208,
        4.43546577808,
        4.44148694708,
        4.44112173008,
        4.44685233208,
        4.47496892308,
        4.83612366808,
        4.67973203708
      ]
    },
    {
      "command": "pnpr@HEAD",
      "mean": 3.61365417218,
      "stddev": 0.14718813006176856,
      "median": 3.6081675560799997,
      "user": 1.2119615,
      "system": 1.20977014,
      "min": 3.44233162008,
      "max": 3.84653325908,
      "times": [
        3.81521250508,
        3.6118216720799996,
        3.7235100120799998,
        3.4629151710799997,
        3.44233162008,
        3.4840554290799997,
        3.84653325908,
        3.6615987680799997,
        3.60451344008,
        3.48404984508
      ]
    },
    {
      "command": "pnpr@main",
      "mean": 3.5497577247799996,
      "stddev": 0.08339040850955814,
      "median": 3.5338581085799996,
      "user": 1.248741,
      "system": 1.3040229399999999,
      "min": 3.44978694208,
      "max": 3.6819412260799997,
      "times": [
        3.48060193408,
        3.50784035408,
        3.4740589360799996,
        3.63719479808,
        3.55987586308,
        3.64494731008,
        3.58219826308,
        3.44978694208,
        3.6819412260799997,
        3.4791316210799996
      ]
    }
  ]
}

@github-actions

Copy link
Copy Markdown
Contributor

🐰 Bencher Report

Projectpnpm's project
Branchpr/13859
Testbedpacquet
Click to view all benchmark results
BenchmarkLatencyBenchmark Result
milliseconds (ms)
(Result Δ%)
Upper Boundary
milliseconds (ms)
(Limit %)
isolated-linker.fresh-install.cold-cache.cold-store📈 view plot
🚷 view threshold
2,701.61 ms
(-0.98%)Baseline: 2,728.31 ms
3,273.97 ms
(82.52%)
isolated-linker.fresh-install.cold-cache.hot-store📈 view plot
🚷 view threshold
1,867.27 ms
(+1.35%)Baseline: 1,842.44 ms
2,210.93 ms
(84.46%)
isolated-linker.fresh-install.hot-cache.hot-store📈 view plot
🚷 view threshold
412.37 ms
(-9.93%)Baseline: 457.81 ms
549.37 ms
(75.06%)
isolated-linker.fresh-resolve.hot-cache.offline📈 view plot
🚷 view threshold
188.41 ms
(-15.89%)Baseline: 224.01 ms
268.82 ms
(70.09%)
isolated-linker.fresh-restore.cold-cache.cold-store📈 view plot
🚷 view threshold
2,354.58 ms
(-4.96%)Baseline: 2,477.47 ms
2,972.97 ms
(79.20%)
isolated-linker.fresh-restore.cold-cache.cold-store.cold-pnpr📈 view plot
🚷 view threshold
4,419.01 ms
(-2.17%)Baseline: 4,517.13 ms
5,420.56 ms
(81.52%)
isolated-linker.fresh-restore.hot-cache.hot-store📈 view plot
🚷 view threshold
255.59 ms
(-13.30%)Baseline: 294.80 ms
353.76 ms
(72.25%)
isolated-linker.peer-heavy-resolve.hot-cache.offline📈 view plot
🚷 view threshold
440.64 ms
(-34.46%)Baseline: 672.34 ms
806.80 ms
(54.62%)
🐰 View full continuous benchmarking report in Bencher

@github-actions

Copy link
Copy Markdown
Contributor

🐰 Bencher Report

Projectpnpm's project
Branchpr/13859
Testbedpnpr

⚠️ WARNING: No Threshold found!

Without a Threshold, no Alerts will ever be generated.

Click here to create a new Threshold
For more information, see the Threshold documentation.
To only post results if a Threshold exists, set the --ci-only-thresholds flag.

Click to view all benchmark results
BenchmarkLatencymilliseconds (ms)
isolated-linker.fresh-install.cold-cache.cold-store📈 view plot
⚠️ NO THRESHOLD
1,435.61 ms
isolated-linker.fresh-install.cold-cache.hot-store📈 view plot
⚠️ NO THRESHOLD
293.12 ms
isolated-linker.fresh-install.hot-cache.hot-store📈 view plot
⚠️ NO THRESHOLD
297.25 ms
isolated-linker.fresh-resolve.hot-cache.offline📈 view plot
⚠️ NO THRESHOLD
84.67 ms
isolated-linker.fresh-restore.cold-cache.cold-store📈 view plot
⚠️ NO THRESHOLD
1,357.16 ms
isolated-linker.fresh-restore.cold-cache.cold-store.cold-pnpr📈 view plot
⚠️ NO THRESHOLD
3,442.33 ms
isolated-linker.fresh-restore.hot-cache.hot-store📈 view plot
⚠️ NO THRESHOLD
249.18 ms
🐰 View full continuous benchmarking report in Bencher

… bound

The keyed matching had thorough unit coverage, but nothing guarded the
side where the dangerous bugs live: what the walk *collects*. During
development, a frame pushed after the provider preview made every key
miss the walk's own peer-provider consultations — and the entire
existing suite passed while real installs produced wrong lockfiles.
These two tests close that class.

- `one_context_keeps_both_truncations_of_a_cycle_package_apart` drives
  `resolve_peers` over a ring where the same package is cycle-truncated
  two different ways in one install: re-entered through the full lap it
  loses its `w`-consuming edge, reached under a direct entry on a later
  ring member it keeps it. A key that under-collects merges the two and
  one variant disappears from the graph — #5108 as a fixture.
  Verified failing against a key that skips the chain comparison.

- `cycle_re_walks_collapse_instead_of_multiplying_occurrences` pins the
  perf property itself, deterministically: per-entry `w` versions block
  every untruncated verdict from transferring across entries, `home`
  edges make each lap re-enter the cycle many times, and fanout under
  the transferable members gives each avoided re-walk children worth
  counting. The cached walk realizes ~2,230 occurrence nodes; with
  cycle-verdict reuse disabled it realizes ~4,360. The bound sits at
  3,000, between the two. No wall clocks, no platform noise.

Building the fixture also reproduced a resolver bug that predates this
branch: a keyless verdict recorded under a truncating chain plainly
matches a context where the subtree is intact, and a `w` variant
silently disappears. The fixture only works around it (consumers on the
odd ring members keep every keyless item context-specific); the bug is
tracked separately.

Also rewords three comments that described the change relative to the
previous behavior instead of stating the current contract.
Copilot AI review requested due to automatic review settings August 12, 2026 12:23
@greptile-apps
greptile-apps Bot dismissed their stale review August 12, 2026 12:23

Dismissed because a newer commit was pushed; Greptile will re-review the current head.

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 August 12, 2026 12:31
@greptile-apps
greptile-apps Bot dismissed their stale review August 12, 2026 12:31

Dismissed because a newer commit was pushed; Greptile will re-review the current head.

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 merged commit fef7544 into main Aug 12, 2026
29 checks passed
@zkochan
zkochan deleted the fix-13681-cycle-cache-key branch August 12, 2026 12:34
@qodo-code-review

Copy link
Copy Markdown

Code review by qodo was updated up to the latest commit f5020a4

@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 added a commit that referenced this pull request Aug 13, 2026
Break dependency cycles canonically during peer resolution: each
strongly connected component's members sort by package id and every
intra-SCC edge whose target is not canonically later is cut, the same
cut at every occurrence. The SCC becomes a DAG: no walk path revisits a
package, every peer verdict is a plain (package, context) function, and
the lockfile is identical however the walk is ordered (Closes
#13846, Closes #13865).

A cut back-edge is still a real dependency edge: it is realized against
a shared record-only occurrence of its target, walked once at importer
context by the drivers, with peer-issue emission suppressed (every real
position reports its own state). Back-edge targets nothing reaches
forward are queued from the realized-children skip so they stay in the
graph. The shared occurrences persist across peer-hoist discovery
rounds.

The #13859 cycle-truncation verdict keys had nothing left to
scope and are deleted, as is the interim hoisted-region rule this
branch previously carried. Single-importer bit fixture: 0.66 s /
0.60 GB / 9.6k walks vs main's 1.61 s / 0.82 GB / ~27k; 5-importer:
0.73 s / 0.61 GB vs 2.57 s / 0.92 GB; lockfiles 23-37% smaller and
byte-identical across runs and orderings.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

product: pacquet reviewed: coderabbit CodeRabbit submitted an approving review

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants