feat(package-manager): dispatch Binary/Variations to runtime fetchers (#437 slice D1)#492
Conversation
…#437 slice D1) Replace the cold-path `UnsupportedResolution` arms for `LockfileResolution::{Binary, Variations}` with actual fetcher dispatch. Slice C wired the per-archive download (`DownloadTarballToStore` / `DownloadZipArchiveToStore`); this slice routes lockfile resolutions through them. - `Binary(b)` dispatches on `b.archive` (`Tarball` / `Zip`): - `Tarball` → `DownloadTarballToStore` (same shape as registry / tarball entries minus the `package_unpacked_size` hint). - `Zip` → `DownloadZipArchiveToStore` with `archive_prefix: b.prefix.as_deref()` so the runtime archive's top-level wrapper (e.g. `node-vX.Y.Z-darwin-arm64/`) is stripped before the CAS keys are written. - `Variations(v)` runs `select_platform_variant` against a freshly-built `PlatformSelector` (`pacquet_graph_hasher`'s `host_platform` / `host_arch` / `host_libc`, mapping `"unknown"` → `None` per upstream's `process.platform === 'linux' ? family : null` convention). The picked variant's inner resolution must be `Binary`; any other shape (corrupt lockfile or a future shape pacquet hasn't learned about) raises the typed `VariantHasNonBinaryResolution` error rather than silently routing. - `create_virtual_store::snapshot_cache_key` returns the proper warm-cache key for both new arms: `Binary` uses `store_index_key(integrity, pkg_id)`; `Variations` runs the same selector and keys off the picked variant. A miss on variant selection or a non-`Binary` inner shape returns `Ok(None)` and lets the cold path raise the typed error. - Two new error variants on `InstallPackageBySnapshotError`: - `NoMatchingPlatformVariant { package_key, host_os, host_cpu, host_libc, available_targets }` — fires when no variant matches the host; carries the host triple + the rendered available target list so the user can see at a glance why. - `VariantHasNonBinaryResolution { package_key, inner_kind }` — defensive guard for malformed lockfiles. The Node-runtime `NODE_EXTRAS_IGNORE_PATTERN` filter (strips bundled `npm` / `corepack` from the archive) and bin-link cmd-shims for runtime executables will land in Slice D2; the filter slot stays `None` for now and `BinaryResolution::bin` is read but not yet acted on. Slice E adds `--no-runtime` and Slice F adds the end-to-end install fixtures. Two new unit tests cover the helpers: - `host_platform_selector_omits_libc_on_non_linux_hosts` — pins the `host_libc() == "unknown"` ⇔ `selector.libc.is_none()` relationship without needing platform-gated tests. - `render_variant_targets_formats_each_triple_with_optional_libc` — locks in the `os/cpu[+libc]` rendering used by the `NoMatchingPlatformVariant` error message.
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (3)
📜 Recent review details⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (4)
🧰 Additional context used📓 Path-based instructions (1)**/*.rs📄 CodeRabbit inference engine (AGENTS.md)
Files:
🧠 Learnings (4)📚 Learning: 2026-05-07T23:19:08.272ZApplied to files:
📚 Learning: 2026-05-13T19:22:48.951ZApplied to files:
📚 Learning: 2026-05-13T20:09:22.171ZApplied to files:
📚 Learning: 2026-05-01T10:01:33.766ZApplied to files:
🔇 Additional comments (13)
📝 WalkthroughWalkthroughThis PR extends the package manager to support binary and platform-variant lockfile resolutions by adding runtime installation logic and warm cache key generation. Binary archives are downloaded into the content-addressed store, platform variants are selected using host OS/CPU/libc matching, and new error diagnostics capture host-triple mismatches and unsupported inner resolutions. ChangesBinary and Variant Lockfile Resolution Support
Sequence DiagramsequenceDiagram
participant InstallPackageBySnapshot
participant HostPlatformSelector
participant BinaryFetch
participant CAS
InstallPackageBySnapshot->>HostPlatformSelector: host_platform_selector()
HostPlatformSelector-->>InstallPackageBySnapshot: PlatformSelector (with os/cpu/libc)
alt Binary resolution
InstallPackageBySnapshot->>BinaryFetch: fetch_binary_resolution_to_cas(binary)
BinaryFetch->>CAS: download and store archive
CAS-->>BinaryFetch: relative-path → CAS-path map
BinaryFetch-->>InstallPackageBySnapshot: snapshot map
else Variations resolution
InstallPackageBySnapshot->>HostPlatformSelector: select_platform_variant(variations)
HostPlatformSelector-->>InstallPackageBySnapshot: matching variant
alt Variant is Binary
InstallPackageBySnapshot->>BinaryFetch: fetch_binary_resolution_to_cas(binary)
BinaryFetch->>CAS: download and store archive
CAS-->>InstallPackageBySnapshot: snapshot map
else Variant is not Binary
InstallPackageBySnapshot-->>InstallPackageBySnapshot: error: VariantHasNonBinaryResolution
end
else No matching variant
InstallPackageBySnapshot-->>InstallPackageBySnapshot: error: NoMatchingPlatformVariant
end
Estimated code review effort🎯 4 (Complex) | ⏱️ ~45 minutes Possibly related issues
Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Comment |
|
@coderabbitai full review |
✅ Actions performedFull review triggered. |
Micro-Benchmark ResultsLinux |
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #492 +/- ##
==========================================
- Coverage 88.82% 88.32% -0.50%
==========================================
Files 121 121
Lines 12597 12738 +141
==========================================
+ Hits 11189 11251 +62
- Misses 1408 1487 +79 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Summary
Slice D1 of #437 — wires the runtime fetchers landed in slice C (#472) into the install dispatcher. Replaces the
Binary/Variationsarms ininstall_package_by_snapshot.rsandcreate_virtual_store.rs::snapshot_cache_key. After this slice a frozen-lockfile install can dispatch a runtime resolution end-to-end through the existing CAS-write pipeline (just without the per-archive ignore filter or bin-link cmd-shims yet — see D2 below).LockfileResolution::Binary(b)dispatches onb.archive: tarball usesDownloadTarballToStore, zip usesDownloadZipArchiveToStorewitharchive_prefix: b.prefix.as_deref().LockfileResolution::Variations(v)builds aPlatformSelectorfrompacquet_graph_hasher::{host_platform, host_arch, host_libc}, runsselect_platform_variant, and routes the matched variant's innerBinaryResolutionthrough the same dispatcher. A non-Binaryinner shape (corrupt lockfile or future shape) raises a typed error rather than silently routing.snapshot_cache_keyreturns the proper warm-cache key for both new arms —Binaryusesstore_index_key(integrity, pkg_id);Variationsruns the same selector and keys off the picked variant.InstallPackageBySnapshotError:NoMatchingPlatformVariant— carries the host triple + rendered available-target list so the user can see at a glance why selection failed.VariantHasNonBinaryResolution— defensive guard.What's not in this slice
Splitting the issue's Slice D into smaller PRs (per the established cadence). Follow-up slices:
NODE_EXTRAS_IGNORE_PATTERNfilter forpkg.name == "node"(strip bundlednpm/corepack); bin-link cmd-shims for the runtime executables (binfield onBinaryResolution);@runtime:substring handling in skip lists / reporter prefixes.--no-runtimeflag.--no-runtime, integrity mismatch, path-traversal).Test plan
host_platform_selector_omits_libc_on_non_linux_hosts— pins thehost_libc() == "unknown"⇔selector.libc.is_none()relationship (covers both Linux and non-Linux hosts via the same assertion).render_variant_targets_formats_each_triple_with_optional_libc— locks in theos/cpu[+libc]rendering used byNoMatchingPlatformVariant.just readygreentaplo format --check,just dylint,cargo doc -D warningsgreenEnd-to-end runtime install tests live in slice F (the slice's whole point is to fixture them once the rest of the pipeline is in place).
Written by an agent (Claude Code, claude-opus-4-7).
Summary by CodeRabbit
New Features
Improvements