Repository navigation
feat(injected-deps-syncer): sync injected copies after the named scripts - #13834
Conversation
An injected dependency is materialized as a tree of hardlinks into the virtual store, so a build script that rewrites its source package leaves every copy pointing at the old inodes. The TypeScript CLI has taken `syncInjectedDepsAfterScripts` since it grew the setting; pacquet recognized the config key and did nothing with it. Add the crate that does the work. It walks the source and each target with the same directory fetcher the installer uses, diffs the two into inode maps, and patches each target: removals first, then directories shallowest-first, then the hardlinks. An inode that cannot be hardlinked — a FIFO, a socket, a device — is left out of the map, and a target holding one is cleared and retried rather than failing the sync. Bins are re-linked afterwards, since a build script can add or drop one. `pnpm run` calls it after a script whose name the setting lists, and only when the script succeeded, matching the TypeScript call site.
📝 WalkthroughWalkthroughAdds ChangesInjected dependency synchronization
Estimated code review effort: 4 (Complex) | ~45 minutes Sequence Diagram(s)sequenceDiagram
participant run_stages
participant sync_injected_deps
participant DirPatcher
participant workspace_projects
run_stages->>sync_injected_deps: invoke after a configured script
sync_injected_deps->>DirPatcher: synchronize injected targets
DirPatcher-->>sync_injected_deps: return patch result
sync_injected_deps->>workspace_projects: refresh binary links
workspace_projects-->>run_stages: return synchronization result
Possibly related PRs
Suggested labels: ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
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. Comment |
PR Summary by QodoSync injected workspace deps after configured scripts
AI Description
Diagram
High-Level Assessment
Files changed (14)
|
Confidence Score: 5/5The PR appears safe to merge. No blocking failure remains. Reviews (4): Last reviewed commit: "fix(injected-deps-syncer): key file iden..." | Re-trigger Greptile |
There was a problem hiding this comment.
Actionable comments posted: 2
🧹 Nitpick comments (1)
pnpm/crates/cli/tests/suite/sync_injected_deps_after_scripts.rs (1)
76-126: 🎯 Functional Correctness | 🔵 Trivial | ⚡ Quick winAdd coverage for a failed lifecycle stage.
The tests only cover successful script execution. Add a configured
buildscript with a failingpostbuild. Assert that the injected copy remains unchanged after the command fails.This verifies the requirement that synchronization runs only after all stages succeed.
As per path instructions:
CONTRIBUTING.mdrequires regression tests for feature behavior.🤖 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/cli/tests/suite/sync_injected_deps_after_scripts.rs` around lines 76 - 126, Add a regression test alongside a_listed_script_refreshes_every_injected_copy that configures build and a failing postbuild lifecycle script, runs build in project-1, and asserts the command fails. Capture injected_copies before execution and verify each copy remains unchanged afterward, confirming synchronization occurs only when all lifecycle stages succeed.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.
Inline comments:
In `@pnpm/crates/injected-deps-syncer/src/lib.rs`:
- Around line 115-121: Validate each target_dir before building resolved_targets
in the injected-dependency sync flow, rejecting absolute, prefixed, and
parent-relative paths and ensuring the joined path remains within the
workspace-managed store. Perform validation before calling
DirPatcher::from_multiple_targets, return the existing sync error type for
invalid entries, and add regression coverage for malformed target paths.
- Around line 141-150: Update the manifest handling around has_bin_and_name so
packages whose updated package.json no longer declares bin still reach the
cleanup-aware relinking logic instead of returning early. Preserve skipping
unrelated manifests without bin or name, and add an end-to-end test that removes
a previously declared bin and verifies its stale shims are removed from the
virtual-store and workspace .bin directories.
---
Nitpick comments:
In `@pnpm/crates/cli/tests/suite/sync_injected_deps_after_scripts.rs`:
- Around line 76-126: Add a regression test alongside
a_listed_script_refreshes_every_injected_copy that configures build and a
failing postbuild lifecycle script, runs build in project-1, and asserts the
command fails. Capture injected_copies before execution and verify each copy
remains unchanged afterward, confirming synchronization occurs only when all
lifecycle stages succeed.
🪄 Autofix
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro Plus
Run ID: 1e81e01b-f688-44bc-81c3-43ee141b54c0
⛔ Files ignored due to path filters (1)
Cargo.lockis excluded by!**/*.lock,!Cargo.lock
📒 Files selected for processing (13)
.changeset/pacquet-sync-injected-deps-after-scripts.mdCargo.tomlpnpm/crates/cli/Cargo.tomlpnpm/crates/cli/src/cli_args/run.rspnpm/crates/cli/tests/suite/main.rspnpm/crates/cli/tests/suite/sync_injected_deps_after_scripts.rspnpm/crates/config/src/env_overlay.rspnpm/crates/config/src/lib.rspnpm/crates/config/src/workspace_yaml.rspnpm/crates/injected-deps-syncer/Cargo.tomlpnpm/crates/injected-deps-syncer/src/dir_patcher.rspnpm/crates/injected-deps-syncer/src/dir_patcher/tests.rspnpm/crates/injected-deps-syncer/src/lib.rs
Code Review by Qodo
1.
|
Micro-Benchmark ResultsLinux |
PR Code Suggestions ✨Warning
No code suggestions found for the PR. |
Every schema key also reads from `PNPM_CONFIG_*`, so the setting reaches a project that has no `pnpm-workspace.yaml`. Erroring there failed a run whose script had already succeeded. Nothing can be injected outside a workspace, so there is nothing to sync: log and return. The TypeScript CLI throws `ERR_PNPM_NO_WORKSPACE_DIR` in the same spot, but cannot reach it — `syncInjectedDepsAfterScripts` is only readable from `pnpm-workspace.yaml` there, and that file is what defines the workspace dir. Verified against the built bundle. Also restore the missing field to the `Config` literal in deps-restorer's tests, which the workspace build caught but a crate-scoped check did not.
|
Code review by qodo was updated up to the latest commit 0790deb |
PR Code Suggestions ✨Warning
No code suggestions found for the PR. |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
pnpm/crates/cli/tests/suite/sync_injected_deps_after_scripts.rs (1)
128-153: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winAdd a TypeScript test for environment configuration outside a workspace.
The existing TypeScript tests cover configured and unlisted scripts only within a workspace. Add the non-workspace
PNPM_CONFIG_SYNC_INJECTED_DEPS_AFTER_SCRIPTSscenario with the same successful script behavior as the Rust test.🤖 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/cli/tests/suite/sync_injected_deps_after_scripts.rs` around lines 128 - 153, Add a TypeScript test covering PNPM_CONFIG_SYNC_INJECTED_DEPS_AFTER_SCRIPTS for a project outside a workspace, matching the Rust test’s setup and behavior. Define a standalone package with a successful script, run it with the environment variable configured for that script, and assert the command succeeds.Sources: Coding guidelines, Learnings
🤖 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/cli/tests/suite/sync_injected_deps_after_scripts.rs`:
- Around line 128-153: Add a TypeScript test covering
PNPM_CONFIG_SYNC_INJECTED_DEPS_AFTER_SCRIPTS for a project outside a workspace,
matching the Rust test’s setup and behavior. Define a standalone package with a
successful script, run it with the environment variable configured for that
script, and assert the command succeeds.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro Plus
Run ID: 82e992aa-3702-4115-9c5a-e17df222b32a
📒 Files selected for processing (4)
pnpm/crates/cli/tests/suite/sync_injected_deps_after_scripts.rspnpm/crates/deps-restorer/src/install_package_from_registry/tests.rspnpm/crates/injected-deps-syncer/src/dir_patcher.rspnpm/crates/injected-deps-syncer/src/lib.rs
🚧 Files skipped from review as they are similar to previous changes (2)
- pnpm/crates/injected-deps-syncer/src/dir_patcher.rs
- pnpm/crates/injected-deps-syncer/src/lib.rs
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #13834 +/- ##
==========================================
- Coverage 88.23% 88.22% -0.02%
==========================================
Files 625 627 +2
Lines 102839 103004 +165
==========================================
+ Hits 90742 90872 +130
- Misses 12097 12132 +35 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
`MetadataExt::file_index` sits behind the unstable `windows_by_handle` feature, so the Windows build failed to compile while every Linux gate stayed green. Take the index from a handle instead, via `GetFileInformationByHandle` — the same call libuv makes to fill Node's `Stats.ino`, and the one `shim_dispatch::identity` already makes here. Comparing inodes is what lets an already-hardlinked file cost nothing, so the cheaper Windows alternatives are not equivalent: `(len, mtime)` would skip a replaced file that kept both, leaving the injected copy stale. Verified by compiling the helper for x86_64-pc-windows-msvc under the pinned toolchain; the full graph cannot cross-compile because two transitive C build scripts fail.
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@pnpm/crates/injected-deps-syncer/src/dir_patcher.rs`:
- Line 251: Update file identity generation around file_inode and the
corresponding TypeScript pnpm implementation to include the filesystem or volume
identifier: use (dev, ino) on Unix and (dwVolumeSerialNumber, file_index) on
Windows. Ensure diff_dir compares these composite identities so cross-device or
cross-volume files are not treated as identical, and add fixtures covering both
scenarios.
🪄 Autofix
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro Plus
Run ID: 51b0de79-a996-4640-95e5-d34cc2fc9403
⛔ Files ignored due to path filters (1)
Cargo.lockis excluded by!**/*.lock,!Cargo.lock
📒 Files selected for processing (3)
pnpm/crates/injected-deps-syncer/Cargo.tomlpnpm/crates/injected-deps-syncer/src/dir_patcher.rspnpm/crates/injected-deps-syncer/src/dir_patcher/tests.rs
🚧 Files skipped from review as they are similar to previous changes (2)
- pnpm/crates/injected-deps-syncer/src/dir_patcher/tests.rs
- pnpm/crates/injected-deps-syncer/Cargo.toml
|
Code review by qodo was updated up to the latest commit 5ec7004 |
PR Code Suggestions ✨Warning
No code suggestions found for the PR. |
Integrated-Benchmark Report (Linux)Commit: Regular scenarios report direct and pnpr installs. The peer-heavy resolver scenario compares current Rust, main Rust, and TypeScript pnpm. Bencher consumes pacquet@HEAD and pnpr@HEAD. The tables below show mean ± σ; Bencher thresholds on the minimum latency, which is far less perturbed by shared-runner contention (noise only adds time). Scenario: Isolated linker: fresh restore, cold cache + cold store
BENCHMARK_REPORT.json{
"results": [
{
"command": "pacquet@HEAD",
"mean": 2.5511752982999996,
"stddev": 0.14374224076333436,
"median": 2.4928937873,
"user": 2.3127354999999996,
"system": 1.76499374,
"min": 2.4312050813,
"max": 2.8550545822999998,
"times": [
2.4463684022999996,
2.6144790052999998,
2.5133015822999996,
2.4383991443,
2.4724859922999998,
2.8550545822999998,
2.4312050813,
2.4488530033,
2.5577531343,
2.7338530553
]
},
{
"command": "pacquet@main",
"mean": 2.5805501466,
"stddev": 0.14075859431121268,
"median": 2.5717080453,
"user": 2.0792259999999994,
"system": 1.59957624,
"min": 2.4201581663,
"max": 2.7516809572999996,
"times": [
2.4240421043,
2.4201581663,
2.6853944743,
2.7516809572999996,
2.7197181553,
2.4335222773,
2.6429054213,
2.4827695312999998,
2.7447997092999996,
2.5005106692999997
]
},
{
"command": "pnpr@HEAD",
"mean": 1.7033309488999997,
"stddev": 0.15116949772194374,
"median": 1.7591753593000001,
"user": 1.7755113999999999,
"system": 1.6467689399999994,
"min": 1.4448772713,
"max": 1.8718512123,
"times": [
1.8215190323000001,
1.7092351903,
1.7998806243,
1.5124829603,
1.8718512123,
1.5308128123,
1.7524167203,
1.7659339983000002,
1.4448772713,
1.8242996673
]
},
{
"command": "pnpr@main",
"mean": 1.7105852998,
"stddev": 0.16976336133232836,
"median": 1.7072730833,
"user": 1.9222629000000002,
"system": 1.8048124399999999,
"min": 1.4464778863,
"max": 1.9037601653,
"times": [
1.9037601653,
1.8954995793,
1.4925498803000001,
1.4464778863,
1.6605205303000001,
1.8359055063,
1.8889189503000001,
1.5676743333,
1.6997104083,
1.7148357583
]
}
]
}Scenario: Isolated linker: fresh restore, hot cache + hot store
BENCHMARK_REPORT.json{
"results": [
{
"command": "pacquet@HEAD",
"mean": 0.40702304264,
"stddev": 0.01983892471874705,
"median": 0.40554117184,
"user": 0.37223533999999997,
"system": 0.7383167800000001,
"min": 0.37902646584,
"max": 0.43713716484,
"times": [
0.43060685184,
0.41716271384000003,
0.38707293884,
0.37902646584,
0.39198945184,
0.42340881384,
0.39876740884,
0.41231493484,
0.43713716484,
0.39274368184
]
},
{
"command": "pacquet@main",
"mean": 0.37965756144,
"stddev": 0.035515384586586415,
"median": 0.37565248184,
"user": 0.3324231399999999,
"system": 0.7335242799999999,
"min": 0.34385251084,
"max": 0.45014944084,
"times": [
0.45014944084,
0.42699642284,
0.37903328284,
0.38631013184,
0.38793981384,
0.35602050384,
0.37227168084,
0.34385251084,
0.34645722384,
0.34754460284
]
},
{
"command": "pnpr@HEAD",
"mean": 0.39003716933999993,
"stddev": 0.022349364147849885,
"median": 0.38965453084,
"user": 0.34592243999999994,
"system": 0.7325844800000001,
"min": 0.36275030484,
"max": 0.42664602584,
"times": [
0.39479522384,
0.36831008984,
0.38640380284,
0.39290525884,
0.42207654884,
0.40297803984,
0.42664602584,
0.37574931684,
0.36275030484,
0.36775708184
]
},
{
"command": "pnpr@main",
"mean": 0.37197080484000006,
"stddev": 0.025068436514796556,
"median": 0.37083123084,
"user": 0.32859324,
"system": 0.6929070799999999,
"min": 0.33005707584,
"max": 0.41007176584,
"times": [
0.38667452384,
0.37300424984,
0.35865317584,
0.33005707584,
0.36262051084,
0.34536237184,
0.36865821184,
0.37781938084,
0.40678678184,
0.41007176584
]
}
]
}Scenario: Isolated linker: fresh install, cold cache + cold store
BENCHMARK_REPORT.json{
"results": [
{
"command": "pacquet@HEAD",
"mean": 2.93653936342,
"stddev": 0.08965043621193493,
"median": 2.91374281612,
"user": 2.7760584399999995,
"system": 2.19104882,
"min": 2.79603466212,
"max": 3.11108649912,
"times": [
2.79603466212,
2.8761971911199997,
2.90168888112,
2.98256856612,
2.9011505081199997,
2.96003452612,
3.03453662612,
2.92579675112,
3.11108649912,
2.87629942312
]
},
{
"command": "pacquet@main",
"mean": 2.87050205192,
"stddev": 0.17074414340151328,
"median": 2.83021023262,
"user": 2.59413394,
"system": 2.06099932,
"min": 2.6909109021199997,
"max": 3.1402809021199998,
"times": [
2.78549942212,
2.7468161751199998,
2.72409764212,
2.70840415012,
2.6909109021199997,
2.87675594212,
2.8749210431199996,
3.06468937012,
3.1402809021199998,
3.09264497012
]
},
{
"command": "pnpr@HEAD",
"mean": 1.8053988059200001,
"stddev": 0.14824597825555677,
"median": 1.81321815412,
"user": 1.8411847399999999,
"system": 1.7270801199999997,
"min": 1.56158196212,
"max": 2.05653429312,
"times": [
2.05653429312,
1.63270980912,
1.80731797412,
1.91129294812,
1.7238591441200002,
1.72564391112,
1.8191183341200001,
1.9080946311200002,
1.90783505212,
1.56158196212
]
},
{
"command": "pnpr@main",
"mean": 1.73428578342,
"stddev": 0.18844646230588258,
"median": 1.69029385612,
"user": 1.78984514,
"system": 1.62457712,
"min": 1.49643788012,
"max": 1.98675431312,
"times": [
1.98609324912,
1.98675431312,
1.62382546312,
1.59621904512,
1.80640946912,
1.54900892212,
1.59468633512,
1.7567622491200001,
1.49643788012,
1.94666090812
]
}
]
}Scenario: Isolated linker: fresh install, hot cache + hot store
BENCHMARK_REPORT.json{
"results": [
{
"command": "pacquet@HEAD",
"mean": 0.6995956716600001,
"stddev": 0.07881999081407431,
"median": 0.70214258486,
"user": 0.97176784,
"system": 1.0488552800000002,
"min": 0.58862235186,
"max": 0.83209235686,
"times": [
0.66345182986,
0.70061568786,
0.74164253286,
0.63324774486,
0.77949094286,
0.70366948186,
0.6020484538599999,
0.83209235686,
0.75107533386,
0.58862235186
]
},
{
"command": "pacquet@main",
"mean": 0.6899858681600001,
"stddev": 0.041260939474883705,
"median": 0.6770587378599999,
"user": 0.9265449400000001,
"system": 1.04986398,
"min": 0.64827580986,
"max": 0.77638783286,
"times": [
0.66722087886,
0.77638783286,
0.65743371486,
0.69230550186,
0.68050166286,
0.65850286486,
0.6736158128599999,
0.74550408786,
0.70011051486,
0.64827580986
]
},
{
"command": "pnpr@HEAD",
"mean": 0.44955993796,
"stddev": 0.014313924317055034,
"median": 0.4472726368600001,
"user": 0.35351914000000006,
"system": 0.7474228799999999,
"min": 0.42767383986,
"max": 0.47213652586000004,
"times": [
0.46446683886000006,
0.46594090086000006,
0.44964944986000005,
0.44643859086000004,
0.42767383986,
0.43225701086,
0.44358015686,
0.47213652586000004,
0.44534938286000003,
0.44810668286000005
]
},
{
"command": "pnpr@main",
"mean": 0.4600527447599999,
"stddev": 0.01802664356145062,
"median": 0.46379143336000006,
"user": 0.34988174,
"system": 0.7608823800000001,
"min": 0.42856626286000005,
"max": 0.48464444286,
"times": [
0.44791562086000003,
0.42856626286000005,
0.47441040686,
0.46287550786000003,
0.46470735886000003,
0.43979123686000005,
0.47977120286,
0.45045208386,
0.48464444286,
0.46739332386000004
]
}
]
}Scenario: Isolated linker: fresh install, cold cache + hot store
BENCHMARK_REPORT.json{
"results": [
{
"command": "pacquet@HEAD",
"mean": 2.07748291516,
"stddev": 0.04700424456681593,
"median": 2.0608416853600002,
"user": 1.4230235599999999,
"system": 1.26896998,
"min": 2.00981990436,
"max": 2.1592581813600003,
"times": [
2.1592581813600003,
2.1129243953600003,
2.05259075336,
2.0666903423600003,
2.10891400036,
2.05499302836,
2.12701697436,
2.03570993836,
2.04691163336,
2.00981990436
]
},
{
"command": "pacquet@main",
"mean": 2.07622689926,
"stddev": 0.0927173880557876,
"median": 2.0742797153600003,
"user": 1.45669056,
"system": 1.21682728,
"min": 1.94945117536,
"max": 2.1985998383600003,
"times": [
1.9997876383599997,
1.94945117536,
1.98142130336,
1.99918727536,
2.08521397736,
2.06334545336,
2.17819417836,
2.19199455136,
2.1985998383600003,
2.11507360136
]
},
{
"command": "pnpr@HEAD",
"mean": 0.51550616876,
"stddev": 0.017830073018458816,
"median": 0.50876613186,
"user": 0.4143602599999999,
"system": 0.76825918,
"min": 0.49404994036000005,
"max": 0.54199431036,
"times": [
0.54199431036,
0.50203522236,
0.53571066436,
0.49404994036000005,
0.49463066536000005,
0.50672282636,
0.50704403936,
0.53314943236,
0.5292363623599999,
0.51048822436
]
},
{
"command": "pnpr@main",
"mean": 0.5340492610600001,
"stddev": 0.029904738663872093,
"median": 0.5398659863599999,
"user": 0.41583755999999994,
"system": 0.80074768,
"min": 0.47528651636,
"max": 0.56972235636,
"times": [
0.49524185036,
0.47528651636,
0.5471793993599999,
0.56972235636,
0.53255257336,
0.5513363783599999,
0.52924122836,
0.52450625236,
0.56510818136,
0.55031787436
]
}
]
}Scenario: Isolated linker: fresh resolve, hot cache, offline
BENCHMARK_REPORT.json{
"results": [
{
"command": "pacquet@HEAD",
"mean": 0.48768021696,
"stddev": 0.05030557681297799,
"median": 0.49854548436,
"user": 0.46217173999999994,
"system": 0.14147751999999997,
"min": 0.36841660386,
"max": 0.5427685118600001,
"times": [
0.52090702186,
0.44819431986,
0.51962770486,
0.52222521386,
0.47389183286000003,
0.5084939778600001,
0.48367999186000005,
0.5427685118600001,
0.36841660386,
0.48859699086
]
},
{
"command": "pacquet@main",
"mean": 0.5084534945600001,
"stddev": 0.036481792781183124,
"median": 0.5231954513600001,
"user": 0.48082614,
"system": 0.14798802,
"min": 0.44371569586000004,
"max": 0.54318425786,
"times": [
0.47890102086,
0.53804184786,
0.53578483286,
0.51133898586,
0.44371569586000004,
0.53351830586,
0.5256051608600001,
0.45365909586000003,
0.52078574186,
0.54318425786
]
},
{
"command": "pnpr@HEAD",
"mean": 0.14348115049157895,
"stddev": 0.011928729930460163,
"median": 0.14749443086,
"user": 0.04908057684210526,
"system": 0.029002088421052633,
"min": 0.12128885986,
"max": 0.16543051786000001,
"times": [
0.14651527686000002,
0.12973976386,
0.13762673286000002,
0.15482654186,
0.12128885986,
0.14749443086,
0.14226834586,
0.15164921686000002,
0.16543051786000001,
0.13511004386,
0.15002657086,
0.13192389786,
0.15462765786000002,
0.13060597786,
0.14842564486,
0.12391768686,
0.15159961586,
0.15264448686,
0.15042058986
]
},
{
"command": "pnpr@main",
"mean": 0.14301486322842105,
"stddev": 0.01163156292334355,
"median": 0.14623124386,
"user": 0.05322257684210526,
"system": 0.024741351578947367,
"min": 0.11959635386,
"max": 0.15798591386000002,
"times": [
0.14199409886,
0.15114113986,
0.14623124386,
0.14987433486,
0.11959635386,
0.12505560086,
0.15427486886,
0.15798591386000002,
0.15378923886,
0.12557221386,
0.14050106986000002,
0.13071795786,
0.13561538786000002,
0.15124351186,
0.14262149886,
0.15025427486,
0.13337908086,
0.15106256886,
0.15637204286
]
}
]
}Scenario: Isolated linker: peer-heavy resolve, hot cache, offline
BENCHMARK_REPORT.json{
"results": [
{
"command": "pacquet@HEAD",
"mean": 1.1148370617022223,
"stddev": 0.2577640055452791,
"median": 1.13040921048,
"user": 1.0922788555555554,
"system": 0.22802145777777774,
"min": 0.82452055548,
"max": 1.6956152694800002,
"times": [
0.82452055548,
1.0743196944800002,
0.90342224348,
1.2012333244800002,
1.13040921048,
1.1431078594800002,
1.17339655548,
1.6956152694800002,
0.8875088424800001
]
},
{
"command": "pacquet@main",
"mean": 1.2523525032577778,
"stddev": 0.22626719999704695,
"median": 1.27078029548,
"user": 1.239421411111111,
"system": 0.24513323555555555,
"min": 0.96158943748,
"max": 1.5928324424800002,
"times": [
1.06553482148,
1.5928324424800002,
1.4153609224800001,
1.27078029548,
1.1047832834800002,
1.03906122648,
1.2882857164800001,
0.96158943748,
1.5329443834800003
]
},
{
"command": "pnpm@HEAD",
"mean": 4.522946656924444,
"stddev": 0.27869492668678364,
"median": 4.5762989764799995,
"user": 6.742607966666666,
"system": 0.4805244577777778,
"min": 4.095400822479999,
"max": 5.05667538948,
"times": [
4.095400822479999,
4.3644813964799996,
5.05667538948,
4.69363289748,
4.625919048479999,
4.47811253048,
4.23833143948,
4.5762989764799995,
4.577667411479999
]
}
]
}Scenario: Isolated linker: fresh restore, cold cache + cold store + cold pnpr
BENCHMARK_REPORT.json{
"results": [
{
"command": "pacquet@HEAD",
"mean": 4.72227130738,
"stddev": 0.1936181545871168,
"median": 4.64017497768,
"user": 2.8492147199999995,
"system": 2.02876758,
"min": 4.54041676068,
"max": 5.06956643868,
"times": [
4.96781278268,
4.69147409668,
4.59906502868,
4.93347864768,
5.06956643868,
4.67269996668,
4.60764998868,
4.54041676068,
4.5912293796800006,
4.54931998368
]
},
{
"command": "pacquet@main",
"mean": 4.538312263980001,
"stddev": 0.15528358676979984,
"median": 4.483078197679999,
"user": 1.9880923199999998,
"system": 1.52231568,
"min": 4.41827509068,
"max": 4.8377803656800005,
"times": [
4.51378910568,
4.48034606368,
4.44854266068,
4.45804666568,
4.48581033168,
4.41827509068,
4.50264134568,
4.81570925168,
4.42218175868,
4.8377803656800005
]
},
{
"command": "pnpr@HEAD",
"mean": 3.5426146214800007,
"stddev": 0.07068928765251281,
"median": 3.53191934118,
"user": 1.37934372,
"system": 1.31113288,
"min": 3.4844693236800004,
"max": 3.71400862668,
"times": [
3.5202716666800002,
3.57905061768,
3.5577235496800004,
3.4844693236800004,
3.71400862668,
3.4860367036800004,
3.5681053456800003,
3.5435670156800003,
3.4873935996800003,
3.4855197656800003
]
},
{
"command": "pnpr@main",
"mean": 3.54290555518,
"stddev": 0.12759753383623976,
"median": 3.48535743368,
"user": 1.38999442,
"system": 1.3067832799999999,
"min": 3.46516231968,
"max": 3.8691029566800004,
"times": [
3.52116170568,
3.65729831468,
3.4730512136800002,
3.48022207068,
3.51449933668,
3.8691029566800004,
3.47852840968,
3.4795364276800003,
3.4904927966800003,
3.46516231968
]
}
]
} |
Dismissed because a newer commit was pushed; Greptile will re-review the current head.
|
Code review by qodo was updated up to the latest commit da56cfc |
PR Code Suggestions ✨Warning
No code suggestions found for the PR. |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
pnpm/crates/injected-deps-syncer/src/dir_patcher.rs (1)
24-29: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winCorrect the file-identity invariant.
Distinct files can have identical bytes. The patcher skips work only when both paths have the same
FileId. It does not compare file content.Proposed fix
-/// A file carries its identity rather than its content, because that is -/// all a hardlink comparison needs: two paths hold the same bytes -/// exactly when they are the same file, so an unchanged file costs no -/// filesystem work. +/// The patcher treats matching file identities as unchanged. It does not +/// compare file content. Equal content in distinct files still requires +/// replacement so the source and target share a hardlink.As per coding guidelines, comments must document non-obvious invariants and describe current behavior.
🤖 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/injected-deps-syncer/src/dir_patcher.rs` around lines 24 - 29, Update the documentation for the InodeMap path value to state that a file stores its FileId and that unchanged work is skipped only when both paths have the same FileId; remove the claim that identical bytes or content comparison determine equality.Source: Coding guidelines
🤖 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/injected-deps-syncer/src/dir_patcher.rs`:
- Around line 24-29: Update the documentation for the InodeMap path value to
state that a file stores its FileId and that unchanged work is skipped only when
both paths have the same FileId; remove the claim that identical bytes or
content comparison determine equality.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro Plus
Run ID: 00f54fa2-94ed-4048-8985-7722f340d257
📒 Files selected for processing (3)
pnpm/crates/injected-deps-syncer/src/dir_patcher.rspnpm/crates/injected-deps-syncer/src/dir_patcher/tests.rspnpm/crates/injected-deps-syncer/src/lib.rs
🚧 Files skipped from review as they are similar to previous changes (2)
- pnpm/crates/injected-deps-syncer/src/dir_patcher/tests.rs
- pnpm/crates/injected-deps-syncer/src/lib.rs
The red Bencher Report is testbed noise, not this PRTwo Bencher runs against the same commit (
Identical code, and The mechanism agrees with the statistics. For extra context, Not re-running a third time: two samples on one commit is already the controlled experiment, and another roll would only add a third number to the spread. Written by an agent (Claude Code, claude-opus-5[1m]). |
…acing its parent (#13840) When a workspace package replaced a directory with a file of the same name, that path landed in `modified` while the directory's contents landed in `removed`. The two ran concurrently, so a removal could be issued against a path whose parent had already been relinked as a file and come back ENOTDIR, which removeRecursive rethrows — aborting syncInjectedDepsAfterScripts partway through. Await the removals before applying any change. Nothing a change needs can be removed: a path absent from the source has all its children absent too, so no removal is ever an ancestor of an added or modified path. The Rust CLI reached the same ordering in #13834, where a sequential patcher made this a deterministic failure rather than a race.
…ts inode (#13847) An inode number is only unique within one filesystem, so comparing bare inode numbers lets an unrelated file on another device collide with the one being synced. The diff then reads the two as the same file, skips the replacement, and leaves that path stale in the injected copy. Carry the device alongside it, as a `<device>:<inode>` string. The identity stays a primitive, so the comparison the inode map is built around is still a `===` rather than a structural one; `dev` comes from the same stat that already supplied `ino`, so this costs no extra syscall. Nothing changes where injection works at all: a hardlink cannot cross a filesystem, so the device is equal on both sides and the comparison is the one it was before. It only affects the broken cross-device case, which now reaches a clear EXDEV from `fs.link` instead of silently skipping the file. Matches pacquet, which took the same identity in #13834.
Summary
Brings
syncInjectedDepsAfterScriptsto pacquet. The TypeScript CLI has honored the setting since it grew it; pacquet recognized the config key inconfig_types.rsand did nothing else with it, so a build script in a workspace package left every injected copy of that package stale until the next install.An injected dependency is materialized as a tree of hardlinks into the virtual store. A build script that replaces a file — or adds or deletes one — writes inodes the copies do not share, so the copies have to be re-diffed against the source and patched in place. (A script that rewrites a file in place propagates through the hardlink on its own; that is why the tests below assert on a file the script creates rather than one it overwrites.)
What landed
pacquet-injected-deps-syncercrate. It reads the source and each target with the sameDirectoryFetcherflags the installer uses for injected deps (include_only_package_files: false, resolve_symlinks: false, allow_path_escape: false), expands both into inode maps, diffs them, and patches each target.Config::sync_injected_deps_after_scripts, wired frompnpm-workspace.yamlandPNPM_CONFIG_SYNC_INJECTED_DEPS_AFTER_SCRIPTS.run_stages, placed after thepost<name>stage so it is reached only when every stage succeeded — the same condition as the TypeScript call site, where a failingrunLifecycleHookthrows before the sync.Design notes
BTreeMap, which gets the ordering the patcher needs for free: a directory's path is a strict prefix of everything beneath it, so an ancestor always sorts before its descendants. The TypeScript side sorts explicitly withcomparePathsbecause JS objects do not order.apply_patchis sequential rather than concurrent. The TypeScript implementation runs its three phases underPromise.all, which is where its ordering hazards came from; doing the phases in sequence makes the invariants trivially hold.ENOTDIR. UnderPromise.allthe TypeScript side has the same hazard as a timing-dependent race — see the note below.Hostcapability provider, and no single type implements both trait families. Since every test here uses a realTempDirfixture, the DI seam would not have earned its keep, sosync_injected_depsis not generic and uses each crate's ownHostinternally — per the gating rule inpnpm/AGENTS.md.Parity
This is the pacquet half of a setting the TypeScript CLI already implements, so there is no matching TypeScript change to make. One follow-up worth its own PR:
applyPatchin@pnpm/workspace.injected-deps-syncerstill runs its removals concurrently with its changes, so theENOTDIRfailure this PR fixes deterministically exists there as a latent race. I flagged it while reviewing #13663 and left it alone rather than swallowENOTDIRwithout a test that could provoke it; the ordering fix used here is the better shape for it.Tests
crates/cli/tests/suite/: a listed script refreshes every injected copy, and an unlisted one leaves them alone. Together they pin the gate — the first fails if the sync never fires, the second if it always does.Squash Commit Body
Checklist
pnpm/port, or the description notes what still needs porting.pnpm changeset) if this PR changes any publishedpackage. Keep it short and written for pnpm users — it becomes a release note.
Written by an agent (Claude Code, claude-opus-5[1m]).
Need help on this PR? Tag
@codesmith-botwith what you need. Autofix is disabled.Summary by CodeRabbit
New Features
syncInjectedDepsAfterScripts, refreshing injected dependency copies after configured scripts complete successfully.PNPM_CONFIG_SYNC_INJECTED_DEPS_AFTER_SCRIPTSenvironment variable.Tests