Skip to content

fix: honor trustPolicy in pnpm self-update, and recover from unusable cached engine slots - #12838

Merged
zkochan merged 3 commits into
mainfrom
fix-self-update
Jul 7, 2026
Merged

zkochan merged 3 commits into
mainfrom
fix-self-update

Conversation

@zkochan

@zkochan zkochan commented Jul 7, 2026 •

Copy link
Copy Markdown
Member

Summary

Two pnpm self-update fixes. The first is cross-stack (TypeScript + pacquet); the second is pacquet-only.

1. Honor trustPolicy=no-downgrade when resolving the pnpm engine

pnpm self-update resolved the target pnpm version with a self-update-specific resolver that fetched abbreviated registry metadata (which omits per-version time) and, depending on the stack, either crashed or silently skipped the no-downgrade trust check:

  • pacquet passed trustPolicy into the resolve but the resolver was hard-wired to abbreviated metadata, so the check failed closed on every self-update:
    Error:   × resolve [email protected]
      ╰─▶ trust check failed: missing time for version 12.0.0-alpha.3 of pnpm in metadata
    
  • the TypeScript CLI never passed trustPolicy into its resolve at all, so trustPolicy=no-downgrade was not enforced when picking the pnpm version.

The fix resolves the engine version the same way a regular install does, instead of special-casing self-update — derive the metadata mode from config and pass the trust policy through:

  • pacquet: added Config::requires_full_metadata_for_resolution and use it in both PickPolicy (install path) and the env-installer resolver (resolve_pnpm_version); restored trust_policy* on the resolve options. Under resolutionMode=time-based / trustPolicy=no-downgrade the probe now fetches the full packument the checks need. no-downgrade always fetches full metadata — even when registrySupportsTimeField is set — because abbreviated metadata omits the trust evidence (_npmUser/dist.attestations) the check reads, not just time.
  • TypeScript: compute fullMetadata in selfUpdate.ts (mirroring dlx) and pass fullMetadata/filterMetadata to createResolver; pass trustPolicy/trustPolicyExclude/trustPolicyIgnoreAfter into the resolve() call (self-update's resolve is its sole version selection, unlike dlx, whose real install re-resolves through the store controller).

Tests on both stacks: a trust-downgraded pnpm is rejected under no-downgrade, and a clean update still resolves. The pacquet test serves abbreviated metadata (no time) to the abbreviated Accept header, so it also proves the probe requests full metadata rather than failing closed.

2. Recover when a cached engine slot is unusable (pacquet)

pnpm self-update <= v11 aborted with:

Error:   × the installed pnpm wrapper at <slot>/node_modules/@pnpm/exe resolves outside <slot>

when an existing global @pnpm/exe slot from an older layout symlinks its wrapper outside the per-slot directory (e.g. into the shared global virtual store). On a version cache-hit, link_exe_platform_binary's containment guard rejected the wrapper and the ? aborted the whole self-update.

The cache-hit relink is now best-effort: reuse_cached_engine reports a relink failure as "not reusable", so the caller falls through to a fresh, self-contained, signature-verified install instead of aborting. The containment guard is unchanged — it still refuses to link a wrapper that escapes the slot, and nothing from the rejected slot is linked or executed.

Both errors were reproduced with the built binary and confirmed fixed. A focused security review of the diff found no newly-introduced vulnerabilities (guards preserved; fresh-install fallback is signature-verified; the no-downgrade gate is now enforced more consistently, not less).

Squash Commit Body

Two pnpm self-update fixes:

1. Honor trustPolicy=no-downgrade when resolving the pnpm engine. Both
   stacks now resolve the engine version like a regular install — deriving
   the metadata mode from config (full metadata under time-based /
   no-downgrade) and passing the trust policy into the resolve — instead of
   a self-update-specific abbreviated-metadata path. Fixes pacquet's "trust
   check failed: missing time" crash and the TypeScript CLI silently not
   enforcing the policy. pacquet centralizes the metadata decision in
   Config::requires_full_metadata_for_resolution, shared with PickPolicy.

2. (pacquet) Reinstall pnpm when a cached engine slot's wrapper resolves
   outside its slot (older global-virtual-store layout). The cache-hit
   native-binary relink is now best-effort: on the containment guard's
   refusal, fall through to a fresh signature-verified install rather than
   aborting self-update. The guard itself is unchanged.

Checklist

  • The change is implemented in both the TypeScript CLI and the Rust
    pacquet/ port, or the description notes what still needs porting.
    Fix 1 lands in both stacks. Fix 2 addresses a pacquet-only mechanism
    (the @pnpm/exe native-binary relink guard) with no TypeScript
    counterpart.
  • Added a changeset (@pnpm/engine.pm.commands + pnpm, patch) for
    the user-visible self-update trust-policy change.
  • Added or updated tests.

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

Copilot AI review requested due to automatic review settings July 7, 2026 12:31

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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

@qodo-free-for-open-source-projects

qodo-free-for-open-source-projects Bot commented Jul 7, 2026 •

Copy link
Copy Markdown

PR Summary by Qodo

fix(pacquet-cli): skip trust check when resolving pnpm engine version

🐞 Bug fix 🧪 Tests 🕐 10-20 Minutes

Grey Divider

AI Description

• Prevent pnpm self-update from failing under trustPolicy=no-downgrade.
• Stop applying resolver-time trust downgrade checks during pnpm engine version selection.
• Add regression test covering abbreviated registry metadata without per-version time.
Diagram

graph TD
  A["CLI commands"] --> B["resolve_pnpm_version"] --> C["NpmResolver.resolve"] --> D[("Bootstrap registry")]
  B --> E["minimumReleaseAge gate"]
  F["Install-time lockfile verifier"] --> D
Loading
High-Level Assessment

The following are alternative approaches to this PR:

1. Fetch full metadata for engine pick and keep trust check
  • ➕ Preserves trustPolicy=no-downgrade enforcement during version selection
  • ➕ Keeps policy semantics consistent between install-time and self-update-time decisions
  • ➖ Adds extra network round-trip and latency to self-update / auto-switch flows
  • ➖ More complex resolver path (abbreviated→full upgrade) and more failure modes
  • ➖ Would diverge from TypeScript pnpm selfUpdate.ts behavior noted in PR context
2. Defer all policy enforcement to install/verification only
  • ➕ Simplifies resolution further and avoids policy decisions on partial metadata
  • ➖ Would weaken the existing minimumReleaseAge early safety signal (currently retained)
  • ➖ Moves user feedback later in the flow, potentially after more work is done

Recommendation: Keep the PR’s approach: omit trustPolicy during pnpm engine version resolution while preserving minimumReleaseAge. This matches upstream TypeScript pnpm self-update behavior, avoids false failures on abbreviated metadata, and keeps the trust downgrade guarantee enforced where full metadata is already fetched (install-time lockfile verification).

Files changed (2) +95 / -25

Bug fix (1) +22 / -25
config_deps.rsRemove trustPolicy options from pnpm engine version resolution +22/-25

Remove trustPolicy options from pnpm engine version resolution

• Updates 'resolve_pnpm_version' to apply only the 'minimumReleaseAge' maturity gate and to intentionally skip passing 'trustPolicy'/excludes into resolver options. Improves doc comments to explain why the trust downgrade check is not run during self-update version selection and adds a test module hook.

pacquet/crates/cli/src/config_deps.rs

Tests (1) +73 / -0
tests.rsRegression test: resolve pnpm under no-downgrade with abbreviated metadata +73/-0

Regression test: resolve pnpm under no-downgrade with abbreviated metadata

• Adds an async test using a mocked registry packument without a per-version 'time' map to ensure 'resolve_pnpm_version' succeeds even when 'trust_policy=NoDowngrade'. Asserts resolution picks the expected version and does not report a policy violation.

pacquet/crates/cli/src/config_deps/tests.rs

@coderabbitai

coderabbitai Bot commented Jul 7, 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: 1c5f9ec3-6889-4667-aab3-29ae8ed53908

📥 Commits

Reviewing files that changed from the base of the PR and between ba5234a and 3271334.

📒 Files selected for processing (3)
  • pacquet/crates/cli/src/config_deps/tests.rs
  • pacquet/crates/config/src/lib.rs
  • pnpm11/engine/pm/commands/src/self-updater/selfUpdate.ts
🚧 Files skipped from review as they are similar to previous changes (1)
  • pnpm11/engine/pm/commands/src/self-updater/selfUpdate.ts

📝 Walkthrough

Walkthrough

The PR updates self-update resolution to use full metadata when needed, removes trust-policy gating from the Rust probe, forwards trust-policy inputs in the pnpm self-updater, and changes cached pnpm reuse so native slots are reused only when relinking succeeds.

Changes

Self-update resolution and reuse

Layer / File(s) Summary
Resolution metadata helper
pacquet/crates/config/src/lib.rs, pacquet/crates/package-manager/src/resolution_policy.rs
Adds Config::requires_full_metadata_for_resolution() and uses it to derive full_metadata in resolver policy selection.
Rust probe and metadata wiring
pacquet/crates/cli/src/config_deps.rs, pacquet/crates/cli/src/config_deps/tests.rs
resolve_pnpm_version now documents maturity-only policy handling, derives resolver metadata mode from config, and is covered by no-downgrade packument tests.
Self-update resolver flow
.changeset/self-update-trust-policy.md, pnpm11/engine/pm/commands/src/self-updater/selfUpdate.ts, pnpm11/engine/pm/commands/test/self-updater/selfUpdate.test.ts
The self-updater requests full metadata when needed, forwards trust-policy options into version resolution, and adds a trust-downgrade regression test.
Cached engine reuse
pacquet/crates/cli/src/cli_args/self_update/install_pnpm.rs, pacquet/crates/cli/src/cli_args/self_update/install_pnpm/tests.rs
Cached-slot reuse now depends on version matching plus native relinkability, with tests for matching, mismatched, and out-of-slot wrappers.

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

Possibly related PRs

  • pnpm/pnpm#11794: Also threads resolver full_metadata selection through install/version-resolution paths.
  • pnpm/pnpm#11911: Also changes no-downgrade trust-evidence handling and downgrade classification.
  • pnpm/pnpm#12693: Also updates resolve_pnpm_version self-update probing and related trust-policy behavior.

Suggested labels: product: pacquet

✨ 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-self-update

Warning

There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure.

🔧 ESLint

If the error stems from missing dependencies, add them to the package.json file. For unrecoverable errors (e.g., due to private dependencies), disable the tool in the CodeRabbit configuration.

ESLint install failed. For unrecoverable errors, disable the tool in CodeRabbit configuration.


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.

@github-actions

github-actions Bot commented Jul 7, 2026 •

Copy link
Copy Markdown
Contributor

Micro-Benchmark Results

Linux

group                          main                                   pr
-----                          ----                                   --
tarball/download_dependency    1.00      7.0±0.25ms   617.2 KB/sec    1.01      7.1±0.41ms   613.7 KB/sec

@github-actions github-actions Bot added the reviewed: coderabbit CodeRabbit submitted an approving review label Jul 7, 2026
@qodo-free-for-open-source-projects

qodo-free-for-open-source-projects Bot commented Jul 7, 2026 •

Copy link
Copy Markdown

Code Review by Qodo

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

Grey Divider


Action required

1. No-downgrade can miss trust 🐞 Bug ⛨ Security
Description
Config::requires_full_metadata_for_resolution() allows trustPolicy=no-downgrade to avoid full
packuments when registry_supports_time_field=true, but abbreviated packuments can omit the
trust-evidence fields the downgrade check needs, so the downgrade can be missed and a weaker-trust
version can be selected.
Code

pacquet/crates/config/src/lib.rs[R1568-1572]

+    pub fn requires_full_metadata_for_resolution(&self) -> bool {
+        (self.resolution_mode == ResolutionMode::TimeBased
+            || self.trust_policy == TrustPolicy::NoDowngrade)
+            && !self.registry_supports_time_field
+    }
Evidence
The resolver’s abbreviated packument mode is documented to omit _npmUser and dist.attestations,
and the trust-downgrade check reads those exact fields. Because
requires_full_metadata_for_resolution() can return false under trustPolicy=no-downgrade (when
registry_supports_time_field=true), the resolver can remain in abbreviated mode (via the Accept
header selection) and thus lack the evidence required to detect a downgrade.

pacquet/crates/config/src/lib.rs[1557-1572]
pacquet/crates/cli/src/config_deps.rs[292-313]
pacquet/crates/resolving-npm-resolver/src/fetch_full_metadata.rs[3-18]
pacquet/crates/resolving-npm-resolver/src/fetch_full_metadata_cached.rs[104-106]
pacquet/crates/resolving-npm-resolver/src/trust_checks.rs[248-267]
pnpm11/engine/pm/commands/src/self-updater/selfUpdate.ts[83-100]
pnpm11/resolving/npm-resolver/src/trustChecks.ts[34-80]

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

## Issue description
`trustPolicy=no-downgrade` requires per-version trust evidence (e.g. `_npmUser.*` and `dist.attestations.*`) to detect a downgrade. The current `requires_full_metadata_for_resolution()` returns `false` when `registry_supports_time_field=true`, which can keep resolution on abbreviated `install-v1` packuments; those packuments may omit the trust-evidence fields, making the downgrade check ineffective (false negatives).
### Issue Context
- Pacquet’s metadata fetcher documents that the abbreviated packument drops `_npmUser` and `dist.attestations`, which are exactly what the trust checks read.
- The trust check implementation indeed uses `version.npm_user.*` and `version.dist.attestations.*`.
- EnvInstallerContext wires `Config::requires_full_metadata_for_resolution()` into the resolver’s `full_metadata` flag, which controls the `Accept` header.
- pnpm11’s `selfUpdate.ts` uses the same `&& !opts.registrySupportsTimeField` gating for `trustPolicy='no-downgrade'`, so TypeScript self-update has the same risk.
### Fix Focus Areas
- pacquet/crates/config/src/lib.rs[1557-1572]
- pacquet/crates/cli/src/config_deps.rs[304-312]
- pacquet/crates/resolving-npm-resolver/src/fetch_full_metadata.rs[3-18]
- pacquet/crates/resolving-npm-resolver/src/trust_checks.rs[248-267]
- pnpm11/engine/pm/commands/src/self-updater/selfUpdate.ts[83-100]
### Suggested fix
- Make `trustPolicy=no-downgrade` force full metadata regardless of `registry_supports_time_field` (security > perf), e.g.:
- Rust: `if self.trust_policy == TrustPolicy::NoDowngrade { return true; }` and keep the time-based branch gated by `!registry_supports_time_field`.
- TypeScript: similarly set `fullMetadata = opts.trustPolicy === 'no-downgrade' || ((...) && !opts.registrySupportsTimeField)`.
- Add/adjust tests to cover `trustPolicy=no-downgrade` with `registrySupportsTimeField=true` and assert it still fetches full metadata (or still rejects a downgrade).

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


2. No-downgrade can miss trust 🐞 Bug ⛨ Security
Description
Config::requires_full_metadata_for_resolution() allows trustPolicy=no-downgrade to avoid full
packuments when registry_supports_time_field=true, but abbreviated packuments can omit the
trust-evidence fields the downgrade check needs, so the downgrade can be missed and a weaker-trust
version can be selected.
Code

pacquet/crates/config/src/lib.rs[R1568-1572]

+    pub fn requires_full_metadata_for_resolution(&self) -> bool {
+        (self.resolution_mode == ResolutionMode::TimeBased
+            || self.trust_policy == TrustPolicy::NoDowngrade)
+            && !self.registry_supports_time_field
+    }
Evidence
The resolver’s abbreviated packument mode is documented to omit _npmUser and dist.attestations,
and the trust-downgrade check reads those exact fields. Because
requires_full_metadata_for_resolution() can return false under trustPolicy=no-downgrade (when
registry_supports_time_field=true), the resolver can remain in abbreviated mode (via the Accept
header selection) and thus lack the evidence required to detect a downgrade.

pacquet/crates/config/src/lib.rs[1557-1572]
pacquet/crates/cli/src/config_deps.rs[292-313]
pacquet/crates/resolving-npm-resolver/src/fetch_full_metadata.rs[3-18]
pacquet/crates/resolving-npm-resolver/src/fetch_full_metadata_cached.rs[104-106]
pacquet/crates/resolving-npm-resolver/src/trust_checks.rs[248-267]
pnpm11/engine/pm/commands/src/self-updater/selfUpdate.ts[83-100]
pnpm11/resolving/npm-resolver/src/trustChecks.ts[34-80]

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

## Issue description
`trustPolicy=no-downgrade` requires per-version trust evidence (e.g. `_npmUser.*` and `dist.attestations.*`) to detect a downgrade. The current `requires_full_metadata_for_resolution()` returns `false` when `registry_supports_time_field=true`, which can keep resolution on abbreviated `install-v1` packuments; those packuments may omit the trust-evidence fields, making the downgrade check ineffective (false negatives).
### Issue Context
- Pacquet’s metadata fetcher documents that the abbreviated packument drops `_npmUser` and `dist.attestations`, which are exactly what the trust checks read.
- The trust check implementation indeed uses `version.npm_user.*` and `version.dist.attestations.*`.
- EnvInstallerContext wires `Config::requires_full_metadata_for_resolution()` into the resolver’s `full_metadata` flag, which controls the `Accept` header.
- pnpm11’s `selfUpdate.ts` uses the same `&& !opts.registrySupportsTimeField` gating for `trustPolicy='no-downgrade'`, so TypeScript self-update has the same risk.
### Fix Focus Areas
- pacquet/crates/config/src/lib.rs[1557-1572]
- pacquet/crates/cli/src/config_deps.rs[304-312]
- pacquet/crates/resolving-npm-resolver/src/fetch_full_metadata.rs[3-18]
- pacquet/crates/resolving-npm-resolver/src/trust_checks.rs[248-267]
- pnpm11/engine/pm/commands/src/self-updater/selfUpdate.ts[83-100]
### Suggested fix
- Make `trustPolicy=no-downgrade` force full metadata regardless of `registry_supports_time_field` (security > perf), e.g.:
- Rust: `if self.trust_policy == TrustPolicy::NoDowngrade { return true; }` and keep the time-based branch gated by `!registry_supports_time_field`.
- TypeScript: similarly set `fullMetadata = opts.trustPolicy === 'no-downgrade' || ((...) && !opts.registrySupportsTimeField)`.
- Add/adjust tests to cover `trustPolicy=no-downgrade` with `registrySupportsTimeField=true` and assert it still fetches full metadata (or still rejects a downgrade).

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



Remediation recommended

3. Full-metadata cache parse cost 🐞 Bug ➹ Performance
Description
EnvInstallerContext::build now sets filter_metadata=true whenever full_metadata is required, which
stores packuments in the filtered NDJSON cache format and forces full JSON deserialization on every
warm cache hit. Since resolve_pnpm_version is on the CLI switching/with/self-update paths, this can
add avoidable CPU overhead whenever trustPolicy=no-downgrade or resolutionMode=time-based is
enabled.
Code

pacquet/crates/cli/src/config_deps.rs[R304-311]

+            // Derive the metadata mode from config exactly as the install
+            // resolver does (via `PickPolicy`), so resolving the pnpm engine
+            // (or a config dependency) under `resolutionMode=time-based` /
+            // `trustPolicy=no-downgrade` fetches the full packument the
+            // `minimumReleaseAge` and trust checks need — instead of failing
+            // closed on abbreviated metadata that omits `time`.
+            full_metadata: config.requires_full_metadata_for_resolution(),
+            filter_metadata: config.requires_full_metadata_for_resolution(),
Evidence
The changed code enables filter_metadata whenever full metadata is required; the resolver’s cached
fetcher writes filtered full metadata in NDJSON form, and NDJSON loads deserialize the entire JSON
body. This can increase CPU on warm cache hits for engine-version resolution, which is called on CLI
switching and pnpm with paths.

pacquet/crates/cli/src/config_deps.rs[304-313]
pacquet/crates/resolving-npm-resolver/src/fetch_full_metadata_cached.rs[56-58]
pacquet/crates/resolving-npm-resolver/src/fetch_full_metadata_cached.rs[105-106]
pacquet/crates/resolving-npm-resolver/src/fetch_full_metadata_cached.rs[191-206]
pacquet/crates/resolving-npm-resolver/src/mirror.rs[460-470]
pacquet/crates/resolving-npm-resolver/src/mirror.rs[495-504]
pacquet/crates/cli/src/cli_args/switch_cli_version.rs[68-83]
pacquet/crates/cli/src/cli_args/with.rs[64-91]

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

## Issue description
`EnvInstallerContext::build` sets both `full_metadata` and `filter_metadata` from `Config::requires_full_metadata_for_resolution()`. When `filter_metadata` is enabled alongside `full_metadata`, pacquet persists the packument in the filtered NDJSON mirror format, which requires full-body JSON parsing on cache reads (warm path). For the engine-version probe (`resolve_pnpm_version`) used by CLI switching and `pnpm with`, this can add unnecessary CPU overhead.
## Issue Context
- Filtered full metadata is written as NDJSON (not the indexed mirror).
- NDJSON loads deserialize the entire JSON body, whereas the indexed mirror keeps per-version fragments lazy.
- This matters most for high-churn packages like `pnpm` and on repeated CLI invocations.
## Fix Focus Areas
- pacquet/crates/cli/src/config_deps.rs[304-312]
## Suggested fix
Set `filter_metadata: false` (or gate it behind a separate config knob) for the `EnvInstallerContext` used by engine probing/config-deps, while keeping `full_metadata` derived from `requires_full_metadata_for_resolution()`. This retains the indexed mirror format for full metadata, reducing warm-run parse cost while preserving the security requirement to fetch full metadata when needed.

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


4. Repo can block self-update 🐞 Bug ☼ Reliability
Description
Config::requires_full_metadata_for_resolution() treats registrySupportsTimeField as
authoritative, but that value is configurable in pnpm-workspace.yaml (repo-controlled). A
malicious repo can set it to true so self-update under trustPolicy=no-downgrade does not force
full metadata and can hit the fail-closed trust-check error path when time is missing, blocking
updates.
Code

pacquet/crates/config/src/lib.rs[R1568-1572]

+    pub fn requires_full_metadata_for_resolution(&self) -> bool {
+        (self.resolution_mode == ResolutionMode::TimeBased
+            || self.trust_policy == TrustPolicy::NoDowngrade)
+            && !self.registry_supports_time_field
+    }
Evidence
The repo can set registrySupportsTimeField via workspace YAML, while
requires_full_metadata_for_resolution() uses !registry_supports_time_field to decide whether to
force full metadata. The trust check fails closed when the per-version time entry is missing, so
if an untrusted repo flips the flag, self-update can be forced back onto abbreviated metadata and
block updates with the same “missing time” failure mode.

pacquet/crates/config/src/workspace_yaml.rs[419-423]
pacquet/crates/config/src/lib.rs[1557-1572]
pacquet/crates/cli/src/config_deps.rs[293-312]
pacquet/crates/resolving-npm-resolver/src/trust_checks.rs[116-125]

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

## Issue description
`registrySupportsTimeField` is configurable via `pnpm-workspace.yaml` (repo-controlled). Using it to decide whether `pnpm self-update` must fetch full metadata under `trustPolicy=no-downgrade` lets an untrusted repo influence a security-sensitive update path and can re-trigger the fail-closed “missing time” trust-check error (update-blocking DoS).
### Issue Context
- The trust downgrade check requires per-version publish times (`time`) and fails closed when missing.
- The new central helper `requires_full_metadata_for_resolution()` gates full metadata fetch on `!registry_supports_time_field`.
- `pnpm-workspace.yaml` can set `registrySupportsTimeField`, so a repo can set it contrary to reality.
### Fix Focus Areas
- pacquet/crates/config/src/lib.rs[1557-1572]
- pacquet/crates/cli/src/config_deps.rs[304-312]
- pacquet/crates/config/src/workspace_yaml.rs[419-423]
### Suggested direction
For package-manager bootstrap resolution paths (self-update / engine probe), do not honor repo-controlled `registrySupportsTimeField` when `trustPolicy=no-downgrade` is active. Options include:
- Force `full_metadata=true` for bootstrap resolution whenever `trust_policy==NoDowngrade` (regardless of `registry_supports_time_field`).
- Or scope `registrySupportsTimeField` so it cannot be set from workspace config for bootstrap/self-update contexts (trusted/user config only).

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


5. Misleading verification guarantee 🐞 Bug ⚙ Maintainability
Description
The new resolve_pnpm_version doc comment states verify_pnpm_engine_identity verifies downloaded
bytes before the engine is executed, but cache-hit paths can execute an already-present engine
without running that verifier. This is documentation drift that can mislead operators/reviewers
about which execution paths are actually verified.
Code

pacquet/crates/cli/src/config_deps.rs[R94-99]

+/// The no-downgrade gate is not lost by skipping it here: the subsequent
+/// engine install keeps `trust_policy` in its config, so the install's
+/// resolver fetches full metadata and runs the check on the picked engine
+/// components — and `verify_pnpm_engine_identity` separately verifies the
+/// downloaded bytes against npm's embedded registry signing keys before
+/// the engine is executed.
Evidence
The comment claims verification happens before execution, but the verifier module explicitly
documents it runs only on cache misses, and pnpm with has an explicit cache-hit short-circuit that
links/executes without calling the verifier.

pacquet/crates/cli/src/config_deps.rs[87-99]
pacquet/crates/cli/src/cli_args/self_update/verify_engine.rs[14-16]
pacquet/crates/cli/src/cli_args/with/install_pnpm_to_store.rs[80-101]

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

## Issue description
`resolve_pnpm_version`'s doc comment currently implies `verify_pnpm_engine_identity` always verifies bytes before execution. In reality, `verify_pnpm_engine_identity` is designed to run on genuine downloads (cache misses), and cache-hit paths may execute an already-present engine without re-running that verifier.
### Issue Context
This PR adds/expands the comment explaining why trustPolicy is skipped during version resolution; part of that comment now over-promises about when byte verification happens.
### Fix Focus Areas
- pacquet/crates/cli/src/config_deps.rs[87-99]
### Suggested change
Reword the final sentence(s) to scope the claim to fresh-download installs, e.g.:
- "...and `verify_pnpm_engine_identity` verifies the engine *on fresh downloads (cache misses)* before it is executed."

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


View more (10)
6. resolve_pnpm_version doc duplicates test 📘 Rule violation ⚙ Maintainability
Description
The rationale for skipping trustPolicy='no-downgrade' during self-update resolution is explained
in detail both in the function doc comment and again in the new test, which increases maintenance
cost and can drift over time. Keep the detailed scenario narrative in one place and let the other
location reference it briefly.
Code

pacquet/crates/cli/src/config_deps.rs[R87-94]

+/// The `trustPolicy='no-downgrade'` check is intentionally *not* applied
+/// here, matching the TypeScript `self-update` (`selfUpdate.ts`), which
+/// resolves the target version without passing `trustPolicy`. The engine
+/// pick uses abbreviated metadata (no per-version `time`), which the
+/// trust check requires; running it here would fail closed with a
+/// "missing time" error on every self-update. The trust downgrade is
+/// still enforced by the install-time lockfile verifier, which fetches
+/// full metadata for the check.
Evidence
PR Compliance ID 713470 requires avoiding duplicated test-scenario explanations across
implementation docs and tests. The resolve_pnpm_version doc comment contains a full narrative of
the abbreviated-metadata/missing-time issue and trust-policy rationale, and the new test repeats
the same explanation immediately above the test.

Rule 713470: Avoid duplicating test scenario explanations in both code and doc comments
pacquet/crates/cli/src/config_deps.rs[81-94]
pacquet/crates/cli/src/config_deps/tests.rs[42-47]

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 detailed explanation of why `trustPolicy='no-downgrade'` is skipped for `resolve_pnpm_version` is duplicated between the function doc comment and the regression test doc comment. This violates the guideline to avoid repeating the same scenario explanation in multiple places.
## Issue Context
The function doc comment in `config_deps.rs` explains the abbreviated metadata / missing `time` reasoning, and the test in `tests.rs` repeats essentially the same narrative.
## Fix Focus Areas
- pacquet/crates/cli/src/config_deps.rs[81-94]
- pacquet/crates/cli/src/config_deps/tests.rs[42-47]

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


7. Historical older layout comment 📘 Rule violation ⚙ Maintainability
Description
The new reuse_cached_engine doc comment uses historical phrasing (older ... layout) instead of
describing the current behavior and constraints, which can quickly become inaccurate as layouts
evolve. This violates the requirement to avoid historical implementation commentary in source
comments.
Code

pacquet/crates/cli/src/cli_args/self_update/install_pnpm.rs[R131-134]

+/// A slot whose wrapper escapes the slot is what an older global-virtual-
+/// store layout legitimately produces (the wrapper symlinks into the
+/// shared `<store>/links` tree), so this recovery is the common upgrade
+/// path, not only an adversarial one.
Evidence
The rule forbids comments that reference past behavior/implementations using historical phrasing
like older. The added doc comment explicitly describes an older ... layout as the motivating
case.

Rule 772199: Comments must describe current behavior, not historical implementations
pacquet/crates/cli/src/cli_args/self_update/install_pnpm.rs[131-134]

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 `reuse_cached_engine` doc comment uses historical phrasing (e.g., `older ... layout`), which violates the rule that comments must describe current behavior, not past implementations.
## Issue Context
This comment is explaining why wrapper-containment failures should cause a fresh install fallback. That rationale can be expressed without anchoring it to a temporal claim like "older".
## Fix Focus Areas
- pacquet/crates/cli/src/cli_args/self_update/install_pnpm.rs[131-134]

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


8. Duplicate reuse_cached_engine explanation 📘 Rule violation ⚙ Maintainability
Description
The wrapper-escape scenario and expected fallback behavior are explained both in the
reuse_cached_engine doc comment and again in the test comment, duplicating the same narrative.
This increases maintenance cost and risks drift between the two descriptions.
Code

pacquet/crates/cli/src/cli_args/self_update/install_pnpm/tests.rs[R205-208]

+/// A slot left by an older layout whose wrapper symlink escapes the slot
+/// (e.g. into a shared global virtual store) must not be reused — the
+/// caller falls through to a fresh install instead of aborting the whole
+/// self-update on the wrapper-containment guard.
Evidence
The checklist rule forbids duplicating scenario explanations across docs and tests. The test comment
describes the same wrapper-escape/fallback-to-fresh-install narrative that is already covered in the
reuse_cached_engine doc comment.

Rule 713470: Avoid duplicating test scenario explanations in both code and doc comments
pacquet/crates/cli/src/cli_args/self_update/install_pnpm/tests.rs[205-208]
pacquet/crates/cli/src/cli_args/self_update/install_pnpm.rs[119-134]

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 test comment for `reuse_cached_engine_rejects_a_wrapper_that_escapes_the_slot` repeats the same scenario/rationale already documented on `reuse_cached_engine` itself.
## Issue Context
Prefer to keep the detailed rationale in one place (typically the function doc comment) and keep the test comment minimal (or remove it), letting the test name + assertions describe the behavior.
## Fix Focus Areas
- pacquet/crates/cli/src/cli_args/self_update/install_pnpm/tests.rs[205-208]
- pacquet/crates/cli/src/cli_args/self_update/install_pnpm.rs[115-134]

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


9. Relink errors silently dropped 🐞 Bug ◔ Observability
Description
reuse_cached_engine() collapses any link_exe_platform_binary() error into false via
.is_ok(), so self-update falls back to a reinstall without surfacing why the cached slot couldn’t
be reused. This makes troubleshooting and security auditing harder (e.g., distinguishing legacy
layout vs. unexpected filesystem/link failures) and can lead to repeated reinstall attempts when the
underlying relink failure is persistent.
Code

pacquet/crates/cli/src/cli_args/self_update/install_pnpm.rs[R139-140]

+    !package.links_native_binary || link_exe_platform_binary(install_dir, package.name).is_ok()
+}
Evidence
The reuse decision now depends on link_exe_platform_binary(...).is_ok(), which discards the error;
and install_pnpm() uses this boolean to choose reuse vs. reinstall without logging the relink
failure reason.

pacquet/crates/cli/src/cli_args/self_update/install_pnpm.rs[68-78]
pacquet/crates/cli/src/cli_args/self_update/install_pnpm.rs[135-140]

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

## Issue description
`reuse_cached_engine()` currently converts `link_exe_platform_binary()` failures into a plain `false` (`.is_ok()`), which drops the underlying error context. The caller then silently falls back to a fresh install. This is an observability regression vs. the prior behavior (which surfaced the relink error), and it makes persistent relink failures hard to diagnose.
### Issue Context
The intent (fallback to fresh install instead of aborting self-update) is good and should remain. The fix should preserve that behavior while retaining enough diagnostics to explain why reuse was rejected.
### Fix Focus Areas
- pacquet/crates/cli/src/cli_args/self_update/install_pnpm.rs[139-140]
### Suggested implementation direction
- Replace the `.is_ok()` collapse with explicit error capture:
- `match link_exe_platform_binary(...) { Ok(()) => true, Err(e) => { /* log */; false } }`
- Emit a debug/warn log containing the error (and possibly the install_dir/package) before returning `false`.
- Keep the fallback-to-fresh-install behavior unchanged.

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


10. Redundant scenario comments in tests 📘 Rule violation ⚙ Maintainability
Description
pacquet/crates/cli/src/config_deps/tests.rs contains long doc comments that restate the same
scenario already encoded by the test setup and assertions (and also repeats nearby constant
comments). This duplication increases maintenance cost and risks comment/test drift over time.
Code

pacquet/crates/cli/src/config_deps/tests.rs[R90-136]

+/// Abbreviated packument: no `time` map. Served only to the abbreviated
+/// `Accept` header, so the probe reaches it only if it *fails* to request
+/// full metadata — in which case the trust check fails closed with
+/// "missing time". A test that instead sees a "trust downgrade" (or a
+/// clean resolve) proves the probe requested full metadata.
+const ABBREVIATED_BODY: &str = r#"{
+    "name": "pnpm",
+    "dist-tags": { "latest": "1.1.0" },
+    "versions": {
+        "1.0.0": {
+            "name": "pnpm",
+            "version": "1.0.0",
+            "dist": {
+                "integrity": "sha512-AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA==",
+                "shasum": "0000000000000000000000000000000000000000",
+                "tarball": "https://registry/pnpm-1.0.0.tgz"
+            }
+        },
+        "1.1.0": {
+            "name": "pnpm",
+            "version": "1.1.0",
+            "dist": {
+                "integrity": "sha512-BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB==",
+                "shasum": "1111111111111111111111111111111111111111",
+                "tarball": "https://registry/pnpm-1.1.0.tgz"
+            }
+        }
+    }
+}"#;
+
+fn no_downgrade_config(registry: String, cache_dir: &Path) -> Config {
+    let mut config = Config {
+        trust_policy: TrustPolicy::NoDowngrade,
+        cache_dir: cache_dir.to_path_buf(),
+        ..Config::default()
+    };
+    config.package_manager_bootstrap.registry = registry;
+    config
+}
+
+/// Under `trustPolicy=no-downgrade`, the self-update probe must resolve
+/// against **full** metadata — the same as a regular install — so the
+/// no-downgrade check actually runs. It reaches the full packument (with
+/// `time`), sees the downgrade, and rejects it. If the probe fetched
+/// abbreviated metadata it would instead fail closed with "missing time";
+/// if it skipped the check it would resolve `1.1.0` with no error.
+#[tokio::test]
Evidence
The constant comment explains what would happen with abbreviated metadata ("missing time"), and the
test doc comment repeats the same narrative about full vs abbreviated metadata and expected
rejection; the assertions already validate the observable behavior. This is exactly the kind of
duplicated scenario explanation these rules prohibit.

Rule 713470: Avoid duplicating test scenario explanations in both code and doc comments
Rule 713467: Avoid redundant comments that restate the code
pacquet/crates/cli/src/config_deps/tests.rs[90-136]

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

## Issue description
New/modified doc comments in the Rust tests repeat detailed scenario narratives that are already expressed by the test data and assertions, and in some cases duplicate other nearby comments. This violates the guideline to avoid duplicating scenario explanations in both code and doc comments and creates drift risk.
## Issue Context
The file adds extensive explanatory prose for packument fixtures and the `resolve_pnpm_version_*` tests. The tests themselves (mock setup + assertions) already communicate the key behavior, so these comments can be shortened to focus on *why the scenario matters*.
## Fix Focus Areas
- pacquet/crates/cli/src/config_deps/tests.rs[90-136]

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


11. Redundant scenario comments in tests 📘 Rule violation ⚙ Maintainability
Description
pacquet/crates/cli/src/config_deps/tests.rs contains long doc comments that restate the same
scenario already encoded by the test setup and assertions (and also repeats nearby constant
comments). This duplication increases maintenance cost and risks comment/test drift over time.
Code

pacquet/crates/cli/src/config_deps/tests.rs[R90-136]

+/// Abbreviated packument: no `time` map. Served only to the abbreviated
+/// `Accept` header, so the probe reaches it only if it *fails* to request
+/// full metadata — in which case the trust check fails closed with
+/// "missing time". A test that instead sees a "trust downgrade" (or a
+/// clean resolve) proves the probe requested full metadata.
+const ABBREVIATED_BODY: &str = r#"{
+    "name": "pnpm",
+    "dist-tags": { "latest": "1.1.0" },
+    "versions": {
+        "1.0.0": {
+            "name": "pnpm",
+            "version": "1.0.0",
+            "dist": {
+                "integrity": "sha512-AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA==",
+                "shasum": "0000000000000000000000000000000000000000",
+                "tarball": "https://registry/pnpm-1.0.0.tgz"
+            }
+        },
+        "1.1.0": {
+            "name": "pnpm",
+            "version": "1.1.0",
+            "dist": {
+                "integrity": "sha512-BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB==",
+                "shasum": "1111111111111111111111111111111111111111",
+                "tarball": "https://registry/pnpm-1.1.0.tgz"
+            }
+        }
+    }
+}"#;
+
+fn no_downgrade_config(registry: String, cache_dir: &Path) -> Config {
+    let mut config = Config {
+        trust_policy: TrustPolicy::NoDowngrade,
+        cache_dir: cache_dir.to_path_buf(),
+        ..Config::default()
+    };
+    config.package_manager_bootstrap.registry = registry;
+    config
+}
+
+/// Under `trustPolicy=no-downgrade`, the self-update probe must resolve
+/// against **full** metadata — the same as a regular install — so the
+/// no-downgrade check actually runs. It reaches the full packument (with
+/// `time`), sees the downgrade, and rejects it. If the probe fetched
+/// abbreviated metadata it would instead fail closed with "missing time";
+/// if it skipped the check it would resolve `1.1.0` with no error.
+#[tokio::test]
Evidence
The constant comment explains what would happen with abbreviated metadata ("missing time"), and the
test doc comment repeats the same narrative about full vs abbreviated metadata and expected
rejection; the assertions already validate the observable behavior. This is exactly the kind of
duplicated scenario explanation these rules prohibit.

Rule 713470: Avoid duplicating test scenario explanations in both code and doc comments
Rule 713467: Avoid redundant comments that restate the code
pacquet/crates/cli/src/config_deps/tests.rs[90-136]

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

## Issue description
New/modified doc comments in the Rust tests repeat detailed scenario narratives that are already expressed by the test data and assertions, and in some cases duplicate other nearby comments. This violates the guideline to avoid duplicating scenario explanations in both code and doc comments and creates drift risk.
## Issue Context
The file adds extensive explanatory prose for packument fixtures and the `resolve_pnpm_version_*` tests. The tests themselves (mock setup + assertions) already communicate the key behavior, so these comments can be shortened to focus on *why the scenario matters*.
## Fix Focus Areas
- pacquet/crates/cli/src/config_deps/tests.rs[90-136]

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


12. Duplicate reuse_cached_engine explanation 📘 Rule violation ⚙ Maintainability
Description
The wrapper-escape scenario and expected fallback behavior are explained both in the
reuse_cached_engine doc comment and again in the test comment, duplicating the same narrative.
This increases maintenance cost and risks drift between the two descriptions.
Code

pacquet/crates/cli/src/cli_args/self_update/install_pnpm/tests.rs[R205-208]

+/// A slot left by an older layout whose wrapper symlink escapes the slot
+/// (e.g. into a shared global virtual store) must not be reused — the
+/// caller falls through to a fresh install instead of aborting the whole
+/// self-update on the wrapper-containment guard.
Evidence
The checklist rule forbids duplicating scenario explanations across docs and tests. The test comment
describes the same wrapper-escape/fallback-to-fresh-install narrative that is already covered in the
reuse_cached_engine doc comment.

Rule 713470: Avoid duplicating test scenario explanations in both code and doc comments
pacquet/crates/cli/src/cli_args/self_update/install_pnpm/tests.rs[205-208]
pacquet/crates/cli/src/cli_args/self_update/install_pnpm.rs[119-134]

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 test comment for `reuse_cached_engine_rejects_a_wrapper_that_escapes_the_slot` repeats the same scenario/rationale already documented on `reuse_cached_engine` itself.
## Issue Context
Prefer to keep the detailed rationale in one place (typically the function doc comment) and keep the test comment minimal (or remove it), letting the test name + assertions describe the behavior.
## Fix Focus Areas
- pacquet/crates/cli/src/cli_args/self_update/install_pnpm/tests.rs[205-208]
- pacquet/crates/cli/src/cli_args/self_update/install_pnpm.rs[115-134]

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


13. Relink errors silently dropped 🐞 Bug ◔ Observability
Description
reuse_cached_engine() collapses any link_exe_platform_binary() error into false via
.is_ok(), so self-update falls back to a reinstall without surfacing why the cached slot couldn’t
be reused. This makes troubleshooting and security auditing harder (e.g., distinguishing legacy
layout vs. unexpected filesystem/link failures) and can lead to repeated reinstall attempts when the
underlying relink failure is persistent.
Code

pacquet/crates/cli/src/cli_args/self_update/install_pnpm.rs[R139-140]

+    !package.links_native_binary || link_exe_platform_binary(install_dir, package.name).is_ok()
+}
Evidence
The reuse decision now depends on link_exe_platform_binary(...).is_ok(), which discards the error;
and install_pnpm() uses this boolean to choose reuse vs. reinstall without logging the relink
failure reason.

pacquet/crates/cli/src/cli_args/self_update/install_pnpm.rs[68-78]
pacquet/crates/cli/src/cli_args/self_update/install_pnpm.rs[135-140]

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

## Issue description
`reuse_cached_engine()` currently converts `link_exe_platform_binary()` failures into a plain `false` (`.is_ok()`), which drops the underlying error context. The caller then silently falls back to a fresh install. This is an observability regression vs. the prior behavior (which surfaced the relink error), and it makes persistent relink failures hard to diagnose.
### Issue Context
The intent (fallback to fresh install instead of aborting self-update) is good and should remain. The fix should preserve that behavior while retaining enough diagnostics to explain why reuse was rejected.
### Fix Focus Areas
- pacquet/crates/cli/src/cli_args/self_update/install_pnpm.rs[139-140]
### Suggested implementation direction
- Replace the `.is_ok()` collapse with explicit error capture:
- `match link_exe_platform_binary(...) { Ok(()) => true, Err(e) => { /* log */; false } }`
- Emit a debug/warn log containing the error (and possibly the install_dir/package) before returning `false`.
- Keep the fallback-to-fresh-install behavior unchanged.

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


14. Historical older layout comment 📘 Rule violation ⚙ Maintainability
Description
The new reuse_cached_engine doc comment uses historical phrasing (older ... layout) instead of
describing the current behavior and constraints, which can quickly become inaccurate as layouts
evolve. This violates the requirement to avoid historical implementation commentary in source
comments.
Code

pacquet/crates/cli/src/cli_args/self_update/install_pnpm.rs[R131-134]

+/// A slot whose wrapper escapes the slot is what an older global-virtual-
+/// store layout legitimately produces (the wrapper symlinks into the
+/// shared `<store>/links` tree), so this recovery is the common upgrade
+/// path, not only an adversarial one.
Evidence
The rule forbids comments that reference past behavior/implementations using historical phrasing
like older. The added doc comment explicitly describes an older ... layout as the motivating
case.

Rule 772199: Comments must describe current behavior, not historical implementations
pacquet/crates/cli/src/cli_args/self_update/install_pnpm.rs[131-134]

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 `reuse_cached_engine` doc comment uses historical phrasing (e.g., `older ... layout`), which violates the rule that comments must describe current behavior, not past implementations.
## Issue Context
This comment is explaining why wrapper-containment failures should cause a fresh install fallback. That rationale can be expressed without anchoring it to a temporal claim like "older".
## Fix Focus Areas
- pacquet/crates/cli/src/cli_args/self_update/install_pnpm.rs[131-134]

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


15. resolve_pnpm_version doc duplicates test ✓ Resolved 📘 Rule violation ⚙ Maintainability
Description
The rationale for skipping trustPolicy='no-downgrade' during self-update resolution is explained
in detail both in the function doc comment and again in the new test, which increases maintenance
cost and can drift over time. Keep the detailed scenario narrative in one place and let the other
location reference it briefly.
Code

pacquet/crates/cli/src/config_deps.rs[R87-94]

+/// The `trustPolicy='no-downgrade'` check is intentionally *not* applied
+/// here, matching the TypeScript `self-update` (`selfUpdate.ts`), which
+/// resolves the target version without passing `trustPolicy`. The engine
+/// pick uses abbreviated metadata (no per-version `time`), which the
+/// trust check requires; running it here would fail closed with a
+/// "missing time" error on every self-update. The trust downgrade is
+/// still enforced by the install-time lockfile verifier, which fetches
+/// full metadata for the check.
Evidence
PR Compliance ID 713470 requires avoiding duplicated test-scenario explanations across
implementation docs and tests. The resolve_pnpm_version doc comment contains a full narrative of
the abbreviated-metadata/missing-time issue and trust-policy rationale, and the new test repeats
the same explanation immediately above the test.

Rule 713470: Avoid duplicating test scenario explanations in both code and doc comments
pacquet/crates/cli/src/config_deps.rs[81-94]
pacquet/crates/cli/src/config_deps/tests.rs[42-47]

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 detailed explanation of why `trustPolicy='no-downgrade'` is skipped for `resolve_pnpm_version` is duplicated between the function doc comment and the regression test doc comment. This violates the guideline to avoid repeating the same scenario explanation in multiple places.
## Issue Context
The function doc comment in `config_deps.rs` explains the abbreviated metadata / missing `time` reasoning, and the test in `tests.rs` repeats essentially the same narrative.
## Fix Focus Areas
- pacquet/crates/cli/src/config_deps.rs[81-94]
- pacquet/crates/cli/src/config_deps/tests.rs[42-47]

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


Grey Divider

Qodo Logo

@qodo-code-review

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

Copy link
Copy Markdown

Code Review by Qodo

🐞 Bugs (3) 📘 Rule violations (3) 📜 Skill insights (0)

Context used
✅ Compliance rules (platform): 51 rules

Grey Divider


Action required

1. No-downgrade can miss trust ✓ Resolved 🐞 Bug ⛨ Security
Description
Config::requires_full_metadata_for_resolution() allows trustPolicy=no-downgrade to avoid full
packuments when registry_supports_time_field=true, but abbreviated packuments can omit the
trust-evidence fields the downgrade check needs, so the downgrade can be missed and a weaker-trust
version can be selected.
Code

pacquet/crates/config/src/lib.rs[R1568-1572]

+    pub fn requires_full_metadata_for_resolution(&self) -> bool {
+        (self.resolution_mode == ResolutionMode::TimeBased
+            || self.trust_policy == TrustPolicy::NoDowngrade)
+            && !self.registry_supports_time_field
+    }
Evidence
The resolver’s abbreviated packument mode is documented to omit _npmUser and dist.attestations,
and the trust-downgrade check reads those exact fields. Because
requires_full_metadata_for_resolution() can return false under trustPolicy=no-downgrade (when
registry_supports_time_field=true), the resolver can remain in abbreviated mode (via the Accept
header selection) and thus lack the evidence required to detect a downgrade.

pacquet/crates/config/src/lib.rs[1557-1572]
pacquet/crates/cli/src/config_deps.rs[292-313]
pacquet/crates/resolving-npm-resolver/src/fetch_full_metadata.rs[3-18]
pacquet/crates/resolving-npm-resolver/src/fetch_full_metadata_cached.rs[104-106]
pacquet/crates/resolving-npm-resolver/src/trust_checks.rs[248-267]
pnpm11/engine/pm/commands/src/self-updater/selfUpdate.ts[83-100]
pnpm11/resolving/npm-resolver/src/trustChecks.ts[34-80]

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

### Issue description
`trustPolicy=no-downgrade` requires per-version trust evidence (e.g. `_npmUser.*` and `dist.attestations.*`) to detect a downgrade. The current `requires_full_metadata_for_resolution()` returns `false` when `registry_supports_time_field=true`, which can keep resolution on abbreviated `install-v1` packuments; those packuments may omit the trust-evidence fields, making the downgrade check ineffective (false negatives).

### Issue Context
- Pacquet’s metadata fetcher documents that the abbreviated packument drops `_npmUser` and `dist.attestations`, which are exactly what the trust checks read.
- The trust check implementation indeed uses `version.npm_user.*` and `version.dist.attestations.*`.
- EnvInstallerContext wires `Config::requires_full_metadata_for_resolution()` into the resolver’s `full_metadata` flag, which controls the `Accept` header.
- pnpm11’s `selfUpdate.ts` uses the same `&& !opts.registrySupportsTimeField` gating for `trustPolicy='no-downgrade'`, so TypeScript self-update has the same risk.

### Fix Focus Areas
- pacquet/crates/config/src/lib.rs[1557-1572]
- pacquet/crates/cli/src/config_deps.rs[304-312]
- pacquet/crates/resolving-npm-resolver/src/fetch_full_metadata.rs[3-18]
- pacquet/crates/resolving-npm-resolver/src/trust_checks.rs[248-267]
- pnpm11/engine/pm/commands/src/self-updater/selfUpdate.ts[83-100]

### Suggested fix
- Make `trustPolicy=no-downgrade` force full metadata regardless of `registry_supports_time_field` (security > perf), e.g.:
 - Rust: `if self.trust_policy == TrustPolicy::NoDowngrade { return true; }` and keep the time-based branch gated by `!registry_supports_time_field`.
 - TypeScript: similarly set `fullMetadata = opts.trustPolicy === 'no-downgrade' || ((...) && !opts.registrySupportsTimeField)`.
- Add/adjust tests to cover `trustPolicy=no-downgrade` with `registrySupportsTimeField=true` and assert it still fetches full metadata (or still rejects a downgrade).

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



Remediation recommended

2. Duplicated metadata-mode predicate 🐞 Bug ⚙ Maintainability ⭐ New
Description
selfUpdate.ts re-implements the "requires full metadata" predicate inline, which reintroduces
drift risk across one-shot resolvers and the install path; past drift here caused security policy
enforcement gaps. Centralizing this predicate (like pacquet’s
requires_full_metadata_for_resolution) reduces the chance of future trust-policy bypasses when one
call site is updated and another isn’t.
Code

pnpm11/engine/pm/commands/src/self-updater/selfUpdate.ts[R91-92]

+    opts.trustPolicy === 'no-downgrade' ||
+    (opts.resolutionMode === 'time-based' && !opts.registrySupportsTimeField)
Evidence
The new inline predicate is present in selfUpdate.ts. The repo already has multiple call sites
computing fullMetadata, and pacquet explicitly centralizes it to prevent drift, indicating this
predicate is important to keep consistent.

pnpm11/engine/pm/commands/src/self-updater/selfUpdate.ts[83-99]
pnpm11/exec/commands/src/dlx.ts[109-122]
pacquet/crates/config/src/lib.rs[1557-1581]

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

### Issue description
`pnpm self-update` now computes `fullMetadata` inline. Similar logic exists in other one-shot paths (e.g. `dlx`) and in store/controller setup; duplicating the predicate invites future divergence and reintroduces trust-policy enforcement bugs.

### Issue Context
- Rust/pacquet addressed this by centralizing the decision in `Config::requires_full_metadata_for_resolution()`.
- TS currently has multiple predicates in different files.

### Fix Focus Areas
- pnpm11/engine/pm/commands/src/self-updater/selfUpdate.ts[83-99]

### Suggested fix approach
- Extract a shared helper in a TS module that already owns policy logic (e.g. alongside existing version-policy/trust-policy utilities) that computes whether full metadata is required for resolution.
- Use that helper in `selfUpdate.ts` (and optionally other one-shot callers) so future policy changes land in one place.
- Add/adjust a focused unit test for the helper to lock the intended behavior for `trustPolicy='no-downgrade'` and `resolutionMode='time-based'`.

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


3. Redundant scenario comments in tests 📘 Rule violation ⚙ Maintainability
Description
pacquet/crates/cli/src/config_deps/tests.rs contains long doc comments that restate the same
scenario already encoded by the test setup and assertions (and also repeats nearby constant
comments). This duplication increases maintenance cost and risks comment/test drift over time.
Code

pacquet/crates/cli/src/config_deps/tests.rs[R90-136]

+/// Abbreviated packument: no `time` map. Served only to the abbreviated
+/// `Accept` header, so the probe reaches it only if it *fails* to request
+/// full metadata — in which case the trust check fails closed with
+/// "missing time". A test that instead sees a "trust downgrade" (or a
+/// clean resolve) proves the probe requested full metadata.
+const ABBREVIATED_BODY: &str = r#"{
+    "name": "pnpm",
+    "dist-tags": { "latest": "1.1.0" },
+    "versions": {
+        "1.0.0": {
+            "name": "pnpm",
+            "version": "1.0.0",
+            "dist": {
+                "integrity": "sha512-AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA==",
+                "shasum": "0000000000000000000000000000000000000000",
+                "tarball": "https://registry/pnpm-1.0.0.tgz"
+            }
+        },
+        "1.1.0": {
+            "name": "pnpm",
+            "version": "1.1.0",
+            "dist": {
+                "integrity": "sha512-BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB==",
+                "shasum": "1111111111111111111111111111111111111111",
+                "tarball": "https://registry/pnpm-1.1.0.tgz"
+            }
+        }
+    }
+}"#;
+
+fn no_downgrade_config(registry: String, cache_dir: &Path) -> Config {
+    let mut config = Config {
+        trust_policy: TrustPolicy::NoDowngrade,
+        cache_dir: cache_dir.to_path_buf(),
+        ..Config::default()
+    };
+    config.package_manager_bootstrap.registry = registry;
+    config
+}
+
+/// Under `trustPolicy=no-downgrade`, the self-update probe must resolve
+/// against **full** metadata — the same as a regular install — so the
+/// no-downgrade check actually runs. It reaches the full packument (with
+/// `time`), sees the downgrade, and rejects it. If the probe fetched
+/// abbreviated metadata it would instead fail closed with "missing time";
+/// if it skipped the check it would resolve `1.1.0` with no error.
+#[tokio::test]
Evidence
The constant comment explains what would happen with abbreviated metadata ("missing time"), and the
test doc comment repeats the same narrative about full vs abbreviated metadata and expected
rejection; the assertions already validate the observable behavior. This is exactly the kind of
duplicated scenario explanation these rules prohibit.

Rule 713470: Avoid duplicating test scenario explanations in both code and doc comments
Rule 713467: Avoid redundant comments that restate the code
pacquet/crates/cli/src/config_deps/tests.rs[90-136]

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

## Issue description
New/modified doc comments in the Rust tests repeat detailed scenario narratives that are already expressed by the test data and assertions, and in some cases duplicate other nearby comments. This violates the guideline to avoid duplicating scenario explanations in both code and doc comments and creates drift risk.

## Issue Context
The file adds extensive explanatory prose for packument fixtures and the `resolve_pnpm_version_*` tests. The tests themselves (mock setup + assertions) already communicate the key behavior, so these comments can be shortened to focus on *why the scenario matters*.

## Fix Focus Areas
- pacquet/crates/cli/src/config_deps/tests.rs[90-136]

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


4. Duplicate reuse_cached_engine explanation 📘 Rule violation ⚙ Maintainability
Description
The wrapper-escape scenario and expected fallback behavior are explained both in the
reuse_cached_engine doc comment and again in the test comment, duplicating the same narrative.
This increases maintenance cost and risks drift between the two descriptions.
Code

pacquet/crates/cli/src/cli_args/self_update/install_pnpm/tests.rs[R205-208]

+/// A slot left by an older layout whose wrapper symlink escapes the slot
+/// (e.g. into a shared global virtual store) must not be reused — the
+/// caller falls through to a fresh install instead of aborting the whole
+/// self-update on the wrapper-containment guard.
Evidence
The checklist rule forbids duplicating scenario explanations across docs and tests. The test comment
describes the same wrapper-escape/fallback-to-fresh-install narrative that is already covered in the
reuse_cached_engine doc comment.

Rule 713470: Avoid duplicating test scenario explanations in both code and doc comments
pacquet/crates/cli/src/cli_args/self_update/install_pnpm/tests.rs[205-208]
pacquet/crates/cli/src/cli_args/self_update/install_pnpm.rs[119-134]

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 test comment for `reuse_cached_engine_rejects_a_wrapper_that_escapes_the_slot` repeats the same scenario/rationale already documented on `reuse_cached_engine` itself.

## Issue Context
Prefer to keep the detailed rationale in one place (typically the function doc comment) and keep the test comment minimal (or remove it), letting the test name + assertions describe the behavior.

## Fix Focus Areas
- pacquet/crates/cli/src/cli_args/self_update/install_pnpm/tests.rs[205-208]
- pacquet/crates/cli/src/cli_args/self_update/install_pnpm.rs[115-134]

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


View more (3)
5. Relink errors silently dropped 🐞 Bug ◔ Observability
Description
reuse_cached_engine() collapses any link_exe_platform_binary() error into false via
.is_ok(), so self-update falls back to a reinstall without surfacing why the cached slot couldn’t
be reused. This makes troubleshooting and security auditing harder (e.g., distinguishing legacy
layout vs. unexpected filesystem/link failures) and can lead to repeated reinstall attempts when the
underlying relink failure is persistent.
Code

pacquet/crates/cli/src/cli_args/self_update/install_pnpm.rs[R139-140]

+    !package.links_native_binary || link_exe_platform_binary(install_dir, package.name).is_ok()
+}
Evidence
The reuse decision now depends on link_exe_platform_binary(...).is_ok(), which discards the error;
and install_pnpm() uses this boolean to choose reuse vs. reinstall without logging the relink
failure reason.

pacquet/crates/cli/src/cli_args/self_update/install_pnpm.rs[68-78]
pacquet/crates/cli/src/cli_args/self_update/install_pnpm.rs[135-140]

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

### Issue description
`reuse_cached_engine()` currently converts `link_exe_platform_binary()` failures into a plain `false` (`.is_ok()`), which drops the underlying error context. The caller then silently falls back to a fresh install. This is an observability regression vs. the prior behavior (which surfaced the relink error), and it makes persistent relink failures hard to diagnose.

### Issue Context
The intent (fallback to fresh install instead of aborting self-update) is good and should remain. The fix should preserve that behavior while retaining enough diagnostics to explain why reuse was rejected.

### Fix Focus Areas
- pacquet/crates/cli/src/cli_args/self_update/install_pnpm.rs[139-140]

### Suggested implementation direction
- Replace the `.is_ok()` collapse with explicit error capture:
 - `match link_exe_platform_binary(...) { Ok(()) => true, Err(e) => { /* log */; false } }`
- Emit a debug/warn log containing the error (and possibly the install_dir/package) before returning `false`.
- Keep the fallback-to-fresh-install behavior unchanged.

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


6. Historical older layout comment 📘 Rule violation ⚙ Maintainability
Description
The new reuse_cached_engine doc comment uses historical phrasing (older ... layout) instead of
describing the current behavior and constraints, which can quickly become inaccurate as layouts
evolve. This violates the requirement to avoid historical implementation commentary in source
comments.
Code

pacquet/crates/cli/src/cli_args/self_update/install_pnpm.rs[R131-134]

+/// A slot whose wrapper escapes the slot is what an older global-virtual-
+/// store layout legitimately produces (the wrapper symlinks into the
+/// shared `<store>/links` tree), so this recovery is the common upgrade
+/// path, not only an adversarial one.
Evidence
The rule forbids comments that reference past behavior/implementations using historical phrasing
like older. The added doc comment explicitly describes an older ... layout as the motivating
case.

Rule 772199: Comments must describe current behavior, not historical implementations
pacquet/crates/cli/src/cli_args/self_update/install_pnpm.rs[131-134]

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 `reuse_cached_engine` doc comment uses historical phrasing (e.g., `older ... layout`), which violates the rule that comments must describe current behavior, not past implementations.

## Issue Context
This comment is explaining why wrapper-containment failures should cause a fresh install fallback. That rationale can be expressed without anchoring it to a temporal claim like "older".

## Fix Focus Areas
- pacquet/crates/cli/src/cli_args/self_update/install_pnpm.rs[131-134]

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


7. resolve_pnpm_version doc duplicates test ✓ Resolved 📘 Rule violation ⚙ Maintainability
Description
The rationale for skipping trustPolicy='no-downgrade' during self-update resolution is explained
in detail both in the function doc comment and again in the new test, which increases maintenance
cost and can drift over time. Keep the detailed scenario narrative in one place and let the other
location reference it briefly.
Code

pacquet/crates/cli/src/config_deps.rs[R87-94]

+/// The `trustPolicy='no-downgrade'` check is intentionally *not* applied
+/// here, matching the TypeScript `self-update` (`selfUpdate.ts`), which
+/// resolves the target version without passing `trustPolicy`. The engine
+/// pick uses abbreviated metadata (no per-version `time`), which the
+/// trust check requires; running it here would fail closed with a
+/// "missing time" error on every self-update. The trust downgrade is
+/// still enforced by the install-time lockfile verifier, which fetches
+/// full metadata for the check.
Evidence
PR Compliance ID 713470 requires avoiding duplicated test-scenario explanations across
implementation docs and tests. The resolve_pnpm_version doc comment contains a full narrative of
the abbreviated-metadata/missing-time issue and trust-policy rationale, and the new test repeats
the same explanation immediately above the test.

Rule 713470: Avoid duplicating test scenario explanations in both code and doc comments
pacquet/crates/cli/src/config_deps.rs[81-94]
pacquet/crates/cli/src/config_deps/tests.rs[42-47]

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 detailed explanation of why `trustPolicy='no-downgrade'` is skipped for `resolve_pnpm_version` is duplicated between the function doc comment and the regression test doc comment. This violates the guideline to avoid repeating the same scenario explanation in multiple places.

## Issue Context
The function doc comment in `config_deps.rs` explains the abbreviated metadata / missing `time` reasoning, and the test in `tests.rs` repeats essentially the same narrative.

## Fix Focus Areas
- pacquet/crates/cli/src/config_deps.rs[81-94]
- pacquet/crates/cli/src/config_deps/tests.rs[42-47]

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



Informational

8. Brittle error text asserts 🐞 Bug ☼ Reliability ⭐ New
Description
The new Rust self-update resolver tests assert on format!("{err:?}") substring contents, so
harmless error formatting/refactoring can break CI without changing behavior. This makes the tests
fragile and increases maintenance churn around security-policy error reporting.
Code

pacquet/crates/cli/src/config_deps/tests.rs[R268-272]

+    let report = format!("{err:?}");
+    assert!(
+        report.contains("trust downgrade"),
+        "expected a trust-downgrade rejection, got: {report}",
+    );
Evidence
The test uses debug formatting plus substring checks to detect the downgrade path; the trust
downgrade error is a structured diagnostic with a stable code, so tests can assert on structured
info instead of debug text.

pacquet/crates/cli/src/config_deps/tests.rs[235-273]
pacquet/crates/resolving-npm-resolver/src/trust_checks.rs[41-66]

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

### Issue description
The test `resolve_pnpm_version_forces_full_metadata_for_no_downgrade_despite_registry_time_field` matches on debug-formatted error text. Debug output is not a stable contract and can change due to unrelated formatting changes, causing noisy CI failures.

### Issue Context
The underlying trust downgrade error has a structured diagnostic code/type; tests can assert on that instead of string-matching `Debug`.

### Fix Focus Areas
- pacquet/crates/cli/src/config_deps/tests.rs[235-273]

### Suggested fix approach
- Prefer asserting on:
 - the error's `Display` text (more stable than `Debug`) **and/or**
 - the `miette::Diagnostic` code (e.g. `pacquet_resolving_npm_resolver::trust_downgrade`) **and/or**
 - downcasting the root cause to the trust-violation type if accessible.
- Avoid `format!("{err:?}")` in assertions unless the debug format is explicitly part of the contract.

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


Grey Divider

Previous review results

Review updated until commit 3271334

Results up to commit f9cf80b


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


Remediation recommended
1. resolve_pnpm_version doc duplicates test ✓ Resolved 📘 Rule violation ⚙ Maintainability
Description
The rationale for skipping trustPolicy='no-downgrade' during self-update resolution is explained
in detail both in the function doc comment and again in the new test, which increases maintenance
cost and can drift over time. Keep the detailed scenario narrative in one place and let the other
location reference it briefly.
Code

pacquet/crates/cli/src/config_deps.rs[R87-94]

+/// The `trustPolicy='no-downgrade'` check is intentionally *not* applied
+/// here, matching the TypeScript `self-update` (`selfUpdate.ts`), which
+/// resolves the target version without passing `trustPolicy`. The engine
+/// pick uses abbreviated metadata (no per-version `time`), which the
+/// trust check requires; running it here would fail closed with a
+/// "missing time" error on every self-update. The trust downgrade is
+/// still enforced by the install-time lockfile verifier, which fetches
+/// full metadata for the check.
Evidence
PR Compliance ID 713470 requires avoiding duplicated test-scenario explanations across
implementation docs and tests. The resolve_pnpm_version doc comment contains a full narrative of
the abbreviated-metadata/missing-time issue and trust-policy rationale, and the new test repeats
the same explanation immediately above the test.

Rule 713470: Avoid duplicating test scenario explanations in both code and doc comments
pacquet/crates/cli/src/config_deps.rs[81-94]
pacquet/crates/cli/src/config_deps/tests.rs[42-47]

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 detailed explanation of why `trustPolicy='no-downgrade'` is skipped for `resolve_pnpm_version` is duplicated between the function doc comment and the regression test doc comment. This violates the guideline to avoid repeating the same scenario explanation in multiple places.

## Issue Context
The function doc comment in `config_deps.rs` explains the abbreviated metadata / missing `time` reasoning, and the test in `tests.rs` repeats essentially the same narrative.

## Fix Focus Areas
- pacquet/crates/cli/src/config_deps.rs[81-94]
- pacquet/crates/cli/src/config_deps/tests.rs[42-47]

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


Results up to commit 117e24e


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


Remediation recommended
1. Relink errors silently dropped 🐞 Bug ◔ Observability
Description
reuse_cached_engine() collapses any link_exe_platform_binary() error into false via
.is_ok(), so self-update falls back to a reinstall without surfacing why the cached slot couldn’t
be reused. This makes troubleshooting and security auditing harder (e.g., distinguishing legacy
layout vs. unexpected filesystem/link failures) and can lead to repeated reinstall attempts when the
underlying relink failure is persistent.
Code

pacquet/crates/cli/src/cli_args/self_update/install_pnpm.rs[R139-140]

+    !package.links_native_binary || link_exe_platform_binary(install_dir, package.name).is_ok()
+}
Evidence
The reuse decision now depends on link_exe_platform_binary(...).is_ok(), which discards the error;
and install_pnpm() uses this boolean to choose reuse vs. reinstall without logging the relink
failure reason.

pacquet/crates/cli/src/cli_args/self_update/install_pnpm.rs[68-78]
pacquet/crates/cli/src/cli_args/self_update/install_pnpm.rs[135-140]

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

### Issue description
`reuse_cached_engine()` currently converts `link_exe_platform_binary()` failures into a plain `false` (`.is_ok()`), which drops the underlying error context. The caller then silently falls back to a fresh install. This is an observability regression vs. the prior behavior (which surfaced the relink error), and it makes persistent relink failures hard to diagnose.

### Issue Context
The intent (fallback to fresh install instead of aborting self-update) is good and should remain. The fix should preserve that behavior while retaining enough diagnostics to explain why reuse was rejected.

### Fix Focus Areas
- pacquet/crates/cli/src/cli_args/self_update/install_pnpm.rs[139-140]

### Suggested implementation direction
- Replace the `.is_ok()` collapse with explicit error capture:
 - `match link_exe_platform_binary(...) { Ok(()) => true, Err(e) => { /* log */; false } }`
- Emit a debug/warn log containing the error (and possibly the install_dir/package) before returning `false`.
- Keep the fallback-to-fresh-install behavior unchanged.

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


2. Duplicate reuse_cached_engine explanation 📘 Rule violation ⚙ Maintainability
Description
The wrapper-escape scenario and expected fallback behavior are explained both in the
reuse_cached_engine doc comment and again in the test comment, duplicating the same narrative.
This increases maintenance cost and risks drift between the two descriptions.
Code

pacquet/crates/cli/src/cli_args/self_update/install_pnpm/tests.rs[R205-208]

+/// A slot left by an older layout whose wrapper symlink escapes the slot
+/// (e.g. into a shared global virtual store) must not be reused — the
+/// caller falls through to a fresh install instead of aborting the whole
+/// self-update on the wrapper-containment guard.
Evidence
The checklist rule forbids duplicating scenario explanations across docs and tests. The test comment
describes the same wrapper-escape/fallback-to-fresh-install narrative that is already covered in the
reuse_cached_engine doc comment.

Rule 713470: Avoid duplicating test scenario explanations in both code and doc comments
pacquet/crates/cli/src/cli_args/self_update/install_pnpm/tests.rs[205-208]
pacquet/crates/cli/src/cli_args/self_update/install_pnpm.rs[119-134]

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 test comment for `reuse_cached_engine_rejects_a_wrapper_that_escapes_the_slot` repeats the same scenario/rationale already documented on `reuse_cached_engine` itself.

## Issue Context
Prefer to keep the detailed rationale in one place (typically the function doc comment) and keep the test comment minimal (or remove it), letting the test name + assertions describe the behavior.

## Fix Focus Areas
- pacquet/crates/cli/src/cli_args/self_update/install_pnpm/tests.rs[205-208]
- pacquet/crates/cli/src/cli_args/self_update/install_pnpm.rs[115-134]

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


3. Historical older layout comment 📘 Rule violation ⚙ Maintainability
Description
The new reuse_cached_engine doc comment uses historical phrasing (older ... layout) instead of
describing the current behavior and constraints, which can quickly become inaccurate as layouts
evolve. This violates the requirement to avoid historical implementation commentary in source
comments.
Code

pacquet/crates/cli/src/cli_args/self_update/install_pnpm.rs[R131-134]

+/// A slot whose wrapper escapes the slot is what an older global-virtual-
+/// store layout legitimately produces (the wrapper symlinks into the
+/// shared `<store>/links` tree), so this recovery is the common upgrade
+/// path, not only an adversarial one.
Evidence
The rule forbids comments that reference past behavior/implementations using historical phrasing
like older. The added doc comment explicitly describes an older ... layout as the motivating
case.

Rule 772199: Comments must describe current behavior, not historical implementations
pacquet/crates/cli/src/cli_args/self_update/install_pnpm.rs[131-134]

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 `reuse_cached_engine` doc comment uses historical phrasing (e.g., `older ... layout`), which violates the rule that comments must describe current behavior, not past implementations.

## Issue Context
This comment is explaining why wrapper-containment failures should cause a fresh install fallback. That rationale can be expressed without anchoring it to a temporal claim like "older".

## Fix Focus Areas
- pacquet/crates/cli/src/cli_args/self_update/install_pnpm.rs[131-134]

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


Results up to commit ba5234a


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


Action required
1. No-downgrade can miss trust ✓ Resolved 🐞 Bug ⛨ Security
Description
Config::requires_full_metadata_for_resolution() allows trustPolicy=no-downgrade to avoid full
packuments when registry_supports_time_field=true, but abbreviated packuments can omit the
trust-evidence fields the downgrade check needs, so the downgrade can be missed and a weaker-trust
version can be selected.
Code

pacquet/crates/config/src/lib.rs[R1568-1572]

+    pub fn requires_full_metadata_for_resolution(&self) -> bool {
+        (self.resolution_mode == ResolutionMode::TimeBased
+            || self.trust_policy == TrustPolicy::NoDowngrade)
+            && !self.registry_supports_time_field
+    }
Evidence
The resolver’s abbreviated packument mode is documented to omit _npmUser and dist.attestations,
and the trust-downgrade check reads those exact fields. Because
requires_full_metadata_for_resolution() can return false under trustPolicy=no-downgrade (when
registry_supports_time_field=true), the resolver can remain in abbreviated mode (via the Accept
header selection) and thus lack the evidence required to detect a downgrade.

pacquet/crates/config/src/lib.rs[1557-1572]
pacquet/crates/cli/src/config_deps.rs[292-313]
pacquet/crates/resolving-npm-resolver/src/fetch_full_metadata.rs[3-18]
pacquet/crates/resolving-npm-resolver/src/fetch_full_metadata_cached.rs[104-106]
pacquet/crates/resolving-npm-resolver/src/trust_checks.rs[248-267]
pnpm11/engine/pm/commands/src/self-updater/selfUpdate.ts[83-100]
pnpm11/resolving/npm-resolver/src/trustChecks.ts[34-80]

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

### Issue description
`trustPolicy=no-downgrade` requires per-version trust evidence (e.g. `_npmUser.*` and `dist.attestations.*`) to detect a downgrade. The current `requires_full_metadata_for_resolution()` returns `false` when `registry_supports_time_field=true`, which can keep resolution on abbreviated `install-v1` packuments; those packuments may omit the trust-evidence fields, making the downgrade check ineffective (false negatives).

### Issue Context
- Pacquet’s metadata fetcher documents that the abbreviated packument drops `_npmUser` and `dist.attestations`, which are exactly what the trust checks read.
- The trust check implementation indeed uses `version.npm_user.*` and `version.dist.attestations.*`.
- EnvInstallerContext wires `Config::requires_full_metadata_for_resolution()` into the resolver’s `full_metadata` flag, which controls the `Accept` header.
- pnpm11’s `selfUpdate.ts` uses the same `&& !opts.registrySupportsTimeField` gating for `trustPolicy='no-downgrade'`, so TypeScript self-update has the same risk.

### Fix Focus Areas
- pacquet/crates/config/src/lib.rs[1557-1572]
- pacquet/crates/cli/src/config_deps.rs[304-312]
- pacquet/crates/resolving-npm-resolver/src/fetch_full_metadata.rs[3-18]
- pacquet/crates/resolving-npm-resolver/src/trust_checks.rs[248-267]
- pnpm11/engine/pm/commands/src/self-updater/selfUpdate.ts[83-100]

### Suggested fix
- Make `trustPolicy=no-downgrade` force full metadata regardless of `registry_supports_time_field` (security > perf), e.g.:
 - Rust: `if self.trust_policy == TrustPolicy::NoDowngrade { return true; }` and keep the time-based branch gated by `!registry_supports_time_field`.
 - TypeScript: similarly set `fullMetadata = opts.trustPolicy === 'no-downgrade' || ((...) && !opts.registrySupportsTimeField)`.
- Add/adjust tests to cover `trustPolicy=no-downgrade` with `registrySupportsTimeField=true` and assert it still fetches full metadata (or still rejects a downgrade).

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



Remediation recommended
2. Redundant scenario comments in tests 📘 Rule violation ⚙ Maintainability
Description
pacquet/crates/cli/src/config_deps/tests.rs contains long doc comments that restate the same
scenario already encoded by the test setup and assertions (and also repeats nearby constant
comments). This duplication increases maintenance cost and risks comment/test drift over time.
Code

pacquet/crates/cli/src/config_deps/tests.rs[R90-136]

+/// Abbreviated packument: no `time` map. Served only to the abbreviated
+/// `Accept` header, so the probe reaches it only if it *fails* to request
+/// full metadata — in which case the trust check fails closed with
+/// "missing time". A test that instead sees a "trust downgrade" (or a
+/// clean resolve) proves the probe requested full metadata.
+const ABBREVIATED_BODY: &str = r#"{
+    "name": "pnpm",
+    "dist-tags": { "latest": "1.1.0" },
+    "versions": {
+        "1.0.0": {
+            "name": "pnpm",
+            "version": "1.0.0",
+            "dist": {
+                "integrity": "sha512-AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA==",
+                "shasum": "0000000000000000000000000000000000000000",
+                "tarball": "https://registry/pnpm-1.0.0.tgz"
+            }
+        },
+        "1.1.0": {
+            "name": "pnpm",
+            "version": "1.1.0",
+            "dist": {
+                "integrity": "sha512-BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB==",
+                "shasum": "1111111111111111111111111111111111111111",
+                "tarball": "https://registry/pnpm-1.1.0.tgz"
+            }
+        }
+    }
+}"#;
+
+fn no_downgrade_config(registry: String, cache_dir: &Path) -> Config {
+    let mut config = Config {
+        trust_policy: TrustPolicy::NoDowngrade,
+        cache_dir: cache_dir.to_path_buf(),
+        ..Config::default()
+    };
+    config.package_manager_bootstrap.registry = registry;
+    config
+}
+
+/// Under `trustPolicy=no-downgrade`, the self-update probe must resolve
+/// against **full** metadata — the same as a regular install — so the
+/// no-downgrade check actually runs. It reaches the full packument (with
+/// `time`), sees the downgrade, and rejects it. If the probe fetched
+/// abbreviated metadata it would instead fail closed with "missing time";
+/// if it skipped the check it would resolve `1.1.0` with no error.
+#[tokio::test]
Evidence
The constant comment explains what would happen with abbreviated metadata ("missing time"), and the
test doc comment repeats the same narrative about full vs abbreviated metadata and expected
rejection; the assertions already validate the observable behavior. This is exactly the kind of
duplicated scenario explanation these rules prohibit.

Rule 713470: Avoid duplicating test scenario explanations in both code and doc comments
Rule 713467: Avoid redundant comments that restate the code
pacquet/crates/cli/src/config_deps/tests.rs[90-136]

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

## Issue description
New/modified doc comments in the Rust tests repeat detailed scenario narratives that are already expressed by the test data and assertions, and in some cases duplicate other nearby comments. This violates the guideline to avoid duplicating scenario explanations in both code and doc comments and creates drift risk.

## Issue Context
The file adds extensive explanatory prose for packument fixtures and the `resolve_pnpm_version_*` tests. The tests themselves (mock setup + assertions) already communicate the key behavior, so these comments can be shortened to focus on *why the scenario matters*.

## Fix Focus Areas
- pacquet/crates/cli/src/config_deps/tests.rs[90-136]

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


Qodo Logo

@qodo-code-review

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

Copy link
Copy Markdown

PR Code Suggestions ✨

Latest suggestions up to ba5234a

Warning

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

CategorySuggestion                                                                                                                                    Impact
Possible issue
Fetch full metadata when needed

Include minimumReleaseAge in the requires_full_metadata_for_resolution function
to fetch full metadata when needed.

pacquet/crates/config/src/lib.rs [1567-1572]

 #[must_use]
 pub fn requires_full_metadata_for_resolution(&self) -> bool {
     (self.resolution_mode == ResolutionMode::TimeBased
-        || self.trust_policy == TrustPolicy::NoDowngrade)
+        || self.trust_policy == TrustPolicy::NoDowngrade
+        || self.resolved_minimum_release_age().is_some())
         && !self.registry_supports_time_field
 }
  • Apply / Chat
Suggestion importance[1-10]: 8

__

Why: This suggestion accurately catches a missing condition in the Rust implementation compared to the TypeScript one, preventing potential failures due to missing time metadata and ensuring parity.

Medium
Assert full-metadata fetch in test

Update the mock test to return different metadata based on the request's Accept
header. This ensures the test accurately verifies whether full metadata was
requested.

pnpm11/engine/pm/commands/test/self-updater/selfUpdate.test.ts [337-339]

+const abbreviatedMetadata = { ...metadata }
+delete (abbreviatedMetadata as any).time
+
 getMockAgent().get(registry.replace(/\/$/, ''))
-  .intercept({ path: '/pnpm', method: 'GET' })
+  .intercept({
+    path: '/pnpm',
+    method: 'GET',
+    headers: { accept: 'application/json; q=1.0, */*' },
+  })
   .reply(200, metadata).persist()
 
+getMockAgent().get(registry.replace(/\/$/, ''))
+  .intercept({
+    path: '/pnpm',
+    method: 'GET',
+    headers: { accept: 'application/vnd.npm.install-v1+json; q=1.0, application/json; q=0.8, */*' },
+  })
+  .reply(200, abbreviatedMetadata).persist()
+
  • Apply / Chat
Suggestion importance[1-10]: 7

__

Why: This improves test reliability by explicitly verifying the Accept header used for metadata requests, preventing false positives if abbreviated metadata were incorrectly requested.

Medium
  • More

Previous suggestions

Suggestions up to commit 117e24e
CategorySuggestion                                                                                                                                    Impact
Possible issue
Clean up after relink failure

Clean up pnpm executable paths in the wrapper directory if
link_exe_platform_binary fails.

pacquet/crates/cli/src/cli_args/self_update/install_pnpm.rs [135-140]

 fn reuse_cached_engine(install_dir: &Path, package: PnpmPackageToInstall, version: &str) -> bool {
     if installed_version(install_dir, package.name).as_deref() != Some(version) {
         return false;
     }
-    !package.links_native_binary || link_exe_platform_binary(install_dir, package.name).is_ok()
+
+    if !package.links_native_binary {
+        return true;
+    }
+
+    match link_exe_platform_binary(install_dir, package.name) {
+        Ok(()) => true,
+        Err(_) => {
+            let _ = fs::remove_file(package_dir(install_dir, package.name).join("pnpm"));
+            let _ = fs::remove_file(package_dir(install_dir, package.name).join("pnpm.exe"));
+            false
+        }
+    }
 }
Suggestion importance[1-10]: 2

__

Why: The docstring explicitly states that link_exe_platform_binary performs containment checks before linking and links nothing on refusal, and the rejected slot is abandoned, making this cleanup unnecessary.

Low
Suggestions up to commit f9cf80b
CategorySuggestion                                                                                                                                    Impact
General
Explicitly disable trust policy

Explicitly set the trust_policy fields to None in ResolveOptions.

pacquet/crates/cli/src/config_deps.rs [134-139]

 let opts = ResolveOptions {
     default_tag: Some("latest".to_string()),
     published_by,
     published_by_exclude,
+    trust_policy: None,
+    trust_policy_ignore_after: None,
     ..ResolveOptions::default()
 };
Suggestion importance[1-10]: 4

__

Why: Explicitly setting these fields to None provides a defensive safeguard against potential future changes to the default values of ResolveOptions, aligning with the explicit docstring about omitting the trust check.

Low
Add JSON content-type header

Add a content-type: application/json header to the mockito mock response.

pacquet/crates/cli/src/config_deps/tests.rs [51-56]

 let _mock = server
     .mock("GET", "/pnpm")
     .with_status(200)
+    .with_header("content-type", "application/json")
     .with_body(ABBREVIATED_PNPM_BODY)
     .create_async()
     .await;
Suggestion importance[1-10]: 3

__

Why: Adding the content-type header makes the mocked server response more robust and closely mirror a real registry API response, though the test likely passes without it.

Low

@codecov-commenter

codecov-commenter commented Jul 7, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 90.47619% with 2 lines in your changes missing coverage. Please review.
✅ Project coverage is 85.82%. Comparing base (de1371d) to head (3271334).
⚠️ Report is 2 commits behind head on main.

Files with missing lines Patch % Lines
...rates/cli/src/cli_args/self_update/install_pnpm.rs 85.71% 1 Missing ⚠️
pacquet/crates/config/src/lib.rs 80.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main   #12838      +/-   ##
==========================================
+ Coverage   85.80%   85.82%   +0.01%     
==========================================
  Files         448      448              
  Lines       69402    69415      +13     
==========================================
+ Hits        59552    59575      +23     
+ Misses       9850     9840      -10     

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

@qodo-free-for-open-source-projects

Copy link
Copy Markdown

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

@github-actions

github-actions Bot commented Jul 7, 2026 •

Copy link
Copy Markdown
Contributor

Integrated-Benchmark Report (Linux)

Commit: 32713349ad17

Each scenario reports direct installs and pnpr installs. Bencher consumes pacquet@HEAD and pnpr@HEAD.

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

Command Mean [s] Min [s] Max [s] Relative
pacquet@HEAD 4.066 ± 0.126 3.912 4.311 1.96 ± 0.08
pacquet@main 4.096 ± 0.160 3.936 4.403 1.97 ± 0.10
pnpr@HEAD 2.089 ± 0.107 1.978 2.251 1.01 ± 0.06
pnpr@main 2.078 ± 0.062 1.992 2.218 1.00
BENCHMARK_REPORT.json
{
  "results": [
    {
      "command": "pacquet@HEAD",
      "mean": 4.06586162206,
      "stddev": 0.125982355271281,
      "median": 4.04707061346,
      "user": 3.9178871599999994,
      "system": 3.40018442,
      "min": 3.91213405046,
      "max": 4.31137130146,
      "times": [
        4.17658962446,
        4.14263586946,
        3.98598513446,
        3.93198621046,
        4.01581294046,
        3.96994721946,
        4.13382558346,
        4.07832828646,
        3.91213405046,
        4.31137130146
      ]
    },
    {
      "command": "pacquet@main",
      "mean": 4.09641589346,
      "stddev": 0.15997308657144915,
      "median": 4.06867726496,
      "user": 3.94253156,
      "system": 3.41087572,
      "min": 3.93578447846,
      "max": 4.40330334446,
      "times": [
        3.95805712946,
        4.15209099946,
        3.98526353046,
        3.96319012246,
        3.95040188646,
        4.40330334446,
        4.21410434846,
        3.93578447846,
        4.17913316946,
        4.22282992546
      ]
    },
    {
      "command": "pnpr@HEAD",
      "mean": 2.08882299086,
      "stddev": 0.10700174920133913,
      "median": 2.0461062959599996,
      "user": 2.73610966,
      "system": 2.91414632,
      "min": 1.97760552446,
      "max": 2.25074835546,
      "times": [
        2.07521213746,
        2.0170004544599998,
        1.97760552446,
        2.10162013146,
        2.24476158846,
        2.00126515346,
        2.20551708346,
        2.25074835546,
        2.00285663746,
        2.01164284246
      ]
    },
    {
      "command": "pnpr@main",
      "mean": 2.0776696549600002,
      "stddev": 0.062197095106126754,
      "median": 2.06537869946,
      "user": 2.7268348599999994,
      "system": 2.9472400199999997,
      "min": 1.99230418846,
      "max": 2.21788323046,
      "times": [
        2.21788323046,
        2.0898436184599998,
        2.06493906046,
        2.05448696946,
        2.04787583646,
        2.06581833846,
        2.08449523346,
        2.13402223446,
        2.02502783946,
        1.99230418846
      ]
    }
  ]
}

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

Command Mean [ms] Min [ms] Max [ms] Relative
pacquet@HEAD 653.7 ± 17.9 626.9 677.3 1.00
pacquet@main 691.0 ± 107.3 635.4 992.2 1.06 ± 0.17
pnpr@HEAD 717.6 ± 42.5 693.2 836.1 1.10 ± 0.07
pnpr@main 737.5 ± 58.3 698.9 893.1 1.13 ± 0.09
BENCHMARK_REPORT.json
{
  "results": [
    {
      "command": "pacquet@HEAD",
      "mean": 0.6537102620999999,
      "stddev": 0.01792142708403315,
      "median": 0.6541717146999999,
      "user": 0.4039797399999999,
      "system": 1.32991952,
      "min": 0.6268850547,
      "max": 0.6772599887,
      "times": [
        0.6715607017,
        0.6350024877,
        0.6772599887,
        0.6553441227,
        0.6425977467,
        0.6363387766999999,
        0.6724824597,
        0.6666319757,
        0.6268850547,
        0.6529993067
      ]
    },
    {
      "command": "pacquet@main",
      "mean": 0.6910375616,
      "stddev": 0.10733942488869277,
      "median": 0.6568112257000001,
      "user": 0.39542853999999994,
      "system": 1.33397852,
      "min": 0.6353627747,
      "max": 0.9921962357,
      "times": [
        0.6500222807,
        0.6532999887,
        0.6582783337,
        0.6668642167,
        0.6360189367,
        0.6634329587,
        0.6995557727,
        0.6353627747,
        0.6553441177,
        0.9921962357
      ]
    },
    {
      "command": "pnpr@HEAD",
      "mean": 0.7175578007000001,
      "stddev": 0.042517408373944354,
      "median": 0.7062471717000001,
      "user": 0.4175645399999999,
      "system": 1.35871452,
      "min": 0.6932158147,
      "max": 0.8361491517,
      "times": [
        0.7125222877,
        0.7132542857,
        0.6932158147,
        0.6977958567,
        0.7117341417,
        0.6961405697,
        0.7165194687,
        0.6974862287,
        0.8361491517,
        0.7007602017
      ]
    },
    {
      "command": "pnpr@main",
      "mean": 0.7375032165000001,
      "stddev": 0.05830786505659497,
      "median": 0.7145740272,
      "user": 0.4145084399999999,
      "system": 1.36559852,
      "min": 0.6988866277,
      "max": 0.8930585217,
      "times": [
        0.7674061717,
        0.7128286087,
        0.7134768917,
        0.7056332347,
        0.7398718747,
        0.6988866277,
        0.8930585217,
        0.7032396657,
        0.7249594057,
        0.7156711627
      ]
    }
  ]
}

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

Command Mean [s] Min [s] Max [s] Relative
pacquet@HEAD 4.205 ± 0.041 4.155 4.296 2.01 ± 0.09
pacquet@main 4.189 ± 0.042 4.107 4.260 2.01 ± 0.09
pnpr@HEAD 2.149 ± 0.174 1.964 2.564 1.03 ± 0.09
pnpr@main 2.087 ± 0.092 2.002 2.326 1.00
BENCHMARK_REPORT.json
{
  "results": [
    {
      "command": "pacquet@HEAD",
      "mean": 4.204961475500001,
      "stddev": 0.04088301012367777,
      "median": 4.2009659603,
      "user": 3.79545058,
      "system": 3.27286942,
      "min": 4.1545004403,
      "max": 4.2960811843,
      "times": [
        4.2368345603,
        4.2010729453,
        4.2136478953,
        4.1555191843,
        4.2960811843,
        4.1545004403,
        4.1919683853,
        4.2008589753,
        4.2136860913,
        4.1854450933
      ]
    },
    {
      "command": "pacquet@main",
      "mean": 4.1893324009,
      "stddev": 0.042355585494679895,
      "median": 4.1989112303,
      "user": 3.7789081800000006,
      "system": 3.2639145199999993,
      "min": 4.1071059863,
      "max": 4.2599961883,
      "times": [
        4.2599961883,
        4.2043174103,
        4.1071059863,
        4.1642353053,
        4.1948316973,
        4.2198085433,
        4.2133993403,
        4.2029907633,
        4.1481729013,
        4.1784658732999995
      ]
    },
    {
      "command": "pnpr@HEAD",
      "mean": 2.1494470711,
      "stddev": 0.17401753682038193,
      "median": 2.1048025143,
      "user": 2.5452264799999993,
      "system": 2.7917180200000002,
      "min": 1.9640200853000003,
      "max": 2.5635570813,
      "times": [
        2.0214588452999998,
        2.1820812993,
        2.0862164623,
        2.0018453823,
        2.2334581022999997,
        2.0711591182999998,
        2.5635570813,
        2.2472857683,
        1.9640200853000003,
        2.1233885663
      ]
    },
    {
      "command": "pnpr@main",
      "mean": 2.0868335123999997,
      "stddev": 0.09175458563207867,
      "median": 2.0663089787999995,
      "user": 2.59398458,
      "system": 2.74770252,
      "min": 2.0019638373,
      "max": 2.3256946693,
      "times": [
        2.0716545752999997,
        2.1135237313,
        2.0019638373,
        2.0898622893,
        2.0609633822999998,
        2.0192562483,
        2.0606822172999997,
        2.0208723403,
        2.1038618333,
        2.3256946693
      ]
    }
  ]
}

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

Command Mean [s] Min [s] Max [s] Relative
pacquet@HEAD 1.373 ± 0.014 1.354 1.395 2.12 ± 0.04
pacquet@main 1.345 ± 0.013 1.327 1.365 2.08 ± 0.04
pnpr@HEAD 0.646 ± 0.009 0.632 0.658 1.00
pnpr@main 0.669 ± 0.078 0.632 0.888 1.04 ± 0.12
BENCHMARK_REPORT.json
{
  "results": [
    {
      "command": "pacquet@HEAD",
      "mean": 1.372779129,
      "stddev": 0.013573728412099735,
      "median": 1.3726224429,
      "user": 1.3280538200000003,
      "system": 1.6970642599999999,
      "min": 1.3543871589,
      "max": 1.3952641849,
      "times": [
        1.3543871589,
        1.3939266619000001,
        1.3742244169,
        1.3641974639,
        1.3674192619,
        1.3753277589000001,
        1.3570254439,
        1.3710204689,
        1.3952641849,
        1.3749984699
      ]
    },
    {
      "command": "pacquet@main",
      "mean": 1.3448204546,
      "stddev": 0.013180361602811821,
      "median": 1.3437945659000001,
      "user": 1.28767442,
      "system": 1.6723378600000003,
      "min": 1.3272853359,
      "max": 1.3645211209,
      "times": [
        1.3586580679,
        1.3566906589,
        1.3645211209,
        1.3530644819000002,
        1.3391762329,
        1.3285771299,
        1.3356543979,
        1.3484128989,
        1.3361642209,
        1.3272853359
      ]
    },
    {
      "command": "pnpr@HEAD",
      "mean": 0.6461976376,
      "stddev": 0.009237896194321433,
      "median": 0.6454433654,
      "user": 0.35008282,
      "system": 1.22900906,
      "min": 0.6316936769000001,
      "max": 0.6575531139,
      "times": [
        0.6428898549000001,
        0.6535378179000001,
        0.6424378849000001,
        0.6316936769000001,
        0.6363330369000001,
        0.6551123989000001,
        0.6563680299000001,
        0.6380536859000001,
        0.6575531139,
        0.6479968759000001
      ]
    },
    {
      "command": "pnpr@main",
      "mean": 0.6693546278,
      "stddev": 0.07822851922471682,
      "median": 0.6411754319,
      "user": 0.33182232,
      "system": 1.2545651599999998,
      "min": 0.6316299959,
      "max": 0.8883341759000001,
      "times": [
        0.6450681359,
        0.6316299959,
        0.6376380359,
        0.6363181369,
        0.6385867339000001,
        0.6356006469000001,
        0.6437641299000001,
        0.6799619529,
        0.8883341759000001,
        0.6566443339000001
      ]
    }
  ]
}

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

Command Mean [s] Min [s] Max [s] Relative
pacquet@HEAD 3.099 ± 0.050 3.026 3.187 4.74 ± 0.11
pacquet@main 3.036 ± 0.030 2.975 3.068 4.65 ± 0.09
pnpr@HEAD 0.669 ± 0.009 0.655 0.684 1.02 ± 0.02
pnpr@main 0.653 ± 0.011 0.632 0.666 1.00
BENCHMARK_REPORT.json
{
  "results": [
    {
      "command": "pacquet@HEAD",
      "mean": 3.0990724697600003,
      "stddev": 0.049969356260155244,
      "median": 3.09307968536,
      "user": 1.8257968999999996,
      "system": 1.9719896600000002,
      "min": 3.02550325286,
      "max": 3.18655186186,
      "times": [
        3.18655186186,
        3.09255827986,
        3.14982796086,
        3.09360109086,
        3.05724358186,
        3.02550325286,
        3.07350630986,
        3.11982501986,
        3.05185703086,
        3.14025030886
      ]
    },
    {
      "command": "pacquet@main",
      "mean": 3.03621299046,
      "stddev": 0.030334381772600266,
      "median": 3.04392122036,
      "user": 1.7510197,
      "system": 1.98277456,
      "min": 2.97462389786,
      "max": 3.06795214786,
      "times": [
        3.05484072886,
        3.01953825486,
        2.97462389786,
        3.04197472386,
        3.00617684186,
        3.04586771686,
        3.0218763968599998,
        3.06632469486,
        3.06795214786,
        3.06295450086
      ]
    },
    {
      "command": "pnpr@HEAD",
      "mean": 0.6691020908599999,
      "stddev": 0.009445930106421405,
      "median": 0.6677585298600001,
      "user": 0.3511463999999999,
      "system": 1.28924216,
      "min": 0.65513488586,
      "max": 0.68362119986,
      "times": [
        0.68362119986,
        0.68290296986,
        0.65513488586,
        0.66402664186,
        0.66045424586,
        0.67486470186,
        0.6627282518600001,
        0.6644747278600001,
        0.6710423318600001,
        0.67177095186
      ]
    },
    {
      "command": "pnpr@main",
      "mean": 0.6532680764600001,
      "stddev": 0.010965460673887248,
      "median": 0.6570279638600001,
      "user": 0.32776869999999997,
      "system": 1.2749804599999999,
      "min": 0.63212870886,
      "max": 0.6657034618600001,
      "times": [
        0.6657034618600001,
        0.64925032486,
        0.6564165818600001,
        0.64309611586,
        0.63212870886,
        0.65880355086,
        0.6624625228600001,
        0.64318235286,
        0.66399779886,
        0.6576393458600001
      ]
    }
  ]
}

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

Command Mean [ms] Min [ms] Max [ms] Relative
pacquet@HEAD 659.5 ± 12.0 645.9 688.4 6.13 ± 0.12
pacquet@main 660.0 ± 6.0 652.9 670.1 6.14 ± 0.06
pnpr@HEAD 107.5 ± 0.5 106.8 109.7 1.00
pnpr@main 109.2 ± 2.3 106.2 113.1 1.02 ± 0.02
BENCHMARK_REPORT.json
{
  "results": [
    {
      "command": "pacquet@HEAD",
      "mean": 0.65954988444,
      "stddev": 0.011992128590816829,
      "median": 0.65651651734,
      "user": 0.61947276,
      "system": 0.14792487999999998,
      "min": 0.64592466534,
      "max": 0.68841086534,
      "times": [
        0.68841086534,
        0.66704689134,
        0.64592466534,
        0.64713300234,
        0.65601909734,
        0.65701393734,
        0.66207978634,
        0.66134710734,
        0.65519362334,
        0.65532986834
      ]
    },
    {
      "command": "pacquet@main",
      "mean": 0.6599586253399999,
      "stddev": 0.005969254078177028,
      "median": 0.65851457334,
      "user": 0.61728916,
      "system": 0.15249108,
      "min": 0.65288954534,
      "max": 0.67012844734,
      "times": [
        0.6544615553400001,
        0.66477233934,
        0.65667638134,
        0.65288954534,
        0.66482156134,
        0.65687620234,
        0.67012844734,
        0.66529111534,
        0.66015294434,
        0.65351616134
      ]
    },
    {
      "command": "pnpr@HEAD",
      "mean": 0.10753116606000003,
      "stddev": 0.0005211713855071677,
      "median": 0.10741075834000001,
      "user": 0.02716454,
      "system": 0.020566959999999995,
      "min": 0.10676130334000002,
      "max": 0.10966246234000002,
      "times": [
        0.10966246234000002,
        0.10738833434000002,
        0.10712284934,
        0.10794530034000001,
        0.10693821434,
        0.10775471234,
        0.10745048334000001,
        0.10714555834000002,
        0.10790176434000001,
        0.10740431434000001,
        0.10740167434,
        0.10676130334000002,
        0.10738794834000001,
        0.10732683234000001,
        0.10764475634000001,
        0.10731900934000001,
        0.10741075834000001,
        0.10747282234000001,
        0.10736814934000001,
        0.10753533634000001,
        0.10776985534000001,
        0.10752161834000001,
        0.10734638134,
        0.10773403134000001,
        0.10756468134000001
      ]
    },
    {
      "command": "pnpr@main",
      "mean": 0.10916617446,
      "stddev": 0.0022608869681470588,
      "median": 0.10788323634000001,
      "user": 0.027376739999999997,
      "system": 0.021189119999999995,
      "min": 0.10621577434000001,
      "max": 0.11309895434000002,
      "times": [
        0.10728895534,
        0.10735049734,
        0.10832014134000001,
        0.10621577434000001,
        0.10788323634000001,
        0.10905002834000001,
        0.11197326534000002,
        0.10744645734000001,
        0.10692990234000001,
        0.10771428734,
        0.10692633734000001,
        0.10759127134000002,
        0.10746589734,
        0.11309895434000002,
        0.11155402234000002,
        0.10736560534,
        0.10853887634,
        0.11117985734000001,
        0.11227516134000001,
        0.11204679134000001,
        0.11287116134000001,
        0.11123515134,
        0.10765482634000001,
        0.11170693334000001,
        0.10747096934000001
      ]
    }
  ]
}

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

Command Mean [s] Min [s] Max [s] Relative
pacquet@HEAD 6.844 ± 0.177 6.666 7.256 1.39 ± 0.05
pacquet@main 6.818 ± 0.133 6.647 7.005 1.39 ± 0.04
pnpr@HEAD 4.938 ± 0.150 4.763 5.278 1.00 ± 0.04
pnpr@main 4.922 ± 0.105 4.804 5.103 1.00
BENCHMARK_REPORT.json
{
  "results": [
    {
      "command": "pacquet@HEAD",
      "mean": 6.844423583300001,
      "stddev": 0.17657928126218403,
      "median": 6.782227355400001,
      "user": 4.08910004,
      "system": 3.6428145599999993,
      "min": 6.6657322264,
      "max": 7.2563375034,
      "times": [
        6.754292743400001,
        6.900415969400001,
        6.6657322264,
        6.9949273814,
        6.772984557400001,
        6.778059698400001,
        6.868572252400001,
        6.6665184884,
        6.786395012400001,
        7.2563375034
      ]
    },
    {
      "command": "pacquet@main",
      "mean": 6.8180905890000005,
      "stddev": 0.13261201380704468,
      "median": 6.8357972559,
      "user": 4.138535639999999,
      "system": 3.67783306,
      "min": 6.6471764144000005,
      "max": 7.004961913400001,
      "times": [
        6.7128676004,
        6.6599932374,
        6.6998250354,
        6.8551063784,
        6.9625856694,
        7.004961913400001,
        6.8164881334,
        6.9588568734,
        6.8630446344000005,
        6.6471764144000005
      ]
    },
    {
      "command": "pnpr@HEAD",
      "mean": 4.937600537600001,
      "stddev": 0.15037465984401516,
      "median": 4.898406216400001,
      "user": 2.81105724,
      "system": 3.09712806,
      "min": 4.7630235004,
      "max": 5.278133367400001,
      "times": [
        5.278133367400001,
        4.884998337400001,
        4.8232901834,
        4.935852043400001,
        4.9118140954000005,
        4.9421822064,
        4.7630235004,
        4.8815112094,
        5.1083753964000005,
        4.8468250364
      ]
    },
    {
      "command": "pnpr@main",
      "mean": 4.9221657156,
      "stddev": 0.10459489275537265,
      "median": 4.8773127164000005,
      "user": 2.8352564399999993,
      "system": 3.1155261600000004,
      "min": 4.803715283400001,
      "max": 5.1026267694000005,
      "times": [
        4.891451125400001,
        4.9473200654000005,
        5.1026267694000005,
        4.803715283400001,
        4.8424108834,
        4.8631743074000005,
        4.8578944034000004,
        5.0746303154,
        4.8384285894,
        5.0000054134
      ]
    }
  ]
}

@github-actions

github-actions Bot commented Jul 7, 2026 •

Copy link
Copy Markdown
Contributor

🐰 Bencher Report

Branchpr/12838
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
4,204.96 ms
(-0.51%)Baseline: 4,226.41 ms
5,071.69 ms
(82.91%)
isolated-linker.fresh-install.cold-cache.hot-store📈 view plot
🚷 view threshold
3,099.07 ms
(+2.79%)Baseline: 3,014.96 ms
3,617.96 ms
(85.66%)
isolated-linker.fresh-install.hot-cache.hot-store📈 view plot
🚷 view threshold
1,372.78 ms
(+2.74%)Baseline: 1,336.10 ms
1,603.32 ms
(85.62%)
isolated-linker.fresh-resolve.hot-cache.offline📈 view plot
🚷 view threshold
659.55 ms
(+4.09%)Baseline: 633.64 ms
760.37 ms
(86.74%)
isolated-linker.fresh-restore.cold-cache.cold-store📈 view plot
🚷 view threshold
4,065.86 ms
(+2.19%)Baseline: 3,978.68 ms
4,774.41 ms
(85.16%)
isolated-linker.fresh-restore.cold-cache.cold-store.cold-pnpr📈 view plot
🚷 view threshold
6,844.42 ms
(+0.39%)Baseline: 6,817.85 ms
8,181.42 ms
(83.66%)
isolated-linker.fresh-restore.hot-cache.hot-store📈 view plot
🚷 view threshold
653.71 ms
(+3.46%)Baseline: 631.84 ms
758.21 ms
(86.22%)
🐰 View full continuous benchmarking report in Bencher

@github-actions

github-actions Bot commented Jul 7, 2026 •

Copy link
Copy Markdown
Contributor

🐰 Bencher Report

Branchpr/12838
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
2,149.45 ms
isolated-linker.fresh-install.cold-cache.hot-store📈 view plot
⚠️ NO THRESHOLD
669.10 ms
isolated-linker.fresh-install.hot-cache.hot-store📈 view plot
⚠️ NO THRESHOLD
646.20 ms
isolated-linker.fresh-resolve.hot-cache.offline📈 view plot
⚠️ NO THRESHOLD
107.53 ms
isolated-linker.fresh-restore.cold-cache.cold-store📈 view plot
⚠️ NO THRESHOLD
2,088.82 ms
isolated-linker.fresh-restore.cold-cache.cold-store.cold-pnpr📈 view plot
⚠️ NO THRESHOLD
4,937.60 ms
isolated-linker.fresh-restore.hot-cache.hot-store📈 view plot
⚠️ NO THRESHOLD
717.56 ms
🐰 View full continuous benchmarking report in Bencher

@zkochan zkochan changed the title fix(pacquet-cli): skip trust check when resolving the pnpm engine version fix(pacquet-cli): fix pnpm self-update trust-check and engine-relink failures Jul 7, 2026

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🧹 Nitpick comments (1)
pacquet/crates/cli/src/cli_args/self_update/install_pnpm/tests.rs (1)

184-194: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Add coverage for the Windows relink path.

This positive reuse test is Unix-only, but reuse_cached_engine now calls link_exe_platform_binary, which has Windows-specific .exe and alias-linking behavior. Please add a Windows-specific regression test, or make the fixture exercise both executable names where CI supports it. As per path instructions, “tests must prove the changed behavior,” and pacquet tests should cover behavior changes at the right level.

🤖 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 `@pacquet/crates/cli/src/cli_args/self_update/install_pnpm/tests.rs` around
lines 184 - 194, The existing reuse_cached_engine regression test only covers
the Unix relink path, but link_exe_platform_binary now has Windows-specific .exe
and alias-linking behavior. Add a Windows-focused test alongside
reuse_cached_engine_accepts_a_healthy_slot, or extend the fixture in
install_pnpm/tests.rs to exercise both executable names when running on Windows,
so the test proves the changed behavior for reuse_cached_engine and
link_exe_platform_binary. Keep the coverage at the same integration level as the
current pnpm install tests and verify the linked executable/alias state after
relinking.

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 `@pacquet/crates/cli/src/cli_args/self_update/install_pnpm/tests.rs`:
- Around line 184-194: The existing reuse_cached_engine regression test only
covers the Unix relink path, but link_exe_platform_binary now has
Windows-specific .exe and alias-linking behavior. Add a Windows-focused test
alongside reuse_cached_engine_accepts_a_healthy_slot, or extend the fixture in
install_pnpm/tests.rs to exercise both executable names when running on Windows,
so the test proves the changed behavior for reuse_cached_engine and
link_exe_platform_binary. Keep the coverage at the same integration level as the
current pnpm install tests and verify the linked executable/alias state after
relinking.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: 3e94d2dc-b955-4028-ba88-781f628724ad

📥 Commits

Reviewing files that changed from the base of the PR and between f9cf80b and 117e24e.

📒 Files selected for processing (3)
  • pacquet/crates/cli/src/cli_args/self_update/install_pnpm.rs
  • pacquet/crates/cli/src/cli_args/self_update/install_pnpm/tests.rs
  • pacquet/crates/cli/src/config_deps.rs
🚧 Files skipped from review as they are similar to previous changes (1)
  • pacquet/crates/cli/src/config_deps.rs

@qodo-code-review

Copy link
Copy Markdown

Code review by qodo was updated up to the latest commit 117e24e

@qodo-free-for-open-source-projects

Copy link
Copy Markdown

Code review by qodo was updated up to the latest commit 117e24e

1 similar comment
@qodo-free-for-open-source-projects

Copy link
Copy Markdown

Code review by qodo was updated up to the latest commit 117e24e

zkochan added 2 commits July 7, 2026 16:33
`pnpm self-update` (and, in pacquet, `pnpm with` / CLI auto-switching)
resolved the target pnpm version with a self-update-specific resolver that
fetched abbreviated registry metadata and — depending on the stack — either
crashed or silently skipped the no-downgrade trust check:

- pacquet passed `trustPolicy` into the resolve but the resolver was hard-
  wired to abbreviated metadata (no per-version `time`), so the check
  failed closed on every self-update with "trust check failed: missing
  time for version <version> of pnpm in metadata".
- the TypeScript CLI never passed `trustPolicy` into its resolve at all, so
  `trustPolicy=no-downgrade` was not enforced when picking the pnpm version.

Resolve the engine version the same way a regular install does instead of
special-casing self-update: derive the metadata mode from config and pass
the trust policy through.

- pacquet: add `Config::requires_full_metadata_for_resolution` and use it in
  both `PickPolicy` (install path) and the env-installer resolver
  (`resolve_pnpm_version`), and restore `trust_policy*` on its resolve
  options. Under `resolutionMode=time-based` / `trustPolicy=no-downgrade`
  the probe now fetches the full packument the checks need.
- TypeScript: compute `fullMetadata` in `selfUpdate.ts` (mirroring `dlx`)
  and pass `fullMetadata`/`filterMetadata` to `createResolver`, and pass
  `trustPolicy`/`trustPolicyExclude`/`trustPolicyIgnoreAfter` into the
  `resolve()` call (its resolve is the sole version selection, unlike
  `dlx`).

Adds tests on both stacks: a trust-downgraded pnpm is rejected under
no-downgrade, and a clean update still resolves. The pacquet test serves
abbreviated metadata without `time` to the abbreviated `Accept` header, so
it also proves the probe requests full metadata rather than failing closed.
`pnpm self-update <target <= v11>` aborted with "the installed pnpm
wrapper at <slot>/node_modules/`@pnpm/exe` resolves outside <slot>" when an
existing global `@pnpm/exe` slot left by an older layout symlinks its
wrapper into a shared location outside the per-slot directory (e.g. the
global virtual store).

On a version cache-hit, `install_pnpm` relinks the engine's native
platform binary; because the wrapper resolved outside the slot,
`link_exe_platform_binary`'s containment guard rejected it and the `?`
propagated the error, failing the whole self-update.

Make the cache-hit relink best-effort: `reuse_cached_engine` reports a
relink failure as "not reusable", so the caller falls through to a fresh,
self-contained install instead of aborting. The containment guard is
unchanged — it still refuses to link a wrapper that escapes the slot, and
nothing from the rejected slot is linked or executed; the fresh install
downloads and signature-verifies the engine into a new slot, then the old
slot is orphaned and cleaned on a later run.

Add unit tests: a healthy slot is reused (and relinked), a version
mismatch is not reused, and a slot whose wrapper escapes the slot is not
reused so the caller reinstalls.
Copilot AI review requested due to automatic review settings July 7, 2026 14:35
@zkochan
zkochan force-pushed the fix-self-update branch from 117e24e to ba5234a Compare July 7, 2026 14:35

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 changed the title fix(pacquet-cli): fix pnpm self-update trust-check and engine-relink failures fix: honor trustPolicy in pnpm self-update, and recover from unusable cached engine slots Jul 7, 2026
Comment thread pacquet/crates/config/src/lib.rs Resolved
@qodo-code-review

Copy link
Copy Markdown

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

@qodo-free-for-open-source-projects

Copy link
Copy Markdown

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

1 similar comment
@qodo-free-for-open-source-projects

Copy link
Copy Markdown

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

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 1

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
pnpm11/engine/pm/commands/src/self-updater/selfUpdate.ts (1)

61-73: 🎯 Functional Correctness | 🟠 Major | ⚡ Quick win

Add the missing config fields to SelfUpdateCommandOptions

SelfUpdateCommandOptions only inherits CreateStoreControllerOptions plus the current Pick<Config, ...>, but this function reads opts.resolutionMode, opts.trustPolicy, opts.trustPolicyExclude, opts.trustPolicyIgnoreAfter, and opts.registrySupportsTimeField. Those need to be included here, or this won’t type-check.

🤖 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 `@pnpm11/engine/pm/commands/src/self-updater/selfUpdate.ts` around lines 61 -
73, `SelfUpdateCommandOptions` is missing several config properties that
`selfUpdate` reads directly. Update the type definition to include
`resolutionMode`, `trustPolicy`, `trustPolicyExclude`, `trustPolicyIgnoreAfter`,
and `registrySupportsTimeField` in the existing `Pick<Config, ...>` for
`SelfUpdateCommandOptions`, alongside the current fields, so `selfUpdate`
type-checks correctly.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@pacquet/crates/config/src/lib.rs`:
- Around line 1567-1573: The Config::requires_full_metadata_for_resolution
method is missing the minimumReleaseAge trigger, so Rust no longer matches the
TypeScript fullMetadata logic. Update this method to also return true when
minimumReleaseAge is configured, alongside ResolutionMode::TimeBased and
TrustPolicy::NoDowngrade, while still gating on registry_supports_time_field.
Keep the behavior aligned with the TS selfUpdate.ts equivalent and preserve the
existing method structure and symbols.

---

Outside diff comments:
In `@pnpm11/engine/pm/commands/src/self-updater/selfUpdate.ts`:
- Around line 61-73: `SelfUpdateCommandOptions` is missing several config
properties that `selfUpdate` reads directly. Update the type definition to
include `resolutionMode`, `trustPolicy`, `trustPolicyExclude`,
`trustPolicyIgnoreAfter`, and `registrySupportsTimeField` in the existing
`Pick<Config, ...>` for `SelfUpdateCommandOptions`, alongside the current
fields, so `selfUpdate` type-checks correctly.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

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

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: 5411e07c-eb34-4408-a007-a81ad12fdf25

📥 Commits

Reviewing files that changed from the base of the PR and between 117e24e and ba5234a.

📒 Files selected for processing (9)
  • .changeset/self-update-trust-policy.md
  • pacquet/crates/cli/src/cli_args/self_update/install_pnpm.rs
  • pacquet/crates/cli/src/cli_args/self_update/install_pnpm/tests.rs
  • pacquet/crates/cli/src/config_deps.rs
  • pacquet/crates/cli/src/config_deps/tests.rs
  • pacquet/crates/config/src/lib.rs
  • pacquet/crates/package-manager/src/resolution_policy.rs
  • pnpm11/engine/pm/commands/src/self-updater/selfUpdate.ts
  • pnpm11/engine/pm/commands/test/self-updater/selfUpdate.test.ts
✅ Files skipped from review due to trivial changes (1)
  • .changeset/self-update-trust-policy.md
🚧 Files skipped from review as they are similar to previous changes (2)
  • pacquet/crates/cli/src/cli_args/self_update/install_pnpm.rs
  • pacquet/crates/cli/src/cli_args/self_update/install_pnpm/tests.rs

Comment thread pacquet/crates/config/src/lib.rs Resolved
The no-downgrade check reads per-version trust evidence (`_npmUser` /
`dist.attestations`) that the abbreviated packument never carries — even a
`registrySupportsTimeField` registry only adds `time`, not the evidence.
So `Config::requires_full_metadata_for_resolution` and the TypeScript
`selfUpdate.ts` formula must request full metadata for
`trustPolicy=no-downgrade` regardless of `registrySupportsTimeField`;
otherwise the check sees no evidence and silently misses a downgrade.

`minimumReleaseAge` stays out of the up-front decision in both stacks: the
resolver upgrades abbreviated metadata to full on demand for the maturity
check, matching the install path (`PickPolicy` /
`createNewStoreController`). This also aligns the Rust and TypeScript
formulas, which had diverged on the `minimumReleaseAge` term.

Add a pacquet regression test that serves abbreviated-with-`time`-but-no-
evidence to the abbreviated `Accept` header under
`registrySupportsTimeField=true` and asserts the downgrade is still
rejected.

The install-time lockfile verifier already fetches full metadata
unconditionally for its trust check, so a downgrade was still blocked
there; this makes the resolver-time and self-update probe checks sound too.
@qodo-free-for-open-source-projects

qodo-free-for-open-source-projects Bot commented Jul 7, 2026 •

Copy link
Copy Markdown

Code Review by Qodo

Grey Divider

New Review Started

This review has been superseded by a new analysis

Grey Divider

Qodo Logo

@qodo-free-for-open-source-projects

Copy link
Copy Markdown

Qodo is busy working

Check back in a few minutes. Qodo's code review agents are on it.

Grey Divider

@qodo-code-review

Copy link
Copy Markdown

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

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

Auto-approved notes - no code suggestions found
- 'approve_pr_on_self_review' flag enabled

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants