Repository navigation
Conversation
…one policy module The registry metadata cache's decisions were spread across the fetchers and the pick layers: - FetchAttempt::metadata_request and stored_full_etag decided the Accept header, the validators, and Cache-Control: no-cache. - DecodeMeta::persist and persist_upgraded_to_mirror each chose which MetaHeaders constructor described the stored document. Each also removed an uncacheable mirror after a failed save, in its own copy. - document_from_response and DecodeMeta each read ETag, Cache-Control, and Content-Type off the response and decided normalization separately. - mirror_fast_paths and pick_package each tested `uncacheable` against the network policy. The new metadata_cache_policy module holds these decisions as pure functions: - DocumentKind (Abbreviated, Full, FullInAbbreviatedMirror) names the representation. for_mirror derives it from the mirror slot and its stored tags. accept and revalidation give the request shape. A mirror's validators go out only for the kind that recorded them. - MirrorWrite::on_response reads a 2xx response once. Its headers method is the only place that builds a fetched document's header line, and discard_after_failed_save does the clean-up after a failed save. - mirror_may_answer is the uncacheable gate for picks. The release-age upgrade now requests a FullInAbbreviatedMirror document through fetch_metadata_document, and UpgradeOutcome carries its MirrorWrite in place of loose full_etag and uncacheable fields. MetaHeaders::for_full_meta_in_abbreviated_mirror is removed. No behavior changes. Table-driven unit tests cover each function, and the existing fetch and pick tests still pass. Swapping the representation's tag, or always allowing an uncacheable mirror, fails both the new tests and the existing integration tests. Part of pnpm/tasks#146. Out of scope here: a single decide() over the pick layers, merging the two v12 request pipelines, the v11 counterpart, and the request-log harnesses tracked in pnpm/tasks#141. Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info
📝 Walkthrough
Merge Risk: ⚪ Minimal · up to
|
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #17024 +/- ##
=======================================
Coverage 92.53% 92.53%
=======================================
Files 1775 1776 +1
Lines 228551 228560 +9
=======================================
+ Hits 211490 211509 +19
+ Misses 17061 17051 -10 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Micro-Benchmark ResultsLinux |
Same-run regression checkHEAD and main are measured on the same runner. The tolerance is 5% of the main median or 2 ms, whichever is larger. A regression requires both the median slowdown and the gap between the fastest retained HEAD sample and slowest retained main sample to exceed this tolerance, after trimming up to 10% from each tail. Suspected regressions are rerun once with target order reversed and only fail if reproduced. This conservative noise guard is not a statistical confidence interval. Inconclusive rows do not fail the check. They remain visible for performance review. Bencher retains absolute minimum timings for historical tracking; historical alerts do not gate this PR. Sequential measurements can still be affected by runner drift.
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; the linked and injected workspace scenarios compare current Rust against main Rust. Bencher consumes pacquet@HEAD and pnpr@HEAD. The tables below show mean ± σ. Bencher tracks absolute minimum latency; PR regression checks compare HEAD and main samples from the same runner. Historical timing alerts do not gate PRs. Scenario: Isolated linker: fresh restore, cold cache + cold store
BENCHMARK_REPORT.json{
"results": [
{
"command": "pacquet@HEAD",
"mean": 2.406893844,
"stddev": 0.1338654444617656,
"median": 2.3742158118,
"user": 1.31856682,
"system": 1.3932612999999998,
"min": 2.2630275778,
"max": 2.6473074018
},
{
"command": "pacquet@main",
"mean": 2.3795437246999995,
"stddev": 0.11636417984411501,
"median": 2.3440949213,
"user": 1.1871532200000001,
"system": 1.3205487999999999,
"min": 2.2341657857999997,
"max": 2.5643985498
},
{
"command": "pnpr@HEAD",
"mean": 1.45580571,
"stddev": 0.14081613181304856,
"median": 1.3953836478000001,
"user": 1.12888612,
"system": 1.2007508999999998,
"min": 1.2941415508,
"max": 1.6545811838
},
{
"command": "pnpr@main",
"mean": 1.4429766599999998,
"stddev": 0.14537170494430493,
"median": 1.4421002928,
"user": 1.16612392,
"system": 1.2373792,
"min": 1.2858749628,
"max": 1.6203182107999998
}
]
}Scenario: Isolated linker: fresh restore, hot cache + hot store
BENCHMARK_REPORT.json{
"results": [
{
"command": "pacquet@HEAD",
"mean": 0.23208635192,
"stddev": 0.004313432253218221,
"median": 0.23134080182000002,
"user": 0.26610822,
"system": 0.58445876,
"min": 0.22692866782,
"max": 0.24028386082000003
},
{
"command": "pacquet@main",
"mean": 0.23530224932000002,
"stddev": 0.010037845923038654,
"median": 0.23353379832000004,
"user": 0.27393622,
"system": 0.5696512599999999,
"min": 0.22664306982000001,
"max": 0.26132898282
},
{
"command": "pnpr@HEAD",
"mean": 0.24784920221999998,
"stddev": 0.006571094093282952,
"median": 0.24738866782000002,
"user": 0.28329842000000005,
"system": 0.5584482599999999,
"min": 0.23786458282000003,
"max": 0.25920850682
},
{
"command": "pnpr@main",
"mean": 0.24992437912000004,
"stddev": 0.012416733683928692,
"median": 0.24633636332,
"user": 0.27874871999999995,
"system": 0.5831914599999999,
"min": 0.23673246582000002,
"max": 0.27452695282
}
]
}Scenario: Isolated linker: repeat install, hot cache + hot store
BENCHMARK_REPORT.json{
"results": [
{
"command": "pacquet@HEAD",
"mean": 0.0077790831107006405,
"stddev": 0.00046177968480149453,
"median": 0.00773653734,
"user": 0.004540173248407644,
"system": 0.0038927028662420395,
"min": 0.00698563984,
"max": 0.009778971840000001
},
{
"command": "pacquet@main",
"mean": 0.008183996384342508,
"stddev": 0.0006085107051626989,
"median": 0.00805809684,
"user": 0.005104629051987771,
"system": 0.003882185993883793,
"min": 0.00690324484,
"max": 0.011281396840000001
},
{
"command": "pnpr@HEAD",
"mean": 0.00840215713180328,
"stddev": 0.0005158098964210538,
"median": 0.008330097840000002,
"user": 0.005003204590163932,
"system": 0.004246559868852452,
"min": 0.007241510840000001,
"max": 0.010497843840000002
},
{
"command": "pnpr@main",
"mean": 0.00863081291073955,
"stddev": 0.0005835309170287393,
"median": 0.00855594284,
"user": 0.005495968167202573,
"system": 0.003996453311897106,
"min": 0.00736202784,
"max": 0.011687089840000001
}
]
}Scenario: Isolated linker: repeat install, cold cache + hot store
Confirmation (reversed target order)
BENCHMARK_REPORT.json{
"results": [
{
"command": "pacquet@HEAD",
"mean": 0.007704555800000008,
"stddev": 0.0005386704584853986,
"median": 0.0076352768,
"user": 0.004517405961538463,
"system": 0.003845098557692307,
"min": 0.0069269073,
"max": 0.011596291300000002
},
{
"command": "pacquet@main",
"mean": 0.011211724887837837,
"stddev": 0.0033206565443437207,
"median": 0.0118253403,
"user": 0.00644899081081081,
"system": 0.0057018243243243255,
"min": 0.0070364433,
"max": 0.020351611300000003
},
{
"command": "pnpr@HEAD",
"mean": 0.013817687408108107,
"stddev": 0.0017384990638855602,
"median": 0.0141604928,
"user": 0.007682878108108103,
"system": 0.007114331081081084,
"min": 0.007398943300000001,
"max": 0.017518245300000002
},
{
"command": "pnpr@main",
"mean": 0.007929824177622379,
"stddev": 0.0004346092409354325,
"median": 0.0078861328,
"user": 0.0047768478321678345,
"system": 0.0039038391608391594,
"min": 0.0070103743,
"max": 0.0102069233
}
],
"confirmation": {
"results": [
{
"command": "pnpr@main",
"mean": 0.00837002582106464,
"stddev": 0.0003476127463641182,
"median": 0.00836773338,
"user": 0.004570851482889734,
"system": 0.004558033079847907,
"min": 0.00767684538,
"max": 0.01006465238
},
{
"command": "pnpr@HEAD",
"mean": 0.008378416464558825,
"stddev": 0.0002984015851251827,
"median": 0.00839283138,
"user": 0.005143743970588234,
"system": 0.004070232205882352,
"min": 0.007670463380000001,
"max": 0.01007981238
},
{
"command": "pacquet@main",
"mean": 0.008316564641194032,
"stddev": 0.00026579514171718024,
"median": 0.00834743538,
"user": 0.004909600149253728,
"system": 0.004248177686567165,
"min": 0.007621801380000001,
"max": 0.009077627380000002
},
{
"command": "pacquet@HEAD",
"mean": 0.008356840057902616,
"stddev": 0.00036882857980970624,
"median": 0.00837626038,
"user": 0.004922552284644194,
"system": 0.00427021138576779,
"min": 0.007452102380000001,
"max": 0.009759549380000001
}
]
}
}Scenario: Isolated linker: fresh install, cold cache + cold store
BENCHMARK_REPORT.json{
"results": [
{
"command": "pacquet@HEAD",
"mean": 2.4758235620600004,
"stddev": 0.01844805094030008,
"median": 2.4761958496600003,
"user": 1.6532847,
"system": 1.5174751999999998,
"min": 2.44652125716,
"max": 2.50212965016
},
{
"command": "pacquet@main",
"mean": 2.4653794644600002,
"stddev": 0.01479021244994916,
"median": 2.4658898326600003,
"user": 1.6845016000000002,
"system": 1.478945,
"min": 2.4453695031600002,
"max": 2.49023730116
},
{
"command": "pnpr@HEAD",
"mean": 1.54293964086,
"stddev": 0.10199048346933431,
"median": 1.5157848886599998,
"user": 1.1246262,
"system": 1.181026,
"min": 1.43086074816,
"max": 1.7570519011599999
},
{
"command": "pnpr@main",
"mean": 1.52802729446,
"stddev": 0.11161332154073651,
"median": 1.52556061166,
"user": 1.0948124,
"system": 1.2056448,
"min": 1.40150940716,
"max": 1.67117711416
}
]
}Scenario: Isolated linker: fresh install, hot cache + hot store
BENCHMARK_REPORT.json{
"results": [
{
"command": "pacquet@HEAD",
"mean": 0.43744764640000006,
"stddev": 0.01847358293867846,
"median": 0.43782897620000005,
"user": 0.62762116,
"system": 0.72718146,
"min": 0.40323448370000003,
"max": 0.46139220670000003
},
{
"command": "pacquet@main",
"mean": 0.47458323680000003,
"stddev": 0.07033801171059839,
"median": 0.4494927027000001,
"user": 0.69626596,
"system": 0.78293726,
"min": 0.4316560347,
"max": 0.6679900697000001
},
{
"command": "pnpr@HEAD",
"mean": 0.3180034996000001,
"stddev": 0.04835070998907029,
"median": 0.29817186320000005,
"user": 0.28794435999999995,
"system": 0.61505656,
"min": 0.28192697070000006,
"max": 0.42293647970000003
},
{
"command": "pnpr@main",
"mean": 0.2911997343,
"stddev": 0.006677378668025698,
"median": 0.29212241120000004,
"user": 0.25059665999999997,
"system": 0.5777893599999999,
"min": 0.2757065287,
"max": 0.30108661570000006
}
]
}Scenario: Isolated linker: fresh install, cold cache + hot store
BENCHMARK_REPORT.json{
"results": [
{
"command": "pacquet@HEAD",
"mean": 1.61646874486,
"stddev": 0.018867881829044548,
"median": 1.61817095296,
"user": 0.8765425199999999,
"system": 0.8715444399999999,
"min": 1.58131312146,
"max": 1.65220044846
},
{
"command": "pacquet@main",
"mean": 1.6539619216600001,
"stddev": 0.09689648982017496,
"median": 1.62537071196,
"user": 0.92636782,
"system": 0.96225804,
"min": 1.5991114664600001,
"max": 1.9246100464600002
},
{
"command": "pnpr@HEAD",
"mean": 0.28686555696,
"stddev": 0.01188457392904141,
"median": 0.29075676796000005,
"user": 0.24433952000000003,
"system": 0.56335174,
"min": 0.25982781946000005,
"max": 0.30353977046
},
{
"command": "pnpr@main",
"mean": 0.29348019556000005,
"stddev": 0.006597045444757363,
"median": 0.29554796796000005,
"user": 0.26622112,
"system": 0.5573062399999998,
"min": 0.27933250746000005,
"max": 0.29951307946000005
}
]
}Scenario: Isolated linker: fresh resolve, hot cache, offline
BENCHMARK_REPORT.json{
"results": [
{
"command": "pacquet@HEAD",
"mean": 0.28596448854,
"stddev": 0.01708587048163046,
"median": 0.28938578114,
"user": 0.25391674000000003,
"system": 0.12439942,
"min": 0.26075629714000004,
"max": 0.30779534514
},
{
"command": "pacquet@main",
"mean": 0.27376480441272727,
"stddev": 0.006743397115607006,
"median": 0.27596610114000003,
"user": 0.26074604909090904,
"system": 0.11904364727272726,
"min": 0.25992983614000004,
"max": 0.28107680714
},
{
"command": "pnpr@HEAD",
"mean": 0.09864836593310343,
"stddev": 0.0021702833119382364,
"median": 0.09839849914,
"user": 0.04490803655172413,
"system": 0.017544057931034484,
"min": 0.09492329714,
"max": 0.10246325414
},
{
"command": "pnpr@main",
"mean": 0.09731167010666666,
"stddev": 0.0029918794902646932,
"median": 0.09782306864000001,
"user": 0.04294494,
"system": 0.01683378666666667,
"min": 0.09118393213999999,
"max": 0.10298883514
}
]
}Scenario: Isolated linker: peer-heavy resolve, hot cache, offline
BENCHMARK_REPORT.json{
"results": [
{
"command": "pacquet@HEAD",
"mean": 0.24668367337333333,
"stddev": 0.008310293621489214,
"median": 0.24598414104000002,
"user": 0.2479533711111111,
"system": 0.06305299555555555,
"min": 0.23424626904,
"max": 0.26291547104
},
{
"command": "pacquet@main",
"mean": 0.26575365404,
"stddev": 0.042900132608395966,
"median": 0.24144330004,
"user": 0.26723003777777776,
"system": 0.06857332888888888,
"min": 0.23145830404,
"max": 0.35209063004
},
{
"command": "pnpm@HEAD",
"mean": 4.085683648151111,
"stddev": 0.2902592227904482,
"median": 4.03635655404,
"user": 5.795362371111111,
"system": 0.4556903288888889,
"min": 3.8072041630399998,
"max": 4.58591703904
}
]
}Scenario: Isolated linker: linked-workspace resolve, hot cache, offline
BENCHMARK_REPORT.json{
"results": [
{
"command": "pacquet@HEAD",
"mean": 0.19299027858750004,
"stddev": 0.005288085059958609,
"median": 0.1925912489,
"user": 0.1549037325,
"system": 0.07470169500000001,
"min": 0.18400495790000002,
"max": 0.2011389359
},
{
"command": "pacquet@main",
"mean": 0.19291375196666666,
"stddev": 0.00509518508814311,
"median": 0.1932026769,
"user": 0.15251942,
"system": 0.07477465333333333,
"min": 0.18651160390000002,
"max": 0.2010569619
}
]
}Scenario: Isolated linker: injected workspace repeat install, hot cache + hot store
BENCHMARK_REPORT.json{
"results": [
{
"command": "pacquet@HEAD",
"mean": 0.06984122455142858,
"stddev": 0.0018707004336609308,
"median": 0.06930889298000001,
"user": 0.027829221904761912,
"system": 0.046958416190476186,
"min": 0.06753624248000001,
"max": 0.07528326748000001
},
{
"command": "pacquet@main",
"mean": 0.07680023128487805,
"stddev": 0.00468853471577764,
"median": 0.07578579348,
"user": 0.025829106341463418,
"system": 0.056702342439024375,
"min": 0.06969733948000001,
"max": 0.09017751848000001
}
]
}Scenario: Isolated linker: fresh restore, cold cache + cold store + cold pnpr
BENCHMARK_REPORT.json{
"results": [
{
"command": "pacquet@HEAD",
"mean": 4.542857126220001,
"stddev": 0.13015705299866165,
"median": 4.542479051420001,
"user": 1.4891795799999998,
"system": 1.5744912999999996,
"min": 4.37249257092,
"max": 4.794689449920001
},
{
"command": "pacquet@main",
"mean": 4.60353763362,
"stddev": 0.10743227379460497,
"median": 4.635217781420001,
"user": 1.4002904800000002,
"system": 1.4087280999999998,
"min": 4.4371490409200005,
"max": 4.77512247092
},
{
"command": "pnpr@HEAD",
"mean": 3.52345466632,
"stddev": 0.0931223895608491,
"median": 3.51371616592,
"user": 1.3517810799999999,
"system": 1.3300918999999998,
"min": 3.41110438692,
"max": 3.66084074592
},
{
"command": "pnpr@main",
"mean": 3.5308566631199994,
"stddev": 0.1166796894889577,
"median": 3.4932161749199997,
"user": 1.32945258,
"system": 1.3057599999999998,
"min": 3.40952972692,
"max": 3.79936757192
}
]
}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. Scenarios run on separate machines, so compare main and branch within each table.
BENCHMARK_REPORT.json{
"results": [
{
"command": "pacquet@HEAD",
"mean": 0.18832999939473682,
"stddev": 0.04162124015386866,
"median": 0.2067641195,
"user": 0.2244489084210526,
"system": 0.18485060105263157,
"min": 0.11533776350000001,
"max": 0.2472018215
},
{
"command": "pacquet@main",
"mean": 0.21149669434615387,
"stddev": 0.01796527504548687,
"median": 0.21150831050000002,
"user": 0.24817307846153847,
"system": 0.19925517999999995,
"min": 0.1785463725,
"max": 0.23881578450000002
},
{
"command": "pnpr@HEAD",
"mean": 0.1455128268,
"stddev": 0.037588155029135324,
"median": 0.134294638,
"user": 0.18117444,
"system": 0.13226768,
"min": 0.1293951055,
"max": 0.2522400845
},
{
"command": "pnpr@main",
"mean": 0.12801011885,
"stddev": 0.00326325981748227,
"median": 0.12780973950000002,
"user": 0.15085888999999997,
"system": 0.12361138,
"min": 0.12246693850000001,
"max": 0.1364715915
}
]
}Scenario: Store only: unlocked direct deps, cold cache + hot storeStore-only install (
BENCHMARK_REPORT.json{
"results": [
{
"command": "pacquet@HEAD",
"mean": 1.1037728269600002,
"stddev": 0.017332841147652187,
"median": 1.1032236795600001,
"user": 0.49007366,
"system": 0.21309921999999998,
"min": 1.07332995156,
"max": 1.12859712656
},
{
"command": "pacquet@main",
"mean": 1.1843497505600002,
"stddev": 0.08215096838142286,
"median": 1.1562541100600001,
"user": 0.63900476,
"system": 0.26367251999999997,
"min": 1.09949045556,
"max": 1.30534131056
}
]
} |
|
@coderabbitai review |
There was a problem hiding this comment.
Your trial has ended. Reactivate Greptile to resume code reviews.
PR Summary by QodoCentralize npm metadata cache decisions in a policy module
AI Description
Diagram
High-Level Assessment
Files changed (13)
|
Code Review by Qodo
1. Repeated installs lack log coverage
|
PR Code Suggestions ✨Warning
No code suggestions found for the PR. |
|
Summary
First step of pnpm/tasks#146 (Related to pnpm/tasks#146), in pnpm v12 only. The request shape, the mirror header writes, and the
uncacheablegate now live in one pure module,metadata_cache_policy. There is no behavior change.Before, these decisions were spread over several places:
Cache-Control: no-cacheFetchAttempt::metadata_request+stored_full_etagDocumentKind::for_mirror,accept,revalidationDecodeMeta::persist,persist_upgraded_to_mirror(two constructors)MirrorWrite::headers(sole writer for fetched documents)DecodeMetaanddocument_from_response, separatelyMirrorWrite::on_responseMirrorWrite::discard_after_failed_savemirror_fast_paths,pick_packagemirror_may_answerThe release-age upgrade now requests a
DocumentKind::FullInAbbreviatedMirrordocument, andUpgradeOutcomecarries itsMirrorWritein place of loosefull_etag/uncacheablefields.Tests. Table-driven unit tests over kind × stored headers × bypass, response ETag × Cache-Control × Content-Type, and network policy × uncacheable. All 613 tests of
pnpm-resolving-npm-resolverpass. Sabotage checks:upgraded_mirror_revalidation::*.version_selection::uncacheable_*tests.Not in this PR. These parts of the task are left for follow-ups:
decide()over the pick layers (cached_pick, the four mirror fast paths,offline_disk_pick,disk_fallback).No changeset, since nothing changes for users.
Squash Commit Body
Checklist
already linked to it solves it.
are implemented in every affected version.
Written by an agent (Claude Code, claude-opus-5-5).
🤖 Generated with Claude Code
Need help on this PR? Tag
@codesmith-botwith what you need.Summary by CodeRabbit