Repository navigation
fix: honor same-second edits on whole-second-mtime filesystems - #12975
Conversation
The optimistic repeat-install fast path and verify-deps-before-run decide whether a package.json, .pnpmfile.cjs, or patch file changed since the last install by comparing its mtime against the last-validated timestamp with a strict `>`. On a filesystem that records mtimes at whole-second resolution (ext4 with 128-byte inodes, HFS+, some CI runner disks) a file edited in the same second as the install gets an mtime that rounds down below the timestamp, so the edit looks unchanged, the fast path short-circuits, and re-resolution is skipped — the second install is a no-op and keeps the stale result. Detect a whole-second mtime (no sub-second component) and treat its whole second as possibly-after the reference, falling through to the authoritative content check instead of trusting the rounded-down mtime. Erring toward "modified" only ever runs the content check; it never skips a needed install. On sub-second filesystems the mtime carries a fractional part, so the comparison stays exact and the common case is completely unaffected — the existing deps-status unit tests pass unchanged. Landed in both stacks: pacquet's optimistic_repeat_install and pnpm's checkDepsStatus, with a regression test on each side that forces a whole-second mtime so the coarse-filesystem path is exercised on any filesystem.
There was a problem hiding this comment.
zkochan has reached the 50-credit limit for trial accounts. To continue receiving code reviews, upgrade your plan.
📝 WalkthroughWalkthroughDependency status and repeat-install freshness checks now account for whole-second filesystem mtimes. Manifest, lockfile, patch, and pnpmfile checks fall back to content validation when timestamps may indicate same-second edits. ChangesCoarse-mtime freshness handling
Estimated code review effort: 4 (Complex) | ~45 minutes Possibly related issues
Possibly related PRs
Suggested labels: Suggested reviewers: ✨ 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 QodoFix repeat-install mtime gating on whole-second filesystems
AI Description
Diagram
High-Level Assessment
Files changed (7)
|
Code Review by Qodo
Context used✅ Compliance rules (platform):
18 rules 1.
|
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/package-manager/src/optimistic_repeat_install.rs`:
- Around line 560-568: After successful single-project validation in the Rust
flow around assert_wanted_lockfile_equals_current, refresh or persist the
existing trusted validation marker so subsequent unchanged checks use the warm
fast path without adding extra filesystem or content checks. Apply the same
marker update mechanism in
pnpm/crates/package-manager/src/optimistic_repeat_install.rs lines 560-568 and
mirror it in pnpm11/deps/status/src/checkDepsStatus.ts lines 563-574.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro Plus
Run ID: 6f210610-0a9f-4122-9ab9-0252ca38751b
📒 Files selected for processing (7)
.changeset/repeat-install-coarse-mtime.mdcspell.jsonpnpm/crates/cli/tests/stale_pin_dedupe.rspnpm/crates/package-manager/src/optimistic_repeat_install.rspnpm/crates/package-manager/src/optimistic_repeat_install/tests.rspnpm11/deps/status/src/checkDepsStatus.tspnpm11/deps/status/test/checkDepsStatus.test.ts
PR Code Suggestions ✨Warning
Explore these optional code suggestions:
|
||||||||||||
|
Found 3 test failures on Blacksmith runners: Failures
|
|
A couple of clarifications on the automated feedback: On the "use On the Blacksmith CI failures (
Both are pre-existing failures that the Blacksmith migration (#12969) exposed; they were previously masked by nextest's fail-fast stopping at the mtime failures this PR fixes. This PR's own added tests pass on both stacks. Written by an agent (Claude Code, claude-opus-4-8). |
Temporary diagnostic. The optimistic repeat-install integration tests flake on the Blacksmith Linux runner: an edit made in the same second as the previous install is intermittently not detected, so the fast path skips re-resolution. The whole-second-mtime handling in #12975 fixed the deterministic cases but not this residual flakiness, which points at either a coarser-than-expected (or non-whole-second) mtime granularity or skew between the wall clock (used for lastValidatedTimestamp) and the filesystem mtime clock in the microVM. Add a probe step that measures, on the actual runner, the fresh-file mtime granularity, the wall-clock-vs-mtime delta, and whether two writes a few ms apart get distinguishable mtimes. Runs on every Rust test OS so the Blacksmith Linux/Windows behavior can be compared against GitHub-hosted macOS. To be removed once the root cause is confirmed.
Micro-Benchmark ResultsLinux |

Summary
The optimistic repeat-install fast path (and
verify-deps-before-run) decides whether apackage.json,.pnpmfile.cjs, or patch file changed since the last install by comparing its mtime against the last-validated timestamp with a strict>. On a filesystem that records mtimes at whole-second resolution (ext4 with 128-byte inodes, HFS+, some CI runner disks), a file edited in the same second as the previous install gets an mtime that rounds down below the timestamp — so the edit looks unchanged, the fast path short-circuits, and re-resolution is skipped. The second install becomes a no-op and keeps the stale result.This is a real, if narrow, correctness bug: a human editing a manifest and reinstalling is always >1s later, so it only bites automated same-second reinstalls on a coarse-mtime filesystem. It surfaced as deterministic pacquet integration-test failures (
stale_pin_dedupe,custom_resolvers) once the Rust CI test job moved to a runner whose disk has second-granularity mtimes.The fix
Detect a whole-second mtime (no sub-second component) and treat its whole second as possibly-after the reference —
mtime + 1000 > referenceinstead ofmtime > reference— so the comparison falls through to the authoritative content check instead of trusting the rounded-down mtime. Erring toward "modified" only ever runs the (cheap) content check; it never skips a needed install.Key property: a complete no-op on sub-second filesystems. On ext4/APFS/NTFS/xfs the mtime carries a fractional part, so the branch stays strict and behavior/perf are unchanged — the existing
checkDepsStatusandoptimistic_repeat_installunit suites pass without modification. (An earlier fixed-tolerance attempt was rejected precisely because it regressed the common path; this variant keys off each file's own sub-second component, so it doesn't.)Landed in both stacks:
pnpm/crates/package-manager/src/optimistic_repeat_install.rs(newFileMtimecarrying awhole_secondflag +modified_at_or_after).pnpm11/deps/status/src/checkDepsStatus.ts(modifiedAtOrAfter, usingmtimeMsto detect the whole second).Each side gets a regression test that forces a whole-second mtime so the coarse-filesystem path is exercised on any filesystem (both verified to fail without the fix). I also removed the temporary per-test mtime bumps added in #12969 so
stale_pin_dedupegenuinely validates this fix.Squash Commit Body
Checklist
pnpm/port, or the description notes what still needs porting.pnpm changeset) if this PR changes any published package. (@pnpm/deps.status,pnpm,pacquet— patch.)Written by an agent (Claude Code, claude-opus-4-8).
Need help on this PR? Tag
/codesmithwith what you need. Autofix is disabled.Summary by CodeRabbit