Repository navigation
Conversation
…workspace A workspace root defined by pnpm-workspace.yaml alone is legal without a root manifest, and the TypeScript CLI never scaffolds one. pacquet's State::init did, which turned the workspace root into a selectable project carrying the init template's failing test script: a verify-deps-before-run install spawned by a recursive run would write the manifest, and a changed-packages filter picking up a root-level change would then select and run it. State::init now uses the scaffold manifest in memory without persisting it when a pnpm-workspace.yaml sits next to the missing package.json. Co-Authored-By: Claude Fable 5 <[email protected]>
The server half of the stage command. POST -/stage/package/:pkg accepts a regular publish document, validates and authorizes it exactly like a direct publish, and holds it back under a fresh UUID stage id instead of committing it. GET -/stage lists the held records (paginated, package filter, filtered to what the caller may publish), GET -/stage/:id and GET -/stage/:id/tarball inspect one, POST -/stage/:id/approve replays the held document through the regular validate/stage/commit publish flow (so a version published in the meantime surfaces as the usual 409), and DELETE -/stage/:id rejects it. Every route has a registry-prefixed twin, and a record is only visible through the address it was staged with. Records persist as two objects (metadata plus the raw publish body) under a reserved .staged/ namespace of the hosted store on both the fs and S3 backends. The leading dot keeps them out of the package namespace, the storage layer validates stage ids before they reach a path or object key, and the package-name listings never surface them. Co-Authored-By: Claude Fable 5 <[email protected]>
Ports pnpm stage with all six subcommands, matching the TypeScript CLI's surface, error codes, endpoints, and output: - stage publish runs the regular publish pipeline (packing, lifecycle scripts, OIDC, OTP/web-auth) against the registry's staging endpoint and renders staged-with-id lines or a name-keyed --json map. - stage list / view read the -/stage API (paginated, package filter with package-scoped auth, version specifiers rejected). - stage approve / reject drive POST -/stage/:id/approve and DELETE -/stage/:id through the shared OTP / web-auth flow, sending any configured --otp on the first attempt. - stage download fetches -/stage/:id/tarball, summarizes the tarball in the publish --json shape, and writes it under a validated filename (package name, semver version, and separator checks block traversal through a hostile manifest). Also fixes the staged-publish route in pacquet-publish: a staged upload now sends POST -/stage/package/:pkg (libnpmpublish's stage route) instead of the regular packument PUT. The path was previously unreachable because the CLI hardcoded stage: false. Supporting refactors: PublishArgs splits its flags into a reusable PublishFlags and returns summaries instead of printing them; the capped response-body reader moves into pacquet-network (shared with dist-tag); pacquet-pack exports its en-locale path sort for the tarball summary. Co-Authored-By: Claude Fable 5 <[email protected]>
Co-Authored-By: Claude Fable 5 <[email protected]>
Co-Authored-By: Claude Fable 5 <[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:
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (2)
🚧 Files skipped from review as they are similar to previous changes (2)
📝 WalkthroughWalkthroughAdds Rust support for two-phase package publishing through ChangesStaged publishing
Estimated code review effort: 5 (Critical) | ~120 minutes Sequence Diagram(s)sequenceDiagram
participant CLI as pnpm stage
participant Registry as pnpr stage routes
participant Storage as staged storage
CLI->>Registry: POST staged publish
Registry->>Storage: write staged body and metadata
CLI->>Registry: GET list/view/download
Registry->>Storage: read staged record or tarball
CLI->>Registry: POST approve or DELETE reject
Registry->>Storage: promote or remove staged data
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 QodoPort
AI Description
Diagram
High-Level Assessment
Files changed (29)
|
Code Review by Qodo
Context used✅ Compliance rules (platform):
18 rules 1.
|
Micro-Benchmark ResultsLinux |
PR Code Suggestions ✨Latest suggestions up to 593c7dd Warning
Previous suggestionsSuggestions up to commit 0a5319b
Suggestions up to commit 8cd7ccc
Suggestions up to commit bbc9366
|
|||||||||||||||||||||||||||||||||||||||||||||||||
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## main #12922 +/- ##
==========================================
- Coverage 85.51% 85.43% -0.08%
==========================================
Files 469 474 +5
Lines 72988 74546 +1558
==========================================
+ Hits 62417 63691 +1274
- Misses 10571 10855 +284 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Actionable comments posted: 5
🧹 Nitpick comments (1)
pnpm/crates/cli/src/cli_args/dispatch_query.rs (1)
238-241: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winRemove the implementation-narrating doc comment.
This explains local control flow rather than a public contract or non-obvious constraint. As per coding guidelines, “Avoid comments that restate code … or narrate the function body.”
🤖 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/cli/src/cli_args/dispatch_query.rs` around lines 238 - 241, Remove the implementation-narrating doc comment immediately above the stage dispatch logic, leaving the code unchanged.Source: Coding guidelines
🤖 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/cli/src/cli_args/dispatch_query.rs`:
- Around line 242-245: Propagate the global recursive report-summary setting in
`stage()` by reading `ctx.recursive_report_summary` and merging it into the
`StageArgs` or publish dispatch path before invoking
`StageArgs::stage_publish()` and `run_recursive()`, matching the behavior in
`publish()` while keeping pacquet and pnpm implementations identical.
In `@pnpm/crates/cli/src/cli_args/stage.rs`:
- Around line 310-349: stage_download currently loads the entire registry
tarball via response.bytes() without limiting attacker-controlled input. Replace
this with the existing read_limited_body helper, using an explicit appropriate
tarball-size cap, and preserve request-failure error mapping before passing the
bounded bytes to summarize_tarball.
- Around line 217-251: Bound pagination in stage_list so repeated full pages or
an inflated response.total cannot cause unbounded requests and memory growth.
Add a hard maximum page count or equivalent fail-safe while preserving the
existing completion checks based on total and page length, and handle the cap
consistently with the command’s error/result behavior.
In `@pnpm/crates/cli/src/cli_args/stage/summarize_tarball.rs`:
- Around line 126-133: Prevent gzip-bomb memory exhaustion in maybe_gunzip by
enforcing a maximum decompressed size while reading from GzDecoder. Use a
bounded reader or otherwise stop decompression once the configured limit is
exceeded, and preserve the existing fallback behavior for invalid or oversized
gzip data by returning the original input bytes.
In `@pnpr/crates/pnpr/src/storage.rs`:
- Around line 525-532: Update remove_staged to treat body deletion as
best-effort after metadata removal: preserve and return the removed result,
catch non-NotFound errors from the staged body removal, and log them instead of
propagating them. Keep expected NotFound handling consistent with existing
cleanup behavior, using remove_staged and the surrounding storage logging
conventions.
---
Nitpick comments:
In `@pnpm/crates/cli/src/cli_args/dispatch_query.rs`:
- Around line 238-241: Remove the implementation-narrating doc comment
immediately above the stage dispatch logic, leaving the code unchanged.
🪄 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: 6f47ee7e-5305-4b51-89e1-e6f57737b568
📒 Files selected for processing (29)
pnpm/crates/cli/Cargo.tomlpnpm/crates/cli/src/cli_args.rspnpm/crates/cli/src/cli_args/cli_command.rspnpm/crates/cli/src/cli_args/dispatch.rspnpm/crates/cli/src/cli_args/dispatch_query.rspnpm/crates/cli/src/cli_args/dist_tag.rspnpm/crates/cli/src/cli_args/publish.rspnpm/crates/cli/src/cli_args/publish/recursive.rspnpm/crates/cli/src/cli_args/publish/tests.rspnpm/crates/cli/src/cli_args/stage.rspnpm/crates/cli/src/cli_args/stage/summarize_tarball.rspnpm/crates/cli/src/cli_args/stage/tests.rspnpm/crates/cli/src/cli_args/switch_cli_version.rspnpm/crates/cli/src/state.rspnpm/crates/cli/tests/stage.rspnpm/crates/cli/tests/workspace_install.rspnpm/crates/network/src/lib.rspnpm/crates/network/src/limited_body.rspnpm/crates/pack/src/lib.rspnpm/crates/package-manifest/src/lib.rspnpm/crates/publish/src/publish_packed_pkg.rspnpm/crates/publish/src/publish_packed_pkg/tests.rspnpr/crates/pnpr/src/s3.rspnpr/crates/pnpr/src/search.rspnpr/crates/pnpr/src/server.rspnpr/crates/pnpr/src/server/staged.rspnpr/crates/pnpr/src/server/staged/tests.rspnpr/crates/pnpr/src/storage.rspnpr/crates/pnpr/tests/staged_publish.rs
- Cap the staged tarball download and its decompression at 512 MiB each; the response bytes are attacker-controlled input and previously went through response.bytes() and an unbounded gunzip. - Bound the stage list pagination loop at 1000 pages in both stacks, so a registry that keeps answering full pages with an inflated total cannot drive it forever (with a changeset for the TypeScript side). - Thread the global --report-summary flag into stage publish and accept it on the stage command, matching publish. - Make the staged-body removal in pnpr best-effort once the metadata is gone, so a body-removal failure cannot orphan an undiscoverable object while misreporting the record as still present. - Fix the staged-list doc comment: records are sorted oldest-first. Co-Authored-By: Claude Fable 5 <[email protected]>
Co-Authored-By: Claude Fable 5 <[email protected]>
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 `@pnpm11/releasing/commands/src/stage/list.ts`:
- Around line 10-12: Add a regression test for the pagination logic in the list
command that mocks registry responses with full pages and an inflated total,
then verifies pagination stops at the MAX_PAGES cap rather than continuing
indefinitely. Assert the resulting request count or termination behavior and
keep the test focused on the MAX_PAGES fail-safe.
🪄 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: 644583c3-e942-4e92-887c-a42f6355f7fd
📒 Files selected for processing (8)
.changeset/stage-list-page-cap.mdpnpm/crates/cli/src/cli_args/cli_command.rspnpm/crates/cli/src/cli_args/dispatch_query.rspnpm/crates/cli/src/cli_args/stage.rspnpm/crates/cli/src/cli_args/stage/summarize_tarball.rspnpm11/releasing/commands/src/stage/list.tspnpr/crates/pnpr/src/server/staged.rspnpr/crates/pnpr/src/storage.rs
✅ Files skipped from review due to trivial changes (1)
- .changeset/stage-list-page-cap.md
🚧 Files skipped from review as they are similar to previous changes (5)
- pnpm/crates/cli/src/cli_args/cli_command.rs
- pnpm/crates/cli/src/cli_args/dispatch_query.rs
- pnpm/crates/cli/src/cli_args/stage/summarize_tarball.rs
- pnpr/crates/pnpr/src/server/staged.rs
- pnpm/crates/cli/src/cli_args/stage.rs
|
Code review by qodo was updated up to the latest commit 8cd7ccc |
Co-Authored-By: Claude Fable 5 <[email protected]>
|
Re the two latest qodo suggestions (up to 8cd7ccc): Serialize approval validation — declined. Validate server-side identifiers — already in place, one layer down: the storage layer rejects any stage id that isn't hex-and-hyphens before it can reach a filesystem path or object key ( The earlier high-level note about Written by an agent (Claude Code, claude-fable-5). |
Summary
Ports
pnpm stageto the Rust CLI and implements the registry side of staged publishing in pnpr, so the two stacks stay at feature parity and the Rust CLI has a real registry to stage against.Rust CLI (
pnpm/):publish(regular publish pipeline against the staging endpoint,+ [email protected] (staged with id …)/(would stage)lines or a name-keyed--jsonmap),list(paginated with package filter and package-scoped auth),view,approve/reject(full OTP / web-auth challenge handling, configured--otpon the first attempt), anddownload(tarball summary in thepublish --jsonshape, with traversal-safe filenames).pacquet-publish: a staged upload now sendsPOST /-/stage/package/:pkg(libnpmpublish's stage route) instead of the regular packumentPUT. This path was previously unreachable because the CLI hardcodedstage: false.pnpr:
POST /-/stage/package/:pkgvalidates and authorizes exactly like a direct publish, then holds the document under a fresh UUID;GET /-/stage(paginated, package filter, filtered to what the caller may publish),GET /-/stage/:id,GET /-/stage/:id/tarball,POST /-/stage/:id/approve(replays through the regular validate → stage → commit flow, so a version published in the meantime surfaces as the usual 409),DELETE /-/stage/:id. Each route has a/~<registry>/-prefixed twin, and a record is only visible through the address it was staged with. Records persist under a reserved.staged/namespace on both the fs and S3 backends.Also fixes a broken test on main (a semantic conflict between two green-merged PRs, #12910 and #12914):
pacquet installscaffolded a rootpackage.jsonat a manifest-less workspace root, which the verify-deps-before-run install wrote to disk and a[<since>]filter then selected as a runnable project with the init template's failingtestscript.State::initnow uses the scaffold in memory without persisting it when apnpm-workspace.yamlsits next to the missing manifest, matching the TypeScript CLI (which never scaffolds).The TypeScript side needed one change, prompted by review:
pnpm stage listgained the same fail-safe pagination cap (1000 pages) as the Rust port, with a patch changeset. The Rust download path additionally caps the tarball body and its decompression at 512 MiB each — following the dist-tag precedent of hardening beyond the TypeScript implementation, which reads these unbounded. One deliberate micro-divergence: a 401 OTP challenge on the read-only stage GETs surfaces asERR_PNPM_STAGE_REGISTRY_ERRORrather than TS's internalSyntheticOtpErrorleaking through; no registry challenges GETs in practice.Squash Commit Body
Checklist
pnpm/port (the TypeScript stage command already exists; this PR is itsRust port, plus the pnpr server side).
stage listpagination cap).Written by an agent (Claude Code, claude-fable-5).
Summary by CodeRabbit
pnpm stage(publish,list,view,approve,reject,download) with both JSON and human-readable output, including staged tarball details.package.jsonscaffolding when onlypnpm-workspace.yamlis present.stage listpagination after excessive pages.stage downloadfilenames/paths safer against traversal.