Repository navigation
refactor(tarball): split the crate root into per-concern modules - #13652
Conversation
`pacquet-tarball`'s `lib.rs` had grown to 3251 lines holding six unrelated concerns. Split along the seams that were already there: - `error` — the error enums and the reqwest source-chain walker - `download` — retry policy, integrity verification, progress events - `extract` — gzip decode and tar entry extraction into the CAS - `zip_archive` — the parallel path for runtime archives - `prefetch` — the bulk store-index read - `local_tarball` — reads of archives already on disk The crate root keeps the shared statics, type aliases, and the resolution-time fetch entry point, and re-exports each module so the public API is unchanged. Named `zip_archive` rather than `zip` so the module cannot shadow the `zip` crate it calls into. Pure code motion: no behavior change, verified by comparing every content line of the original against the union of the new modules. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
|
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:
📝 WalkthroughWalkthroughThe tarball crate is modularized into download, extraction, local-tarball, prefetch, zip-archive, and error modules. The pipelines validate archives, verify integrity, write CAS entries, reuse store-index data, report progress, and retry transient failures. ChangesTarball archive pipeline
Estimated code review effort: 5 (Critical) | ~120 minutes Sequence Diagram(s)sequenceDiagram
participant DownloadTarballToStore
participant HttpClient
participant TarballExtractor
participant StoreDir
DownloadTarballToStore->>HttpClient: fetch tarball
HttpClient-->>DownloadTarballToStore: return response body
DownloadTarballToStore->>TarballExtractor: verify, decompress, and extract
TarballExtractor->>StoreDir: write CAS entries and package index
StoreDir-->>DownloadTarballToStore: return stored paths
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 QodoRefactor tarball crate root into per-concern modules
AI Description
Diagram
High-Level Assessment
Files changed (8)
|
Confidence Score: 5/5The PR appears safe to merge. No blocking failure remains within the eligible scope of this follow-up review. Reviews (8): Last reviewed commit: "docs(tarball): cut the prose that code a..." | Re-trigger Greptile |
Code Review by Qodo
1. Prefetch decode peak-RSS spike
|
Micro-Benchmark ResultsLinux |
There was a problem hiding this comment.
Actionable comments posted: 4
🧹 Nitpick comments (1)
pnpm/crates/tarball/src/zip_archive.rs (1)
534-534: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winDerive the store-index key once.
Line 534 and Line 600 compute the same key with the same inputs. Line 550 moves
cache_keyintoload_cached_cas_paths, so Line 600 recomputes it, including a secondpackage_integrity.to_string()format of the full integrity string.The read path and the write path must always agree on this key. If one call site changes later, warm reinstalls miss silently. Clone the key before the move and reuse it.
♻️ Proposed refactor
if let Some(cas_paths) = load_cached_cas_paths( store_index, store_dir, - cache_key, + cache_key.clone(), verify_store_integrity, verified_files_cache, )- let index_key = store_index_key(&package_integrity.to_string(), package_id); + let index_key = cache_key; if let Some(writer) = store_index_writer {Also applies to: 600-600
🤖 Prompt for 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. In `@pnpm/crates/tarball/src/zip_archive.rs` at line 534, Derive the store-index key once in the surrounding archive flow and preserve a clone before moving it into load_cached_cas_paths. Reuse the cloned key for the later store-index write instead of recomputing package_integrity.to_string() with store_index_key, ensuring both read and write paths use the identical key.
🤖 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/tarball/src/download.rs`:
- Around line 626-635: Update the explanatory comment above the
clippy::too_many_arguments attribute to state 12 arguments and include
download_priority and progress_key in the parameter enumeration, keeping the
existing rationale intact.
- Around line 550-562: Move the retry-policy rustdoc block from
emit_progress_found_in_store to immediately above fetch_and_extract_with_retry,
preserving its full text and documenting the retry function instead of the
progress emitter. Leave the found_in_store emitter with documentation specific
to its progress behavior.
In `@pnpm/crates/tarball/src/lib.rs`:
- Around line 1-21: Reorder the module declarations in the crate root so mod
zip_archive, prefetch, extract, local_tarball, download, and error all appear
before any corresponding pub use or pub(crate) use statements. Preserve every
existing re-export and visibility unchanged.
In `@pnpm/crates/tarball/src/prefetch.rs`:
- Around line 13-38: Move the function-contract documentation describing
reconstruction, verify_store_integrity, None returns, and integrity checks from
the PrefetchedCasPaths type alias to load_cached_cas_paths. Keep the shared
pre-fetched map and Arc-wrapping documentation on PrefetchedCasPaths, and retain
the alias as focused public type documentation.
---
Nitpick comments:
In `@pnpm/crates/tarball/src/zip_archive.rs`:
- Line 534: Derive the store-index key once in the surrounding archive flow and
preserve a clone before moving it into load_cached_cas_paths. Reuse the cloned
key for the later store-index write instead of recomputing
package_integrity.to_string() with store_index_key, ensuring both read and write
paths use the identical key.
🪄 Autofix
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: ee8aea45-ad2f-49d6-af01-12f283a012cd
📒 Files selected for processing (8)
pnpm/crates/tarball/src/download.rspnpm/crates/tarball/src/error.rspnpm/crates/tarball/src/extract.rspnpm/crates/tarball/src/lib.rspnpm/crates/tarball/src/local_tarball.rspnpm/crates/tarball/src/prefetch.rspnpm/crates/tarball/src/tests.rspnpm/crates/tarball/src/zip_archive.rs
PR Code Suggestions ✨Latest suggestions up to c409c46 Warning
Previous suggestionsSuggestions up to commit 337ba19
Suggestions up to commit 5e8c5e7
Suggestions up to commit 8af1393
Suggestions up to commit 8c11027
Suggestions up to commit c8e7074
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## main #13652 +/- ##
==========================================
- Coverage 88.10% 88.07% -0.03%
==========================================
Files 584 590 +6
Lines 98677 98784 +107
==========================================
+ Hits 86935 87005 +70
- Misses 11742 11779 +37 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Both defects predate the split and were carried across by it: The retry-policy doc block sat above `emit_progress_found_in_store`, two items away from the `fetch_and_extract_with_retry` it describes, so rustdoc rendered the retry contract on the progress emitter while the retry function had no documentation at all. The neighbouring comment claimed 9 arguments and enumerated 9; the signature takes 12. `download_priority`, `progress_key`, and `auth_headers` were missing from the enumeration. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
|
Code review by qodo was updated up to the latest commit f51184b |
Each split module reached std and third-party symbols through
`use super::{...}`, binding it to `lib.rs`'s private imports: a module
could not be read on its own to see where a name came from, and any
tidy-up of the root's imports would break modules that never mentioned
those crates.
Each module now imports std and external items directly and keeps
`use super::{...}` for crate-local items only, matching the convention
the other split modules follow. The root sheds the imports it was
holding purely on their behalf.
Also rewrites two comments that explained the current design by
contrasting it with a previous one. Both predate this split. The
rationale and the issue anchors are kept; only the historical framing
goes, per the repository's comment rules.
Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
|
Both Qodo findings are addressed in c8e7074. Fragile Historical phrasing — valid. Both comments predate this split and were carried across, but the repository's comment rules forbid explaining current behavior by contrast with a previous implementation, so they are rewritten in the present tense. The rationale and both issue anchors are preserved: the batched Gates after the change: Written by an agent (Claude Code, claude-opus-5). |
|
Code review by qodo was updated up to the latest commit c8e7074 |
|
On the
Exact-size check on local tarball reads — declining here. The suggestion is reasonable TOCTOU hardening, but it changes a Written by an agent (Claude Code, claude-opus-5). |
… doc Declares every module up front, then the re-exports, rather than interleaving the two. Moves four paragraphs off `PrefetchedCasPaths` and onto `load_cached_cas_paths`, which they describe: they document a `None` return and a `verify_store_integrity` parameter, and the alias is a `HashMap` with neither. The misattribution predates this split. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
|
Code review by qodo was updated up to the latest commit 8c11027 |
…place `extract_tarball_entries` joins entry components by hand so keys stay forward-slashed on every platform: the `index.db` is shared with pnpm, whose path layer is string-based, so `PathBuf`'s native separator would desynchronize the two. Nothing tested that, and the extraction tests are gated off Windows, so a ten-line comment was carrying the invariant on its own. It is now a test, and the comment is the one-line why. Also collapses the warm-cache rationale, which was stated at length in both `run_with_mem_cache` and `run_without_mem_cache`, into one statement per site of what that site actually does, and drops the framing that explained each by contrast with an earlier implementation. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
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
Summary
pacquet-tarball'slib.rshad grown to 3251 lines — the largest production Rust file in the repo after theinstall.rsandcreate_virtual_storesplits landed. It held six unrelated concerns in one file.Split along the seams that were already there:
errordownloadextractzip_archiveprefetchlocal_tarballlib.rsdrops to 674 lines, keeping the shared statics, type aliases, and the resolution-time fetch entry point, and re-exporting each module so the public API is unchanged.The module is named
zip_archiverather thanzipso it cannot shadow thezipcrate it calls into.Squash Commit Body
Split
pacquet-tarball's 3251-line crate root into per-concern modules (error,download,extract,zip_archive,prefetch,local_tarball), leaving the root with the shared statics, type aliases, and resolution-time entry point. Pure code motion; the public API is unchanged.Checklist
lib.rsagainst the union of the new modules (zero lines lost, zero unexpected, modulo visibility prefixes andrustfmtreflow)cargo clippy --workspace --all-targets -D warnings,cargo doc --document-private-items -D warnings, andcargo dylint --allall cleantarball,deps-restorer,package-manager, andcliWritten by an agent (Claude Code, claude-opus-5).
Need help on this PR? Tag
@codesmith-botwith what you need. Autofix is disabled.Summary by CodeRabbit
New Features
file:dependencies, gzip decompression, bundled manifests, and automatic package metadata.Bug Fixes