Repository navigation
Conversation
As for npm, PyPI and Composer, the pub.dev metadata rewrite moves out of internal/handler into internal/metadata/pub: archive URLs pointing at the proxy, cooldown filtering, and latest following the versions kept. It takes the proxy URL, cooldown policy and evaluation time in Options and reports held-back versions through OnCooldownFilter, which the handler logs and records. It builds for wasip1. Cooldown is checked with Evaluate at one EvaluatedAt per rewrite instead of IsAllowed per version. The cooldown coverage test now also reads internal/metadata, where the extracted rewrites check cooldown.
|
No actionable comments were generated in the recent review. Walkthrough
Merge Risk:
|
Part of #501, the pub.dev step.
As in #612 for npm, the pub.dev metadata transformations move out of
internal/handlerintointernal/metadata/pub:Rewrite: archive URLs pointing at the proxy, cooldown filtering, andlatestfollowing the versions kept (the newest stable version left, else the newest prerelease, dropped when none is left)ArchiveURL, where the proxy serves a version's archiveThe package takes its inputs explicitly in
Options: proxy URL, cooldown policy and the time cooldown is evaluated at. It reports versions cooldown holds back throughOnCooldownFilter, which the handler logs and records as before. It doesn't depend onhandler.Proxy.What stays in the handler: fetching, the metadata cache, routes, downloads and their cooldown check.
rewriteMetadatastays as a thin wrapper, so the handler tests run unchanged against the real routes.Cooldown in the rewrite is checked with
Evaluateat oneEvaluatedAtinstead ofIsAllowedper version, as ininternal/metadata/npm. The handler passestime.Now(), so results are the same unless a rewrite runs across a cooldown boundary. The per-version debug log of rewritten archive URLs is gone.TestCooldownSupportedCoversHandlersnow also readsinternal/metadata, since pub's only literal cooldown check was the rewrite; downloads go through the shared download check.Portability:
GOOS=wasip1 GOARCH=wasm go build ./internal/metadata/pubworks.imports_test.gofails on any non-standard import outside an allowlist (cooldown, purl, vers, packageurl-go,internal/packageurl, and Masterminds/semver forlatest) and onnet,net/http,log/slogordatabase/sql.New tests in
internal/metadata/pubcover the archive URL rewrite, cooldown evaluated atEvaluatedAt, the callback, versions without a usable publish time, a disabled and a missing policy, everylatestcase, and documents without versions. They were mutation-checked, as was the handler's wiring. There are no pub benchmarks to compare.go test ./...andgolangci-lint run ./...pass.Summary by CodeRabbit