Repository navigation
test: give the freshness tests explicit mtimes, not sleeps - #13620
Conversation
…clock The optimistic-repeat-install fast path decides a project is up to date by comparing filesystem mtimes against the `lastValidatedTimestamp` recorded in `node_modules/.pnpm-workspace-state-v1.json`. The recorded value is already a filesystem mtime, so the production comparison sits on a single clock, but the tests around it did not: they seeded the timestamp from `now_millis()` and separated writes with `sleep(Duration::from_millis(20))`. Every such assertion silently depended on the wall clock and the kernel's coarse mtime clock staying within 20 ms of each other, and on the filesystem keeping sub-second mtimes at all. Neither holds everywhere. A whole-second-mtime filesystem collapses the 20 ms gap to nothing, and CI microVMs have been observed with the two clocks a few milliseconds apart. Give the tests a deterministic mtime toolkit in `pacquet-testing-utils::fs` and stop reading the wall clock from them: - `validate_existing_files` backdates everything under a workspace root and returns the `lastValidatedTimestamp` that matches it, so files already written read as validated and anything written afterwards reads as modified, with no sleeping in between. Both gaps are a full second wide, which no supported filesystem's mtime granularity can collapse. - `bump_mtime` now derives the new mtime from the recorded timestamp instead of `SystemTime::now() + 2s`. A wall-clock offset can land below a baseline that an earlier bump already pushed into the future, which made repeated bumps on one workspace unreliable. - `mtime_ms`, `set_mtime_ms`, and `MTIME_STEP_MS` back both of the above and replace the hand-rolled `set_times` blocks that had been copied into three test modules. `build_workspace_state` keeps one wall-clock read: the fallback used when no lockfile and no manifest can be stat'd. It now goes through the `Clock` capability that `pacquet-modules-yaml` already exposes, with the crate's existing `Host` as the production provider, so the branch is driven by a `FrozenClock` fake rather than asserted with `last_validated_timestamp > 0`. Resolves #12730 Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01DBmc6DVLRVY9A9YivZiUGi
|
Note Reviews pausedIt 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 Use the following commands to manage reviews:
Use the checkboxes below for quick actions:
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Plus Run ID: ⛔ Files ignored due to path filters (1)
📒 Files selected for processing (5)
🚧 Files skipped from review as they are similar to previous changes (5)
Included review availability: Your plan includes up to 10 reviews per rolling hour; 9 remain after this review. 📝 WalkthroughWalkthroughThe change adds shared filesystem mtime helpers, injects clock handling into workspace-state construction, and replaces sleeps and future timestamps in package-manager and CLI tests with deterministic filesystem state. ChangesDeterministic mtime utilities
Clock-injected workspace-state construction
Package-manager freshness tests
CLI manifest-update tests
Estimated code review effort: 3 (Moderate) | ~25 minutes Merge Risk: ⚪ Minimal · up to This change makes freshness tests deterministic while preserving production behavior; no actionable merge-blocking risk remains beyond normal checks and review. Assessment against linked issues
Possibly related PRs
✨ 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 |
Micro-Benchmark ResultsLinux |
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #13620 +/- ##
=======================================
Coverage 88.17% 88.17%
=======================================
Files 645 645
Lines 106806 106829 +23
=======================================
+ Hits 94172 94196 +24
+ Misses 12634 12633 -1 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
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.40468871998,
"stddev": 0.1465482026329009,
"median": 2.36285291928,
"user": 1.28837628,
"system": 1.39752264,
"min": 2.26508700028,
"max": 2.67297081328
},
{
"command": "pacquet@main",
"mean": 2.47266811688,
"stddev": 0.1524183955936297,
"median": 2.4433183222799997,
"user": 1.30757338,
"system": 1.41328754,
"min": 2.29888089428,
"max": 2.71273397928
},
{
"command": "pnpr@HEAD",
"mean": 1.54930665368,
"stddev": 0.1499800910384662,
"median": 1.59206303228,
"user": 1.25610248,
"system": 1.3370762399999998,
"min": 1.3012052792800002,
"max": 1.7153994432800002
},
{
"command": "pnpr@main",
"mean": 1.5989146368800002,
"stddev": 0.1133615482981227,
"median": 1.6077010127800002,
"user": 1.23128868,
"system": 1.3224214399999998,
"min": 1.32684542428,
"max": 1.7231269592800003
}
]
}Scenario: Isolated linker: fresh restore, hot cache + hot store
BENCHMARK_REPORT.json{
"results": [
{
"command": "pacquet@HEAD",
"mean": 0.2779983441800001,
"stddev": 0.014138190751209272,
"median": 0.27560532028000007,
"user": 0.21261281999999998,
"system": 0.48884992,
"min": 0.25779691478000005,
"max": 0.30438320378000006
},
{
"command": "pacquet@main",
"mean": 0.27818823028,
"stddev": 0.013589431105770208,
"median": 0.27711425728000005,
"user": 0.22701941999999997,
"system": 0.49354781999999997,
"min": 0.25266568678,
"max": 0.29578637678
},
{
"command": "pnpr@HEAD",
"mean": 0.27795216168000003,
"stddev": 0.00813695285761605,
"median": 0.27905061528,
"user": 0.21350611999999997,
"system": 0.49801562,
"min": 0.26689187078000004,
"max": 0.29241383278000005
},
{
"command": "pnpr@main",
"mean": 0.2791096222800001,
"stddev": 0.002898763172950732,
"median": 0.2784223947800001,
"user": 0.22520922,
"system": 0.4919416200000001,
"min": 0.27567988678000005,
"max": 0.28413206378000005
}
]
}Scenario: Isolated linker: repeat install, hot cache + hot store
BENCHMARK_REPORT.json{
"results": [
{
"command": "pacquet@HEAD",
"mean": 0.006219211377660816,
"stddev": 0.0005304262141235006,
"median": 0.00602973048,
"user": 0.0042678879532163745,
"system": 0.0020342647953216363,
"min": 0.005619760980000001,
"max": 0.00815207798
},
{
"command": "pacquet@main",
"mean": 0.006906555626575349,
"stddev": 0.0007275790567990854,
"median": 0.006835554980000001,
"user": 0.004484831780821919,
"system": 0.002499103561643837,
"min": 0.00579506998,
"max": 0.01052866198
},
{
"command": "pnpr@HEAD",
"mean": 0.00671471970051282,
"stddev": 0.0005969684960662325,
"median": 0.006532671480000001,
"user": 0.004290070769230773,
"system": 0.002499155692307691,
"min": 0.00580842598,
"max": 0.00974666398
},
{
"command": "pnpr@main",
"mean": 0.006123685452440948,
"stddev": 0.0004187513740981915,
"median": 0.006030592980000001,
"user": 0.004056005879265091,
"system": 0.002149725669291339,
"min": 0.00566238098,
"max": 0.00881918098
}
]
}Scenario: Isolated linker: repeat install, cold cache + hot store
BENCHMARK_REPORT.json{
"results": [
{
"command": "pacquet@HEAD",
"mean": 0.006805402540638978,
"stddev": 0.000501271812925482,
"median": 0.0067905449400000005,
"user": 0.004508294696485621,
"system": 0.002328325367412141,
"min": 0.0058287489400000005,
"max": 0.009533316940000001
},
{
"command": "pacquet@main",
"mean": 0.007433539846060608,
"stddev": 0.0007179082802049235,
"median": 0.007330584940000001,
"user": 0.004832943636363635,
"system": 0.002628030909090907,
"min": 0.00597018394,
"max": 0.010168781940000001
},
{
"command": "pnpr@HEAD",
"mean": 0.007364348347854978,
"stddev": 0.00045984814902003406,
"median": 0.007360392940000001,
"user": 0.004826676374622356,
"system": 0.0025666331117824774,
"min": 0.006299540940000001,
"max": 0.00890941594
},
{
"command": "pnpr@main",
"mean": 0.007038879031803281,
"stddev": 0.0003177991560849307,
"median": 0.0070854579400000004,
"user": 0.004725043934426229,
"system": 0.0023499196065573766,
"min": 0.00616765394,
"max": 0.00791665894
}
]
}Scenario: Isolated linker: fresh install, cold cache + cold store
BENCHMARK_REPORT.json{
"results": [
{
"command": "pacquet@HEAD",
"mean": 2.74216839734,
"stddev": 0.018091700127479377,
"median": 2.7460474776400003,
"user": 1.5161218199999997,
"system": 1.2445287000000003,
"min": 2.70722722614,
"max": 2.7627456781400004
},
{
"command": "pacquet@main",
"mean": 2.79734353194,
"stddev": 0.03886026119411361,
"median": 2.8005852211400004,
"user": 1.6460969199999997,
"system": 1.3686747000000001,
"min": 2.73895685014,
"max": 2.87177021414
},
{
"command": "pnpr@HEAD",
"mean": 1.55797123214,
"stddev": 0.1478563056843864,
"median": 1.54188811164,
"user": 1.14445322,
"system": 1.3597822999999998,
"min": 1.39260300514,
"max": 1.77548579514
},
{
"command": "pnpr@main",
"mean": 1.5705717629399998,
"stddev": 0.13352811985354612,
"median": 1.54168837264,
"user": 1.1939065199999999,
"system": 1.3132142999999998,
"min": 1.42336592514,
"max": 1.7634400211399999
}
]
}Scenario: Isolated linker: fresh install, hot cache + hot store
BENCHMARK_REPORT.json{
"results": [
{
"command": "pacquet@HEAD",
"mean": 0.5076455616600001,
"stddev": 0.04795462146612529,
"median": 0.49778831396,
"user": 0.65726366,
"system": 0.6863316799999998,
"min": 0.46993719046000004,
"max": 0.6382017484600001
},
{
"command": "pacquet@main",
"mean": 0.5153885341600001,
"stddev": 0.02098451880577252,
"median": 0.52122450046,
"user": 0.65392066,
"system": 0.69393938,
"min": 0.48791101846,
"max": 0.5481575904600001
},
{
"command": "pnpr@HEAD",
"mean": 0.35614030496,
"stddev": 0.009953614752188632,
"median": 0.36044543646000005,
"user": 0.23156936,
"system": 0.53677148,
"min": 0.34393308346,
"max": 0.36837045146
},
{
"command": "pnpr@main",
"mean": 0.34405432165999994,
"stddev": 0.011070819178742614,
"median": 0.34506734946,
"user": 0.22516286000000002,
"system": 0.5145161799999999,
"min": 0.31658960846,
"max": 0.35632715146
}
]
}Scenario: Isolated linker: fresh install, cold cache + hot store
BENCHMARK_REPORT.json{
"results": [
{
"command": "pacquet@HEAD",
"mean": 1.93645306876,
"stddev": 0.022851452699808327,
"median": 1.94279409226,
"user": 0.8197084199999999,
"system": 0.75795948,
"min": 1.8927718472600001,
"max": 1.96228840126
},
{
"command": "pacquet@main",
"mean": 1.9473945652600002,
"stddev": 0.023196045111026537,
"median": 1.94123115076,
"user": 0.8386925199999998,
"system": 0.78833948,
"min": 1.91911058526,
"max": 1.9883885002600001
},
{
"command": "pnpr@HEAD",
"mean": 0.32808835196,
"stddev": 0.008474599349283435,
"median": 0.32816398226000004,
"user": 0.20918072000000004,
"system": 0.49335518,
"min": 0.31679089626,
"max": 0.34743190526
},
{
"command": "pnpr@main",
"mean": 0.31354453396000004,
"stddev": 0.012011438666601053,
"median": 0.31125424726000006,
"user": 0.19405742000000004,
"system": 0.47370438000000004,
"min": 0.29754327626000004,
"max": 0.33204560726000004
}
]
}Scenario: Isolated linker: fresh resolve, hot cache, offline
BENCHMARK_REPORT.json{
"results": [
{
"command": "pacquet@HEAD",
"mean": 0.21481797898615385,
"stddev": 0.020901987092312724,
"median": 0.21334878014000003,
"user": 0.16514457846153843,
"system": 0.05908074769230769,
"min": 0.18054101314,
"max": 0.26497739314
},
{
"command": "pacquet@main",
"mean": 0.21847667564000003,
"stddev": 0.014631621666117152,
"median": 0.22509667364000002,
"user": 0.17077054,
"system": 0.05778718999999999,
"min": 0.18842461114,
"max": 0.23450795714000003
},
{
"command": "pnpr@HEAD",
"mean": 0.09592394349714288,
"stddev": 0.0021357555402812586,
"median": 0.09611543814000001,
"user": 0.026906397142857145,
"system": 0.011447118571428569,
"min": 0.09198153714000001,
"max": 0.10025002914000002
},
{
"command": "pnpr@main",
"mean": 0.10807913230666667,
"stddev": 0.004524212692805122,
"median": 0.10898773314000001,
"user": 0.03676750666666666,
"system": 0.01251234,
"min": 0.09393064914000002,
"max": 0.11452250914
}
]
}Scenario: Isolated linker: peer-heavy resolve, hot cache, offline
BENCHMARK_REPORT.json{
"results": [
{
"command": "pacquet@HEAD",
"mean": 0.5921697548377778,
"stddev": 0.0855080394289695,
"median": 0.56274216706,
"user": 0.5642267555555556,
"system": 0.1225346511111111,
"min": 0.47412465306,
"max": 0.74321115106
},
{
"command": "pacquet@main",
"mean": 0.6002085353933333,
"stddev": 0.10694512831221756,
"median": 0.63238453806,
"user": 0.5608589777777778,
"system": 0.10981598444444444,
"min": 0.45140889206,
"max": 0.78439272906
},
{
"command": "pnpm@HEAD",
"mean": 3.041103804615556,
"stddev": 0.1666207253644337,
"median": 3.01067502106,
"user": 4.631309977777778,
"system": 0.2884238733333333,
"min": 2.8212718650600004,
"max": 3.37999339006
}
]
}Scenario: Isolated linker: fresh restore, cold cache + cold store + cold pnpr
BENCHMARK_REPORT.json{
"results": [
{
"command": "pacquet@HEAD",
"mean": 4.421928659880001,
"stddev": 0.14726777103814254,
"median": 4.3559262077800005,
"user": 1.4410811399999999,
"system": 1.4855935399999998,
"min": 4.303758294780001,
"max": 4.707255126780001
},
{
"command": "pacquet@main",
"mean": 4.459863498980001,
"stddev": 0.15906787001040987,
"median": 4.43144274578,
"user": 1.46995384,
"system": 1.4100250399999998,
"min": 4.2943591127800005,
"max": 4.75092780078
},
{
"command": "pnpr@HEAD",
"mean": 3.45366877838,
"stddev": 0.12130542142364523,
"median": 3.4001623612799996,
"user": 1.3118535400000002,
"system": 1.3697986399999997,
"min": 3.3607212287799997,
"max": 3.72463649778
},
{
"command": "pnpr@main",
"mean": 3.50720065028,
"stddev": 0.1721215727316434,
"median": 3.45612288228,
"user": 1.27325094,
"system": 1.40202344,
"min": 3.35222901578,
"max": 3.80875959378
}
]
}Scenario: GVS linker: fresh restore, hot cache + hot storeSame install as the isolated fresh-restore hot/hot scenario, into the shared virtual store — the layout pnpm 12 installs into by default. Comparable to that scenario head-to-head.
BENCHMARK_REPORT.json{
"results": [
{
"command": "pacquet@HEAD",
"mean": 0.1640440466025,
"stddev": 0.0041704619865801625,
"median": 0.16360996054,
"user": 0.1855087675,
"system": 0.1909307925,
"min": 0.15702627904,
"max": 0.17196451904
},
{
"command": "pacquet@main",
"mean": 0.16369726260249998,
"stddev": 0.0037232266319237525,
"median": 0.16435155304,
"user": 0.19764583,
"system": 0.18371804249999993,
"min": 0.15732099204,
"max": 0.16946089504
},
{
"command": "pnpr@HEAD",
"mean": 0.1706409535066667,
"stddev": 0.004210327223018179,
"median": 0.16904429304000002,
"user": 0.18769997999999996,
"system": 0.18427387999999997,
"min": 0.16307313704,
"max": 0.17828282804
},
{
"command": "pnpr@main",
"mean": 0.1700406772275,
"stddev": 0.006693188939350843,
"median": 0.16997072904,
"user": 0.187512205,
"system": 0.19312848,
"min": 0.15985757704,
"max": 0.19001358304000002
}
]
} |
Picks up #13609, which normalizes a BOM or CRLF line endings before splitting the combined `pnpm-lock.yaml` into its env and main documents, and #13621, which passes the restart tests' log path through `process.argv` instead of interpolating it into a JS string literal. Neither touches the files this branch edits, so the merge is clean.
|
| Project | pnpm's project |
| Branch | pr/13620 |
| Testbed | pnpr |
⚠️ 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-thresholdsflag.
Click to view all benchmark results
| Benchmark | Latency | milliseconds (ms) |
|---|---|---|
| gvs-linker.fresh-restore.hot-cache.hot-store | 📈 view plot | 163.07 ms |
| isolated-linker.fresh-install.cold-cache.cold-store | 📈 view plot | 1,392.60 ms |
| isolated-linker.fresh-install.cold-cache.hot-store | 📈 view plot | 316.79 ms |
| isolated-linker.fresh-install.hot-cache.hot-store | 📈 view plot | 343.93 ms |
| isolated-linker.fresh-resolve.hot-cache.offline | 📈 view plot | 91.98 ms |
| isolated-linker.fresh-restore.cold-cache.cold-store | 📈 view plot | 1,301.21 ms |
| isolated-linker.fresh-restore.cold-cache.cold-store.cold-pnpr | 📈 view plot | 3,360.72 ms |
| isolated-linker.fresh-restore.hot-cache.hot-store | 📈 view plot | 266.89 ms |
| isolated-linker.repeat-install.cold-cache.hot-store | 📈 view plot | 6.30 ms |
| isolated-linker.repeat-install.hot-cache.hot-store | 📈 view plot | 5.81 ms |
Picks up the install-module decomposition (#13640 and #13624), the headless-install extraction (#13637), the PnP-loader fix for virtual-store-only installs (#13636), and a dependency bump (#13631). `build_workspace_state` moved out of `install.rs` into the new `install/workspace_state.rs`, and its two call sites moved into `install/apply_materialization.rs` and `install/prepare_modules_state.rs`. This branch's `Sys: Clock` seam and the `::<Host>` turbofish are re-applied at those new homes. # Conflicts: # pnpm/crates/package-manager/src/install.rs
`validate_existing_files` read as a check, but it rewrites the mtime of every regular file under the root. Rename it to `backdate_existing_files` so the mutation is visible at the call site, and state in the doc comment that the rewrite and the returned `lastValidatedTimestamp` are one contract: the timestamp is only meaningful for a tree the same call just backdated, which is why they are not separate functions. Splitting the two apart was the alternative. It would leave an order-dependent protocol, because an accessor called before the mutator returns a timestamp that marks later writes as unmodified too, and the matching offsets would live in two places with nothing keeping them in step. Neither hazard is a compile error, so the single call stays. Rename only; no behavior change.
The sandbox was recycled while the rename was in progress, leaving the local checkout at the commit that predates both `main` merges, so `refactor(testing-utils): name the mtime backdating for what it does` was committed against that older base. This merge brings the pushed branch back in; both sides combine without conflicts, and the result keeps the install-module decomposition, the `Sys: Clock` seam, and the rename together. No source change of its own.
`bump_mtime` fell back to the file's own mtime when it found no workspace state to read `lastValidatedTimestamp` from. Resilience buys continuity at the cost of correctness, which is a trade production code can make and test code cannot: a degraded bump does not make the test pass or fail correctly, it makes the test reach a freshness verdict for a reason unrelated to what it asserts. Without a recorded timestamp there is nothing to push past, so the call cannot do what its name promises. Panic and name the path instead. Every caller bumps after an install that records the state, so no test reaches the new panic: the five CLI suites that call `bump_mtime` pass (66 tests, including the repeated-bump `error_action_follows_the_ dependency_state`), as do the four `install::tests` callers.
KSXGitHub
left a comment
There was a problem hiding this comment.
The two issues highlight a flaw common in AI generated code.
They tend to describe history where it doesn't belong.
I suspect that the two items are not the only items added here.
You shall scan for others (introduced by this PR) and fix them as well.
The rustdoc on the mtime helpers justified itself against what this PR replaced: `bump_mtime` and `backdate_existing_files` each explained that their value comes from a recorded timestamp "rather than from `SystemTime::now`", `recorded_validation_timestamp` said it panics "rather than substituting a weaker baseline", and `backdate_existing_files` argued why it is not two functions. A reader of the published docs has no view of the diff those sentences answer. State the current contract instead. `bump_mtime` documents the rule it applies, that the new mtime is a step past whichever of the recorded timestamp and the file's own mtime is later, and why the recorded one can be the later of the two. `recorded_validation_timestamp` documents what the panic protects. `backdate_existing_files` documents that the returned value belongs to the tree it just backdated. Docs only; no behavior change.
Picks up the store-index helper sharing (#13647) and the headless-install bin shim for publicly hoisted workspace packages (#13644), which moves the linking and materialization-plan modules from `package-manager` into `deps-restorer`. Neither touches the mtime helpers or the workspace-state clock seam this branch changes, so the merge is clean.
Picks up sixteen commits, most of them module splits: the optimistic repeat-install check (#13661), the frozen install and its build phase (#13659, #13662), `create_virtual_store` (#13649), the tarball crate root (#13652), and the audit command (#13657). Also the move to the `rc` lane and pacquet 12.0.0-rc.0 (#13666, #13667). #13661 split `optimistic_repeat_install.rs` into per-concern modules, moving one of this branch's two `build_workspace_state::<Host>` call sites into the new `deps_status.rs`. The turbofish is re-applied at both of its new homes. # Conflicts: # pnpm/crates/package-manager/src/optimistic_repeat_install.rs
Picks up a large batch, of which two reshape this branch's changes: #13948 renames the Rust crates from `pacquet-` to `pnpm-`, and #13679 moves the CLI end-to-end tests under `tests/suite/` so they build as one target. This branch's helpers move with them. The `pnpm-testing-utils` mtime helpers keep their names, their imports follow the crate rename, and the `bump_mtime` call sites travel to the relocated suite files. The `Sys: Clock` seam on `build_workspace_state` and its `::<Host>` call sites are re-applied against the renamed crates.
KSXGitHub
left a comment
There was a problem hiding this comment.
Claude Code,
Below are many different reviews. Each may belong to different categories.
I wish that you do not collapse all the unrelated tasks into a single commit.
You shall analyze the reviews. You shall make groups of related reviews.
Each group of related reviews correspond to a task and a git commit.
A git commit should have its purpose clear and focused.
If there would be multiple groups of related reviews, then I expect multiple commits.
`build_workspace_state`'s bound was written as
`Sys: pnpm_modules_yaml::Clock`, the only inline-qualified `Clock` bound
in the workspace. Every other one — in `network-web-auth` and
`auth-commands` — spells it `Sys: Clock` over an import, and
`install/workspace_state.rs` reaches every other name it uses through
its `use super::{…}` list, `Host` from the same crate among them.
Route `Clock` the same way: import it in `install.rs` alongside `Host`
and pull it into the submodule through `use super::{…}`.
`mtime_ms` and `backdate_existing_files` each open with a free function wrapping their argument, then chain methods off the result. Reading either meant starting in the middle — at `fs::metadata` / `WalkDir::new` — stepping inward to find the subject, then back out through the chain. `CODE_STYLE_GUIDE.md` covers this shape under "Continuing a method chain through a free function and back to methods", whose own example (`url.pipe(normalize_registry_url).map(Cow::Borrowed)`) is the same binding-then-chain structure. Pipe both so each reads in one direction: path to metadata to modified, and root to walk to filter to collect. `pipe-trait` joins `pnpm-testing-utils`' dependencies, which had no call sites for it before.
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 15 out of 16 changed files in this pull request and generated no new comments.
Suppressed comments (1)
pnpm/crates/package-manager/src/install.rs:32
Clockis imported frompnpm_modules_yamlbut never used in this module (the only reference is in thisuselist). With workspace lints, this is likely to fail as an unused import; it can be removed.
use pnpm_modules_yaml::{
Clock, Host, IncludedDependencies, LayoutVersion, Modules, NodeLinker as ModulesNodeLinker,
ReadModulesError, WriteModulesError, write_modules_manifest,
};
`mtime_ms` panics with the offending path when a file cannot be stat'd and when its mtime predates the epoch, then silently clamped to `i64::MAX` for the one remaining conversion failure. A test given a saturated timestamp does not fail — it compares against a value no file can exceed, so a freshness assertion built on it passes for the wrong reason. Test helpers should surface a bad input rather than absorb it. Report this failure the way the other two are reported, quoting the millisecond count that would not fit.
Dismissed because a newer commit was pushed; Greptile will re-review the current head.
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 15 out of 16 changed files in this pull request and generated no new comments.
Suppressed comments (1)
pnpm/crates/package-manager/src/install.rs:32
Clockis imported frompnpm_modules_yamlbut never used in this file. If workspace lints treat warnings as errors, this will fail the build; even if not, it introduces an avoidable warning.
use pnpm_modules_yaml::{
Clock, Host, IncludedDependencies, LayoutVersion, Modules, NodeLinker as ModulesNodeLinker,
ReadModulesError, WriteModulesError, write_modules_manifest,
};
The final step of `mtime_ms` reads outward-in: `i64::try_from` wrapped the millisecond count, and the recovery hung off the end. Pipe it so the whole body runs one direction, matching the `fs::metadata` call that opens the function. `i64` stays the return type. Both consumers combine the value with `WorkspaceState::last_validated_timestamp`, which is `i64`, and `backdate_existing_files` subtracts `2 * MTIME_STEP_MS` from it, which an unsigned type would underflow for a file dated within two seconds of the epoch.
Dismissed because a newer commit was pushed; Greptile will re-review the current head.
Picks up 193 commits. Two touch the test files this PR rewrites. #13963 reverts the `enableGlobalVirtualStore` default back to `false`, which retires the `project_local_config()` helper its predecessor needed: the call sites go back to `Config::new()`. Those are the same regions where this branch replaced `sleep(20ms)` and `now_millis()` seeds with explicit mtimes, hence the conflict. Resolved by taking main's `Config::new()` and keeping this branch's seeding. #13961 adds store-verification reporting tests to `install/tests.rs`. They construct a `VerifiedFileIntegrity` with a literal `Duration` and assert the rendered message, so the duration is input rather than measured elapsed time. Nothing to convert. Across all 193 commits main adds no `sleep`, no `now_millis()` seed, and no `SystemTime::now()` in test code, so this branch's conversion still covers the suite.
Dismissed because a newer commit was pushed; Greptile will re-review the current head.
Summary
Resolves #12730.
The optimistic-repeat-install fast path compares filesystem mtimes against the
lastValidatedTimestampinnode_modules/.pnpm-workspace-state-v1.json. Production keeps both sides on one clock, but the tests seeded that timestamp fromnow_millis()and ordered writes withsleep(20ms), so they depended on the wall clock and the kernel's coarse mtime clock staying close, and on sub-second mtimes existing at all. A whole-second-mtime filesystem collapses that gap to nothing.The tests now control mtimes explicitly instead of reading the wall clock, through new
backdate_existing_files,mtime_ms,set_mtime_ms, andMTIME_STEP_MShelpers inpnpm-testing-utils::fs, andbump_mtimederives from the recorded timestamp rather thanSystemTime::now() + 2s. No integration test is converted to a unit test, per the issue's request to strengthen them in place. The one remaining production clock read, the fallbackbuild_workspace_stateuses when nothing can be stat'd, now goes through theClockseampnpm-modules-yamlalready exposes, driven by aFrozenClockfake. That seam — aSys: Clockparameter, its call sites, and one extracted helper — is the whole of the production diff, and it changes no behavior.Squash Commit Body
Checklist
pnpm/port, or the description notes what still needs porting. Pacquet-only, with no user-visible behavior to mirror.pnpm changeset) if this PR changes any published package. Not applicable: every crate touched ispublish = false, and no published package changes behavior.Written by an agent (Claude Code, claude-opus-5).
Summary by CodeRabbit
Bug Fixes
Tests