Skip to content

fix: don't spawn an install outside a project; port verify-deps-before-run to pacquet - #12910

Merged
zkochan merged 8 commits into
mainfrom
fix/verify-deps-before-run-no-manifest
Jul 10, 2026
Merged

zkochan merged 8 commits into
mainfrom
fix/verify-deps-before-run-no-manifest

Conversation

@zkochan

@zkochan zkochan commented Jul 10, 2026 •

Copy link
Copy Markdown
Member

Summary

Running pnpm in a directory without a package.json — most commonly through a mistyped command that falls back to pnpm run (e.g. pnpm witch 10 login) — crashed with a confusing error under the default verify-deps-before-run: install:

[ERR_PNPM_NO_PKG_MANIFEST] No package.json found in /home/zoltan/src/pnpm
[ERROR] Command failed with exit code 1: '.../pnpm' install
    at getFinalError (...)
    ...

checkDepsStatus found no workspace state and reported the dependencies as outdated, so runDepsStatusCheck spawned a pnpm install that could only fail with NO_PKG_MANIFEST, and the parent process dumped a raw execa stack trace.

TypeScript fix: checkDepsStatus now reports "unknown" (upToDate: undefined) when there is no root manifest, no workspace, and no project list. runDepsStatusCheck already skips the check in that case, so the command fails with the regular, single-line "no package.json found" error.

pacquet: this PR also ports the entire verify-deps-before-run gate to pacquet (it was in the NOT_PORTED parity list), including the fix above:

  • VerifyDepsBeforeRun config setting (install default matching pnpm's defaultOptions), readable from pnpm-workspace.yaml, the global config.yaml, PNPM_CONFIG_VERIFY_DEPS_BEFORE_RUN / pnpm_config_verify_deps_before_run, and --config.verify-deps-before-run=...; moved from NOT_PORTED to the mapped parity rows.
  • check_deps_status_before_run in pacquet-package-manager: a second consumer of the deps-status machinery behind the install fast path, with the run gate's differences — runs regardless of optimisticRepeatInstall, no local-file-dep bail, ignores dev/optional/production drift, compares configuration dependencies, and reports pnpm's user-facing issue wording. The no-project guard returns "skip" so a mistyped command outside a project never spawns a doomed install (the same fix as the TS side).
  • Gate wiring in run, exec, their recursive paths, and the top-level fallback, with the install / prompt / error / warn actions (ERR_PNPM_VERIFY_DEPS_BEFORE_RUN, non-interactive prompt error, --production/--dev/--no-optional install args derived from the recorded workspace state).
  • Recursion guard: every spawned script gets pnpm_config_verify_deps_before_run=false, and that env var outranks every other config source for this key (infinite loop with a postinstall task and verifyDepsBeforeRun: install #10060).
  • Drive-by fix the new default exposed: pacquet install in a package.yaml project used to scaffold a default package.json that shadowed the real manifest; State::init now loads an existing alternate manifest base name instead.

Known message divergences (noted for follow-up): deep lockfile-content mismatches reuse pacquet's existing diagnostic strings rather than pnpm's exact issue wording, and lockfile merge conflicts surface as a parse failure instead of pnpm's dedicated conflict message. Both only affect the text shown by warn/error modes.

Squash Commit Body

pnpm (TypeScript): when pnpm was executed in a directory without a
package.json (most commonly through a mistyped command falling back to
`pnpm run`), checkDepsStatus found no workspace state and reported the
dependencies as outdated. With verify-deps-before-run set to "install"
(the default), that spawned a `pnpm install` which could only fail with
NO_PKG_MANIFEST, and the parent process crashed with a raw execa stack
trace. Report "unknown" (upToDate: undefined) instead when there is no
root manifest, no workspace, and no project list — runDepsStatusCheck
already skips the check in that case.

pacquet: port the verify-deps-before-run gate (config setting with the
'install' default, deps-status check for the run/exec paths, the
install/prompt/error/warn actions, and the script-env recursion guard),
including the same no-project skip. Also stop `pacquet install` from
scaffolding a package.json over an existing package.yaml manifest,
which the gate's default install action exposed.

Checklist

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

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

Summary by CodeRabbit

  • New Features

    • Added a verify-deps-before-run gate for pnpm run and pnpm exec, supporting install, warn, error, prompt, and boolean modes.
    • Gate configuration is recognized via CLI, workspace settings, and environment variables, with proper precedence and non-interactive-safe prompting.
  • Bug Fixes

    • Running mistyped commands outside a project directory no longer triggers dependency installation; it now returns the standard “no package.json found” error.
    • Nested lifecycle/child executions skip duplicate dependency verification.

Copilot AI review requested due to automatic review settings July 10, 2026 14:37

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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

@coderabbitai

coderabbitai Bot commented Jul 10, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

Note

Reviews paused

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

Use the following commands to manage reviews:

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

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review
📝 Walkthrough

Walkthrough

Pacquet now verifies dependency freshness before run and exec, supports configuration and environment precedence, handles missing project context without spawning installs, and preserves standard command errors in manifest-less directories.

Changes

Verify dependencies before execution

Layer / File(s) Summary
Verification configuration contract
pnpm/crates/cli/src/config_overrides.rs, pnpm/crates/config/src/env_overlay.rs
Parses verify-deps-before-run configuration and applies environment-variable precedence and fallback behavior.
Dependency freshness evaluation
pnpm/crates/package-manager/src/{install.rs,optimistic_repeat_install.rs}, pnpm11/deps/status/*
Discovers project context, evaluates dependency freshness, reports drift details, preserves install selections, and distinguishes missing context from incomplete workspace state.
Run and exec verification gate
pnpm/crates/cli/src/cli_args/*, pnpm/crates/executor/src/*
Adds verification before run and exec flows, configured install/prompt/error/warning handling, and nested-invocation suppression through an environment stamp.
Manifest fallback and regression coverage
pnpm/crates/cli/src/state.rs, pnpm/crates/cli/tests/*, pnpm/crates/cli/src/cli_args/{restart,stop}/tests.rs, .changeset/*
Loads alternate manifests, updates in-process test configuration, covers gate behavior, and verifies manifest-less command fallback.

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

Sequence Diagram(s)

sequenceDiagram
  participant Command
  participant VerifyDeps as verify_deps_before_run
  participant Status as check_deps_status_before_run_at
  participant Install
  Command->>VerifyDeps: verify dependencies
  VerifyDeps->>Status: check freshness
  Status-->>VerifyDeps: dependency status
  VerifyDeps->>Install: spawn install when configured
  Install-->>Command: return status or continue execution
Loading

Possibly related PRs

  • pnpm/pnpm#11943: Provides related optimistic repeat-install freshness logic used by this dependency-status implementation.
  • pnpm/pnpm#12301: Coordinates handling for missing manifest or workspace context.
  • pnpm/pnpm#12400: Overlaps with lifecycle environment construction in make_env.rs.

Suggested labels: product: pacquet, product: pnpm@11

Suggested reviewers: qodo-code-review, KSXGitHub

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/verify-deps-before-run-no-manifest

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

❤️ Share

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

@qodo-code-review

Copy link
Copy Markdown

PR Summary by Qodo

Skip verify-deps-before-run install when no project manifest exists

🐞 Bug fix 🧪 Tests 🕐 20-40 Minutes

Grey Divider

AI Description

• Prevent verify-deps-before-run from spawning pnpm install outside a project.
• Return deps status as "unknown" when no manifest/workspace/projects are present.
• Add regression coverage and ship a patch changeset.
Diagram

graph TD
  A["pnpm command (mistyped)"] --> B["runDepsStatusCheck"] --> C["checkDepsStatus"] --> D{"workspaceState found?"}
  D -->|"yes"| E["normal status evaluation"]
  D -->|"no"| F{"manifest/workspace/projects?"} -->|"none"| G["return upToDate: undefined"] --> H["deps gate skipped"]
  F -->|"some"| I["return upToDate: false + issue"] --> J["verify-deps-before-run may install"]
Loading
High-Level Assessment

The following are alternative approaches to this PR:

1. Move the guard to runDepsStatusCheck only
  • ➕ Keeps checkDepsStatus returning only boolean upToDate results (true/false)
  • ➕ Avoids adding more 'context detection' logic to the status function
  • ➖ Requires duplicating context detection that checkDepsStatus already has (manifest/workspace/projects inputs)
  • ➖ Harder to ensure all callers of checkDepsStatus get consistent behavior
2. Treat missing project as upToDate: true
  • ➕ Simplifies downstream logic (no tri-state)
  • ➕ Would also avoid spawning installs
  • ➖ Semantically incorrect: 'up-to-date' implies a project exists and was evaluated
  • ➖ Could mask real issues in edge cases where inputs are partially populated

Recommendation: The PR’s approach (returning upToDate: undefined only when there is clearly no project/workspace/projects context) is the best trade-off: it preserves existing 'outdated' behavior when a project context exists, while preventing a pointless spawned install and letting pnpm surface its standard NO_PKG_MANIFEST error. Alternatives either duplicate logic in the caller or introduce misleading semantics.

Files changed (3) +62 / -0

Bug fix (1) +8 / -0
checkDepsStatus.tsReturn unknown deps state when no manifest/workspace/projects exist +8/-0

Return unknown deps state when no manifest/workspace/projects exist

• Adds an early return when workspace state is missing and there is no root manifest, no workspaceDir, and no project list. This prevents reporting 'outdated' in non-project directories, avoiding verify-deps-before-run spawning a doomed 'pnpm install'.

pnpm11/deps/status/src/checkDepsStatus.ts

Tests (1) +48 / -0
checkDepsStatus.test.tsAdd regression tests for missing workspace state behavior +48/-0

Add regression tests for missing workspace state behavior

• Introduces a new test suite covering the tri-state behavior when workspace state cannot be loaded. Verifies upToDate is undefined in a no-project context, but remains false when a manifest or workspace context is present.

pnpm11/deps/status/test/checkDepsStatus.test.ts

Documentation (1) +6 / -0
violet-pianos-brush.mdAdd patch changeset for missing-manifest deps gate fix +6/-0

Add patch changeset for missing-manifest deps gate fix

• Adds release notes for the behavior change: when run outside a project, verify-deps-before-run no longer spawns an install and pnpm fails with the normal missing package.json error.

.changeset/violet-pianos-brush.md

@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)
.changeset/violet-pianos-brush.md (1)

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

Minor wording nit: "outside of" → "outside".

LanguageTool flags "outside of a project" as redundant; "outside a project" is more concise. Purely cosmetic for changeset prose.

✏️ Proposed wording tweak
-A mistyped command run outside of a project (for example `pnpm witch 10 login`)
+A mistyped command run outside a project (for example `pnpm witch 10 login`)
🤖 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 @.changeset/violet-pianos-brush.md at line 6, Update the changeset prose by
replacing “outside of a project” with “outside a project”; make no other
changes.

Source: Linters/SAST tools

🤖 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 @.changeset/violet-pianos-brush.md:
- Line 6: Update the changeset prose by replacing “outside of a project” with
“outside a project”; make no other changes.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: eef5fbd7-8c98-4c23-810c-21b6c21a7835

📥 Commits

Reviewing files that changed from the base of the PR and between 52b57ad and f21995f.

📒 Files selected for processing (3)
  • .changeset/violet-pianos-brush.md
  • pnpm11/deps/status/src/checkDepsStatus.ts
  • pnpm11/deps/status/test/checkDepsStatus.test.ts

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

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

Copy link
Copy Markdown

Code Review by Qodo

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

Context used
✅ Compliance rules (platform): 18 rules

Grey Divider


Action required

1. Empty VERIFY_DEPS env ignored ✓ Resolved 📘 Rule violation ⌂ Architecture ⭐ New
Description
verify_deps_env_is_set() treats an empty PNPM_CONFIG_VERIFY_DEPS_BEFORE_RUN /
pnpm_config_verify_deps_before_run as “not set”, allowing CLI overrides to apply. pnpm treats the
env var as overriding when it is present (even if empty), so this creates a pnpm↔pacquet
user-visible precedence mismatch and can change whether the gate is disabled/enabled in edge cases.
Code

pnpm/crates/cli/src/config_overrides.rs[R184-188]

+fn verify_deps_env_is_set() -> bool {
+    ["PNPM_CONFIG_VERIFY_DEPS_BEFORE_RUN", pacquet_executor::VERIFY_DEPS_BEFORE_RUN_ENV]
+        .iter()
+        .any(|name| std::env::var(name).is_ok_and(|value| !value.is_empty()))
+}
Evidence
Pacquet’s env-detection requires a non-empty value (!value.is_empty()), while pnpm’s config reader
overrides based on presence (!= null) without an emptiness check. This difference means an empty
env var affects config layering differently between the two implementations.

Rule 713428: Keep pnpm TypeScript and pacquet Rust user-visible behavior changes in sync
Rule 713429: Pacquet must not introduce new user-visible behavior beyond pnpm
pnpm/crates/cli/src/config_overrides.rs[184-188]
pnpm11/config/reader/src/index.ts[1070-1077]

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

## Issue description
`verify_deps_env_is_set()` currently ignores the env var when it is set to an empty string. pnpm considers `process.env.pnpm_config_verify_deps_before_run != null` (presence-only), so pacquet should treat the env var as set even if empty to keep precedence behavior in sync.

## Issue Context
This affects the priority/recursion-guard semantics for `verify-deps-before-run` and can create pnpm↔pacquet divergence in how `--config.verify-deps-before-run=...` interacts with `PNPM_CONFIG_VERIFY_DEPS_BEFORE_RUN`.

## Fix Focus Areas
- pnpm/crates/cli/src/config_overrides.rs[184-188]

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



Remediation recommended

2. Lockfile errors reported as missing ✓ Resolved 🐞 Bug ☼ Reliability ⭐ New
Description
missing_wanted_lockfile_stand_in_ok() maps *any* error loading the current lockfile
(read/permission/parse) to “Cannot find a lockfile…”, which is misleading and hides the underlying
failure mode. This can send users down the wrong debugging path and may trigger an incorrect
verify-deps action/message when the lockfile exists but is unreadable/invalid.
Code

pnpm/crates/package-manager/src/optimistic_repeat_install.rs[R1520-1531]

+fn missing_wanted_lockfile_stand_in_ok(
+    check: &OptimisticRepeatInstallCheck<'_>,
+) -> Result<(), String> {
+    if check.lockfile.is_loaded_or_on_disk() || !check.config.lockfile {
+        return Ok(());
+    }
+    match Lockfile::load_current_from_virtual_store_dir(&check.config.virtual_store_dir) {
+        Ok(Some(_)) => Ok(()),
+        Ok(None) | Err(_) => {
+            Err(format!("Cannot find a lockfile in {}", check.workspace_root.display()))
+        }
+    }
Evidence
The gate converts any Err(_) from current-lockfile load into a missing-lockfile message, but the
lockfile loader can fail on read/parse errors, so “missing” is not accurate for those cases.

pnpm/crates/package-manager/src/optimistic_repeat_install.rs[1520-1531]
pnpm/crates/lockfile/src/load_lockfile.rs[84-99]

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

### Issue description
`missing_wanted_lockfile_stand_in_ok()` currently treats `Ok(None)` and `Err(_)` from `Lockfile::load_current_from_virtual_store_dir(...)` the same and returns a “Cannot find a lockfile…” issue. This masks IO/permission/YAML-parse failures as if the lockfile were absent.

### Issue Context
`Lockfile::load_current_from_virtual_store_dir()` reads and parses YAML and can return read/parse errors, not just `None` for absence.

### Fix Focus Areas
- pnpm/crates/package-manager/src/optimistic_repeat_install.rs[1520-1531]

### Suggested fix
Differentiate the cases:
- `Ok(Some(_))` -> `Ok(())`
- `Ok(None)` -> `Err(format!("Cannot find a lockfile in {}", ...))`
- `Err(e)` -> return a more accurate issue string (e.g. “Cannot check whether dependencies are outdated” or “the current lockfile cannot be read or parsed”), optionally including `e` if consistent with pnpm’s intended wording.

This avoids misreporting parse/permission problems as a missing lockfile.

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


3. Duplicate workspace-state load ✓ Resolved 🐞 Bug ➹ Performance ⭐ New
Description
check_deps_status_before_run_at() now loads workspace-state.json to short-circuit discovery, but
check_deps_status_before_run() immediately loads the same state again, adding redundant IO/parse
overhead in the verify-deps preflight path. This is a performance-only inefficiency that can affect
every gated run/exec that reaches the deps-status check.
Code

pnpm/crates/package-manager/src/install.rs[R2397-2403]

+    // pnpm reports "cannot check" straight from the missing workspace
+    // state, before any project discovery — a fresh project (the common
+    // out-of-sync case) must not pay for the workspace-projects walk
+    // only to reach the same verdict inside the check.
+    if !matches!(pacquet_workspace_state::load_workspace_state(&workspace_root), Ok(Some(_))) {
+        return cannot_check();
+    }
Evidence
The new early check loads workspace state before discovery, but the deps-status checker loads it
again at the start, resulting in two loads/parses per invocation that reaches the check.

pnpm/crates/package-manager/src/install.rs[2397-2403]
pnpm/crates/package-manager/src/optimistic_repeat_install.rs[1401-1406]

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

### Issue description
`check_deps_status_before_run_at()` calls `pacquet_workspace_state::load_workspace_state()` to avoid expensive project discovery when state is missing, but the downstream `check_deps_status_before_run()` re-loads the same workspace state again. This duplicates filesystem IO and JSON parse work on the `run`/`exec` hot path.

### Issue Context
- `check_deps_status_before_run_at()` already needs the workspace state presence check to avoid walking workspace projects.
- `check_deps_status_before_run()` needs the fully parsed `WorkspaceState` for install args and drift checks.

### Fix Focus Areas
- pnpm/crates/package-manager/src/install.rs[2397-2403]

### Suggested fix
Load the workspace state once in `check_deps_status_before_run_at()` and pass it through, e.g.:
- Extend `OptimisticRepeatInstallCheck` to optionally carry a preloaded `WorkspaceState` (or a reference) and have `check_deps_status_before_run()` use it when present; or
- Add a `check_deps_status_before_run_with_state(check, &WorkspaceState)` helper and call that from `check_deps_status_before_run_at()` after the early load.

This keeps the early short-circuit while eliminating redundant state loads.

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


4. Wrong optional install args 🐞 Bug ≡ Correctness
Description
install_args_from_state treats a missing workspaceState.settings.optional as false, which
makes verify-deps-before-run’s auto-spawned install add --no-optional even when the
workspace-state file simply omits the field. This can silently skip optional dependencies during the
gate-triggered install and break projects (or change behavior) compared to a normal/default install.
Code

pnpm/crates/package-manager/src/optimistic_repeat_install.rs[R1521-1531]

+    let mut args = Vec::new();
+    let dev = settings.dev.unwrap_or(false);
+    let production = settings.production.unwrap_or(false);
+    if production && !dev {
+        args.push("--production".to_string());
+    } else if dev && !production {
+        args.push("--dev".to_string());
+    }
+    if !settings.optional.unwrap_or(false) {
+        args.push("--no-optional".to_string());
+    }
Evidence
The workspace-state schema uses Option<bool> for optional, meaning the key can be absent;
defaulting absence to false changes semantics. The current workspace-state writer records
optional from IncludedDependencies.optional_dependencies (which is typically true for default
installs), so --no-optional should only be produced when the recorded value is explicitly false.

pnpm/crates/package-manager/src/optimistic_repeat_install.rs[1515-1532]
pnpm/crates/package-manager/src/optimistic_repeat_install.rs[1096-1145]
pnpm/crates/workspace-state/src/lib.rs[88-157]
pnpm/crates/package-manager/src/optimistic_repeat_install/tests.rs[17-19]

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

### Issue description
`install_args_from_state()` currently does:
- `if !settings.optional.unwrap_or(false) { "--no-optional" }`

Because workspace-state fields are optional (`Option<bool>`), an omitted `optional` key should not be interpreted as `false`. Doing so can cause the verify-deps-before-run gate (install/prompt actions) to spawn an install that incorrectly excludes optional dependencies.

### Issue Context
- Workspace-state settings fields are `Option` and may be absent.
- The gate’s goal is to reproduce the dependency-group selection from the recorded workspace state; absence should typically mean “don’t force a flag”.

### Fix Focus Areas
- pnpm/crates/package-manager/src/optimistic_repeat_install.rs[1519-1532]

### Suggested change
Change the condition to only emit `--no-optional` when the recorded value is explicitly `false`:

```rust
if settings.optional == Some(false) {
   args.push("--no-optional".to_string());
}
```

(Do not treat `None` as `false`.)

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


View more (5)
5. Redundant test doc comment 📘 Rule violation ⚙ Maintainability
Description
The test doc comment restates the exact scenario and outcomes already asserted in the test body,
duplicating information. This increases maintenance burden because updates must be kept in sync
between comments and assertions.
Code

pacquet/crates/cli/tests/verify_deps_before_run.rs[R45-48]

+/// `error` fails a fresh project ("Cannot check whether dependencies
+/// are outdated"), passes after an install, still passes after an
+/// mtime-only manifest rewrite, and fails again once the manifest no
+/// longer matches the lockfile.
Evidence
PR Compliance ID 713470 requires avoiding duplicative scenario explanations in test doc comments
when the behavior is already captured by the test's assertions. The doc comment above
error_action_follows_the_dependency_state enumerates the same step-by-step outcomes that the test
immediately verifies with multiple assertions.

Rule 713470: Avoid duplicating test scenario explanations in both code and doc comments
pacquet/crates/cli/tests/verify_deps_before_run.rs[45-48]

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

## Issue description
A test doc comment duplicates the scenario narrative already expressed by the test name and assertions.

## Issue Context
Per the compliance rule, tests should avoid repeating detailed scenario walkthroughs in doc comments when the behavior is already clear from the assertions; comments should focus on *why* the scenario matters or add non-obvious context.

## Fix Focus Areas
- pacquet/crates/cli/tests/verify_deps_before_run.rs[45-48]

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


6. Gate writes pnpm-lock.yaml 🐞 Bug ☼ Reliability
Description
check_deps_status_before_run may write pnpm-lock.yaml via
regenerate_wanted_lockfile_if_missing() during the pre-run dependency check, even when the
configured action is warn/error/true (i.e., not an install). This introduces an unexpected
filesystem side-effect and can also cause the run/exec path to fail purely due to lockfile write
permissions.
Code

pacquet/crates/package-manager/src/optimistic_repeat_install.rs[R1471-1484]

+    if modified.is_empty() && !lockfile_modified {
+        return match regenerate_wanted_lockfile_if_missing(check, None) {
+            Ok(()) => RunDepsStatus::UpToDate,
+            Err(reason) => outdated(reason.to_string()),
+        };
+    }
+
+    let projects_to_check: Vec<&ManifestStat<'_>> =
+        if lockfile_modified { manifest_stats.iter().collect() } else { modified };
+    match modified_manifests_match_lockfile(check, &state, &projects_to_check) {
+        Ok(loaded_current) => {
+            if let Err(reason) = regenerate_wanted_lockfile_if_missing(check, loaded_current) {
+                return outdated(reason.to_string());
+            }
Evidence
The verify-deps gate’s status check calls regenerate_wanted_lockfile_if_missing, and that helper
explicitly saves pnpm-lock.yaml. Therefore, the pre-run check can write the lockfile as a side
effect.

pacquet/crates/package-manager/src/optimistic_repeat_install.rs[1471-1484]
pacquet/crates/package-manager/src/optimistic_repeat_install.rs[457-484]

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

### Issue description
The new verify-deps-before-run check (`check_deps_status_before_run`) calls `regenerate_wanted_lockfile_if_missing`, which saves `pnpm-lock.yaml` to disk. A pre-run *check* should not mutate the workspace and should not fail a script due to inability to write the lockfile.

### Issue Context
This helper was originally designed for the install fast-path to preserve install’s on-disk contract. Reusing it in the run/exec gate changes behavior: running scripts can create/overwrite `pnpm-lock.yaml`.

### Fix Focus Areas
- pacquet/crates/package-manager/src/optimistic_repeat_install.rs[1471-1484]
- pacquet/crates/package-manager/src/optimistic_repeat_install.rs[457-484]

### Suggested fix
In `check_deps_status_before_run`, avoid calling `regenerate_wanted_lockfile_if_missing` entirely (or gate it behind an explicit "install is about to run" signal).
- For the verify-deps gate, return `UpToDate` based on read-only checks and leave lockfile regeneration to actual `install` execution paths.

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


7. Env blocks CLI override 🐞 Bug ≡ Correctness
Description
ConfigOverrides::apply skips applying --config.verify-deps-before-run=... whenever the env var
name exists, even if the env value is invalid and therefore ignored by the env overlay. This can
leave users unable to override a garbage PNPM_CONFIG_VERIFY_DEPS_BEFORE_RUN value and silently
fall back to the default action.
Code

pacquet/crates/cli/src/config_overrides.rs[R169-188]

+        // The `pnpm_config_verify_deps_before_run` env var outranks even
+        // the CLI for this one key (pnpm's config reader applies it after
+        // every other layer): pnpm stamps `false` into every spawned
+        // script's env, and a nested `pnpm run` inside a script must see
+        // the check disabled no matter what flags the outer invocation
+        // carried, or the spawned install's lifecycle scripts would
+        // re-enter the check (pnpm/pnpm#10060).
+        if let Some(value) = self.verify_deps_before_run
+            && !verify_deps_env_is_set()
+        {
+            config.verify_deps_before_run = value;
+        }
    }
}

+fn verify_deps_env_is_set() -> bool {
+    ["PNPM_CONFIG_VERIFY_DEPS_BEFORE_RUN", "pnpm_config_verify_deps_before_run"]
+        .iter()
+        .any(|name| std::env::var(name).is_ok_and(|value| !value.is_empty()))
+}
Evidence
The CLI override is skipped based only on env-var presence, but the env overlay only sets
verify_deps_before_run when the value parses; invalid values are dropped. That means an
invalid-but-present env var blocks the CLI from setting the intended value.

pacquet/crates/cli/src/config_overrides.rs[169-188]
pacquet/crates/config/src/env_overlay.rs[21-27]
pacquet/crates/config/src/env_overlay.rs[89-96]

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

### Issue description
`verify_deps_env_is_set()` treats any non-empty `PNPM_CONFIG_VERIFY_DEPS_BEFORE_RUN`/`pnpm_config_verify_deps_before_run` as authoritative, but the config env overlay silently ignores invalid enum values. This mismatch can prevent a valid CLI override from being applied when the env var is present-but-invalid.

### Issue Context
- Env overlay only applies values that successfully parse (`parse_json_or_string::<VerifyDepsBeforeRun>`).
- CLI override layer currently checks only presence/non-empty, not parse success.

### Fix Focus Areas
- pacquet/crates/cli/src/config_overrides.rs[169-188]

### Suggested fix
Change the guard to match env overlay semantics:
- Read the env var value (upper or lower) and treat it as "set" only if it would successfully parse as `VerifyDepsBeforeRun` (accepting JSON bools or strings the same way as `env_overlay`), OR
- Move the env-var precedence enforcement into the config-building pipeline by re-applying the (parsed) env overlay for this key after CLI overrides, so invalid env values don’t suppress valid CLI overrides.

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


8. Historical phrasing in test docs 📘 Rule violation ⚙ Maintainability
Description
The new Rust doc comment for top_level_fallback_without_manifest_does_not_attempt_an_install
includes historical/backstory phrasing about prior behavior (e.g., “where reporting … made the gate
spawn …”), rather than describing only the current contract. This violates the requirement that
comments document current behavior, not past implementations.
Code

pacquet/crates/cli/tests/run.rs[R495-504]

+/// A mistyped top-level command falling back to `run` in a directory
+/// without a manifest must surface the fallback's own missing-command
+/// error and must not attempt an install, even with
+/// `verify-deps-before-run=install` set. Mirrors the TypeScript
+/// regression tests in `pnpm11/deps/status/test/checkDepsStatus.test.ts`
+/// ("missing workspace state"), where reporting the deps as outdated
+/// made the gate spawn a `pnpm install` that could only crash with
+/// `NO_PKG_MANIFEST`. pacquet has not ported the `verify-deps-before-run`
+/// gate yet (see `NOT_PORTED` in `pnpm_default_parity.rs`), so this pins
+/// the required behavior for when it lands.
Evidence
The doc comment uses historical narrative about an earlier failure mode (“where reporting the deps
as outdated made the gate spawn a pnpm install…”) instead of describing only current behavior,
which the rule forbids.

Rule 772199: Comments must describe current behavior, not historical implementations
pacquet/crates/cli/tests/run.rs[495-504]

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

## Issue description
A newly added Rust doc comment describes historical behavior ("where ... made ...") instead of only documenting the current behavior/contract.

## Issue Context
Comments should describe what the code currently guarantees and why the test exists, without narrating prior implementations or past failure modes.

## Fix Focus Areas
- pacquet/crates/cli/tests/run.rs[495-504]

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


9. Test misses manifest side-effect 🐞 Bug ☼ Reliability
Description
The new test asserts that no install ran by checking for node_modules/ and pnpm-lock.yaml, but
pacquet’s install initialization currently creates package.json when missing, so an unintended
install attempt could still mutate the directory without being caught by this test.
Code

pacquet/crates/cli/tests/run.rs[R520-523]

+    assert!(
+        !workspace.join("node_modules").exists() && !workspace.join("pnpm-lock.yaml").exists(),
+        "no install may run in a directory without a manifest",
+    );
Evidence
The test’s current filesystem assertion only checks node_modules/ and pnpm-lock.yaml. However,
pacquet’s install state initialization writes a new package.json when missing (via
PackageManifest::create_if_needed), meaning an install attempt can still cause a manifest
side-effect that this test won’t detect unless it also asserts package.json absence.

pacquet/crates/cli/tests/run.rs[510-523]
pacquet/crates/cli/src/state.rs[59-80]
pacquet/crates/package-manifest/src/lib.rs[88-98]
pacquet/crates/package-manifest/src/lib.rs[148-156]

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 regression test claims to ensure that no install is attempted in a directory without a manifest, but it only asserts absence of `node_modules/` and `pnpm-lock.yaml`. Pacquet’s install/state init path currently *creates* a `package.json` when it’s missing, so this test should also assert that `package.json` does not appear.

### Issue Context
In pacquet, `State::init(...)` uses `PackageManifest::create_if_needed(...)`, which writes a new `package.json` if none exists. If a future `verify-deps-before-run` gate accidentally triggers install/state initialization, the workspace could be mutated via a newly created `package.json` even if `node_modules/` and `pnpm-lock.yaml` are not present.

### Fix Focus Areas
- pacquet/crates/cli/tests/run.rs[520-523]

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



Informational

10. Unnecessary scan without state 🐞 Bug ➹ Performance
Description
check_deps_status_before_run_at eagerly discovers workspace projects and builds a full
project_manifests list before the deps-status logic checks whether the workspace state file
exists. When workspace state is missing (common on a fresh project), this does extra filesystem work
only to immediately return "Cannot check whether dependencies are outdated".
Code

pacquet/crates/package-manager/src/install.rs[R2404-2413]

+    let Ok(workspace_projects) =
+        load_workspace_projects(&workspace_root, workspace_manifest.as_ref())
+    else {
+        return cannot_check();
+    };
+    let project_manifests = build_project_manifests_list(
+        &workspace_root,
+        &root_manifest,
+        workspace_projects.as_deref(),
+    );
Evidence
check_deps_status_before_run_at loads workspace projects and builds the manifest list before
delegating; check_deps_status_before_run then immediately returns Outdated if workspace state is
absent, proving the scan can be wasted work.

pacquet/crates/package-manager/src/install.rs[2367-2436]
pacquet/crates/package-manager/src/optimistic_repeat_install.rs[1401-1406]

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

### Issue description
The new `check_deps_status_before_run_at` does potentially expensive workspace discovery (find projects + read manifests) before `check_deps_status_before_run` loads workspace state and can immediately return `Outdated` when state is missing.

### Issue Context
This is a startup-path performance tax on the common "first run" scenario in large workspaces.

### Fix Focus Areas
- pacquet/crates/package-manager/src/install.rs[2367-2436]
- pacquet/crates/package-manager/src/optimistic_repeat_install.rs[1401-1406]

### Suggested fix
Reorder work in `check_deps_status_before_run_at`:
1) Determine `workspace_root`.
2) Attempt to load workspace state early; if missing, return `RunDepsStatus::Outdated { issue: ..., install_args: vec![] }` without scanning workspace projects.
3) Only if state exists, proceed to `load_workspace_projects` / `build_project_manifests_list` / lockfile checks.

This preserves behavior while avoiding unnecessary scanning in the missing-state case.

ⓘ 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 47257df

Results up to commit 8f170e1


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


Remediation recommended
1. Historical phrasing in test docs 📘 Rule violation ⚙ Maintainability
Description
The new Rust doc comment for top_level_fallback_without_manifest_does_not_attempt_an_install
includes historical/backstory phrasing about prior behavior (e.g., “where reporting … made the gate
spawn …”), rather than describing only the current contract. This violates the requirement that
comments document current behavior, not past implementations.
Code

pacquet/crates/cli/tests/run.rs[R495-504]

+/// A mistyped top-level command falling back to `run` in a directory
+/// without a manifest must surface the fallback's own missing-command
+/// error and must not attempt an install, even with
+/// `verify-deps-before-run=install` set. Mirrors the TypeScript
+/// regression tests in `pnpm11/deps/status/test/checkDepsStatus.test.ts`
+/// ("missing workspace state"), where reporting the deps as outdated
+/// made the gate spawn a `pnpm install` that could only crash with
+/// `NO_PKG_MANIFEST`. pacquet has not ported the `verify-deps-before-run`
+/// gate yet (see `NOT_PORTED` in `pnpm_default_parity.rs`), so this pins
+/// the required behavior for when it lands.
Evidence
The doc comment uses historical narrative about an earlier failure mode (“where reporting the deps
as outdated made the gate spawn a pnpm install…”) instead of describing only current behavior,
which the rule forbids.

Rule 772199: Comments must describe current behavior, not historical implementations
pacquet/crates/cli/tests/run.rs[495-504]

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

## Issue description
A newly added Rust doc comment describes historical behavior ("where ... made ...") instead of only documenting the current behavior/contract.

## Issue Context
Comments should describe what the code currently guarantees and why the test exists, without narrating prior implementations or past failure modes.

## Fix Focus Areas
- pacquet/crates/cli/tests/run.rs[495-504]

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


2. Test misses manifest side-effect 🐞 Bug ☼ Reliability
Description
The new test asserts that no install ran by checking for node_modules/ and pnpm-lock.yaml, but
pacquet’s install initialization currently creates package.json when missing, so an unintended
install attempt could still mutate the directory without being caught by this test.
Code

pacquet/crates/cli/tests/run.rs[R520-523]

+    assert!(
+        !workspace.join("node_modules").exists() && !workspace.join("pnpm-lock.yaml").exists(),
+        "no install may run in a directory without a manifest",
+    );
Evidence
The test’s current filesystem assertion only checks node_modules/ and pnpm-lock.yaml. However,
pacquet’s install state initialization writes a new package.json when missing (via
PackageManifest::create_if_needed), meaning an install attempt can still cause a manifest
side-effect that this test won’t detect unless it also asserts package.json absence.

pacquet/crates/cli/tests/run.rs[510-523]
pacquet/crates/cli/src/state.rs[59-80]
pacquet/crates/package-manifest/src/lib.rs[88-98]
pacquet/crates/package-manifest/src/lib.rs[148-156]

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 regression test claims to ensure that no install is attempted in a directory without a manifest, but it only asserts absence of `node_modules/` and `pnpm-lock.yaml`. Pacquet’s install/state init path currently *creates* a `package.json` when it’s missing, so this test should also assert that `package.json` does not appear.

### Issue Context
In pacquet, `State::init(...)` uses `PackageManifest::create_if_needed(...)`, which writes a new `package.json` if none exists. If a future `verify-deps-before-run` gate accidentally triggers install/state initialization, the workspace could be mutated via a newly created `package.json` even if `node_modules/` and `pnpm-lock.yaml` are not present.

### Fix Focus Areas
- pacquet/crates/cli/tests/run.rs[520-523]

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


Results up to commit 3030a45


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


Remediation recommended
1. Redundant test doc comment 📘 Rule violation ⚙ Maintainability
Description
The test doc comment restates the exact scenario and outcomes already asserted in the test body,
duplicating information. This increases maintenance burden because updates must be kept in sync
between comments and assertions.
Code

pacquet/crates/cli/tests/verify_deps_before_run.rs[R45-48]

+/// `error` fails a fresh project ("Cannot check whether dependencies
+/// are outdated"), passes after an install, still passes after an
+/// mtime-only manifest rewrite, and fails again once the manifest no
+/// longer matches the lockfile.
Evidence
PR Compliance ID 713470 requires avoiding duplicative scenario explanations in test doc comments
when the behavior is already captured by the test's assertions. The doc comment above
error_action_follows_the_dependency_state enumerates the same step-by-step outcomes that the test
immediately verifies with multiple assertions.

Rule 713470: Avoid duplicating test scenario explanations in both code and doc comments
pacquet/crates/cli/tests/verify_deps_before_run.rs[45-48]

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

## Issue description
A test doc comment duplicates the scenario narrative already expressed by the test name and assertions.

## Issue Context
Per the compliance rule, tests should avoid repeating detailed scenario walkthroughs in doc comments when the behavior is already clear from the assertions; comments should focus on *why* the scenario matters or add non-obvious context.

## Fix Focus Areas
- pacquet/crates/cli/tests/verify_deps_before_run.rs[45-48]

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


2. Env blocks CLI override 🐞 Bug ≡ Correctness
Description
ConfigOverrides::apply skips applying --config.verify-deps-before-run=... whenever the env var
name exists, even if the env value is invalid and therefore ignored by the env overlay. This can
leave users unable to override a garbage PNPM_CONFIG_VERIFY_DEPS_BEFORE_RUN value and silently
fall back to the default action.
Code

pacquet/crates/cli/src/config_overrides.rs[R169-188]

+        // The `pnpm_config_verify_deps_before_run` env var outranks even
+        // the CLI for this one key (pnpm's config reader applies it after
+        // every other layer): pnpm stamps `false` into every spawned
+        // script's env, and a nested `pnpm run` inside a script must see
+        // the check disabled no matter what flags the outer invocation
+        // carried, or the spawned install's lifecycle scripts would
+        // re-enter the check (pnpm/pnpm#10060).
+        if let Some(value) = self.verify_deps_before_run
+            && !verify_deps_env_is_set()
+        {
+            config.verify_deps_before_run = value;
+        }
    }
}

+fn verify_deps_env_is_set() -> bool {
+    ["PNPM_CONFIG_VERIFY_DEPS_BEFORE_RUN", "pnpm_config_verify_deps_before_run"]
+        .iter()
+        .any(|name| std::env::var(name).is_ok_and(|value| !value.is_empty()))
+}
Evidence
The CLI override is skipped based only on env-var presence, but the env overlay only sets
verify_deps_before_run when the value parses; invalid values are dropped. That means an
invalid-but-present env var blocks the CLI from setting the intended value.

pacquet/crates/cli/src/config_overrides.rs[169-188]
pacquet/crates/config/src/env_overlay.rs[21-27]
pacquet/crates/config/src/env_overlay.rs[89-96]

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

### Issue description
`verify_deps_env_is_set()` treats any non-empty `PNPM_CONFIG_VERIFY_DEPS_BEFORE_RUN`/`pnpm_config_verify_deps_before_run` as authoritative, but the config env overlay silently ignores invalid enum values. This mismatch can prevent a valid CLI override from being applied when the env var is present-but-invalid.

### Issue Context
- Env overlay only applies values that successfully parse (`parse_json_or_string::<VerifyDepsBeforeRun>`).
- CLI override layer currently checks only presence/non-empty, not parse success.

### Fix Focus Areas
- pacquet/crates/cli/src/config_overrides.rs[169-188]

### Suggested fix
Change the guard to match env overlay semantics:
- Read the env var value (upper or lower) and treat it as "set" only if it would successfully parse as `VerifyDepsBeforeRun` (accepting JSON bools or strings the same way as `env_overlay`), OR
- Move the env-var precedence enforcement into the config-building pipeline by re-applying the (parsed) env overlay for this key after CLI overrides, so invalid env values don’t suppress valid CLI overrides.

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


3. Gate writes pnpm-lock.yaml 🐞 Bug ☼ Reliability
Description
check_deps_status_before_run may write pnpm-lock.yaml via
regenerate_wanted_lockfile_if_missing() during the pre-run dependency check, even when the
configured action is warn/error/true (i.e., not an install). This introduces an unexpected
filesystem side-effect and can also cause the run/exec path to fail purely due to lockfile write
permissions.
Code

pacquet/crates/package-manager/src/optimistic_repeat_install.rs[R1471-1484]

+    if modified.is_empty() && !lockfile_modified {
+        return match regenerate_wanted_lockfile_if_missing(check, None) {
+            Ok(()) => RunDepsStatus::UpToDate,
+            Err(reason) => outdated(reason.to_string()),
+        };
+    }
+
+    let projects_to_check: Vec<&ManifestStat<'_>> =
+        if lockfile_modified { manifest_stats.iter().collect() } else { modified };
+    match modified_manifests_match_lockfile(check, &state, &projects_to_check) {
+        Ok(loaded_current) => {
+            if let Err(reason) = regenerate_wanted_lockfile_if_missing(check, loaded_current) {
+                return outdated(reason.to_string());
+            }
Evidence
The verify-deps gate’s status check calls regenerate_wanted_lockfile_if_missing, and that helper
explicitly saves pnpm-lock.yaml. Therefore, the pre-run check can write the lockfile as a side
effect.

pacquet/crates/package-manager/src/optimistic_repeat_install.rs[1471-1484]
pacquet/crates/package-manager/src/optimistic_repeat_install.rs[457-484]

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

### Issue description
The new verify-deps-before-run check (`check_deps_status_before_run`) calls `regenerate_wanted_lockfile_if_missing`, which saves `pnpm-lock.yaml` to disk. A pre-run *check* should not mutate the workspace and should not fail a script due to inability to write the lockfile.

### Issue Context
This helper was originally designed for the install fast-path to preserve install’s on-disk contract. Reusing it in the run/exec gate changes behavior: running scripts can create/overwrite `pnpm-lock.yaml`.

### Fix Focus Areas
- pacquet/crates/package-manager/src/optimistic_repeat_install.rs[1471-1484]
- pacquet/crates/package-manager/src/optimistic_repeat_install.rs[457-484]

### Suggested fix
In `check_deps_status_before_run`, avoid calling `regenerate_wanted_lockfile_if_missing` entirely (or gate it behind an explicit "install is about to run" signal).
- For the verify-deps gate, return `UpToDate` based on read-only checks and leave lockfile regeneration to actual `install` execution paths.

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



Informational
4. Unnecessary scan without state 🐞 Bug ➹ Performance
Description
check_deps_status_before_run_at eagerly discovers workspace projects and builds a full
project_manifests list before the deps-status logic checks whether the workspace state file
exists. When workspace state is missing (common on a fresh project), this does extra filesystem work
only to immediately return "Cannot check whether dependencies are outdated".
Code

pacquet/crates/package-manager/src/install.rs[R2404-2413]

+    let Ok(workspace_projects) =
+        load_workspace_projects(&workspace_root, workspace_manifest.as_ref())
+    else {
+        return cannot_check();
+    };
+    let project_manifests = build_project_manifests_list(
+        &workspace_root,
+        &root_manifest,
+        workspace_projects.as_deref(),
+    );
Evidence
check_deps_status_before_run_at loads workspace projects and builds the manifest list before
delegating; check_deps_status_before_run then immediately returns Outdated if workspace state is
absent, proving the scan can be wasted work.

pacquet/crates/package-manager/src/install.rs[2367-2436]
pacquet/crates/package-manager/src/optimistic_repeat_install.rs[1401-1406]

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

### Issue description
The new `check_deps_status_before_run_at` does potentially expensive workspace discovery (find projects + read manifests) before `check_deps_status_before_run` loads workspace state and can immediately return `Outdated` when state is missing.

### Issue Context
This is a startup-path performance tax on the common "first run" scenario in large workspaces.

### Fix Focus Areas
- pacquet/crates/package-manager/src/install.rs[2367-2436]
- pacquet/crates/package-manager/src/optimistic_repeat_install.rs[1401-1406]

### Suggested fix
Reorder work in `check_deps_status_before_run_at`:
1) Determine `workspace_root`.
2) Attempt to load workspace state early; if missing, return `RunDepsStatus::Outdated { issue: ..., install_args: vec![] }` without scanning workspace projects.
3) Only if state exists, proceed to `load_workspace_projects` / `build_project_manifests_list` / lockfile checks.

This preserves behavior while avoiding unnecessary scanning in the missing-state case.

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


Results up to commit 00c83a5


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


Remediation recommended
1. Wrong optional install args 🐞 Bug ≡ Correctness
Description
install_args_from_state treats a missing workspaceState.settings.optional as false, which
makes verify-deps-before-run’s auto-spawned install add --no-optional even when the
workspace-state file simply omits the field. This can silently skip optional dependencies during the
gate-triggered install and break projects (or change behavior) compared to a normal/default install.
Code

pnpm/crates/package-manager/src/optimistic_repeat_install.rs[R1521-1531]

+    let mut args = Vec::new();
+    let dev = settings.dev.unwrap_or(false);
+    let production = settings.production.unwrap_or(false);
+    if production && !dev {
+        args.push("--production".to_string());
+    } else if dev && !production {
+        args.push("--dev".to_string());
+    }
+    if !settings.optional.unwrap_or(false) {
+        args.push("--no-optional".to_string());
+    }
Evidence
The workspace-state schema uses Option<bool> for optional, meaning the key can be absent;
defaulting absence to false changes semantics. The current workspace-state writer records
optional from IncludedDependencies.optional_dependencies (which is typically true for default
installs), so --no-optional should only be produced when the recorded value is explicitly false.

pnpm/crates/package-manager/src/optimistic_repeat_install.rs[1515-1532]
pnpm/crates/package-manager/src/optimistic_repeat_install.rs[1096-1145]
pnpm/crates/workspace-state/src/lib.rs[88-157]
pnpm/crates/package-manager/src/optimistic_repeat_install/tests.rs[17-19]

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

### Issue description
`install_args_from_state()` currently does:
- `if !settings.optional.unwrap_or(false) { "--no-optional" }`

Because workspace-state fields are optional (`Option<bool>`), an omitted `optional` key should not be interpreted as `false`. Doing so can cause the verify-deps-before-run gate (install/prompt actions) to spawn an install that incorrectly excludes optional dependencies.

### Issue Context
- Workspace-state settings fields are `Option` and may be absent.
- The gate’s goal is to reproduce the dependency-group selection from the recorded workspace state; absence should typically mean “don’t force a flag”.

### Fix Focus Areas
- pnpm/crates/package-manager/src/optimistic_repeat_install.rs[1519-1532]

### Suggested change
Change the condition to only emit `--no-optional` when the recorded value is explicitly `false`:

```rust
if settings.optional == Some(false) {
   args.push("--no-optional".to_string());
}
```

(Do not treat `None` as `false`.)

ⓘ 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 10, 2026 •

Copy link
Copy Markdown

PR Code Suggestions ✨

Latest suggestions up to 47257df

Warning

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

CategorySuggestion                                                                                                                                    Impact
Possible issue
Avoid installs when listing scripts

Move verify_deps_before_run to execute only when a specific script name is
provided. This prevents pnpm run (without arguments) from unintentionally
triggering a dependency install.

pnpm/crates/cli/src/cli_args/run.rs [108-124]

 fn run_inner(
     self,
     dir: &Path,
     config: &Config,
     silent: bool,
     fallback_to_exec: bool,
 ) -> miette::Result<()> {
-    // Before the manifest is read, so a mistyped command in a
-    // directory without a project skips the check instead of
-    // spawning a doomed install (see check_deps_status_before_run_at).
-    super::verify_deps::verify_deps_before_run(dir, config, silent)?;
     let RunArgs { command, args, if_present, .. } = self;
     let Some(script_name) = command else {
         let manifest = read_project_manifest_only(dir).map_err(RunError::Manifest)?;
         println!("{}", render_project_commands(manifest.value()));
         return Ok(());
     };
+    // Before the manifest is read for commands that actually run a
+    // script, so a mistyped command in a directory without a project
+    // skips the check instead of spawning a doomed install.
+    super::verify_deps::verify_deps_before_run(dir, config, silent)?;

[To ensure code accuracy, apply this suggestion manually]

Suggestion importance[1-10]: 8

__

Why: Listing scripts with pnpm run should be a read-only operation and should not trigger a dependency installation check, which this suggestion correctly addresses while preserving the fix for mistyped commands.

Medium
  • More

Previous suggestions

Suggestions up to commit e39d710
CategorySuggestion                                                                                                                                    Impact
Possible issue
Avoid installs when listing scripts

Move the dependency check after verifying a script name is provided.

pnpm/crates/cli/src/cli_args/run.rs [115-124]

-// Before the manifest is read, so a mistyped command in a
-// directory without a project skips the check instead of
-// spawning a doomed install (see check_deps_status_before_run_at).
-super::verify_deps::verify_deps_before_run(dir, config, silent)?;
 let RunArgs { command, args, if_present, .. } = self;
 let Some(script_name) = command else {
     let manifest = read_project_manifest_only(dir).map_err(RunError::Manifest)?;
     println!("{}", render_project_commands(manifest.value()));
     return Ok(());
 };
+super::verify_deps::verify_deps_before_run(dir, config, silent)?;
Suggestion importance[1-10]: 9

__

Why: This is an excellent catch; running pnpm run without arguments shouldn't trigger an install, and moving the check correctly preserves it for actual script executions without breaking the intended fallback behavior.

High
Preserve the recursion guard

Move the VERIFY_DEPS_BEFORE_RUN_ENV insertion after applying extra_env.

pnpm/crates/executor/src/make_env.rs [103-111]

-// Breaks the recursion a spawned install's lifecycle scripts would
-// otherwise enter (pnpm stamps the same value via `config.extraEnv`).
-env.insert(VERIFY_DEPS_BEFORE_RUN_ENV.into(), "false".into());
-
 // 4. `extra_env` is applied last among the base env writes, so it
 //    overrides anything stamped above.
 for (k, v) in opts.extra_env {
     env.insert(k.clone(), v.clone());
 }
 
+// Breaks the recursion a spawned install's lifecycle scripts would
+// otherwise enter; keep this non-overridable.
+env.insert(VERIFY_DEPS_BEFORE_RUN_ENV.into(), "false".into());
+
Suggestion importance[1-10]: 4

__

Why: While it's good defensive programming to prevent extra_env from overriding this critical guard, it's currently not a real bug since extra_env is populated internally by pacquet and does not contain this variable.

Low
Suggestions up to commit 00c83a5
CategorySuggestion                                                                                                                                    Impact
Possible issue
Avoid installs when listing scripts

Move the verify_deps_before_run call after the script listing check. This
prevents pnpm run without arguments from triggering an unexpected installation.

pnpm/crates/cli/src/cli_args/run.rs [118-124]

-super::verify_deps::verify_deps_before_run(dir, config, silent)?;
 let RunArgs { command, args, if_present, .. } = self;
 let Some(script_name) = command else {
     let manifest = read_project_manifest_only(dir).map_err(RunError::Manifest)?;
     println!("{}", render_project_commands(manifest.value()));
     return Ok(());
 };
+super::verify_deps::verify_deps_before_run(dir, config, silent)?;
Suggestion importance[1-10]: 8

__

Why: Moving the dependency verification after the script listing check prevents an unintended pnpm install when a user simply runs pnpm run to list available scripts, while preserving the intended behavior for mistyped commands.

Medium
Suggestions up to commit 8de2d8a
CategorySuggestion                                                                                                                                    Impact
Possible issue
Avoid installs when listing

Move the verify_deps_before_run check after the block that handles listing
scripts when no command is provided. This prevents pnpm run without arguments
from inadvertently triggering an install.

pacquet/crates/cli/src/cli_args/run.rs [115-124]

-// Before the manifest is read, so a mistyped command in a
-// directory without a project skips the check instead of
-// spawning a doomed install (see check_deps_status_before_run_at).
-super::verify_deps::verify_deps_before_run(dir, config, silent)?;
 let RunArgs { command, args, if_present, .. } = self;
 let Some(script_name) = command else {
     let manifest = read_project_manifest_only(dir).map_err(RunError::Manifest)?;
     println!("{}", render_project_commands(manifest.value()));
     return Ok(());
 };
+super::verify_deps::verify_deps_before_run(dir, config, silent)?;
Suggestion importance[1-10]: 7

__

Why: Moving the check avoids triggering an unintended install when listing scripts, though the proposed snippet drops an important code comment.

Medium
Preserve recursion guard

Move the pnpm_config_verify_deps_before_run assignment after the extra_env
application to ensure the recursion guard cannot be unintentionally overridden.

pacquet/crates/executor/src/make_env.rs [97-108]

-// A nested `pnpm run` / `pnpm exec` inside a script must skip the
-// verify-deps-before-run check — this env var outranks every other
-// source of that setting on the config side, breaking the recursion
-// a spawned install's lifecycle scripts would otherwise enter
-// (pnpm stamps the same value via `config.extraEnv`).
-env.insert("pnpm_config_verify_deps_before_run".into(), "false".into());
-
 // 4. `extra_env` is applied last among the base env writes, so it
 //    overrides anything stamped above.
 for (k, v) in opts.extra_env {
     env.insert(k.clone(), v.clone());
 }
 
+// A nested `pnpm run` / `pnpm exec` inside a script must skip the
+// verify-deps-before-run check; this stamp must outrank `extra_env`
+// to remain an effective recursion breaker.
+env.insert("pnpm_config_verify_deps_before_run".into(), "false".into());
+
Suggestion importance[1-10]: 3

__

Why: While this prevents potential overrides, extra_env is typically internally populated and unlikely to contain this key, making the fix marginal and contradictory to the existing ordering comment.

Low
Suggestions up to commit 8f0926a
CategorySuggestion                                                                                                                                    Impact
Possible issue
Skip installs when listing scripts

Skip dependency verification when listing scripts. Move the
verify_deps_before_run check to run only when a specific script name is
provided.

pacquet/crates/cli/src/cli_args/run.rs [115-124]

-// Before the manifest is read, so a mistyped command in a
-// directory without a project skips the check instead of
-// spawning a doomed install (see check_deps_status_before_run_at).
-super::verify_deps::verify_deps_before_run(dir, config, silent)?;
 let RunArgs { command, args, if_present, .. } = self;
 let Some(script_name) = command else {
     let manifest = read_project_manifest_only(dir).map_err(RunError::Manifest)?;
     println!("{}", render_project_commands(manifest.value()));
     return Ok(());
 };
+// Before the script manifest lookup, so a mistyped command in a
+// directory without a project skips the check instead of spawning
+// a doomed install (see check_deps_status_before_run_at).
+super::verify_deps::verify_deps_before_run(dir, config, silent)?;
Suggestion importance[1-10]: 8

__

Why: Moving the dependency verification after the empty script name check correctly prevents unintended dependency checks or package installations when a user is merely attempting to list available scripts.

Medium
Suggestions up to commit 8f170e1
CategorySuggestion                                                                                                                                    Impact
Possible issue
Handle empty project lists

Check for an empty allProjects array in the project check condition. Update the
guard to treat opts.allProjects.length === 0 the same as a missing value.

pnpm11/deps/status/src/checkDepsStatus.ts [128-135]

-if (opts.allProjects == null && opts.workspaceDir == null && opts.rootProjectManifest == null) {
+if ((opts.allProjects == null || opts.allProjects.length === 0) && opts.workspaceDir == null && opts.rootProjectManifest == null) {
   // There is no project here at all (for example, a mistyped command fell
   // back to `pnpm run` in a directory without a manifest). Reporting
   // "outdated" would make verify-deps-before-run spawn a `pnpm install`
   // that can only fail with NO_PKG_MANIFEST — report "unknown" instead so
   // the caller skips the check and the command fails with its own error.
   return { upToDate: undefined, workspaceState }
 }
Suggestion importance[1-10]: 5

__

Why: This is a valid defensive programming suggestion to handle potential edge cases where opts.allProjects is passed as an empty array instead of null or undefined.

Low

Copilot AI review requested due to automatic review settings July 10, 2026 14:52

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.

@github-actions

github-actions Bot commented Jul 10, 2026 •

Copy link
Copy Markdown
Contributor

Micro-Benchmark Results

Linux

group                          main                                   pr
-----                          ----                                   --
tarball/download_dependency    1.00      6.7±0.18ms   646.3 KB/sec    1.00      6.7±0.40ms   648.3 KB/sec

@qodo-code-review

Copy link
Copy Markdown

Code review by qodo was updated up to the latest commit 8f170e1

@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/tests/run.rs (1)

515-523: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Add logging before non-assert_eq! assertions.

Per pacquet/CODE_STYLE_GUIDE.md, non-assert_eq! assertions should be preceded by logging to aid debugging. The assert! on line 515 and the side-effect assert! on lines 520-523 lack pre-assertion diagnostic output. The stderr assertion on lines 516-519 partially mitigates this by embedding {stderr} in the failure message, but the other two do not.

Consider adding eprintln! calls before each assertion, e.g. printing stderr before the status check and printing the relevant paths before the side-effect check.

♻️ Suggested additions
     let stderr = String::from_utf8_lossy(&output.stderr);
+    eprintln!("pacquet stderr:\n{stderr}");
     assert!(!output.status.success(), "a mistyped command must fail");
     assert!(
         stderr.contains("witch-definitely-not-a-binary") && stderr.contains("not found"),
         "the failure must name the missing command, not come from a spawned install:\n{stderr}",
     );
+    eprintln!(
+        "node_modules exists: {}, pnpm-lock.yaml exists: {}",
+        workspace.join("node_modules").exists(),
+        workspace.join("pnpm-lock.yaml").exists(),
+    );
     assert!(
         !workspace.join("node_modules").exists() && !workspace.join("pnpm-lock.yaml").exists(),
         "no install may run in a directory without a manifest",
     );
🤖 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/tests/run.rs` around lines 515 - 523, Add diagnostic
eprintln! calls immediately before the non-assert_eq! assertions in the relevant
test: print the command output/stderr before the status assertion, and print the
workspace node_modules and pnpm-lock.yaml paths and existence state before the
side-effect assertion. Keep the existing assertions and messages unchanged.

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/tests/run.rs`:
- Around line 515-523: Add diagnostic eprintln! calls immediately before the
non-assert_eq! assertions in the relevant test: print the command output/stderr
before the status assertion, and print the workspace node_modules and
pnpm-lock.yaml paths and existence state before the side-effect assertion. Keep
the existing assertions and messages unchanged.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: 73430a7e-c94e-43b5-a6bd-d4fa1727c6c3

📥 Commits

Reviewing files that changed from the base of the PR and between f21995f and 8f170e1.

📒 Files selected for processing (1)
  • pacquet/crates/cli/tests/run.rs

@codecov-commenter

codecov-commenter commented Jul 10, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 80.04535% with 88 lines in your changes missing coverage. Please review.
✅ Project coverage is 85.45%. Comparing base (8e17c3d) to head (47257df).

Files with missing lines Patch % Lines
...s/package-manager/src/optimistic_repeat_install.rs 76.47% 56 Missing ⚠️
pnpm/crates/cli/src/cli_args/verify_deps.rs 72.72% 15 Missing ⚠️
pnpm/crates/config/src/lib.rs 85.00% 6 Missing ⚠️
pnpm/crates/package-manager/src/install.rs 90.16% 6 Missing ⚠️
pnpm/crates/config/src/pnpm_default_parity.rs 50.00% 5 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main   #12910      +/-   ##
==========================================
- Coverage   85.49%   85.45%   -0.04%     
==========================================
  Files         468      469       +1     
  Lines       72828    73228     +400     
==========================================
+ Hits        62266    62579     +313     
- Misses      10562    10649      +87     

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

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

@github-actions

github-actions Bot commented Jul 10, 2026 •

Copy link
Copy Markdown
Contributor

Integrated-Benchmark Report (Linux)

Commit: 47257df6ae92

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 3.853 ± 0.153 3.679 4.085 1.80 ± 0.11
pacquet@main 3.803 ± 0.136 3.644 4.012 1.77 ± 0.11
pnpr@HEAD 2.146 ± 0.102 2.014 2.319 1.00
pnpr@main 2.169 ± 0.135 2.013 2.369 1.01 ± 0.08
BENCHMARK_REPORT.json
{
  "results": [
    {
      "command": "pacquet@HEAD",
      "mean": 3.8527304613399997,
      "stddev": 0.15302708814422228,
      "median": 3.83381351994,
      "user": 3.57638482,
      "system": 3.4415381000000003,
      "min": 3.67872562744,
      "max": 4.08490330944,
      "times": [
        3.97255157744,
        4.08490330944,
        3.98930022344,
        3.67872562744,
        3.79962590544,
        4.014815404439999,
        3.71015151044,
        3.86800113444,
        3.70881718644,
        3.70041273444
      ]
    },
    {
      "command": "pacquet@main",
      "mean": 3.80264872074,
      "stddev": 0.13550153140862556,
      "median": 3.7754400774400003,
      "user": 3.57870372,
      "system": 3.4609335999999997,
      "min": 3.64399662844,
      "max": 4.01177764744,
      "times": [
        3.84485737044,
        3.7926189534400003,
        3.7582612014400003,
        3.99424083544,
        4.01177764744,
        3.74310856444,
        3.67166346744,
        3.91394853644,
        3.65201400244,
        3.64399662844
      ]
    },
    {
      "command": "pnpr@HEAD",
      "mean": 2.14592961424,
      "stddev": 0.10240832132945765,
      "median": 2.1261309434399998,
      "user": 2.6654210199999997,
      "system": 3.0404145000000007,
      "min": 2.01410237144,
      "max": 2.31872713344,
      "times": [
        2.01410237144,
        2.31872713344,
        2.26491750544,
        2.10658549544,
        2.14567639144,
        2.21908463444,
        2.20625135244,
        2.05935830544,
        2.04027753244,
        2.08431542044
      ]
    },
    {
      "command": "pnpr@main",
      "mean": 2.16933872304,
      "stddev": 0.1347520656507724,
      "median": 2.1494423544399996,
      "user": 2.6198841199999996,
      "system": 3.060248,
      "min": 2.01336874844,
      "max": 2.36872614544,
      "times": [
        2.33481689244,
        2.11787201144,
        2.36872614544,
        2.18101269744,
        2.07375022344,
        2.03341476744,
        2.01336874844,
        2.27080730544,
        2.27330376944,
        2.02631466944
      ]
    }
  ]
}

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

Command Mean [ms] Min [ms] Max [ms] Relative
pacquet@HEAD 657.2 ± 23.8 635.7 712.3 1.00
pacquet@main 661.0 ± 33.9 629.1 745.7 1.01 ± 0.06
pnpr@HEAD 698.6 ± 14.4 681.0 720.8 1.06 ± 0.04
pnpr@main 720.9 ± 11.6 696.9 734.5 1.10 ± 0.04
BENCHMARK_REPORT.json
{
  "results": [
    {
      "command": "pacquet@HEAD",
      "mean": 0.65720957924,
      "stddev": 0.023836524899982964,
      "median": 0.65284062164,
      "user": 0.38904314,
      "system": 1.3481698999999998,
      "min": 0.63566348364,
      "max": 0.71234099764,
      "times": [
        0.71234099764,
        0.68138664364,
        0.66260281064,
        0.63566348364,
        0.64362655264,
        0.63785638964,
        0.65546559764,
        0.63747207364,
        0.65104289864,
        0.65463834464
      ]
    },
    {
      "command": "pacquet@main",
      "mean": 0.6610415271400001,
      "stddev": 0.03389255043656542,
      "median": 0.65436903414,
      "user": 0.39198163999999996,
      "system": 1.3401798999999999,
      "min": 0.62912608464,
      "max": 0.74569619064,
      "times": [
        0.64995279264,
        0.6605930076400001,
        0.62912608464,
        0.63408410764,
        0.68650058864,
        0.6513297166400001,
        0.65740835164,
        0.65787226164,
        0.63785216964,
        0.74569619064
      ]
    },
    {
      "command": "pnpr@HEAD",
      "mean": 0.69863878824,
      "stddev": 0.014426115224161389,
      "median": 0.7005610146400001,
      "user": 0.39845823999999996,
      "system": 1.3580942999999999,
      "min": 0.68104483664,
      "max": 0.72076755864,
      "times": [
        0.72076755864,
        0.68434013064,
        0.71811642464,
        0.68104483664,
        0.7068899696400001,
        0.68175499764,
        0.70133150064,
        0.70379512464,
        0.69979052864,
        0.68855681064
      ]
    },
    {
      "command": "pnpr@main",
      "mean": 0.72085117274,
      "stddev": 0.011642909123142671,
      "median": 0.72348982514,
      "user": 0.39249784,
      "system": 1.4125001000000001,
      "min": 0.69685085964,
      "max": 0.73454017364,
      "times": [
        0.73454017364,
        0.7330625416400001,
        0.72525483164,
        0.72191805864,
        0.7250615916400001,
        0.7154850996400001,
        0.72837740164,
        0.69685085964,
        0.70729523564,
        0.72066593364
      ]
    }
  ]
}

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

Command Mean [s] Min [s] Max [s] Relative
pacquet@HEAD 4.293 ± 0.043 4.241 4.356 1.96 ± 0.10
pacquet@main 4.261 ± 0.034 4.214 4.324 1.95 ± 0.10
pnpr@HEAD 2.270 ± 0.169 2.031 2.452 1.04 ± 0.09
pnpr@main 2.190 ± 0.107 2.069 2.368 1.00
BENCHMARK_REPORT.json
{
  "results": [
    {
      "command": "pacquet@HEAD",
      "mean": 4.293227912940001,
      "stddev": 0.04298547373560574,
      "median": 4.28918101204,
      "user": 3.7745721599999995,
      "system": 3.4429795799999994,
      "min": 4.24057092204,
      "max": 4.3562408470400005,
      "times": [
        4.34882300204,
        4.26795681204,
        4.29126227004,
        4.28709975404,
        4.3562408470400005,
        4.31751517904,
        4.24693646504,
        4.2471524370400004,
        4.24057092204,
        4.32872144104
      ]
    },
    {
      "command": "pacquet@main",
      "mean": 4.260846425639999,
      "stddev": 0.03384096860293878,
      "median": 4.2569059845399995,
      "user": 3.74817976,
      "system": 3.44447848,
      "min": 4.21364520904,
      "max": 4.32405893404,
      "times": [
        4.24305892004,
        4.27681368104,
        4.29818374004,
        4.22049503604,
        4.27365422804,
        4.21364520904,
        4.24474253904,
        4.25272047804,
        4.32405893404,
        4.26109149104
      ]
    },
    {
      "command": "pnpr@HEAD",
      "mean": 2.27014936944,
      "stddev": 0.1686399491614708,
      "median": 2.28479541304,
      "user": 2.49221226,
      "system": 2.9604022800000003,
      "min": 2.03071330504,
      "max": 2.4519013690400002,
      "times": [
        2.13987205304,
        2.39950822404,
        2.42060479404,
        2.15578502604,
        2.17008260204,
        2.07924064504,
        2.03071330504,
        2.44381936504,
        2.4519013690400002,
        2.40996631104
      ]
    },
    {
      "command": "pnpr@main",
      "mean": 2.1897799244400002,
      "stddev": 0.10699909559206539,
      "median": 2.14316931554,
      "user": 2.4867817599999995,
      "system": 2.97086768,
      "min": 2.06853488504,
      "max": 2.36756615204,
      "times": [
        2.20471837504,
        2.06853488504,
        2.10816859304,
        2.14678541004,
        2.13955322104,
        2.3623888280400003,
        2.11421534604,
        2.36756615204,
        2.26347640604,
        2.12239202804
      ]
    }
  ]
}

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

Command Mean [s] Min [s] Max [s] Relative
pacquet@HEAD 1.375 ± 0.013 1.355 1.397 1.97 ± 0.17
pacquet@main 1.378 ± 0.026 1.345 1.445 1.98 ± 0.18
pnpr@HEAD 0.699 ± 0.071 0.665 0.900 1.00 ± 0.13
pnpr@main 0.697 ± 0.061 0.670 0.869 1.00
BENCHMARK_REPORT.json
{
  "results": [
    {
      "command": "pacquet@HEAD",
      "mean": 1.3749179536200002,
      "stddev": 0.013149347042046912,
      "median": 1.3758657675200001,
      "user": 1.32634432,
      "system": 1.73516368,
      "min": 1.3552355425200002,
      "max": 1.39727427052,
      "times": [
        1.3769207445200002,
        1.37778160852,
        1.36760860252,
        1.3729259955200002,
        1.3785600555200002,
        1.3552355425200002,
        1.3569357935200002,
        1.37481079052,
        1.39727427052,
        1.3911261325200002
      ]
    },
    {
      "command": "pacquet@main",
      "mean": 1.3784988000200005,
      "stddev": 0.025893088393895945,
      "median": 1.37318638702,
      "user": 1.31427742,
      "system": 1.73391418,
      "min": 1.3453107675200002,
      "max": 1.44466977152,
      "times": [
        1.3696524115200002,
        1.44466977152,
        1.3744353205200002,
        1.37897240752,
        1.3729059145200002,
        1.3734668595200001,
        1.3453107675200002,
        1.39010158252,
        1.36348500052,
        1.3719879645200002
      ]
    },
    {
      "command": "pnpr@HEAD",
      "mean": 0.69920867332,
      "stddev": 0.07084672104068476,
      "median": 0.67634877302,
      "user": 0.34325691999999997,
      "system": 1.31013598,
      "min": 0.66496915252,
      "max": 0.89995913652,
      "times": [
        0.67324215452,
        0.67419948152,
        0.66496915252,
        0.6750824775200001,
        0.89995913652,
        0.68715978952,
        0.68686503652,
        0.67761506852,
        0.6798876045200001,
        0.6731068315200001
      ]
    },
    {
      "command": "pnpr@main",
      "mean": 0.69715190962,
      "stddev": 0.06060639258634049,
      "median": 0.67722788952,
      "user": 0.34692022,
      "system": 1.32233938,
      "min": 0.67041086352,
      "max": 0.86884282652,
      "times": [
        0.67623565452,
        0.67110211152,
        0.67708525852,
        0.68420290252,
        0.67041086352,
        0.68978659852,
        0.67522892352,
        0.86884282652,
        0.68125343652,
        0.67737052052
      ]
    }
  ]
}

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

Command Mean [s] Min [s] Max [s] Relative
pacquet@HEAD 3.066 ± 0.064 3.004 3.238 4.59 ± 0.11
pacquet@main 3.068 ± 0.061 3.029 3.240 4.59 ± 0.11
pnpr@HEAD 0.668 ± 0.009 0.657 0.681 1.00
pnpr@main 0.684 ± 0.037 0.658 0.788 1.02 ± 0.06
BENCHMARK_REPORT.json
{
  "results": [
    {
      "command": "pacquet@HEAD",
      "mean": 3.06552412636,
      "stddev": 0.06407935237831794,
      "median": 3.0513828925599995,
      "user": 1.79458776,
      "system": 2.0093041,
      "min": 3.00441629906,
      "max": 3.23780859706,
      "times": [
        3.06506731606,
        3.04376774106,
        3.0561534510599997,
        3.0264929110599996,
        3.0485724510599996,
        3.05419333406,
        3.00441629906,
        3.23780859706,
        3.0813326650599997,
        3.03743649806
      ]
    },
    {
      "command": "pacquet@main",
      "mean": 3.06806378676,
      "stddev": 0.061123142735924084,
      "median": 3.05119275656,
      "user": 1.80308966,
      "system": 1.9825525,
      "min": 3.02884555606,
      "max": 3.23984384506,
      "times": [
        3.0411519660599997,
        3.04444536806,
        3.05033358606,
        3.04851857106,
        3.02884555606,
        3.0539610910599997,
        3.05205192706,
        3.23984384506,
        3.06504319606,
        3.05644276106
      ]
    },
    {
      "command": "pnpr@HEAD",
      "mean": 0.6682635529600001,
      "stddev": 0.008955353285908012,
      "median": 0.6679445320600002,
      "user": 0.34916255999999996,
      "system": 1.2976602000000002,
      "min": 0.65705861206,
      "max": 0.6805734710600001,
      "times": [
        0.6805734710600001,
        0.6722990860600001,
        0.66234013006,
        0.6635899780600001,
        0.6773800700600001,
        0.6752459060600001,
        0.6605922400600001,
        0.65705861206,
        0.67616840706,
        0.65738762906
      ]
    },
    {
      "command": "pnpr@main",
      "mean": 0.6836219699600001,
      "stddev": 0.03741004768760641,
      "median": 0.6750526560600001,
      "user": 0.33780906,
      "system": 1.3038203000000002,
      "min": 0.6575357260600001,
      "max": 0.7875780450600001,
      "times": [
        0.6836316100600001,
        0.6575357260600001,
        0.6747420180600001,
        0.6653304940600001,
        0.6661220750600001,
        0.66685201506,
        0.6753632940600001,
        0.68121742906,
        0.7875780450600001,
        0.6778469930600001
      ]
    }
  ]
}

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

Command Mean [ms] Min [ms] Max [ms] Relative
pacquet@HEAD 629.8 ± 9.9 621.2 653.0 5.84 ± 0.10
pacquet@main 636.6 ± 10.6 621.3 656.7 5.90 ± 0.11
pnpr@HEAD 107.8 ± 0.7 105.4 108.8 1.00
pnpr@main 107.9 ± 0.4 107.1 108.7 1.00 ± 0.01
BENCHMARK_REPORT.json
{
  "results": [
    {
      "command": "pacquet@HEAD",
      "mean": 0.6297666129000001,
      "stddev": 0.009883446547638406,
      "median": 0.6272547377000001,
      "user": 0.5997027600000001,
      "system": 0.15050837999999997,
      "min": 0.6211871217000001,
      "max": 0.6530399087000001,
      "times": [
        0.6294680217,
        0.6250414537000001,
        0.6310531437000001,
        0.6211871217000001,
        0.6305878687,
        0.6530399087000001,
        0.6220427377000001,
        0.6221094017000001,
        0.6391299797000001,
        0.6240064917000001
      ]
    },
    {
      "command": "pacquet@main",
      "mean": 0.6366074752000002,
      "stddev": 0.010584463859975184,
      "median": 0.6341116662000001,
      "user": 0.5940817599999999,
      "system": 0.16125578000000002,
      "min": 0.6212938907000001,
      "max": 0.6566505517000001,
      "times": [
        0.6346275897000001,
        0.6395418097000001,
        0.6246599467,
        0.6307780567000001,
        0.6335747037,
        0.6458147907,
        0.6335957427000001,
        0.6566505517000001,
        0.6455376697,
        0.6212938907000001
      ]
    },
    {
      "command": "pnpr@HEAD",
      "mean": 0.10784286304615387,
      "stddev": 0.0007114639967048756,
      "median": 0.10793718320000001,
      "user": 0.02641121384615385,
      "system": 0.020745703076923076,
      "min": 0.10536278470000002,
      "max": 0.10880963970000002,
      "times": [
        0.10536278470000002,
        0.10785029870000001,
        0.10819395470000001,
        0.10761995770000002,
        0.10859969670000001,
        0.10880963970000002,
        0.10626243070000001,
        0.10803412670000001,
        0.10763197870000002,
        0.10798819870000001,
        0.10845460470000001,
        0.10730194170000001,
        0.10783683470000001,
        0.10866666170000001,
        0.10749716570000001,
        0.10781988370000001,
        0.10792897770000001,
        0.10831889870000001,
        0.10796675870000001,
        0.10835759270000002,
        0.10765491370000001,
        0.10768001970000002,
        0.10794538870000002,
        0.1080840187,
        0.10786983670000001,
        0.10817787470000001
      ]
    },
    {
      "command": "pnpr@main",
      "mean": 0.10790370738,
      "stddev": 0.00037585348205968914,
      "median": 0.10787007670000001,
      "user": 0.027970000000000002,
      "system": 0.019001979999999998,
      "min": 0.10713088170000001,
      "max": 0.10870768870000001,
      "times": [
        0.10739611770000002,
        0.10805268070000001,
        0.10870768870000001,
        0.10751956870000001,
        0.10821238870000001,
        0.10779391470000001,
        0.10777763470000001,
        0.10773284870000001,
        0.10768332670000001,
        0.10870439270000001,
        0.10772944270000001,
        0.10779028970000001,
        0.10791429970000001,
        0.10749714770000002,
        0.10795258170000001,
        0.10823310770000001,
        0.10713088170000001,
        0.10824375570000001,
        0.10826035970000002,
        0.10787007670000001,
        0.10747600770000001,
        0.10813012470000001,
        0.10771725970000001,
        0.10795870370000002,
        0.10810808370000001
      ]
    }
  ]
}

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

Command Mean [s] Min [s] Max [s] Relative
pacquet@HEAD 6.616 ± 0.109 6.464 6.755 1.33 ± 0.03
pacquet@main 6.552 ± 0.177 6.360 6.963 1.32 ± 0.04
pnpr@HEAD 5.012 ± 0.072 4.907 5.106 1.01 ± 0.02
pnpr@main 4.956 ± 0.065 4.868 5.054 1.00
BENCHMARK_REPORT.json
{
  "results": [
    {
      "command": "pacquet@HEAD",
      "mean": 6.615612388040001,
      "stddev": 0.10940655886020467,
      "median": 6.61567593624,
      "user": 3.75002382,
      "system": 3.7492559199999995,
      "min": 6.46439885524,
      "max": 6.75519484724,
      "times": [
        6.53097697224,
        6.75519484724,
        6.56534057524,
        6.51569016224,
        6.46439885524,
        6.74177158624,
        6.50880117424,
        6.66601129724,
        6.71459506224,
        6.69334334824
      ]
    },
    {
      "command": "pacquet@main",
      "mean": 6.55238199084,
      "stddev": 0.1768649797737978,
      "median": 6.50380336924,
      "user": 3.77615792,
      "system": 3.7365869199999997,
      "min": 6.36002565424,
      "max": 6.96348023924,
      "times": [
        6.46429441024,
        6.5266540192399995,
        6.56562778024,
        6.36002565424,
        6.46405748924,
        6.4163107222399995,
        6.96348023924,
        6.48095271924,
        6.54187960324,
        6.74053727124
      ]
    },
    {
      "command": "pnpr@HEAD",
      "mean": 5.01188508404,
      "stddev": 0.07200629359235468,
      "median": 5.01940949024,
      "user": 2.7787605199999996,
      "system": 3.274568919999999,
      "min": 4.90727174824,
      "max": 5.10619719924,
      "times": [
        4.98128176324,
        4.94083525124,
        4.90727174824,
        5.00357333024,
        4.92213074624,
        5.05559697324,
        5.03524565024,
        5.10619719924,
        5.07875739324,
        5.08796078524
      ]
    },
    {
      "command": "pnpr@main",
      "mean": 4.95565267964,
      "stddev": 0.06456594666997163,
      "median": 4.93877512074,
      "user": 2.7862506199999997,
      "system": 3.2666924199999996,
      "min": 4.86831171624,
      "max": 5.05353410024,
      "times": [
        5.05353410024,
        5.04802727324,
        4.99854036224,
        4.93957615224,
        4.91003726724,
        4.89767016824,
        4.99551748424,
        4.93797408924,
        4.90733818324,
        4.86831171624
      ]
    }
  ]
}

@github-actions

github-actions Bot commented Jul 10, 2026 •

Copy link
Copy Markdown
Contributor

🐰 Bencher Report

Branchpr/12910
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,293.23 ms
(+0.90%)Baseline: 4,255.00 ms
5,106.00 ms
(84.08%)
isolated-linker.fresh-install.cold-cache.hot-store📈 view plot
🚷 view threshold
3,065.52 ms
(+1.14%)Baseline: 3,031.03 ms
3,637.23 ms
(84.28%)
isolated-linker.fresh-install.hot-cache.hot-store📈 view plot
🚷 view threshold
1,374.92 ms
(+1.42%)Baseline: 1,355.73 ms
1,626.87 ms
(84.51%)
isolated-linker.fresh-resolve.hot-cache.offline📈 view plot
🚷 view threshold
629.77 ms
(-2.81%)Baseline: 647.95 ms
777.54 ms
(81.00%)
isolated-linker.fresh-restore.cold-cache.cold-store📈 view plot
🚷 view threshold
3,852.73 ms
(-5.93%)Baseline: 4,095.73 ms
4,914.88 ms
(78.39%)
isolated-linker.fresh-restore.cold-cache.cold-store.cold-pnpr📈 view plot
🚷 view threshold
6,615.61 ms
(-4.37%)Baseline: 6,917.58 ms
8,301.10 ms
(79.70%)
isolated-linker.fresh-restore.hot-cache.hot-store📈 view plot
🚷 view threshold
657.21 ms
(+3.66%)Baseline: 634.03 ms
760.83 ms
(86.38%)
🐰 View full continuous benchmarking report in Bencher

@github-actions

github-actions Bot commented Jul 10, 2026 •

Copy link
Copy Markdown
Contributor

🐰 Bencher Report

Branchpr/12910
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,270.15 ms
isolated-linker.fresh-install.cold-cache.hot-store📈 view plot
⚠️ NO THRESHOLD
668.26 ms
isolated-linker.fresh-install.hot-cache.hot-store📈 view plot
⚠️ NO THRESHOLD
699.21 ms
isolated-linker.fresh-resolve.hot-cache.offline📈 view plot
⚠️ NO THRESHOLD
107.84 ms
isolated-linker.fresh-restore.cold-cache.cold-store📈 view plot
⚠️ NO THRESHOLD
2,145.93 ms
isolated-linker.fresh-restore.cold-cache.cold-store.cold-pnpr📈 view plot
⚠️ NO THRESHOLD
5,011.89 ms
isolated-linker.fresh-restore.hot-cache.hot-store📈 view plot
⚠️ NO THRESHOLD
698.64 ms
🐰 View full continuous benchmarking report in Bencher

Copilot AI review requested due to automatic review settings July 10, 2026 15:50

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(deps.status): don't spawn an install when run outside of a project fix: don't spawn an install outside a project; port verify-deps-before-run to pacquet Jul 10, 2026
@zkochan
zkochan force-pushed the fix/verify-deps-before-run-no-manifest branch from 8f0926a to 8de2d8a Compare July 10, 2026 15:55
Copilot AI review requested due to automatic review settings July 10, 2026 15:55

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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

Copilot AI review requested due to automatic review settings July 10, 2026 16:00

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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

@zkochan

zkochan commented Jul 10, 2026

Copy link
Copy Markdown
Member Author

Addressed the automated review findings in 3030a45:

  • Qodo bug (test misses manifest side-effect): the no-manifest gate test now also asserts that no package.json appears — an install in a manifest-less directory would scaffold one before doing anything else — alongside node_modules and pnpm-lock.yaml.
  • Qodo rule violation (historical phrasing): the test's doc comment now describes the current contract only, without the narrative about the prior failure mode.
  • CodeRabbit nitpicks: stderr is logged before the assertions per the code style guide, and the changeset wording uses "outside a project".

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

@qodo-code-review

Copy link
Copy Markdown

Code review by qodo was updated up to the latest commit 00c83a5

- Keep the pre-run check read-only: pnpm's run path never writes
  pnpm-lock.yaml (only the install command restores it from the current
  lockfile), so the gate now uses a read-only stand-in check instead of
  regenerate_wanted_lockfile_if_missing, and a missing lockfile without
  a stand-in reports "Cannot find a lockfile" like pnpm instead of
  passing silently.
- Match pnpm's env-var semantics for unrecognized values: pnpm assigns
  pnpm_config_verify_deps_before_run verbatim without validation, so a
  present-but-invalid value is truthy there (check runs, no action
  matches). Parse failures now map to VerifyDepsBeforeRun::True instead
  of being dropped, which also keeps a present env var overriding the
  CLI consistently.
- Report "cannot check" straight from the missing workspace state,
  before the workspace-projects walk, sparing fresh projects the
  discovery cost on every run/exec.
- Share the recursion-guard env-var name through a constant, cover the
  exec-path stamp with a test, and drop a test doc comment that only
  restated the assertions.

Co-Authored-By: Claude Fable 5 <[email protected]>
Copilot AI review requested due to automatic review settings July 10, 2026 16:21

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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

@zkochan

zkochan commented Jul 10, 2026

Copy link
Copy Markdown
Member Author

Triage of the updated Qodo review (which ran against 00c83a5, one commit behind):

Fixed in e39d710:

  • Gate writes pnpm-lock.yaml — the run gate now uses a read-only stand-in check; pnpm's run path never restores the lockfile (only installDeps consumes wantedLockfileToRestore), and a missing lockfile without a stand-in now reports Cannot find a lockfile in … like pnpm instead of silently passing. Covered by a new phase in error_action_follows_the_dependency_state.
  • Env blocks CLI override — fixed for parity rather than as suggested: pnpm assigns pnpm_config_verify_deps_before_run verbatim without validation, so a present-but-invalid value is truthy there (the check runs, no action matches). pacquet now maps unparseable values to the true behavior instead of dropping them, which keeps a present env var overriding the CLI exactly like pnpm. Covered by unrecognized_env_value_checks_without_acting.
  • Unnecessary scan without state — the wrapper now reports "cannot check" straight from the missing workspace state, before the workspace-projects walk.
  • Redundant test doc comment — removed.
  • Historical phrasing / manifest side-effect — already fixed in 3030a45 (stale findings).

Not applied:

  • Wrong optional install args — pnpm's createInstallArgs pushes --no-optional on !optional, and an absent key is undefined (falsy), so pnpm also emits --no-optional for a state file that omits the field (pnpm11/exec/commands/src/runDepsStatusCheck.ts:68-81). Changing pacquet to == Some(false) would diverge from that; both implementations always record the key themselves, so the absent-key case only arises for state files written by neither.
  • CodeRabbit's duplicated-literal nitpick was applied in the same commit: the recursion-guard env var name is now the shared pacquet_executor::VERIFY_DEPS_BEFORE_RUN_ENV constant, and the exec-path stamp has its own test.

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

Comment thread pnpm/crates/cli/src/config_overrides.rs Resolved
@qodo-code-review

Copy link
Copy Markdown

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

…e paths

- Apply the pnpm_config_verify_deps_before_run env var on presence
  alone, like pnpm's `!= null` check: an empty value disables the gate
  (pnpm assigns the empty string, which is falsy there) and still
  overrides the CLI.
- Load the workspace state once: the discovery wrapper already loads it
  to short-circuit before the projects walk, so it now hands the loaded
  state to check_deps_status_before_run instead of having it re-read
  the file.
- Report an unreadable current lockfile as "the current lockfile cannot
  be loaded" instead of pretending it is missing.

Co-Authored-By: Claude Fable 5 <[email protected]>
Copilot AI review requested due to automatic review settings July 10, 2026 16:32

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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

@zkochan

zkochan commented Jul 10, 2026

Copy link
Copy Markdown
Member Author

Triage of the latest Qodo review (against e39d710) — the three new findings are all addressed in 47257df:

  • Empty VERIFY_DEPS env ignored — real parity gap; the env var now applies on presence alone like pnpm's != null check. An empty value disables the gate (pnpm assigns the empty string, which is falsy there) and still overrides the CLI. New test: empty_env_value_disables_the_gate.
  • Duplicate workspace-state load — the discovery wrapper now hands its already-loaded state to check_deps_status_before_run instead of the check re-reading the file.
  • Lockfile errors reported as missing — an unreadable current lockfile now reports "the current lockfile cannot be loaded" instead of "Cannot find a lockfile".

The remaining entries in the review are carried over from earlier commits and were either fixed there (read-only lockfile check, invalid-env handling, early state check, doc comments, side-effect assert — 3030a45 / e39d710) or rejected for TS parity with reasoning in the previous triage comments (--no-optional on an absent optional key matches pnpm's createInstallArgs).


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

@qodo-code-review

Copy link
Copy Markdown

Code review by qodo was updated up to the latest commit 47257df

@zkochan
zkochan merged commit eee7c9a into main Jul 10, 2026
29 of 34 checks passed
@zkochan
zkochan deleted the fix/verify-deps-before-run-no-manifest branch July 10, 2026 18:12
@zkochan

zkochan commented Jul 10, 2026

Copy link
Copy Markdown
Member Author

TS CI failure root cause + fix (67e9b56): the failing jobs never reached any test — the test-pkgs-branch script's own invocation, pn --workspace-concurrency=1 --filter=...[origin/main] --no-sort --if-present .test, died with clap's unexpected argument '--if-present'. pnpm accepts every run option at the top level, but pacquet only declared --if-present on the run/restart/stop subcommands. Since CI started self-updating pnpm to the Rust v12 build, every PR whose TS CI reaches test-pkgs-branch fails the same way (recent runs on other branches show it too, while push runs on main stay green because test-pkgs-all doesn't use --if-present).

Fix: a hidden global --if-present threaded through RunCtx into run, restart, and stop — the same pattern as --resume-from/--report-summary/--no-bail — with the subcommand declarations becoming #[clap(skip)]. Verified the exact CI invocation end to end (parses, runs .test under npm_lifecycle_event, exits 0 on a missing script), plus a regression test.

Note for other PRs: this unblocks their TS CI as well once it lands.


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

eagarwal-notion added a commit to eagarwal-notion/pnpm that referenced this pull request Jul 10, 2026
pnpm installs a workspace whose root has no package.json with no root
importer and never creates one. pacquet's State::init scaffolded the
init-template package.json there instead, which diverges on disk and,
since the verify-deps-before-run gate started spawning an install
ahead of every run (pnpm#12910), poisoned recursive runs: the
scaffolded manifest carries npm's default failing test script, the
root joined the workspace graph as a selectable project, and a root
change (like pnpm-workspace.yaml) selected it — which is what broke
run_recursive's test_pattern_from_workspace_yaml_is_respected_by_the_test_script
on main after pnpm#12910 landed on top of pnpm#12914.

Inside a workspace the stand-in root manifest now stays in memory
only. Non-workspace installs keep scaffolding, and commands that save
the manifest (add) still persist it through their explicit save. The
remaining shape difference — pacquet still writes an empty root
importer to pnpm-lock.yaml where pnpm writes none — is a separate,
smaller parity gap.

Co-Authored-By: Claude Fable 5 <[email protected]>
zkochan pushed a commit to eagarwal-notion/pnpm that referenced this pull request Jul 10, 2026
pnpm installs a workspace whose root has no package.json with no root
importer and never creates one. pacquet's State::init scaffolded the
init-template package.json there instead, which diverges on disk and,
since the verify-deps-before-run gate started spawning an install
ahead of every run (pnpm#12910), poisoned recursive runs: the
scaffolded manifest carries npm's default failing test script, the
root joined the workspace graph as a selectable project, and a root
change (like pnpm-workspace.yaml) selected it — which is what broke
run_recursive's test_pattern_from_workspace_yaml_is_respected_by_the_test_script
on main after pnpm#12910 landed on top of pnpm#12914.

Inside a workspace the stand-in root manifest now stays in memory
only. Non-workspace installs keep scaffolding, and commands that save
the manifest (add) still persist it through their explicit save. The
remaining shape difference — pacquet still writes an empty root
importer to pnpm-lock.yaml where pnpm writes none — is a separate,
smaller parity gap.

Co-Authored-By: Claude Fable 5 <[email protected]>
eagarwal-notion added a commit to eagarwal-notion/pnpm that referenced this pull request Jul 10, 2026
pnpm installs a workspace whose root has no package.json with no root
importer and never creates one. pacquet's State::init scaffolded the
init-template package.json there instead, which diverges on disk and,
since the verify-deps-before-run gate started spawning an install
ahead of every run (pnpm#12910), poisoned recursive runs: the
scaffolded manifest carries npm's default failing test script, the
root joined the workspace graph as a selectable project, and a root
change (like pnpm-workspace.yaml) selected it — which is what broke
run_recursive's test_pattern_from_workspace_yaml_is_respected_by_the_test_script
on main after pnpm#12910 landed on top of pnpm#12914.

Inside a workspace the stand-in root manifest now stays in memory
only. Non-workspace installs keep scaffolding, and commands that save
the manifest (add) still persist it through their explicit save. The
remaining shape difference — pacquet still writes an empty root
importer to pnpm-lock.yaml where pnpm writes none — is a separate,
smaller parity gap.

Co-Authored-By: Claude Fable 5 <[email protected]>
eagarwal-notion added a commit to eagarwal-notion/pnpm that referenced this pull request Jul 10, 2026
pnpm installs a workspace whose root has no package.json with no root
importer and never creates one. pacquet's State::init scaffolded the
init-template package.json there instead, which diverges on disk and,
since the verify-deps-before-run gate started spawning an install
ahead of every run (pnpm#12910), poisoned recursive runs: the
scaffolded manifest carries npm's default failing test script, the
root joined the workspace graph as a selectable project, and a root
change (like pnpm-workspace.yaml) selected it — which is what broke
run_recursive's test_pattern_from_workspace_yaml_is_respected_by_the_test_script
on main after pnpm#12910 landed on top of pnpm#12914.

Inside a workspace the stand-in root manifest now stays in memory
only. Non-workspace installs keep scaffolding, and commands that save
the manifest (add) still persist it through their explicit save. The
remaining shape difference — pacquet still writes an empty root
importer to pnpm-lock.yaml where pnpm writes none — is a separate,
smaller parity gap.

Co-Authored-By: Claude Fable 5 <[email protected]>
zkochan added a commit that referenced this pull request Jul 10, 2026
…o pnpr (#12922)

Port `pnpm stage` (publish, list, view, approve, reject, download) to the
Rust CLI, mirroring the TypeScript command's flags, error codes, endpoints,
and output. `stage publish` reuses the publish pipeline (PublishArgs is
split into a reusable PublishFlags, and the pipeline returns summaries
instead of printing); approve/reject drive the shared OTP / web-auth flow;
download summarizes the tarball with the same traversal protections as
the TypeScript implementation. Also fixes the staged-publish route in
pacquet-publish to POST -/stage/package/:pkg (libnpmpublish's stage route)
instead of the regular packument PUT — previously unreachable because the
CLI hardcoded stage: false.

pnpr grows the server half: POST /-/stage/package/:pkg validates and
authorizes like a direct publish and holds the document under a UUID;
list/view/tarball inspect held records; approve replays the document
through the regular validate/stage/commit flow; reject deletes it. Records
persist under a reserved .staged/ namespace on the fs and S3 backends,
with stage-id validation ahead of any path or object key.

Shared plumbing: the capped response-body reader moves from the dist-tag
command into pacquet-network, and pacquet-pack exports its en-locale path
sort for the tarball summary.

Also fixes a broken test on main (semantic conflict between
#12910 and #12914): State::init no longer persists a
scaffolded root package.json when a pnpm-workspace.yaml sits next to the
missing manifest, so a verify-deps-before-run install can't turn the
workspace root into a selectable project with the init template's failing
test script.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

product: pacquet product: pnpm@11 reviewed: coderabbit CodeRabbit submitted an approving review

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants