Skip to content

fix(pacquet): pin saved node runtime version and preserve package.json formatting - #12948

Merged
zkochan merged 4 commits into
mainfrom
fix-update-lockfile
Jul 12, 2026
Merged

zkochan merged 4 commits into
mainfrom
fix-update-lockfile

Conversation

@zkochan

@zkochan zkochan commented Jul 11, 2026 •

Copy link
Copy Markdown
Member

Summary

The daily update-lockfile PR (related to #12802) regressed after the workflow switched to the Rust pnpm: pnpm runtime set node 26 wrote devEngines.runtime.version: "26" instead of the resolved 26.5.0, and package.json lost its trailing newline. Both were pacquet-only divergences from the TypeScript CLI's manifest-write behavior.

This PR closes them, plus the remaining manifest-formatting parity gaps:

  • Pin the saved node@runtime: specifier to the picked version. The TypeScript CLI rewrites the manifest after resolution with the node resolver's normalized specifier; pacquet decides the saved specifier before the install, so that normalization never ran and the requested range was written verbatim. The node resolver now exposes resolve_save_specifier (the shared parse/mirror/pick-version path, without the platform asset fetch), and Add::run calls it for explicit node@runtime: requests. A ^/~ operator on the previous specifier (or the request) is preserved, exactly like the resolver's normalized_bare_specifier. Deno and bun are unchanged: both stacks save the requested spec for them.
  • Preserve package.json formatting on save. PackageManifest now records the source file's final-newline state and indentation unit at read and reuses both on save (a single-line document round-trips back to compact form); new manifests get two-space indentation and a final newline. The indentation unit is capped at 10 characters on write — the same cap JSON.stringify applies to its space argument, which the TypeScript writer serializes through — so a pathologically indented source file can't amplify the output.
  • Normalize dependency fields on write, ported from the TypeScript project-manifest writer: entries are sorted by name and a field with no entries is dropped, so a reification-only "devDependencies": {} never lands on disk.
  • Skip no-op saves. The parsed on-disk value is kept as a baseline; a save whose folded, normalized value matches it doesn't touch the file, so a no-op pnpm add no longer churns formatting or mtime. This turns PackageManifest::save into a &mut self method. A freshly scaffolded manifest reads its baseline back from the file it just wrote, so scaffolds and pre-existing manifests share one code path.

Verified end to end with the built binary: runtime set node 26 on a tab-indented project writes "version": "26.5.0" keeping tabs and the final newline, leaves no empty devDependencies, and a second run leaves the file untouched.

Squash Commit Body

The update-lockfile workflow runs `pnpm runtime set node 26` and expects
the exact resolved version in devEngines.runtime.version. The TypeScript
CLI rewrites the manifest after resolution with the node resolver's
normalized specifier; pacquet decides the saved specifier before the
install runs, so the requested range was written verbatim ("26" instead
of "26.5.0") even though the lockfile resolved 26.5.0 correctly.

Expose the normalization as NodeResolver::resolve_save_specifier — the
shared parse/mirror/pick-version path without the platform asset fetch —
and call it from Add::run for explicit node@runtime: requests, mirroring
how registry specs are already pinned up front. Deno and bun stay on the
verbatim save path; both stacks normalize those to the requested spec.

Also close the remaining manifest-write parity gaps with the TypeScript
project-manifest reader/writer, which surfaced in the same automated PR:

- Preserve the source file's final-newline state and indentation unit
  across the read/save round-trip; a single-line document round-trips
  back to its compact form, and new manifests get two-space indentation
  plus a final newline. The indentation unit is capped at 10 characters
  on write, the cap JSON.stringify applies to its space argument, which
  the TypeScript writer serializes through.
- Normalize dependency fields on write: sort entries by name and drop a
  field that holds no entries, so a reification-only devDependencies: {}
  never lands on disk.
- Skip the write entirely when the file already encodes the same
  manifest, so a no-op save never churns formatting or mtime. This turns
  PackageManifest::save into a &mut self method (it tracks the on-disk
  baseline). A freshly scaffolded manifest reads its baseline back from
  the file it just wrote, so scaffolds and pre-existing manifests share
  one serialization path.

Related to pnpm/pnpm#12802.

Checklist

  • The change is implemented in both the TypeScript CLI and the Rust
    pnpm/ port, or the description notes what still needs porting. (The
    TypeScript CLI already behaves this way; this PR brings the Rust port to
    parity, so no TypeScript changes are needed.)
  • Added or updated tests.

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

Summary by CodeRabbit

  • New Features

    • Added support for installing Node.js via node@runtime:<version> specifications.
    • Runtime selectors are resolved and pinned to the exact available Node.js version, ensuring consistent package.json updates.
    • Added clear failures when the requested runtime version (or range) can’t be satisfied.
  • Bug Fixes

    • Package manifest saves now preserve existing indentation and final-newline style, keep compact formatting where applicable, and omit empty dependency sections.
    • Prevents unnecessary rewrites by skipping saves when the resulting manifest would be unchanged.

zkochan and others added 3 commits July 12, 2026 01:02
…picked version

`pnpm runtime set node 26` (and `pnpm add node@runtime:26`) wrote the
requested range verbatim into the manifest, so `devEngines.runtime.version`
recorded `26` instead of the resolved `26.5.0`. The TypeScript CLI rewrites
the manifest after resolution with the node resolver's normalized
specifier; pacquet decides the saved specifier before the install, so that
normalization never ran and the daily update-lockfile PR
(#12802) regressed from exact pins to a bare major.

Expose the normalization as `NodeResolver::resolve_save_specifier` — the
shared parse/mirror/pick-version path without the platform asset fetch —
and call it from `Add::run` for explicit `node@runtime:` requests. Deno
and bun are unchanged: both stacks normalize those to the requested spec,
which the verbatim save path already produces.

Co-Authored-By: Claude Fable 5 <[email protected]>
…p saves

Match the TypeScript project-manifest reader/writer contract when writing
package.json:

- Keep the source file's final-newline state (new manifests get one).
  Saves previously always dropped the trailing newline, which showed up as
  churn in the update-lockfile PR (#12802).
- Detect the indentation unit at read and reuse it on save; a single-line
  document round-trips back to its compact form.
- Normalize dependency fields on write: sort entries by name and drop a
  field that holds no entries, so a reification-only `devDependencies: {}`
  never lands on disk.
- Skip the write entirely when the file already encodes the same manifest,
  so a no-op save never churns formatting or mtime. This turns `save` into
  a `&mut self` method (it tracks the on-disk baseline).

Co-Authored-By: Claude Fable 5 <[email protected]>
The perfectionist dylint rejects string literals whose escapes a raw
string would avoid.

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

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 11, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: 2b6cbbf1-8b83-4f84-8da0-d3160a584fe1

📥 Commits

Reviewing files that changed from the base of the PR and between fff9710 and 9e28953.

📒 Files selected for processing (2)
  • pnpm/crates/package-manifest/src/lib.rs
  • pnpm/crates/package-manifest/src/tests.rs
🚧 Files skipped from review as they are similar to previous changes (2)
  • pnpm/crates/package-manifest/src/tests.rs
  • pnpm/crates/package-manifest/src/lib.rs

📝 Walkthrough

Walkthrough

The PR centralizes Node runtime version selection, pins node@runtime: add requests to resolved versions, and refactors PackageManifest to preserve formatting, normalize serialized fields, and skip unchanged writes.

Changes

Node runtime resolution

Layer / File(s) Summary
Pick and save resolved Node versions
pnpm/crates/engine-runtime-node-resolver/src/node_resolver.rs, pnpm/crates/engine-runtime-node-resolver/src/node_resolver/tests.rs
NodeResolver selects concrete runtime versions through a shared helper, uses the selected mirror and channel for asset resolution, and pins saved runtime specifiers. Tests cover selector pinning and unavailable versions.
Integrate runtime selectors into add
pnpm/crates/package-manager/src/add.rs, pnpm/crates/package-manager/src/add/tests.rs
add detects explicit node@runtime: requests, resolves and saves the picked version, reports resolver errors, and preserves existing behavior for other specifiers.

Package manifest round-tripping

Layer / File(s) Summary
Track manifest formatting and disk state
pnpm/crates/package-manifest/src/lib.rs
PackageManifest stores indentation, final-newline state, and a normalized on-disk snapshot across file-backed and in-memory construction paths.
Serialize normalized manifests without redundant writes
pnpm/crates/package-manifest/src/lib.rs, pnpm/crates/package-manifest/src/tests.rs
Saving normalizes dependency fields, preserves source formatting, omits empty dependency objects, skips unchanged writes, and updates cached disk state after writes. Tests cover formatting, sorting, pruning, permissions, failures, and no-op saves.

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

Sequence Diagram(s)

sequenceDiagram
  participant Add
  participant NodeResolver
  participant Mirror
  participant PackageManifest
  Add->>NodeResolver: Resolve node@runtime selector
  NodeResolver->>Mirror: Fetch release index
  Mirror-->>NodeResolver: Return available versions
  NodeResolver-->>Add: Return pinned runtime specifier
  Add->>PackageManifest: Save updated dependency
  PackageManifest-->>Add: Write normalized package.json
Loading

Possibly related PRs

  • pnpm/pnpm#12444: Related to preserving runtime specifier prefixes during Node version normalization.
  • pnpm/pnpm#12576: Related to normalization of blank and runtime selectors in the Node resolution path.
  • pnpm/pnpm#12642: Related to changes in PackageManifest save and file serialization behavior.

Suggested reviewers: qodo-code-review

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

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

Pin saved node@runtime version and preserve package.json formatting on save

🐞 Bug fix ✨ Enhancement 🧪 Tests 🕐 40+ Minutes

Grey Divider

AI Description

• Pin explicit node@runtime: dependencies to the resolved Node.js version before install.
• Preserve package.json indentation and final newline; normalize dependency fields on write.
• Skip no-op manifest saves to avoid formatting churn and mtime updates.
Diagram

graph TD
  A["Add command"] --> B["NodeResolver"] --> E{{"Node release index"}}
  A --> C["PackageManifest"] --> D[("package.json")]

  subgraph Legend
    direction LR
    _cmd["Command"] ~~~ _svc["Resolver/Lib"] ~~~ _ext{{"External"}} ~~~ _file[("File")]
  end
Loading
High-Level Assessment

The following are alternative approaches to this PR:

1. Post-install manifest rewrite using resolved metadata
  • ➕ Avoids pre-fetching Node release index during the save decision path
  • ➕ Centralizes all save normalization on the final resolved graph (single source of truth)
  • ➖ Requires restructuring the current pacquet flow (save happens before install)
  • ➖ Higher risk change with more cross-cutting impacts and harder-to-reason ordering
2. Always save verbatim and rely on lockfile for exact pins
  • ➕ Simpler and avoids network calls during save-specifier decision
  • ➖ Breaks parity with pnpm TypeScript behavior and regresses workflows that expect exact pins in devEngines.runtime.version
  • ➖ Leaves manifests less deterministic and causes drift vs resolved state

Recommendation: Current approach is the best incremental fix: add a dedicated NodeResolver::resolve_save_specifier that reuses the existing parse/mirror/pick-version path (without asset fetching) and call it only for explicit node@runtime: requests. This restores TypeScript CLI parity with minimal disruption, while keeping deno/bun behavior unchanged and containing the normalization logic to the node resolver.

Files changed (6) +434 / -77

Enhancement (1) +115 / -17
lib.rsPreserve package.json formatting, normalize dependency fields, and skip no-op saves +115/-17

Preserve package.json formatting, normalize dependency fields, and skip no-op saves

• Extends 'PackageManifest' to track indentation, final newline state, and a normalized on-disk baseline to avoid unnecessary writes. Normalizes dependency sections (sort keys and drop empty objects) on write, preserves compact single-line formatting when appropriate, and updates save APIs to mutate internal baseline state ('&mut self').

pnpm/crates/package-manifest/src/lib.rs

Bug fix (2) +120 / -51
node_resolver.rsAdd save-specifier normalization path for node runtime versions +52/-17

Add save-specifier normalization path for node runtime versions

• Refactors version picking into 'pick_node_version' and exposes 'resolve_save_specifier' to compute the manifest-saved 'runtime:' specifier using the picked concrete Node version. Keeps '^'/'~' operator preservation via existing normalization logic, without fetching platform asset lists.

pnpm/crates/engine-runtime-node-resolver/src/node_resolver.rs

add.rsPin explicit node@runtime dependencies before saving to manifest +68/-34

Pin explicit node@runtime dependencies before saving to manifest

• Routes explicit 'node@runtime:<spec>' requests through 'NodeResolver::resolve_save_specifier' so the manifest records the picked Node version instead of the raw range. Adds a dedicated 'AddError' variant for runtime resolution failures and a helper to detect node runtime requests.

pnpm/crates/package-manager/src/add.rs

Tests (3) +199 / -9
tests.rsTest runtime save-specifier pinning and error behavior +62/-0

Test runtime save-specifier pinning and error behavior

• Adds async tests asserting that 'runtime:26' saves as 'runtime:26.5.0' (and preserves '^'/'~' based on request or previous specifier). Adds a negative test verifying a structured error code when no version satisfies the request.

pnpm/crates/engine-runtime-node-resolver/src/node_resolver/tests.rs

tests.rsAdd unit tests for node@runtime request detection +13/-1

Add unit tests for node@runtime request detection

• Introduces coverage for 'node_runtime_version_spec', ensuring only explicit 'node' + 'runtime:' requests are handled by the node resolver while other runtimes stay on the verbatim save path.

pnpm/crates/package-manager/src/add/tests.rs

tests.rsAdd tests for formatting round-trip, normalization, and no-op save behavior +124/-8

Add tests for formatting round-trip, normalization, and no-op save behavior

• Updates existing tests for the new '&mut manifest.save()' contract and asserts empty dependency fields are dropped after runtime folding. Adds new tests verifying preservation of final newline and indentation (tabs/wide spaces/single-line), dependency sorting + empty-field removal, and byte-for-byte stability for no-op saves.

pnpm/crates/package-manifest/src/tests.rs

@qodo-code-review

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

Copy link
Copy Markdown

Code Review by Qodo

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

Context used
✅ Compliance rules (platform): 18 rules

Grey Divider


Remediation recommended

1. Indent amplification DoS ✓ Resolved 🐞 Bug ⛨ Security
Description
PackageManifest reuses the source file’s detected indentation unit verbatim during serialization,
so an attacker-controlled package.json with a huge leading-whitespace indent (e.g., thousands of
spaces) can cause saves to allocate and write massively inflated output, creating a
resource-exhaustion risk in CI/tooling that runs pnpm on untrusted repos.
Code

pnpm/crates/package-manifest/src/lib.rs[R533-557]

+/// The indentation unit of a JSON document: the leading whitespace of its
+/// first indented line. Empty for a single-line (or unindented) document,
+/// which then round-trips back to its compact form.
+fn detect_indent(contents: &str) -> &str {
+    contents
+        .lines()
+        .find_map(|line| {
+            let trimmed = line.trim_start_matches([' ', '\t']);
+            (!trimmed.is_empty() && trimmed.len() < line.len())
+                .then(|| &line[..line.len() - trimmed.len()])
+        })
+        .unwrap_or("")
+}
+
+/// Serialize with the manifest's own indentation unit; an empty unit
+/// produces a compact single-line document.
+fn serialize_with_indent(value: &Value, indent: &str) -> Result<String, serde_json::Error> {
+    if indent.is_empty() {
+        return serde_json::to_string(value);
+    }
+    let mut out = Vec::new();
+    let formatter = serde_json::ser::PrettyFormatter::with_indent(indent.as_bytes());
+    let mut serializer = serde_json::Serializer::with_formatter(&mut out, formatter);
+    value.serialize(&mut serializer)?;
+    Ok(String::from_utf8(out).expect("serde_json emits UTF-8"))
Evidence
detect_indent() returns the full leading whitespace prefix of the first indented line with no
length/character constraints, and serialize_with_indent() uses it as the pretty-printer’s
indentation bytes, so a large indent directly increases the amount of whitespace emitted per nesting
level on every write.

pnpm/crates/package-manifest/src/lib.rs[533-557]

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

### Issue description
`detect_indent()` can return arbitrarily long leading whitespace, and `serialize_with_indent()` feeds it directly into `PrettyFormatter::with_indent()`. For attacker-controlled manifests this can amplify output size and CPU/memory usage during any manifest save.

### Issue Context
This behavior is new with the formatting-preservation round-trip and affects any command that mutates and saves `package.json`.

### Fix Focus Areas
- pnpm/crates/package-manifest/src/lib.rs[533-557]

### Suggested fix
- Add a safety cap/validation to the detected indentation unit before storing/using it.
 - Example policy: allow either `"\t"` or 1–8 spaces; reject mixed tabs+spaces; if the detected indent is invalid/too long, fall back to `DEFAULT_INDENT` (or `""` only for genuinely single-line documents).
- Add/extend a unit test that uses a file with an excessively long indent and verifies save falls back to a safe indent instead of expanding output.

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


2. Duplicate Node index fetch 🐞 Bug ➹ Performance
Description
Add::run now pins node@runtime:<spec> by calling NodeResolver::resolve_save_specifier() (which
fetches and parses the Node release index), but the subsequent install resolution still calls
pick_node_version() and fetches the same index again, adding an extra network round-trip and JSON
parse on the add hot path.
Code

pnpm/crates/package-manager/src/add.rs[R194-201]

+        let bare_specifier =
+            if let Some(version_spec) = node_runtime_version_spec(package_name, explicit_spec) {
+                let mut node_resolver = NodeResolver::new(std::sync::Arc::clone(&http_client_arc));
+                node_resolver.offline = config.offline;
+                node_resolver
+                    .resolve_save_specifier(version_spec, prev_specifier.as_deref())
+                    .await
+                    .map_err(AddError::ResolveRuntimeSpec)?
Evidence
The new add path explicitly calls resolve_save_specifier(), which resolves a concrete version
via resolve_node_version() (HTTP GET of index.json). The install resolver still calls
pick_node_version() inside resolve_impl, which again calls resolve_node_version() and
therefore fetches index.json a second time.

pnpm/crates/package-manager/src/add.rs[194-201]
pnpm/crates/engine-runtime-node-resolver/src/node_resolver.rs[141-190]
pnpm/crates/engine-runtime-node-resolver/src/resolve_node_version.rs[72-134]

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

### Issue description
`pacquet add node@runtime:<spec>` resolves the save specifier by fetching `index.json` before the install. The install path then resolves node runtime again and fetches `index.json` again, doubling work.

### Issue Context
- `Add::run` calls `NodeResolver::resolve_save_specifier()`.
- `resolve_save_specifier()` calls `pick_node_version()` → `resolve_node_version()` → `fetch_all_versions()` (HTTP GET `.../index.json`).
- The install resolver path (`NodeResolver::resolve_impl`) also calls `pick_node_version()` and therefore repeats `fetch_all_versions()`.

### Fix Focus Areas
- pnpm/crates/package-manager/src/add.rs[194-201]
- pnpm/crates/engine-runtime-node-resolver/src/node_resolver.rs[141-208]
- pnpm/crates/engine-runtime-node-resolver/src/resolve_node_version.rs[72-134]

### Suggested fix options
Pick one:
1) **Add a cache for the release index** in the node resolver layer (e.g., keyed by the fully-qualified index URL) so both pre-pin and install resolution share the same parsed index within the process.
2) **Defer pinning until after install resolution** by using the already-resolved/picked version from the install/lockfile result to update the manifest before the final save.

Add a test or trace-level assertion that `add node@runtime:<spec>` only fetches the index once per run (or hits the cache on the second call).

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


Grey Divider

Qodo Logo

@github-actions

github-actions Bot commented Jul 11, 2026 •

Copy link
Copy Markdown
Contributor

Micro-Benchmark Results

Linux

group                          main                                   pr
-----                          ----                                   --
tarball/download_dependency    1.01      6.6±0.14ms   657.7 KB/sec    1.00      6.5±0.11ms   667.2 KB/sec

@qodo-code-review

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

Copy link
Copy Markdown

PR Code Suggestions ✨

Latest suggestions up to 9e28953

Warning

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

CategorySuggestion                                                                                                                                    Impact
Possible issue
Preserve configured runtime mirrors

Pass the configured Node.js download mirrors to the NodeResolver instance in
pnpm add.

pnpm/crates/package-manager/src/add.rs [196-201]

 let mut node_resolver = NodeResolver::new(std::sync::Arc::clone(&http_client_arc));
 node_resolver.offline = config.offline;
+node_resolver.node_download_mirrors = config.node_download_mirrors.clone();
 node_resolver
     .resolve_save_specifier(version_spec, prev_specifier.as_deref())
     .await
     .map_err(AddError::ResolveRuntimeSpec)?
  • Apply / Chat
Suggestion importance[1-10]: 8

__

Why: The newly instantiated NodeResolver during pnpm add does not inherit the configured Node.js download mirrors, potentially bypassing mirror settings during resolution.

Medium
  • More

Previous suggestions

Suggestions up to commit fff9710
CategorySuggestion                                                                                                                                    Impact
High-level
Fix compilation error from non-existent sort_keys method

Points out that deps.sort_keys() will cause a compilation error because
serde_json::Map does not natively support in-place key sorting. Recommends
manually extracting, sorting, and reconstructing the map to achieve the desired
behavior.

Examples:

pnpm/crates/package-manifest/src/lib.rs [517-526]
fn normalize_dependency_fields(manifest: &mut Value) {
    let Some(manifest) = manifest.as_object_mut() else { return };
    for field in ["dependencies", "devDependencies", "optionalDependencies", "peerDependencies"] {
        let is_empty_object = match manifest.get_mut(field) {
            Some(Value::Object(deps)) => {
                deps.sort_keys();
                deps.is_empty()
            }
            _ => continue,
        };

Solution Walkthrough:

Before:

let is_empty_object = match manifest.get_mut(field) {
    Some(Value::Object(deps)) => {
        deps.sort_keys();
        deps.is_empty()
    }
    _ => continue,
};

After:

let is_empty_object = match manifest.get_mut(field) {
    Some(Value::Object(deps)) => {
        let mut entries: Vec<_> = std::mem::take(deps).into_iter().collect();
        entries.sort_by(|(k1, _), (k2, _)| k1.cmp(k2));
        *deps = entries.into_iter().collect();
        deps.is_empty()
    }
    _ => continue,
};
Suggestion importance[1-10]: 10

__

Why: The suggestion accurately catches a critical compilation error, as serde_json::Map does not have a sort_keys() method, which would break the build entirely.

High

@greptile-apps

greptile-apps Bot commented Jul 11, 2026 •

Copy link
Copy Markdown
Contributor

Confidence Score: 5/5

Safe to merge — the changes are well-scoped, the new code paths are covered by targeted tests, and the formatting changes are transparent to callers.

The two bug fixes are straightforward: resolve_save_specifier is a thin wrapper around the existing pick_node_version path with no new network calls beyond what resolve() already makes, and the manifest formatting logic is isolated behind the PackageManifest API boundary. Previously flagged concerns (implicit write_to_file/serialize_with_indent coupling; unnormalized on_disk baseline for new manifests) are both addressed in this revision. The test suite covers all new code paths including offline mode, no-match errors, operator forwarding, indent detection edge cases, and the no-op save guard.

No files require special attention.

Reviews (2): Last reviewed commit: "fix(package-manifest): cap the indentati..." | Re-trigger Greptile

Comment thread pnpm/crates/package-manifest/src/lib.rs Resolved

@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)
pnpm/crates/package-manifest/src/lib.rs (1)

109-114: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Duplicated pretty-print logic diverges from DEFAULT_INDENT/serialize_with_indent.

write_to_file hardcodes serde_json::to_string_pretty while self.indent is separately set to DEFAULT_INDENT. They currently agree only because to_string_pretty's built-in default happens to be two spaces. If DEFAULT_INDENT is ever changed, scaffolded files would be written with one indent while the manifest's cached indent (used later by serialize_with_indent on subsequent saves) claims another, producing an inconsistent re-serialization after the first save.

♻️ Proposed fix to use a single source of truth for indentation
     fn write_to_file(path: &Path) -> Result<(Value, String), PackageManifestError> {
         let manifest = PackageManifest::init_value_for(path);
-        let contents = serde_json::to_string_pretty(&manifest)?;
+        let contents = serialize_with_indent(&manifest, DEFAULT_INDENT)?;
         fs::write(path, format!("{contents}\n"))?; // TODO: forbid overwriting existing files
         Ok((manifest, contents))
     }
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@pnpm/crates/package-manifest/src/lib.rs` around lines 109 - 114, Update
write_to_file to serialize the initialized manifest through the existing
serialize_with_indent path using DEFAULT_INDENT, rather than
serde_json::to_string_pretty, so file output and the manifest’s cached
indentation share one source of truth. Preserve the existing trailing newline
and return values.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Nitpick comments:
In `@pnpm/crates/package-manifest/src/lib.rs`:
- Around line 109-114: Update write_to_file to serialize the initialized
manifest through the existing serialize_with_indent path using DEFAULT_INDENT,
rather than serde_json::to_string_pretty, so file output and the manifest’s
cached indentation share one source of truth. Preserve the existing trailing
newline and return values.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: c83fc3ca-310c-40f2-a14e-fdeb9232d19a

📥 Commits

Reviewing files that changed from the base of the PR and between 3e01bc5 and fff9710.

📒 Files selected for processing (6)
  • pnpm/crates/engine-runtime-node-resolver/src/node_resolver.rs
  • pnpm/crates/engine-runtime-node-resolver/src/node_resolver/tests.rs
  • pnpm/crates/package-manager/src/add.rs
  • pnpm/crates/package-manager/src/add/tests.rs
  • pnpm/crates/package-manifest/src/lib.rs
  • pnpm/crates/package-manifest/src/tests.rs

@github-actions github-actions Bot added the reviewed: coderabbit CodeRabbit submitted an approving review label Jul 11, 2026
@codecov-commenter

codecov-commenter commented Jul 11, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 93.58974% with 10 lines in your changes missing coverage. Please review.
✅ Project coverage is 85.65%. Comparing base (3e01bc5) to head (9e28953).
⚠️ Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
pnpm/crates/package-manager/src/add.rs 81.25% 9 Missing ⚠️
.../engine-runtime-node-resolver/src/node_resolver.rs 97.05% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main   #12948      +/-   ##
==========================================
+ Coverage   85.57%   85.65%   +0.07%     
==========================================
  Files         475      475              
  Lines       74718    74920     +202     
==========================================
+ Hits        63940    64172     +232     
+ Misses      10778    10748      -30     

☔ 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 11, 2026 •

Copy link
Copy Markdown
Contributor

Integrated-Benchmark Report (Linux)

Commit: 9e2895386542

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.857 ± 0.193 3.718 4.240 1.85 ± 0.13
pacquet@main 3.737 ± 0.030 3.701 3.772 1.79 ± 0.09
pnpr@HEAD 2.083 ± 0.099 1.984 2.264 1.00
pnpr@main 2.112 ± 0.104 2.011 2.335 1.01 ± 0.07
BENCHMARK_REPORT.json
{
  "results": [
    {
      "command": "pacquet@HEAD",
      "mean": 3.8571183045800006,
      "stddev": 0.192939956333595,
      "median": 3.75291266158,
      "user": 3.61351212,
      "system": 3.45793752,
      "min": 3.71779075058,
      "max": 4.2397822645800005,
      "times": [
        4.2397822645800005,
        3.87213364558,
        3.71845454158,
        3.72715062258,
        4.15698161658,
        3.72274456758,
        3.71779075058,
        3.7402331485799998,
        3.7655921745799996,
        3.91031971358
      ]
    },
    {
      "command": "pacquet@main",
      "mean": 3.7371212431800003,
      "stddev": 0.02957257896852061,
      "median": 3.74301211558,
      "user": 3.6102463199999995,
      "system": 3.4378284199999998,
      "min": 3.70081967358,
      "max": 3.7723214825799998,
      "times": [
        3.75232592058,
        3.7689372845799998,
        3.7723214825799998,
        3.70081967358,
        3.76562419358,
        3.70410379458,
        3.75779029658,
        3.73369831058,
        3.70566660158,
        3.70992487358
      ]
    },
    {
      "command": "pnpr@HEAD",
      "mean": 2.0834786538799994,
      "stddev": 0.09879684749137715,
      "median": 2.05786349558,
      "user": 2.70297022,
      "system": 3.04555702,
      "min": 1.9838837875800002,
      "max": 2.26437627858,
      "times": [
        2.07618842558,
        2.26437627858,
        1.9929130645800002,
        2.03953856558,
        2.0843168515799997,
        2.00759952758,
        1.9838837875800002,
        2.20240119858,
        2.0052414435799997,
        2.1783273955799998
      ]
    },
    {
      "command": "pnpr@main",
      "mean": 2.11156666528,
      "stddev": 0.10439487197322467,
      "median": 2.08467530708,
      "user": 2.6544410199999993,
      "system": 3.01711462,
      "min": 2.0106375105799996,
      "max": 2.33450242358,
      "times": [
        2.02750706858,
        2.2515797915799998,
        2.08572753658,
        2.1400162945799996,
        2.0902659785799997,
        2.0360812135799997,
        2.05572575758,
        2.33450242358,
        2.0106375105799996,
        2.08362307758
      ]
    }
  ]
}

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

Command Mean [ms] Min [ms] Max [ms] Relative
pacquet@HEAD 657.1 ± 11.2 643.2 673.4 1.01 ± 0.02
pacquet@main 647.7 ± 9.7 628.8 660.9 1.00
pnpr@HEAD 750.4 ± 142.9 685.9 1155.5 1.16 ± 0.22
pnpr@main 733.7 ± 100.1 683.7 1017.2 1.13 ± 0.16
BENCHMARK_REPORT.json
{
  "results": [
    {
      "command": "pacquet@HEAD",
      "mean": 0.6571309831400001,
      "stddev": 0.011185224337997297,
      "median": 0.65738901604,
      "user": 0.38329660000000004,
      "system": 1.3420353199999997,
      "min": 0.64318664304,
      "max": 0.67340393504,
      "times": [
        0.64452263304,
        0.64906938604,
        0.6712987190399999,
        0.66208290404,
        0.66311284404,
        0.67340393504,
        0.66489526304,
        0.64704237604,
        0.64318664304,
        0.65269512804
      ]
    },
    {
      "command": "pacquet@main",
      "mean": 0.64771367614,
      "stddev": 0.009673166068253955,
      "median": 0.65208527704,
      "user": 0.3791241,
      "system": 1.32828892,
      "min": 0.62880245904,
      "max": 0.6609460390399999,
      "times": [
        0.65354050804,
        0.6609460390399999,
        0.65111518104,
        0.63872043604,
        0.65381090604,
        0.62880245904,
        0.6530553730399999,
        0.64018587504,
        0.65393200704,
        0.64302797704
      ]
    },
    {
      "command": "pnpr@HEAD",
      "mean": 0.75036933374,
      "stddev": 0.1428783678894957,
      "median": 0.70837265704,
      "user": 0.4058198999999999,
      "system": 1.3660294199999998,
      "min": 0.68590236504,
      "max": 1.1554859820399999,
      "times": [
        0.69160681804,
        0.70253735204,
        0.71299105204,
        0.68590236504,
        0.72457014604,
        0.69376408004,
        0.7078843620399999,
        0.72009022804,
        0.70886095204,
        1.1554859820399999
      ]
    },
    {
      "command": "pnpr@main",
      "mean": 0.73368375164,
      "stddev": 0.10014053754590194,
      "median": 0.70660828504,
      "user": 0.4022398,
      "system": 1.3719338200000002,
      "min": 0.6836525220399999,
      "max": 1.0171994470399999,
      "times": [
        0.69439958704,
        0.71137630804,
        0.71438116804,
        0.70624041904,
        0.70643996804,
        0.68779722104,
        0.70857427404,
        0.70677660204,
        1.0171994470399999,
        0.6836525220399999
      ]
    }
  ]
}

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

Command Mean [s] Min [s] Max [s] Relative
pacquet@HEAD 4.291 ± 0.048 4.227 4.351 1.97 ± 0.12
pacquet@main 4.306 ± 0.076 4.202 4.492 1.98 ± 0.13
pnpr@HEAD 2.336 ± 0.117 2.128 2.462 1.07 ± 0.09
pnpr@main 2.176 ± 0.135 2.072 2.434 1.00
BENCHMARK_REPORT.json
{
  "results": [
    {
      "command": "pacquet@HEAD",
      "mean": 4.29087933396,
      "stddev": 0.04795526265622508,
      "median": 4.30310465126,
      "user": 3.7994803599999996,
      "system": 3.4280009599999994,
      "min": 4.22657836176,
      "max": 4.35137411276,
      "times": [
        4.22789498876,
        4.22657836176,
        4.29569230476,
        4.25175123576,
        4.35137411276,
        4.25003842576,
        4.31051699776,
        4.34169672176,
        4.31686836076,
        4.33638182976
      ]
    },
    {
      "command": "pacquet@main",
      "mean": 4.306188337959999,
      "stddev": 0.07609447202924531,
      "median": 4.30304762726,
      "user": 3.76730696,
      "system": 3.4664546599999992,
      "min": 4.20192274476,
      "max": 4.49152560576,
      "times": [
        4.25472587376,
        4.28698130076,
        4.33323308676,
        4.20192274476,
        4.30692362876,
        4.29917162576,
        4.25284558976,
        4.3162166507599995,
        4.31833727276,
        4.49152560576
      ]
    },
    {
      "command": "pnpr@HEAD",
      "mean": 2.3355453817600003,
      "stddev": 0.11678261289283118,
      "median": 2.35577055026,
      "user": 2.5938992599999997,
      "system": 3.0223982599999997,
      "min": 2.12796161076,
      "max": 2.46242326876,
      "times": [
        2.37084755476,
        2.20883196176,
        2.4111870607599997,
        2.12796161076,
        2.28187814476,
        2.24103857776,
        2.4528737717599998,
        2.46242326876,
        2.3406935457599998,
        2.4577183207599997
      ]
    },
    {
      "command": "pnpr@main",
      "mean": 2.1759610395599998,
      "stddev": 0.13491026611917395,
      "median": 2.1028457987599998,
      "user": 2.5650522600000003,
      "system": 3.0383583599999993,
      "min": 2.07225741876,
      "max": 2.43384628276,
      "times": [
        2.07809674176,
        2.0747817727599998,
        2.43384628276,
        2.11328816876,
        2.20919279476,
        2.08034146176,
        2.3847065917599997,
        2.09240342876,
        2.22069573376,
        2.07225741876
      ]
    }
  ]
}

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

Command Mean [s] Min [s] Max [s] Relative
pacquet@HEAD 1.464 ± 0.010 1.448 1.477 2.06 ± 0.12
pacquet@main 1.428 ± 0.044 1.369 1.526 2.01 ± 0.13
pnpr@HEAD 0.729 ± 0.090 0.679 0.982 1.03 ± 0.14
pnpr@main 0.710 ± 0.041 0.670 0.812 1.00
BENCHMARK_REPORT.json
{
  "results": [
    {
      "command": "pacquet@HEAD",
      "mean": 1.4641670854200002,
      "stddev": 0.009988650719456415,
      "median": 1.46632182592,
      "user": 1.4152042799999998,
      "system": 1.7772444199999995,
      "min": 1.44772416942,
      "max": 1.47729707342,
      "times": [
        1.45986621742,
        1.47729707342,
        1.44772416942,
        1.47488793042,
        1.46987862442,
        1.46704684742,
        1.4655968044199998,
        1.4685472204199999,
        1.46270493942,
        1.44812102742
      ]
    },
    {
      "command": "pacquet@main",
      "mean": 1.42825328592,
      "stddev": 0.04437186863436105,
      "median": 1.42712532392,
      "user": 1.36992078,
      "system": 1.7508735199999996,
      "min": 1.36904147242,
      "max": 1.52559644842,
      "times": [
        1.52559644842,
        1.44445119742,
        1.45774023442,
        1.4139953454199998,
        1.38238019942,
        1.36904147242,
        1.39446717842,
        1.42617253742,
        1.4406101354199998,
        1.42807811042
      ]
    },
    {
      "command": "pnpr@HEAD",
      "mean": 0.7289687476200001,
      "stddev": 0.09007099973851024,
      "median": 0.7026366299200001,
      "user": 0.37555478,
      "system": 1.3184634199999998,
      "min": 0.6788683884200001,
      "max": 0.9821431394200001,
      "times": [
        0.6788683884200001,
        0.6835558954200001,
        0.9821431394200001,
        0.7055798474200001,
        0.70027854042,
        0.69236970342,
        0.71596603142,
        0.7267448414200001,
        0.7049947194200001,
        0.6991863694200001
      ]
    },
    {
      "command": "pnpr@main",
      "mean": 0.71024054932,
      "stddev": 0.040776338447567256,
      "median": 0.6991498059200001,
      "user": 0.36907848,
      "system": 1.3153967199999999,
      "min": 0.6696103854200001,
      "max": 0.8115129124200001,
      "times": [
        0.6899480214200001,
        0.70155455042,
        0.7005583634200001,
        0.6696103854200001,
        0.6873071504200001,
        0.7469141114200001,
        0.6977412484200001,
        0.68914923642,
        0.8115129124200001,
        0.7081095134200001
      ]
    }
  ]
}

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

Command Mean [s] Min [s] Max [s] Relative
pacquet@HEAD 3.160 ± 0.083 3.058 3.369 4.60 ± 0.13
pacquet@main 3.200 ± 0.030 3.167 3.242 4.66 ± 0.07
pnpr@HEAD 0.686 ± 0.008 0.678 0.701 1.00
pnpr@main 0.696 ± 0.028 0.662 0.767 1.01 ± 0.04
BENCHMARK_REPORT.json
{
  "results": [
    {
      "command": "pacquet@HEAD",
      "mean": 3.1601495736799996,
      "stddev": 0.08333522115908573,
      "median": 3.14988424348,
      "user": 1.8675037799999998,
      "system": 2.05256624,
      "min": 3.05804040548,
      "max": 3.36925460348,
      "times": [
        3.1959599554800002,
        3.05804040548,
        3.11280045748,
        3.14988741148,
        3.14715938648,
        3.15963404648,
        3.14988107548,
        3.36925460348,
        3.16522533048,
        3.09365306448
      ]
    },
    {
      "command": "pacquet@main",
      "mean": 3.19994000258,
      "stddev": 0.02967735035841914,
      "median": 3.19370022798,
      "user": 1.8799570799999998,
      "system": 2.0860682399999995,
      "min": 3.16653231448,
      "max": 3.24174763948,
      "times": [
        3.21014398248,
        3.19362460948,
        3.16653231448,
        3.23504201448,
        3.24174763948,
        3.23706931848,
        3.18595857848,
        3.19377584648,
        3.16663258248,
        3.16887313948
      ]
    },
    {
      "command": "pnpr@HEAD",
      "mean": 0.6862915066800002,
      "stddev": 0.007627259747216782,
      "median": 0.6858116229800001,
      "user": 0.35658848,
      "system": 1.3075754400000001,
      "min": 0.6775783004800001,
      "max": 0.7009927544800001,
      "times": [
        0.6785326434800001,
        0.6864386494800001,
        0.7009927544800001,
        0.6824553814800001,
        0.6775783004800001,
        0.6863487964800001,
        0.68527444948,
        0.6903578694800001,
        0.6792143264800001,
        0.6957218954800001
      ]
    },
    {
      "command": "pnpr@main",
      "mean": 0.6955537733800001,
      "stddev": 0.027753321698592775,
      "median": 0.68773776748,
      "user": 0.35556237999999996,
      "system": 1.32006004,
      "min": 0.6621121454800001,
      "max": 0.7671562074800001,
      "times": [
        0.6870111934800001,
        0.6884643414800001,
        0.6896918444800001,
        0.6853097854800001,
        0.68297864748,
        0.6621121454800001,
        0.6846029814800001,
        0.7671562074800001,
        0.7043531854800001,
        0.7038574014800001
      ]
    }
  ]
}

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

Command Mean [ms] Min [ms] Max [ms] Relative
pacquet@HEAD 671.9 ± 10.3 655.2 693.6 6.08 ± 0.53
pacquet@main 675.5 ± 11.7 661.3 698.5 6.12 ± 0.54
pnpr@HEAD 110.6 ± 2.4 107.2 113.9 1.00 ± 0.09
pnpr@main 110.4 ± 9.5 106.4 155.5 1.00
BENCHMARK_REPORT.json
{
  "results": [
    {
      "command": "pacquet@HEAD",
      "mean": 0.67192750708,
      "stddev": 0.010324348720874586,
      "median": 0.67156711258,
      "user": 0.6407092799999999,
      "system": 0.15338005999999998,
      "min": 0.65520850208,
      "max": 0.69363372108,
      "times": [
        0.66065356008,
        0.67436473208,
        0.65520850208,
        0.69363372108,
        0.67850023208,
        0.67546506408,
        0.66857098608,
        0.67290768508,
        0.66974404808,
        0.67022654008
      ]
    },
    {
      "command": "pacquet@main",
      "mean": 0.67546995308,
      "stddev": 0.011707279399103184,
      "median": 0.67151583108,
      "user": 0.6423363799999999,
      "system": 0.15310875999999998,
      "min": 0.66132838308,
      "max": 0.6984824750799999,
      "times": [
        0.67300640108,
        0.66704614408,
        0.6984824750799999,
        0.67815093108,
        0.67833789408,
        0.66838333708,
        0.66132838308,
        0.69203556508,
        0.67002526108,
        0.66790313908
      ]
    },
    {
      "command": "pnpr@HEAD",
      "mean": 0.11058715967999999,
      "stddev": 0.002424240959952362,
      "median": 0.11105663608000002,
      "user": 0.027779280000000003,
      "system": 0.021243219999999997,
      "min": 0.10715096408,
      "max": 0.11388976708000001,
      "times": [
        0.10807497608,
        0.10842001408000002,
        0.10715096408,
        0.10814646108,
        0.10789799208,
        0.10821153308,
        0.10790454708,
        0.10861663708,
        0.10792487108000001,
        0.10833729308000001,
        0.10853594308,
        0.11333366808,
        0.11353675308,
        0.11314315808,
        0.11251713908,
        0.11225231508,
        0.11388976708000001,
        0.11277504008,
        0.11266079608000001,
        0.11283650608000001,
        0.11275217708000002,
        0.11211089308,
        0.11346434908,
        0.11105663608000002,
        0.10912856208000002
      ]
    },
    {
      "command": "pnpr@main",
      "mean": 0.11043507600000002,
      "stddev": 0.009510696527858116,
      "median": 0.10825820108,
      "user": 0.02778556,
      "system": 0.02127734,
      "min": 0.10643959308,
      "max": 0.15549153208000002,
      "times": [
        0.10847176408,
        0.10763391408,
        0.10816501508000001,
        0.11235686608,
        0.10788218308,
        0.10928395508,
        0.11237397908000002,
        0.10743642208000001,
        0.10862863908,
        0.10886762008,
        0.11156257408,
        0.10859727008,
        0.10650863808,
        0.10939807008000002,
        0.10643959308,
        0.10791056508000002,
        0.10832707808,
        0.10821186308,
        0.10825820108,
        0.10753742608,
        0.10777146908000002,
        0.10792248008,
        0.10888812908,
        0.10695165308000001,
        0.15549153208000002
      ]
    }
  ]
}

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

Command Mean [s] Min [s] Max [s] Relative
pacquet@HEAD 6.960 ± 0.236 6.664 7.324 1.38 ± 0.06
pacquet@main 6.806 ± 0.146 6.617 7.106 1.35 ± 0.04
pnpr@HEAD 5.116 ± 0.125 4.914 5.341 1.02 ± 0.03
pnpr@main 5.029 ± 0.111 4.907 5.235 1.00
BENCHMARK_REPORT.json
{
  "results": [
    {
      "command": "pacquet@HEAD",
      "mean": 6.9595586765199995,
      "stddev": 0.2359603785916582,
      "median": 7.00667058242,
      "user": 3.9802611799999994,
      "system": 3.8119454,
      "min": 6.6639151529200005,
      "max": 7.32408788692,
      "times": [
        7.08306861992,
        6.6639151529200005,
        6.97713352492,
        7.08635524892,
        7.23386090092,
        7.03620763992,
        6.70154230892,
        6.67704296792,
        7.32408788692,
        6.812372513920001
      ]
    },
    {
      "command": "pacquet@main",
      "mean": 6.806347343520001,
      "stddev": 0.14552178602868937,
      "median": 6.77349484642,
      "user": 3.9441682799999995,
      "system": 3.7946988,
      "min": 6.61690156292,
      "max": 7.1059115019200005,
      "times": [
        6.73472099592,
        6.92994214292,
        6.83980912892,
        6.72242612392,
        6.81226869692,
        6.674616679920001,
        6.91065933592,
        6.71621726592,
        7.1059115019200005,
        6.61690156292
      ]
    },
    {
      "command": "pnpr@HEAD",
      "mean": 5.11569635972,
      "stddev": 0.12471759898476091,
      "median": 5.100967773920001,
      "user": 2.84757828,
      "system": 3.2918952,
      "min": 4.91374734992,
      "max": 5.34067035592,
      "times": [
        4.91374734992,
        5.11370026592,
        4.98707680192,
        5.08429784892,
        5.34067035592,
        5.2155388379200005,
        5.23860332192,
        5.08823528192,
        5.04484301592,
        5.13025051692
      ]
    },
    {
      "command": "pnpr@main",
      "mean": 5.029275162219999,
      "stddev": 0.11145865701074754,
      "median": 4.98111340042,
      "user": 2.80402648,
      "system": 3.2994091999999995,
      "min": 4.90711734292,
      "max": 5.2346224369200005,
      "times": [
        5.09778742592,
        5.19882031892,
        5.2346224369200005,
        4.90711734292,
        4.9521232919200004,
        4.98462335392,
        4.9498636009200006,
        5.02686678392,
        4.97760344692,
        4.96332361992
      ]
    }
  ]
}

@github-actions

github-actions Bot commented Jul 11, 2026 •

Copy link
Copy Markdown
Contributor

🐰 Bencher Report

Branchpr/12948
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,290.88 ms
(-0.10%)Baseline: 4,295.20 ms
5,154.25 ms
(83.25%)
isolated-linker.fresh-install.cold-cache.hot-store📈 view plot
🚷 view threshold
3,160.15 ms
(+4.30%)Baseline: 3,029.72 ms
3,635.67 ms
(86.92%)
isolated-linker.fresh-install.hot-cache.hot-store📈 view plot
🚷 view threshold
1,464.17 ms
(+7.30%)Baseline: 1,364.55 ms
1,637.45 ms
(89.42%)
isolated-linker.fresh-resolve.hot-cache.offline📈 view plot
🚷 view threshold
671.93 ms
(+4.49%)Baseline: 643.08 ms
771.70 ms
(87.07%)
isolated-linker.fresh-restore.cold-cache.cold-store📈 view plot
🚷 view threshold
3,857.12 ms
(-6.17%)Baseline: 4,110.57 ms
4,932.69 ms
(78.20%)
isolated-linker.fresh-restore.cold-cache.cold-store.cold-pnpr📈 view plot
🚷 view threshold
6,959.56 ms
(-5.27%)Baseline: 7,347.11 ms
8,816.54 ms
(78.94%)
isolated-linker.fresh-restore.hot-cache.hot-store📈 view plot
🚷 view threshold
657.13 ms
(+1.06%)Baseline: 650.24 ms
780.28 ms
(84.22%)
🐰 View full continuous benchmarking report in Bencher

@github-actions

github-actions Bot commented Jul 11, 2026 •

Copy link
Copy Markdown
Contributor

🐰 Bencher Report

Branchpr/12948
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,335.55 ms
isolated-linker.fresh-install.cold-cache.hot-store📈 view plot
⚠️ NO THRESHOLD
686.29 ms
isolated-linker.fresh-install.hot-cache.hot-store📈 view plot
⚠️ NO THRESHOLD
728.97 ms
isolated-linker.fresh-resolve.hot-cache.offline📈 view plot
⚠️ NO THRESHOLD
110.59 ms
isolated-linker.fresh-restore.cold-cache.cold-store📈 view plot
⚠️ NO THRESHOLD
2,083.48 ms
isolated-linker.fresh-restore.cold-cache.cold-store.cold-pnpr📈 view plot
⚠️ NO THRESHOLD
5,115.70 ms
isolated-linker.fresh-restore.hot-cache.hot-store📈 view plot
⚠️ NO THRESHOLD
750.37 ms
🐰 View full continuous benchmarking report in Bencher

…rialization

Address review feedback on the manifest formatting round-trip:

- Cap the preserved indentation unit at 10 characters on write - the cap
  JSON.stringify applies to its space argument, which the TypeScript
  writer serializes through - so a pathologically indented source file
  cannot amplify the output.
- Serialize the init scaffold through serialize_with_indent with
  DEFAULT_INDENT instead of serde_json's own pretty default, so the
  scaffold and every subsequent save share one serialization path.
- Read the scaffold back from disk in create_if_needed instead of
  assembling the manifest by hand, so the formatting state and the
  no-op-save baseline are always derived from the file the same way as
  for a pre-existing manifest.

Co-Authored-By: Claude Fable 5 <[email protected]>
Copilot AI review requested due to automatic review settings July 11, 2026 23: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.

@zkochan

zkochan commented Jul 11, 2026

Copy link
Copy Markdown
Member Author

Response to the two Qodo findings (and Greptile's out-of-diff observation), addressed in 9e28953 where applicable:

1. Indent amplification (detect_indent / serialize_with_indent) — fixed, but framed as a parity fix rather than a whitelist: the TypeScript writer serializes manifests through JSON.stringify(manifest, undefined, indent), and JSON.stringify uses at most the first 10 characters of a string space argument. serialize_with_indent now applies the same 10-character cap on write, which also bounds the output amplification. The suggested tab/1–8-space whitelist with a DEFAULT_INDENT fallback would diverge from the TypeScript CLI's observable behavior (a 12-space source file must round-trip to a 10-space rewrite, not to 2 spaces), and behavioral identity between the two stacks is the repo's cardinal rule.

2. Duplicate Node release-index fetch on add node@runtime:<spec> — real, but left as a follow-up. Pinning the saved specifier before the install mirrors how explicit registry specs are already pinned up front in Add::run; the follow-up install re-resolves in both cases. For registry packuments the second hit is absorbed by the on-disk metadata cache, but the node release index has no disk cache in either stack, so this path pays one extra index.json GET. Sharing the parsed index between the pre-pin and the install resolution requires a cache seam threaded through Install (or resolver reuse across the two phases) that doesn't exist yet — the same missing seam the fast-path note in NodeResolver::resolve_impl already tracks. Deferring the pin until after install resolution would instead contradict the up-front-pin design of Add::run. Given the cost is a single extra HTTP GET on a rare interactive path, this is deliberately not addressed in this PR.

3. Greptile: create_if_needed baseline not normalized — fixed structurally: create_if_needed now writes the scaffold and reads it back through read_from_file, so a scaffolded manifest's formatting state and no-op-save baseline are derived from the file exactly like a pre-existing manifest's; the two construction paths can no longer drift.


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 9e28953

@zkochan
zkochan merged commit f573900 into main Jul 12, 2026
34 checks passed
@zkochan
zkochan deleted the fix-update-lockfile branch July 12, 2026 20:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

reviewed: coderabbit CodeRabbit submitted an approving review

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants