Skip to content

feat(pnpr): keep hosted package metadata in SQLite - #17551

Merged
zkochan merged 6 commits into
mainfrom
pnpr/sql-metadata-storage
Nov 2, 2026
Merged

zkochan merged 6 commits into
mainfrom
pnpr/sql-metadata-storage

Conversation

@zkochan

@zkochan zkochan commented Nov 2, 2026 •

Copy link
Copy Markdown
Member

Summary

Implements steps 1–3 of the SQL metadata storage RFC and the parts of its step 4 conformance suite that apply to an embedded backend. Part of pnpm/tasks#244. This is the base of a stack: atomic workspace publication builds on it.

Opt-in with:

metadata:
  backend: sqlite   # `documents` (default) keeps today's behavior
  # path: defaults to <storage>/.metadata/metadata.sqlite

What it covers

  • Step 1: metadata split from artifact storage. pnpr_storage::metadata::PackageMetadata is the domain interface: read a package view, commit a package document under compare-and-set, change a tag, remove a package, list packages. Storage routes every document operation through it, so handlers, the publish journal, search, export, verify and migration all reach metadata through one interface. Archives, records and tombstones stay in the HostedBackend. The existing behavior is the documents backend.
  • Step 2: embedded SQLite backend. Tables follow the RFC sketch (versions, accepted_manifests, tags, tag_history, annotations, readmes, plus packages and catalogs). Every key column is NOT NULL. An npm packument is stored as rows. A version's manifest and README are insert-only: a write that changes them fails with 409 version_already_published. Deprecations, tags and package fields change without touching them. The identity of every removed version (package key, version, revision key) goes into an insert-only removed_versions table that survives package removal, and the store refuses to accept one again with 403. Unpublishing a version and removing a package both record it, so no write path can bring a removed version back, including startup recovery of a sealed publish. Cargo, Python and OCI documents are stored whole in the same database. Existing artifact validation and staging are unchanged: archives are verified and promoted before the metadata commit, as today.
  • Generations per hosted catalog. Each commit that changes anything advances its org's counter once and stamps the package with it. Identical writes commit nothing. Counters of different orgs are never compared. Hosted npm package responses and dist-tag responses carry pnpr-generation: <org>:<n>.
  • Domain operation for tags. PUT/DELETE /-/package/:pkg/dist-tags/:tag now calls Storage::change_dist_tag. On SQLite that is one row change plus a tag_history row with the principal and time. Document writes carry a principal too, so a publish, a full-document update and a journal roll-forward record who moved a tag. The journal keeps each package's publisher, so recovery records the original one. It does not rewrite the packument. The documents backend keeps its read-modify-write, moved from the handler into pnpr-storage.
  • Step 3: responses generated from SQL with fragment caching. Per-version fragments are cached by catalog, package, version, revision key, profile, representation, renderer version and, because the full packument embeds a version's deprecation, annotation generation. The key has no accepted generation: a version and revision always name the same bytes, since the store keeps removed versions' identities and never accepts one again. Assembled views are cached by package generation. Fragments are copied into the response bytes without being parsed again. A tag change reuses every fragment, a new release renders one, and a deprecation re-renders one. Tests assert these counts through SqliteMetadata::render_stats. Each read checks the package generation inside its own read transaction, so a cached view is never served stale. Reads run on their own WAL connections and share the caches, so a read never waits for a commit or another read's render. Two reads that miss one view at once may both render it.
  • Step 4, the applicable part. Tests cover: concurrent publishers of one version over two connections (exactly one commits, and the loser's retry gets 409); a stale compare-and-set; restart durability with an identical retry committing nothing (lost commit response); a transaction cut off before COMMIT leaving nothing; a cache that missed an invalidation still serving the current view; per-catalog generations; and a schema-version mismatch being refused; a read completing while the write connection holds an open transaction; and a removed version refused by the store, through HTTP with the tombstone deleted, and by startup recovery of a sealed publish (both backends). Integration tests run publish, read, retag, deprecate, unpublish and restart through HTTP with no package document on disk.

Also in this PR

  • Tombstone before removal. Unpublishing a package writes its tombstone before it removes metadata or archives, so a removal that fails partway still keeps the name from other publishers. A packument rewrite that drops versions records them in the tombstone before it writes, so its rollback is gone.
  • Documents backend. It refuses a write that lists a version its tombstone records as removed, unless the stored document still lists it. That closes the same startup-recovery path there.
  • pnpr migrate-storage --from reads another store's metadata from that store's default SQLite database when it has one, and from its documents otherwise, instead of the configured database.

Not covered (remaining work for this RFC)

  • Abbreviated representation fragments. The response layer still derives the abbreviated form from the full view, after per-request OSV filtering, tarball URL rewriting, and dist.pnpr overlays. Making those fragment-level transforms is follow-up work.
  • Historical revision views and selected_revisions. pnpr hosts no registry revisions yet, so every hosted version is ordinary.
  • publication_outcomes: added with atomic workspace publication (next PR in the stack).
  • Conformance cases that need a shared backend or policy epochs: replica lag, policy revocation racing a commit, and export/import between backends. pnpr migrate-storage reads through the interface, so it can already move SQLite metadata to documents in an object store, but it has no import into SQLite.
  • A minimum-generation request header and a capability flag. With one embedded database every read is already at the latest generation.
  • Benchmarks for packages with thousands of versions. The fragment-reuse counts are tested, but nothing is timed.
  • Existing document stores are not imported into SQLite (pnpr is alpha, per pnpr/AGENTS.md).

Design notes for review

  • One write connection behind a mutex on the blocking pool, WAL with synchronous=FULL, and BEGIN IMMEDIATE for writes. Commits are serialized, and a compare-and-set reads the generation it replaces inside its own transaction. Reads take a connection from a small pool of query_only connections.
  • A sealed publish that would bring back a removed version fails startup recovery with the version named. The operator discards it by removing its journal transaction, as the storage docs say.
  • HostedDocumentVersion::Generation is the compare-and-set token, so the journal, the unpublish rewrite and the maintainers path keep working unchanged.
  • SQLite metadata is rejected together with an s3: block, because it is single-instance.

Squash Commit Body

Add a metadata domain interface to pnpr-storage and an embedded SQLite
backend for it, opt-in through `metadata: { backend: sqlite }`.

`Storage` now reaches package documents through `PackageMetadata`: read a
view, commit a document under compare-and-set, change a tag, remove a
package, list packages. The documents backend keeps today's behavior. The
SQLite backend stores an npm packument as rows: insert-only version
manifests and READMEs, tags with an insert-only history, deprecations, and
package-level state. Other ecosystems' documents are stored whole. Every
commit that changes rows advances its catalog's (org's) generation once.
Hosted npm responses and dist-tag changes report it in `pnpr-generation`.

Reads render the packument from cached per-version fragments and cache the
assembled view by package generation. Each read revalidates the generation
inside its read transaction, so a cached view is never stale. A tag change
reuses every fragment, and a deprecation re-renders one. Reads use their
own connections, so they never wait for a commit.

The store keeps the identities of removed versions and never accepts one
again, on either backend and on every write path, startup recovery
included. Unpublishing writes the tombstone before removing anything.
Document writes record their principal with every tag they move.

Implements steps 1-3 of pnpm/rfcs pnpr/text/0000-sql-metadata-storage.md and
the embedded-backend part of its step 4 conformance suite. Part of
pnpm/tasks#244.

Checklist

  • New features are implemented only in the Rust pnpm v12 CLI. Bug fixes
    are implemented in every affected version. (pnpr only.)
  • Added a changeset (pnpm changeset) if this PR changes any published
    package. Keep it short and written for pnpm users — it becomes a release note.
  • Added or updated tests.
  • Updated the documentation if needed.

Written by an agent (Claude Code, claude-opus-5-5).

🤖 Generated with Claude Code


View with [code]smith Autofix with [code]smith
Need help on this PR? Tag @codesmith-bot with what you need.

Summary by CodeRabbit

  • New Features
    • Added optional SQLite storage for hosted package metadata across supported ecosystems. Package archives remain in hosted storage, and document-based metadata remains the default.
    • Hosted package responses and successful dist-tag changes can include a pnpr-generation header. SQLite-backed npm dist-tag changes retain history and publisher attribution.
  • Bug Fixes
    • Prevented changes to already-published npm versions and republishing unpublished versions, including after a restart.
    • Recorded unpublished-version tombstones before removing package data, protecting against interrupted operations.
  • Documentation
    • Added SQLite configuration, backup, and migration guidance, including storage requirements and the fact that existing package documents are not imported.

@coderabbitai

coderabbitai Bot commented Nov 2, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

No actionable comments were generated in the recent review.

Recent review info
Run configuration
Commits

Reviewing files that changed from the base of the PR and between 5aafdb7 and 09b4f59.

Files selected for processing: 1
  • .changeset/unpublish-tombstone-first.md
Files skipped from review as they are similar to previous changes: 1
  • .changeset/unpublish-tombstone-first.md

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 8 remain after this review.

Walkthrough

This change adds configurable SQLite storage for hosted package metadata. Storage routes package reads and mutations through document-backed or SQLite metadata implementations. SQLite persists package data and tag history, renders package views, and tracks catalog generations used in selected response headers. Tombstone ordering also changes for package rewrites, unpublishing, and publish recovery.

Changes: SQLite package metadata

Layer / File(s) Summary
Configure metadata and route storage operations
pnpr/crates/config/*, pnpr/crates/storage/src/lib.rs, pnpr/crates/storage/src/metadata/*, pnpr/crates/pnpr/src/*
Configuration selects document or SQLite metadata. Storage creates namespace-scoped metadata views and routes package operations through them.
Persist and render metadata
pnpr/crates/storage/src/metadata/sqlite/*
SQLite stores package state, versions, tags, generations, tag history, and removed-version identities. Package views are rendered from stored data and served through bounded caches.
Serve metadata and preserve publish state
pnpr/crates/pnpr/src/server/*, pnpr/crates/storage/src/journal*
Package reads and dist-tag mutations use metadata operations. Responses can include catalog generations. Publish principals are carried through journal recovery, and tombstones are recorded before dependent changes.
Validate integrations and document behavior
pnpr/crates/pnpr/tests/*, pnpr/crates/storage/src/*/tests*, pnpr/docs/*, .changeset/*
Tests cover persistence, conflicts, concurrency, restart, migration, recovery, publishing, unpublishing, and configuration. Documentation describes SQLite setup, backup, migration, and runtime behavior.

Estimated code review effort: 5 (Critical) | ~90 minutes

Change: Feature

Sequence Diagram(s)

sequenceDiagram
  participant Client
  participant PackageMutation
  participant Storage
  participant MetadataBackend
  participant SQLite
  Client->>PackageMutation: Submit package or dist-tag mutation
  PackageMutation->>Storage: Write metadata with principal
  Storage->>MetadataBackend: Apply conditional change
  MetadataBackend->>SQLite: Commit state, history, and generation
  SQLite-->>MetadataBackend: Return committed result
  MetadataBackend-->>PackageMutation: Return result and generation
  PackageMutation-->>Client: Return response with generation when available
Loading

Suggested labels: product: pnpr

Suggested reviewers: qodo-code-review

Merge Risk: Minimal · up to 09b4f

No actionable issue remains in the supplied change; it is mergeable after normal checks.

Finishing Touches
Generate unit tests (beta)
  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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.

Share

@github-actions

github-actions Bot commented Nov 2, 2026 •

Copy link
Copy Markdown
Contributor

Micro-Benchmark Results

Linux

group                                            main                                   pr
-----                                            ----                                   --
lockfile/parse_pnpm_lock                         1.10     14.4±1.47ms    26.0 MB/sec    1.00     13.1±1.13ms    28.5 MB/sec
packument/parse                                  1.02     43.0±1.89µs  1542.4 MB/sec    1.00     42.0±0.40µs  1579.9 MB/sec
tarball/download_dependency                      1.09  882.7±122.06µs     4.8 MB/sec    1.00   809.0±66.37µs     5.2 MB/sec
tarball_batch/cold_store_many_medium_tarballs    1.01    215.0±5.51ms 74.4 KElem/sec    1.00   213.2±18.18ms 75.1 KElem/sec
version_pick/repeated_ranges_file                1.05      4.6±0.06ms  6.9 KElem/sec    1.00      4.3±0.18ms  7.2 KElem/sec
version_pick/repeated_ranges_raw                 1.05      4.5±0.26ms  6.9 KElem/sec    1.00      4.3±0.05ms  7.2 KElem/sec
workspace_resolution/hoist_heavy                 1.05   268.0±17.53ms        ? ?/sec    1.00    256.1±6.20ms        ? ?/sec
workspace_sort/chained_projects                  1.00     13.4±1.16ms        ? ?/sec    1.12     15.0±1.96ms        ? ?/sec

@github-actions

github-actions Bot commented Nov 2, 2026 •

Copy link
Copy Markdown
Contributor

Same-run regression check

HEAD 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.

Scenario Engine main median HEAD median Change Tolerance Result
isolated-fresh-restore-cold-cache-cold-store pacquet 2391.42 ms 2296.04 ms -4.0% 119.57 ms Within tolerance
isolated-fresh-restore-cold-cache-cold-store pnpr 1367.06 ms 1500.94 ms 9.8% 68.35 ms Inconclusive (overlapping samples)
isolated-fresh-restore-hot-cache-hot-store pacquet 404.68 ms 389.88 ms -3.7% 20.23 ms Within tolerance
isolated-fresh-restore-hot-cache-hot-store pnpr 421.43 ms 439.37 ms 4.3% 21.07 ms Within tolerance
isolated-repeat-install-hot-cache-hot-store pacquet 11.35 ms 11.41 ms 0.5% 2.00 ms Within tolerance
isolated-repeat-install-hot-cache-hot-store pnpr 10.53 ms 11.04 ms 4.8% 2.00 ms Within tolerance
isolated-repeat-install-cold-cache-hot-store pacquet 10.39 ms 10.55 ms 1.5% 2.00 ms Within tolerance
isolated-repeat-install-cold-cache-hot-store pnpr 10.52 ms 10.60 ms 0.8% 2.00 ms Within tolerance
isolated-fresh-install-cold-cache-cold-store pacquet 2548.28 ms 2611.74 ms 2.5% 127.41 ms Within tolerance
isolated-fresh-install-cold-cache-cold-store pnpr 1483.65 ms 1636.02 ms 10.3% 74.18 ms Inconclusive (overlapping samples)
isolated-fresh-install-hot-cache-hot-store pacquet 604.80 ms 666.82 ms 10.3% 30.24 ms Inconclusive (overlapping samples)
isolated-fresh-install-hot-cache-hot-store pnpr 361.00 ms 351.20 ms -2.7% 18.05 ms Within tolerance
isolated-fresh-install-cold-cache-hot-store pacquet 1619.70 ms 1653.12 ms 2.1% 80.98 ms Within tolerance
isolated-fresh-install-cold-cache-hot-store pnpr 316.15 ms 308.73 ms -2.3% 15.81 ms Within tolerance
isolated-fresh-resolve-hot-cache-offline pacquet 268.93 ms 274.35 ms 2.0% 13.45 ms Within tolerance
isolated-fresh-resolve-hot-cache-offline pnpr 94.22 ms 93.14 ms -1.1% 4.71 ms Within tolerance
isolated-peer-heavy-resolve-hot-cache-offline pacquet 221.85 ms 221.82 ms -0.0% 11.09 ms Within tolerance
isolated-linked-workspace-resolve-hot-cache-offline pacquet 89.04 ms 87.99 ms -1.2% 4.45 ms Within tolerance
isolated-injected-workspace-repeat-install-hot-cache-hot-store pacquet 102.76 ms 102.88 ms 0.1% 5.14 ms Within tolerance
isolated-fresh-restore-cold-cache-cold-store-cold-pnpr pacquet 4745.39 ms 4528.52 ms -4.6% 237.27 ms Within tolerance
isolated-fresh-restore-cold-cache-cold-store-cold-pnpr pnpr 3524.77 ms 3736.85 ms 6.0% 176.24 ms Inconclusive (overlapping samples)
gvs-fresh-restore-hot-cache-hot-store pacquet 142.86 ms 190.44 ms 33.3% 7.14 ms Inconclusive (overlapping samples)
gvs-fresh-restore-hot-cache-hot-store pnpr 155.16 ms 152.49 ms -1.7% 7.76 ms Within tolerance
store-only-unlocked-direct-deps-cold-cache-hot-store pacquet 1238.68 ms 1240.69 ms 0.2% 61.93 ms Within tolerance
cargo-repeat-install-hot-cache-hot-store pacquet 32.45 ms 35.00 ms 7.9% 2.00 ms Inconclusive (overlapping samples)

Same-run syscall check

Each install runs 2 more times per revision, untimed, under strace --follow-forks --summary-only. A file syscall regresses when HEAD's fewest calls exceed main's most by more than 2% of main or 50 calls, whichever is larger. mkdir and mkdirat count only the calls that created a directory, since concurrent installs fail a varying number with EEXIST. A syscall whose identical runs differ by more than that tolerance is reported unstable and not gated, unless HEAD's fewest calls also exceed main's most by more than the tolerance plus that difference. Each scenario lists its largest change relative to its tolerance and every row that is not within tolerance.

Scenario Engine Syscall main calls (max) HEAD calls (min) Change Tolerance Identical-run spread Result
isolated-fresh-restore-cold-cache-cold-store pacquet ioctl 13 23 +76.9% 50 2 Within tolerance
isolated-fresh-restore-cold-cache-cold-store pnpr symlink 3885 3887 +0.1% 77 3 Within tolerance
isolated-fresh-restore-hot-cache-hot-store pacquet access 11 11 +0.0% 50 0 Within tolerance
isolated-fresh-restore-hot-cache-hot-store pnpr access 11 11 +0.0% 50 0 Within tolerance
isolated-repeat-install-hot-cache-hot-store pacquet access 8 8 +0.0% 50 0 Within tolerance
isolated-repeat-install-hot-cache-hot-store pnpr access 8 8 +0.0% 50 0 Within tolerance
isolated-repeat-install-cold-cache-hot-store pacquet access 8 8 +0.0% 50 0 Within tolerance
isolated-repeat-install-cold-cache-hot-store pnpr access 8 8 +0.0% 50 0 Within tolerance
isolated-fresh-install-cold-cache-cold-store pacquet openat 64010 64012 +0.0% 1280 11 Within tolerance
isolated-fresh-install-cold-cache-cold-store pacquet readlink 16574 16105 -2.8% 331 747 Unstable (identical runs differ by 747, not gated)
isolated-fresh-install-cold-cache-cold-store pnpr access 11 11 +0.0% 50 0 Within tolerance
isolated-fresh-install-hot-cache-hot-store pacquet access 11 11 +0.0% 50 0 Within tolerance
isolated-fresh-install-hot-cache-hot-store pnpr readlink 15286 15287 +0.0% 305 41 Within tolerance
isolated-fresh-install-cold-cache-hot-store pacquet access 11 11 +0.0% 50 0 Within tolerance
isolated-fresh-install-cold-cache-hot-store pnpr statx 48986 48987 +0.0% 979 2 Within tolerance
isolated-fresh-resolve-hot-cache-offline pacquet access 8 8 +0.0% 50 0 Within tolerance
isolated-fresh-resolve-hot-cache-offline pnpr access 8 8 +0.0% 50 0 Within tolerance
isolated-peer-heavy-resolve-hot-cache-offline pacquet access 8 8 +0.0% 50 0 Within tolerance
isolated-linked-workspace-resolve-hot-cache-offline pacquet access 8 8 +0.0% 50 0 Within tolerance
isolated-injected-workspace-repeat-install-hot-cache-hot-store pacquet access 11 11 +0.0% 50 0 Within tolerance
isolated-fresh-restore-cold-cache-cold-store-cold-pnpr pacquet readlink 15292 15303 +0.1% 305 15 Within tolerance
isolated-fresh-restore-cold-cache-cold-store-cold-pnpr pnpr access 11 11 +0.0% 50 0 Within tolerance
gvs-fresh-restore-hot-cache-hot-store pacquet access 11 11 +0.0% 50 0 Within tolerance
gvs-fresh-restore-hot-cache-hot-store pnpr access 11 11 +0.0% 50 0 Within tolerance
store-only-unlocked-direct-deps-cold-cache-hot-store pacquet access 8 8 +0.0% 50 0 Within tolerance
cargo-repeat-install-hot-cache-hot-store pacquet access 22 22 +0.0% 50 0 Within tolerance

Integrated-Benchmark Report (Linux)

Commit: 09b4f593d749

Compared against main at: 58762ee53dc3

Regular scenarios report direct and pnpr installs. The peer-heavy resolver scenario compares current Rust, main Rust, and TypeScript pnpm; the linked, injected, and Cargo 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

Command Mean [s] Min [s] Max [s] Relative
pacquet@HEAD 2.379 ± 0.146 2.238 2.587 1.70 ± 0.17
pacquet@main 2.378 ± 0.106 2.213 2.581 1.70 ± 0.15
pnpr@HEAD 1.490 ± 0.117 1.323 1.671 1.06 ± 0.12
pnpr@main 1.401 ± 0.111 1.290 1.587 1.00
BENCHMARK_REPORT.json
{
  "results": [
    {
      "command": "pacquet@HEAD",
      "mean": 2.37927632856,
      "stddev": 0.14572617972833662,
      "median": 2.29603574106,
      "user": 1.9299282799999997,
      "system": 1.4621436600000002,
      "min": 2.23831986406,
      "max": 2.58657047406
    },
    {
      "command": "pacquet@main",
      "mean": 2.3783275036600005,
      "stddev": 0.10585682387195094,
      "median": 2.39142034806,
      "user": 1.8776401799999995,
      "system": 1.5163942600000002,
      "min": 2.21313473006,
      "max": 2.58055597306
    },
    {
      "command": "pnpr@HEAD",
      "mean": 1.48993920316,
      "stddev": 0.11743816677539864,
      "median": 1.50093560056,
      "user": 1.86372978,
      "system": 1.4884404599999999,
      "min": 1.32311394106,
      "max": 1.6708286110600001
    },
    {
      "command": "pnpr@main",
      "mean": 1.40099187036,
      "stddev": 0.11060327201741407,
      "median": 1.36706469356,
      "user": 1.7723014799999999,
      "system": 1.4905222599999999,
      "min": 1.28977362206,
      "max": 1.58661580106
    }
  ]
}

Scenario: Isolated linker: fresh restore, hot cache + hot store

Command Mean [ms] Min [ms] Max [ms] Relative
pacquet@HEAD 392.6 ± 11.8 373.0 413.9 1.00
pacquet@main 407.1 ± 26.4 356.1 444.2 1.04 ± 0.07
pnpr@HEAD 446.0 ± 30.3 417.4 503.6 1.14 ± 0.08
pnpr@main 424.6 ± 28.7 380.1 489.4 1.08 ± 0.08
BENCHMARK_REPORT.json
{
  "results": [
    {
      "command": "pacquet@HEAD",
      "mean": 0.39255396088,
      "stddev": 0.011833904599099698,
      "median": 0.38988428517999996,
      "user": 0.46440348,
      "system": 0.8123435200000001,
      "min": 0.37304250718,
      "max": 0.41393808718
    },
    {
      "command": "pacquet@main",
      "mean": 0.40708880197999997,
      "stddev": 0.0263717056159697,
      "median": 0.40467957918,
      "user": 0.4721676799999999,
      "system": 0.84859512,
      "min": 0.35605150418,
      "max": 0.44422076718000003
    },
    {
      "command": "pnpr@HEAD",
      "mean": 0.44603160968,
      "stddev": 0.030342584249393977,
      "median": 0.43937462017999995,
      "user": 0.49362567999999996,
      "system": 0.8430267199999999,
      "min": 0.41736353818,
      "max": 0.50356094418
    },
    {
      "command": "pnpr@main",
      "mean": 0.4246443294800001,
      "stddev": 0.02871441745729536,
      "median": 0.42143386268,
      "user": 0.48406547999999994,
      "system": 0.8469856200000001,
      "min": 0.38009728718,
      "max": 0.48941096718
    }
  ]
}

Scenario: Isolated linker: repeat install, hot cache + hot store

Command Mean [ms] Min [ms] Max [ms] Relative
pacquet@HEAD 11.5 ± 1.2 9.4 16.6 1.08 ± 0.16
pacquet@main 11.6 ± 1.5 9.0 19.0 1.09 ± 0.18
pnpr@HEAD 11.1 ± 0.9 9.4 13.6 1.05 ± 0.13
pnpr@main 10.7 ± 1.0 8.8 14.0 1.00
BENCHMARK_REPORT.json
{
  "results": [
    {
      "command": "pacquet@HEAD",
      "mean": 0.011536899199074071,
      "stddev": 0.0012213196744214718,
      "median": 0.011407201500000002,
      "user": 0.006311722222222226,
      "system": 0.006231893055555555,
      "min": 0.009364016000000001,
      "max": 0.016589520000000003
    },
    {
      "command": "pacquet@main",
      "mean": 0.011647653735042732,
      "stddev": 0.001479202150651834,
      "median": 0.011351185500000001,
      "user": 0.006989153846153847,
      "system": 0.00568455598290598,
      "min": 0.008969955,
      "max": 0.018992120000000005
    },
    {
      "command": "pnpr@HEAD",
      "mean": 0.011149367442553198,
      "stddev": 0.0008590234361464007,
      "median": 0.011036863000000001,
      "user": 0.006947202127659575,
      "system": 0.00528323855319149,
      "min": 0.009373781000000001,
      "max": 0.013635419000000001
    },
    {
      "command": "pnpr@main",
      "mean": 0.010664555799180325,
      "stddev": 0.001044383176173407,
      "median": 0.010531448500000002,
      "user": 0.005876364754098358,
      "system": 0.005760832704918035,
      "min": 0.008793166,
      "max": 0.014034994
    }
  ]
}

Scenario: Isolated linker: repeat install, cold cache + hot store

Command Mean [ms] Min [ms] Max [ms] Relative
pacquet@HEAD 10.6 ± 1.0 9.4 22.9 1.01 ± 0.12
pacquet@main 10.5 ± 0.8 8.9 13.1 1.00
pnpr@HEAD 10.6 ± 0.7 9.3 13.0 1.01 ± 0.10
pnpr@main 10.5 ± 0.9 8.7 12.9 1.00 ± 0.11
BENCHMARK_REPORT.json
{
  "results": [
    {
      "command": "pacquet@HEAD",
      "mean": 0.010640531488837209,
      "stddev": 0.0010255055981051116,
      "median": 0.01054787934,
      "user": 0.006077153023255816,
      "system": 0.005758693023255812,
      "min": 0.00941950834,
      "max": 0.022888092340000003
    },
    {
      "command": "pacquet@main",
      "mean": 0.01049042117606557,
      "stddev": 0.0007864612871038078,
      "median": 0.01038692934,
      "user": 0.006030420409836069,
      "system": 0.005697328688524593,
      "min": 0.00891998734,
      "max": 0.01310883234
    },
    {
      "command": "pnpr@HEAD",
      "mean": 0.010616044473027515,
      "stddev": 0.0007243522760769688,
      "median": 0.010599439839999999,
      "user": 0.006647995779816514,
      "system": 0.005224261467889908,
      "min": 0.00926777834,
      "max": 0.013034692340000001
    },
    {
      "command": "pnpr@main",
      "mean": 0.010524613339999999,
      "stddev": 0.0008754338489280974,
      "median": 0.01051750434,
      "user": 0.005690266730769231,
      "system": 0.006058808653846157,
      "min": 0.00873898834,
      "max": 0.01287394134
    }
  ]
}

Scenario: Isolated linker: fresh install, cold cache + cold store

Command Mean [s] Min [s] Max [s] Relative
pacquet@HEAD 2.610 ± 0.044 2.533 2.687 1.75 ± 0.11
pacquet@main 2.553 ± 0.043 2.498 2.653 1.71 ± 0.11
pnpr@HEAD 1.606 ± 0.128 1.404 1.783 1.07 ± 0.11
pnpr@main 1.495 ± 0.089 1.375 1.655 1.00
BENCHMARK_REPORT.json
{
  "results": [
    {
      "command": "pacquet@HEAD",
      "mean": 2.6099831015999997,
      "stddev": 0.043662309454098255,
      "median": 2.6117432759,
      "user": 2.48883444,
      "system": 1.7782253799999999,
      "min": 2.5325515459,
      "max": 2.6867570619
    },
    {
      "command": "pacquet@main",
      "mean": 2.5528714255,
      "stddev": 0.04320792022672076,
      "median": 2.5482764473999997,
      "user": 2.38149494,
      "system": 1.68204098,
      "min": 2.4979278699,
      "max": 2.6529805458999998
    },
    {
      "command": "pnpr@HEAD",
      "mean": 1.6058489519,
      "stddev": 0.12766891429471994,
      "median": 1.6360208003999999,
      "user": 1.7795435399999995,
      "system": 1.42258108,
      "min": 1.4043507789,
      "max": 1.7825786579
    },
    {
      "command": "pnpr@main",
      "mean": 1.4954803096,
      "stddev": 0.0889819938649053,
      "median": 1.4836512349,
      "user": 1.7637743399999999,
      "system": 1.37450728,
      "min": 1.3751200069,
      "max": 1.6547765149
    }
  ]
}

Scenario: Isolated linker: fresh install, hot cache + hot store

Command Mean [ms] Min [ms] Max [ms] Relative
pacquet@HEAD 650.4 ± 52.5 571.9 721.4 1.84 ± 0.16
pacquet@main 598.5 ± 29.2 552.0 646.7 1.70 ± 0.10
pnpr@HEAD 352.6 ± 10.0 339.3 368.1 1.00
pnpr@main 362.1 ± 13.7 341.3 384.1 1.03 ± 0.05
BENCHMARK_REPORT.json
{
  "results": [
    {
      "command": "pacquet@HEAD",
      "mean": 0.65038975372,
      "stddev": 0.0525152911210869,
      "median": 0.66681560222,
      "user": 1.00751408,
      "system": 1.37680004,
      "min": 0.57186903622,
      "max": 0.72138794322
    },
    {
      "command": "pacquet@main",
      "mean": 0.59847545542,
      "stddev": 0.029196835021252025,
      "median": 0.60480026722,
      "user": 0.95856908,
      "system": 1.2330945400000002,
      "min": 0.55203407422,
      "max": 0.64668959022
    },
    {
      "command": "pnpr@HEAD",
      "mean": 0.35257336072,
      "stddev": 0.009973388871278955,
      "median": 0.35120263922000006,
      "user": 0.34107118,
      "system": 0.65365544,
      "min": 0.33927989722000007,
      "max": 0.36806620522000005
    },
    {
      "command": "pnpr@main",
      "mean": 0.36214489252000004,
      "stddev": 0.013692674967357894,
      "median": 0.36100429772000003,
      "user": 0.34864497999999994,
      "system": 0.6829640399999999,
      "min": 0.34131189522000005,
      "max": 0.3840955602200001
    }
  ]
}

Scenario: Isolated linker: fresh install, cold cache + hot store

Command Mean [s] Min [s] Max [s] Relative
pacquet@HEAD 1.652 ± 0.027 1.616 1.685 5.35 ± 0.25
pacquet@main 1.623 ± 0.023 1.597 1.679 5.25 ± 0.24
pnpr@HEAD 0.309 ± 0.014 0.292 0.333 1.00
pnpr@main 0.322 ± 0.018 0.296 0.357 1.04 ± 0.07
BENCHMARK_REPORT.json
{
  "results": [
    {
      "command": "pacquet@HEAD",
      "mean": 1.6524099215799999,
      "stddev": 0.02667075237878778,
      "median": 1.65311833788,
      "user": 0.9749414399999999,
      "system": 0.92252718,
      "min": 1.61616675488,
      "max": 1.68497552488
    },
    {
      "command": "pacquet@main",
      "mean": 1.62270077988,
      "stddev": 0.023093289564776003,
      "median": 1.61969519538,
      "user": 0.9105668399999999,
      "system": 0.91041978,
      "min": 1.5965916228800001,
      "max": 1.67854378988
    },
    {
      "command": "pnpr@HEAD",
      "mean": 0.30890101678000004,
      "stddev": 0.013656602562794039,
      "median": 0.30872755688000003,
      "user": 0.26506604,
      "system": 0.6182401800000001,
      "min": 0.29197424788000004,
      "max": 0.33349945788
    },
    {
      "command": "pnpr@main",
      "mean": 0.32246581058,
      "stddev": 0.01756016709660576,
      "median": 0.31614609188000004,
      "user": 0.27997584000000003,
      "system": 0.65042858,
      "min": 0.29641317588000005,
      "max": 0.35745172888000004
    }
  ]
}

Scenario: Isolated linker: fresh resolve, hot cache, offline

Command Mean [ms] Min [ms] Max [ms] Relative
pacquet@HEAD 274.9 ± 11.5 254.2 295.9 2.94 ± 0.16
pacquet@main 269.2 ± 15.7 243.6 295.1 2.88 ± 0.20
pnpr@HEAD 93.5 ± 3.3 86.4 100.6 1.00
pnpr@main 94.4 ± 3.4 87.2 102.4 1.01 ± 0.05
BENCHMARK_REPORT.json
{
  "results": [
    {
      "command": "pacquet@HEAD",
      "mean": 0.27492848036,
      "stddev": 0.011546540234219636,
      "median": 0.27435081126000005,
      "user": 0.24891996,
      "system": 0.32803976,
      "min": 0.25417798576,
      "max": 0.29593236476
    },
    {
      "command": "pacquet@main",
      "mean": 0.26916015006000005,
      "stddev": 0.015722602018914716,
      "median": 0.26893326926000005,
      "user": 0.25918315999999997,
      "system": 0.31009425999999995,
      "min": 0.24360372276000003,
      "max": 0.29510639176000003
    },
    {
      "command": "pnpr@HEAD",
      "mean": 0.09345542636000001,
      "stddev": 0.003263284127116019,
      "median": 0.09314403926,
      "user": 0.040080126666666674,
      "system": 0.020213874666666666,
      "min": 0.08636401776000001,
      "max": 0.10062939576000002
    },
    {
      "command": "pnpr@main",
      "mean": 0.09435288799333334,
      "stddev": 0.0033727403908915196,
      "median": 0.09422186926000001,
      "user": 0.031328126666666664,
      "system": 0.029424493333333326,
      "min": 0.08718067876000002,
      "max": 0.10237977276000002
    }
  ]
}

Scenario: Isolated linker: peer-heavy resolve, hot cache, offline

Command Mean [ms] Min [ms] Max [ms] Relative
pacquet@HEAD 221.4 ± 7.7 204.7 233.2 1.00
pacquet@main 227.4 ± 11.6 213.6 248.2 1.03 ± 0.06
pnpm@HEAD 3849.1 ± 84.1 3730.5 4025.2 17.38 ± 0.71
BENCHMARK_REPORT.json
{
  "results": [
    {
      "command": "pacquet@HEAD",
      "mean": 0.22140639975777782,
      "stddev": 0.0076797232222505065,
      "median": 0.22181518098,
      "user": 0.24745764000000003,
      "system": 0.050178837777777784,
      "min": 0.20469989698,
      "max": 0.23321781398
    },
    {
      "command": "pacquet@main",
      "mean": 0.22739708675777776,
      "stddev": 0.011588657124793613,
      "median": 0.22184940698,
      "user": 0.2546277511111111,
      "system": 0.043718726666666666,
      "min": 0.21357784698,
      "max": 0.24821045298
    },
    {
      "command": "pnpm@HEAD",
      "mean": 3.84907380398,
      "stddev": 0.0840994342154224,
      "median": 3.85708832198,
      "user": 5.912663195555555,
      "system": 0.3799739488888888,
      "min": 3.7304939309800003,
      "max": 4.02520869898
    }
  ]
}

Scenario: Isolated linker: linked-workspace resolve, hot cache, offline

Command Mean [ms] Min [ms] Max [ms] Relative
pacquet@HEAD 89.5 ± 5.1 82.2 105.5 1.00
pacquet@main 90.2 ± 5.3 83.6 108.0 1.01 ± 0.08
BENCHMARK_REPORT.json
{
  "results": [
    {
      "command": "pacquet@HEAD",
      "mean": 0.0895037586369697,
      "stddev": 0.005074673981410847,
      "median": 0.08799022294000002,
      "user": 0.08517581212121213,
      "system": 0.054245256969696974,
      "min": 0.08218873794,
      "max": 0.10549915494
    },
    {
      "command": "pacquet@main",
      "mean": 0.09016963467529412,
      "stddev": 0.0052523898608525296,
      "median": 0.08903761544000001,
      "user": 0.08646327647058824,
      "system": 0.05513532470588236,
      "min": 0.08364610294000001,
      "max": 0.10803997894000002
    }
  ]
}

Scenario: Isolated linker: injected workspace repeat install, hot cache + hot store

Command Mean [ms] Min [ms] Max [ms] Relative
pacquet@HEAD 102.9 ± 6.1 91.4 119.5 1.00
pacquet@main 103.7 ± 7.7 94.5 122.7 1.01 ± 0.10
BENCHMARK_REPORT.json
{
  "results": [
    {
      "command": "pacquet@HEAD",
      "mean": 0.10291318054285715,
      "stddev": 0.0060928759595200695,
      "median": 0.10288012540000001,
      "user": 0.036550005714285703,
      "system": 0.07506794857142855,
      "min": 0.09136547440000001,
      "max": 0.1195464224
    },
    {
      "command": "pacquet@main",
      "mean": 0.10365415805517239,
      "stddev": 0.007717101634943145,
      "median": 0.1027577744,
      "user": 0.03870925448275862,
      "system": 0.0735445717241379,
      "min": 0.0944852484,
      "max": 0.1227094254
    }
  ]
}

Scenario: Isolated linker: fresh restore, cold cache + cold store + cold pnpr

Command Mean [s] Min [s] Max [s] Relative
pacquet@HEAD 4.578 ± 0.173 4.423 4.989 1.30 ± 0.06
pacquet@main 4.752 ± 0.156 4.522 5.074 1.35 ± 0.06
pnpr@HEAD 3.759 ± 0.126 3.555 4.021 1.07 ± 0.04
pnpr@main 3.522 ± 0.085 3.425 3.675 1.00
BENCHMARK_REPORT.json
{
  "results": [
    {
      "command": "pacquet@HEAD",
      "mean": 4.578009518040001,
      "stddev": 0.17301924363731822,
      "median": 4.52852377704,
      "user": 2.30576386,
      "system": 1.62558488,
      "min": 4.42257562804,
      "max": 4.98857310204
    },
    {
      "command": "pacquet@main",
      "mean": 4.75237294454,
      "stddev": 0.1563985763408673,
      "median": 4.74539145704,
      "user": 2.46542946,
      "system": 1.8398360799999995,
      "min": 4.52222165104,
      "max": 5.07406453704
    },
    {
      "command": "pnpr@HEAD",
      "mean": 3.7593864467399998,
      "stddev": 0.12580594134993825,
      "median": 3.7368516305400004,
      "user": 2.29369296,
      "system": 1.8392822799999997,
      "min": 3.55497563804,
      "max": 4.02075950304
    },
    {
      "command": "pnpr@main",
      "mean": 3.5221145138400005,
      "stddev": 0.08482579581720465,
      "median": 3.5247714865399997,
      "user": 1.9643324600000003,
      "system": 1.4503135800000002,
      "min": 3.42512376004,
      "max": 3.67529647604
    }
  ]
}

Scenario: GVS linker: fresh restore, hot cache + hot store

Same 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.

Command Mean [ms] Min [ms] Max [ms] Relative
pacquet@HEAD 187.2 ± 26.6 146.7 240.2 1.25 ± 0.24
pacquet@main 149.7 ± 18.6 132.0 193.5 1.00
pnpr@HEAD 153.0 ± 5.9 143.9 165.7 1.02 ± 0.13
pnpr@main 156.2 ± 5.1 149.2 166.6 1.04 ± 0.13
BENCHMARK_REPORT.json
{
  "results": [
    {
      "command": "pacquet@HEAD",
      "mean": 0.18720737803499998,
      "stddev": 0.026643009159116555,
      "median": 0.19044313216,
      "user": 0.2348582225,
      "system": 0.20891734249999996,
      "min": 0.14666280116,
      "max": 0.24016860716000002
    },
    {
      "command": "pacquet@main",
      "mean": 0.14968992196000003,
      "stddev": 0.018643437107244833,
      "median": 0.14285538116000002,
      "user": 0.18429842666666668,
      "system": 0.17377567999999996,
      "min": 0.13197041516000002,
      "max": 0.19351441916
    },
    {
      "command": "pnpr@HEAD",
      "mean": 0.15300919016,
      "stddev": 0.005887323360805219,
      "median": 0.15248650916,
      "user": 0.17914739529411763,
      "system": 0.1680466329411765,
      "min": 0.14393782116,
      "max": 0.16571661116
    },
    {
      "command": "pnpr@main",
      "mean": 0.15616214342666665,
      "stddev": 0.005145775001390224,
      "median": 0.15515841616,
      "user": 0.19414849333333334,
      "system": 0.15993921333333336,
      "min": 0.14924431116,
      "max": 0.16657172216000002
    }
  ]
}

Scenario: Store only: unlocked direct deps, cold cache + hot store

Store-only install (enableModulesDir: false, per-file store index, trusted lockfile) against a lockfile missing the direct dependencies that have peers, with the metadata cache wiped per iteration: the install resolves those from the registry, reuses their subtrees from the lockfile and checks the store, linking nothing. Direct installs only.

Command Mean [s] Min [s] Max [s] Relative
pacquet@HEAD 1.265 ± 0.059 1.202 1.344 1.01 ± 0.07
pacquet@main 1.255 ± 0.073 1.158 1.380 1.00
BENCHMARK_REPORT.json
{
  "results": [
    {
      "command": "pacquet@HEAD",
      "mean": 1.26531403414,
      "stddev": 0.05870877028277704,
      "median": 1.24069083954,
      "user": 0.67956974,
      "system": 0.25792307999999997,
      "min": 1.20156888554,
      "max": 1.34356990154
    },
    {
      "command": "pacquet@main",
      "mean": 1.25541458564,
      "stddev": 0.07263266498089838,
      "median": 1.2386836135400001,
      "user": 0.70100344,
      "system": 0.26168568000000003,
      "min": 1.15798683854,
      "max": 1.3804962765400002
    }
  ]
}

Scenario: Cargo: repeat install, hot cache + hot store

Frozen repeat install of a Cargo workspace (cargo.enabled: true) whose crates are already materialized in <storeDir>/v11/crates/ and linked into .pnpm/crates/crates-io. Direct installs only.

Command Mean [ms] Min [ms] Max [ms] Relative
pacquet@HEAD 35.7 ± 3.4 30.8 44.4 1.08 ± 0.13
pacquet@main 33.0 ± 2.4 29.7 40.0 1.00
BENCHMARK_REPORT.json
{
  "results": [
    {
      "command": "pacquet@HEAD",
      "mean": 0.035736636898695655,
      "stddev": 0.0034281715821289863,
      "median": 0.035004110039999994,
      "user": 0.02642359217391305,
      "system": 0.019752350869565206,
      "min": 0.030833996040000002,
      "max": 0.044428555040000005
    },
    {
      "command": "pacquet@main",
      "mean": 0.03299740004000001,
      "stddev": 0.0024047006431783865,
      "median": 0.03244582304,
      "user": 0.024802597303370782,
      "system": 0.017800171460674162,
      "min": 0.029702021040000002,
      "max": 0.04001627604
    }
  ]
}

@codecov-commenter

codecov-commenter commented Nov 2, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 94.94071% with 64 lines in your changes missing coverage. Please review.
✅ Project coverage is 92.69%. Comparing base (58762ee) to head (09b4f59).

Files with missing lines Patch % Lines
pnpr/crates/storage/src/metadata/sqlite/cache.rs 79.45% 15 Missing ⚠️
pnpr/crates/storage/src/metadata/documents.rs 89.43% 13 Missing ⚠️
...pr/crates/storage/src/metadata/sqlite/packument.rs 86.88% 8 Missing ⚠️
pnpr/crates/storage/src/metadata/sqlite.rs 96.27% 6 Missing ⚠️
pnpr/crates/storage/src/metadata/sqlite/commit.rs 97.35% 6 Missing ⚠️
pnpr/crates/storage/src/metadata/sqlite/render.rs 97.94% 3 Missing ⚠️
...ates/pnpr/src/server/package_mutation/dist_tags.rs 96.36% 2 Missing ⚠️
...ates/pnpr/src/server/package_mutation/unpublish.rs 90.00% 2 Missing ⚠️
pnpr/crates/storage/src/metadata/sqlite/tags.rs 98.18% 2 Missing ⚠️
...npr/crates/storage/src/metadata/sqlite/versions.rs 97.72% 2 Missing ⚠️
... and 5 more
Additional details and impacted files
@@            Coverage Diff             @@
##             main   #17551      +/-   ##
==========================================
+ Coverage   92.67%   92.69%   +0.02%     
==========================================
  Files        1929     1939      +10     
  Lines      251557   252586    +1029     
==========================================
+ Hits       233129   234137    +1008     
- Misses      18428    18449      +21     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

zkochan and others added 3 commits November 2, 2026 12:27
Add a metadata domain interface to pnpr-storage and an embedded SQLite
backend for it, opt-in through `metadata: { backend: sqlite }`.

`Storage` now reaches package documents through `PackageMetadata`: read a
view, commit a document under compare-and-set, change a tag, remove a
package, list packages. The documents backend keeps today's behavior. The
SQLite backend stores an npm packument as rows: insert-only version
manifests and READMEs, tags with an insert-only history, deprecations, and
package-level state. Other ecosystems' documents are stored whole. Every
commit that changes rows advances its catalog's (org's) generation once;
hosted npm responses and dist-tag changes report it in `pnpr-generation`.

Reads render the packument from cached per-version fragments and cache the
assembled view by package generation. Each read revalidates the generation
inside its read transaction, so a cached view is never stale. A tag change
reuses every fragment, and a deprecation re-renders one.

Part of pnpm/tasks#244.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
A version and revision always name the same bytes, because an unpublished
version is tombstoned and never accepted again, so the fragment cache key
needs no generation to tell a re-accepted version apart. Drop the
`accepted_generation` column too: nothing else in this store reads it.
Only the annotation generation stays, since the full packument embeds a
version's deprecation.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@zkochan
zkochan force-pushed the pnpr/sql-metadata-storage branch from 63b43b6 to a4db6ff Compare November 2, 2026 11:29
@zkochan
zkochan marked this pull request as ready for review November 2, 2026 11:43
Copilot AI balanced review requested due to automatic review settings November 2, 2026 11:43

@greptile-apps greptile-apps Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Your trial has ended. Reactivate Greptile to resume code reviews.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.

@qodo-code-review

Copy link
Copy Markdown

PR Summary by Qodo

Add opt-in SQLite storage for hosted package metadata

✨ Enhancement 🧪 Tests 📝 Documentation 🕐 40+ Minutes

Grey Divider

AI Description

• Add an opt-in SQLite metadata backend while keeping package documents as the default.
• Preserve published npm manifests, record dist-tag history, and expose catalog generations.
• Cache rendered package views and test publication, concurrency, restarts, and configuration.
Diagram

graph TD
  Config["Metadata config"] --> Storage["Storage routing"] --> Metadata["Package metadata"] --> SQLite[("SQLite database")] --> Render["Rendered views"] --> HTTP["Npm responses"]
  Metadata --> Documents["Document backend"]
  Storage --> Artifacts["Hosted artifacts"]
Loading
High-Level Assessment

The following are alternative approaches to this PR:

1. Store whole documents as SQLite JSON
  • ➕ Smaller implementation and simpler round-trip compatibility.
  • ➖ Tag changes still rewrite documents; version immutability, history, and fragment reuse become harder to enforce.
2. Use an external SQL service
  • ➕ Could support multiple registry instances and shared metadata.
  • ➖ Introduces deployment and availability requirements beyond this embedded, single-instance scope.

Recommendation: Keep the opt-in, row-oriented SQLite implementation: it supports the intended immutable-version and targeted-mutation semantics without changing the default backend. Whole-document SQL storage sacrifices those benefits, while an external database is better considered with a separate multi-instance design.

Files changed (41) +2798 / -243

Enhancement (22) +1817 / -191
export.rsOpen configured metadata for export +2/-6

Open configured metadata for export

• Constructs export storage with its selected metadata backend rather than assuming hosted documents.

pnpr/crates/pnpr/src/export.rs

migrate_storage.rsRead migration sources through configured metadata +1/-0

Read migration sources through configured metadata

• Applies the configured metadata backend to the local migration source; the S3 target retains document storage.

pnpr/crates/pnpr/src/migrate_storage.rs

oci_maintenance.rsUse configured storage for OCI maintenance +1/-6

Use configured storage for OCI maintenance

• Initializes OCI maintenance with the selected metadata backend.

pnpr/crates/pnpr/src/oci_maintenance.rs

server.rsDefine the generation response header +7/-1

Define the generation response header

• Introduces the shared 'pnpr-generation' header name and response helper import.

pnpr/crates/pnpr/src/server.rs

lifecycle.rsInitialize lifecycle storage from configuration +2/-10

Initialize lifecycle storage from configuration

• Uses the configured metadata backend during publish-journal recovery and abandoned-upload sweeping.

pnpr/crates/pnpr/src/server/lifecycle.rs

dist_tags.rsRoute dist-tag mutations through storage +104/-148

Route dist-tag mutations through storage

• Moves tag changes to the metadata domain operation, preserving authorization and audit logging. Successful changes include a generation header when supported.

pnpr/crates/pnpr/src/server/package_mutation/dist_tags.rs

package_reads.rsRead hosted packuments with generation metadata +9/-9

Read hosted packuments with generation metadata

• Reads a package view and attaches its generation to successful hosted npm responses.

pnpr/crates/pnpr/src/server/package_reads.rs

package_responses.rsAttach generation headers to responses +14/-0

Attach generation headers to responses

• Adds a helper that inserts the generation header when a backend supplies one.

pnpr/crates/pnpr/src/server/package_responses.rs

state.rsInitialize server storage from metadata settings +1/-5

Initialize server storage from metadata settings

• Builds application storage with the configured metadata backend.

pnpr/crates/pnpr/src/server/state.rs

backend.rsRepresent generation-based document versions +3/-0

Represent generation-based document versions

• Adds a generation token for metadata compare-and-set operations.

pnpr/crates/storage/src/backend.rs

journal.rsRecover publications against configured metadata +1/-5

Recover publications against configured metadata

• Opens storage with the selected metadata backend during publish-journal recovery.

pnpr/crates/storage/src/journal.rs

layout_state.rsNamespace metadata alongside hosted storage +5/-1

Namespace metadata alongside hosted storage

• Creates a catalog-and-ecosystem metadata view for each hosted storage namespace.

pnpr/crates/storage/src/layout_state.rs

metadata.rsIntroduce the package metadata domain interface +174/-0

Introduce the package metadata domain interface

• Defines package views, generations, tag operations, and the interface shared by documents and SQLite backends.

pnpr/crates/storage/src/metadata.rs

sqlite.rsImplement the embedded metadata backend +281/-0

Implement the embedded metadata backend

• Opens and validates the database, binds metadata views to namespaces, and runs SQL operations on the blocking pool behind a shared connection.

pnpr/crates/storage/src/metadata/sqlite.rs

cache.rsBound rendered fragment and view caches +164/-0

Bound rendered fragment and view caches

• Adds byte-budgeted caches, generation-checked assembled views, fragment keys, and rendering statistics.

pnpr/crates/storage/src/metadata/sqlite/cache.rs

commit.rsCommit metadata rows under compare-and-set +291/-0

Commit metadata rows under compare-and-set

• Applies changed package, version, annotation, and tag rows in transactions. Advances the catalog generation only when a write changes stored metadata.

pnpr/crates/storage/src/metadata/sqlite/commit.rs

packument.rsSplit npm packuments into stored parts +125/-0

Split npm packuments into stored parts

• Extracts versions, tags, READMEs, deprecations, and publication times while retaining package-level state for reconstruction.

pnpr/crates/storage/src/metadata/sqlite/packument.rs

render.rsRender generation-checked package views +218/-0

Render generation-checked package views

• Assembles npm packuments from SQL rows and cached version fragments. Checks the package generation within each read transaction before reusing a view.

pnpr/crates/storage/src/metadata/sqlite/render.rs

schema.rsDefine the versioned SQLite metadata schema +142/-0

Define the versioned SQLite metadata schema

• Creates catalog, package, version, manifest, README, tag, history, and annotation tables with non-null keys. Configures WAL, durability, foreign keys, and schema-version validation.

pnpr/crates/storage/src/metadata/sqlite/schema.rs

tags.rsCommit individual tag moves with history +171/-0

Commit individual tag moves with history

• Changes one tag without rewriting version rows, records its prior target, principal, time, and generation, and leaves unchanged moves uncommitted.

pnpr/crates/storage/src/metadata/sqlite/tags.rs

versions.rsStore accepted versions and mutable deprecations +98/-0

Store accepted versions and mutable deprecations

• Inserts version manifests and READMEs separately and manages generation-stamped deprecation annotations.

pnpr/crates/storage/src/metadata/sqlite/versions.rs

hosted_backend.rsReject SQLite generation tokens in S3 writes +3/-0

Reject SQLite generation tokens in S3 writes

• Treats a generation token as a conditional-write conflict rather than an S3 object version.

pnpr/crates/storage/src/s3/hosted_backend.rs

Refactor (2) +209 / -36
lib.rsRoute hosted document operations through metadata +46/-36

Route hosted document operations through metadata

• Adds configured backend initialization and delegates package listing, reads, conditional writes, and removal to metadata. Artifact operations remain on the hosted backend.

pnpr/crates/storage/src/lib.rs

documents.rsPreserve hosted-document metadata behavior +163/-0

Preserve hosted-document metadata behavior

• Implements the default metadata backend and relocates conditional-write retries and packument retagging from their former call sites.

pnpr/crates/storage/src/metadata/documents.rs

Tests (7) +643 / -7
storage.rsTest metadata configuration defaults and constraints +29/-0

Test metadata configuration defaults and constraints

• Checks default and relative SQLite paths, the documents default, and invalid backend combinations.

pnpr/crates/config/src/tests/storage.rs

presets.rsKeep fixture storage on documents by default +12/-6

Keep fixture storage on documents by default

• Centralizes local fixture storage configuration and explicitly selects the documents metadata backend.

pnpr/crates/pnpr-fixtures/src/presets.rs

sql_metadata.rsExercise SQLite metadata through npm routes +140/-0

Exercise SQLite metadata through npm routes

• Tests publish, reads, retagging, deprecation, restart, and unpublish. Confirms archives remain on disk while package documents do not.

pnpr/crates/pnpr/tests/sql_metadata.rs

suite.rsRegister SQLite HTTP tests +1/-0

Register SQLite HTTP tests

• Includes the new SQLite metadata integration tests in the test suite.

pnpr/crates/pnpr/tests/suite.rs

tests.rsTest SQLite metadata semantics and caching +342/-0

Test SQLite metadata semantics and caching

• Covers round trips, immutable manifests, compare-and-set, catalog generations, tag history, cache reuse, removal, and non-npm documents.

pnpr/crates/storage/src/metadata/sqlite/tests.rs

concurrency.rsTest concurrent writes and recovery +114/-0

Test concurrent writes and recovery

• Tests competing publishers, stale cache revalidation, restart persistence, rollback of an uncommitted transaction, and incompatible schema rejection.

pnpr/crates/storage/src/metadata/sqlite/tests/concurrency.rs

tests.rsInitialize metadata in upload test replicas +5/-1

Initialize metadata in upload test replicas

• Adds default document metadata views to manually constructed OCI storage replicas.

pnpr/crates/storage/src/upload/tests.rs

Documentation (4) +46 / -1
sqlite-package-metadata.mdRecord a minor pnpr release +5/-0

Record a minor pnpr release

• Announces the opt-in SQLite backend, immutable npm manifests, tag history, and generation response header.

.changeset/sqlite-package-metadata.md

backup-and-restore.mdDocument SQLite metadata backups +1/-0

Document SQLite metadata backups

• Identifies the SQLite database as authoritative data that must be backed up consistently with hosted archives.

pnpr/docs/backup-and-restore.md

configuration.mdLink to metadata configuration +3/-1

Link to metadata configuration

• Points configuration readers to the SQLite metadata settings.

pnpr/docs/configuration.md

storage.mdDocument SQLite metadata operation and limits +37/-0

Document SQLite metadata operation and limits

• Explains opt-in configuration, immutable versions, tag history, generations, caching, single-instance limits, and the absence of automatic document migration.

pnpr/docs/storage.md

Other (6) +83 / -8
config_file.rsAccept a metadata configuration block +3/-0

Accept a metadata configuration block

• Adds the optional metadata block to parsed pnpr configuration.

pnpr/crates/config/src/config_file.rs

lib.rsExport metadata configuration types +3/-1

Export metadata configuration types

• Exposes the backend selection type and default database-path helper.

pnpr/crates/config/src/lib.rs

loading.rsResolve the configured metadata backend +8/-6

Resolve the configured metadata backend

• Includes metadata backend resolution when constructing storage configuration.

pnpr/crates/config/src/loading.rs

storage_config.rsDefine SQLite metadata settings and validation +67/-1

Define SQLite metadata settings and validation

• Defaults to documents, resolves SQLite paths, and rejects SQLite with S3 or a path on the documents backend.

pnpr/crates/config/src/storage_config.rs

Cargo.tomlAdd SQLite driver to storage +1/-0

Add SQLite driver to storage

• Adds the workspace 'rusqlite' dependency for the embedded metadata backend.

pnpr/crates/storage/Cargo.toml

Cargo.lockLock storage's SQLite dependency +1/-0

Lock storage's SQLite dependency

• Adds 'rusqlite' to the storage crate's locked dependency list.

Cargo.lock

@qodo-code-review

qodo-code-review Bot commented Nov 2, 2026 •

Copy link
Copy Markdown

Code Review by Qodo

🐞 Bugs (0) 📘 Rule violations (0) 📎 Requirement gaps (0) 📜 Skill insights (1)

Grey Divider


Action required

1. Failed deletion can expose a package name ✓ Resolved
Description
Storage::remove_package commits SQLite metadata deletion before attempting filesystem archive
removal. If archive removal fails, the delete handler returns before writing its tombstone, so a
subsequent publisher encounters neither the former maintainers nor the unpublished-version record
and can claim the package under a rule that permits initial publication.
Code

pnpr/crates/storage/src/lib.rs[R380-381]

+        let had_metadata = self.metadata.remove_package(name).await?;
+        let had_files = self.hosted.remove_package(name).await?;
Relevance

●●● Strong

The finding identifies a concrete partial-failure security issue across metadata and archive
deletion.

PR-#14665

ⓘ Recommendations generated based on similar findings in past PRs

Evidence
SQLite removal commits the row deletion, whereas a local directory deletion can return an error. The
handler exits on that error before writing the tombstone; both the reclaim check and the
owner-context authorization then treat a document-free, tombstone-free name as eligible for initial
publication.

pnpr/crates/storage/src/metadata/sqlite/commit.rs[268-282]
pnpr/crates/storage/src/local_store.rs[190-201]
pnpr/crates/pnpr/src/server/package_mutation/unpublish.rs[28-56]
pnpr/crates/pnpr/src/server/publishing/tombstones.rs[13-26]
pnpr/crates/pnpr/src/server/authentication.rs[402-419]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
A filesystem archive-removal failure can occur after SQLite metadata has been deleted but before the server writes the package tombstone, leaving the name and its versions unprotected.

## Fix Focus Areas
- pnpr/crates/storage/src/lib.rs[378-382]
- pnpr/crates/pnpr/src/server/package_mutation/unpublish.rs[28-56]

## Recommended Fix
Make the ownership and unpublished-version tombstone durable before deleting metadata, or otherwise ensure an archive-removal failure leaves the metadata intact. Preserve retry behavior and test a filesystem deletion failure after metadata is available.

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


2. Removed versions can be republished ✓ Resolved
Description
remove_package deletes the package row, and the schema's cascading foreign keys delete its
accepted version rows, so no tombstone remains. After an unpublish, publishing the same version
finds no existing row and insert_version accepts it again, contradicting the
insert-only/version-tombstone behavior.
Code

pnpr/crates/storage/src/metadata/sqlite/commit.rs[R273-276]

+    let removed = commit.transaction.execute(
+        "DELETE FROM packages WHERE catalog = ?1 AND ecosystem = ?2 AND name = ?3",
+        params![catalog, ecosystem, name],
+    )?;
Relevance

●● Moderate

The schema behavior raises a real concern, but server tombstones may intentionally preserve
republish protection.

ⓘ Recommendations generated based on similar findings in past PRs

Evidence
The SQLite removal path deletes the package row, while the version tables declare cascading foreign
keys from the package. Version insertion then accepts any version absent from those tables, so the
changed backend has no mechanism to reject a republished version.

SQL metadata storage and backend conformance
pnpr/crates/storage/src/metadata/sqlite/commit.rs[270-282]
pnpr/crates/storage/src/metadata/sqlite/schema.rs[37-65]
pnpr/crates/storage/src/metadata/sqlite/versions.rs[12-40]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
Unpublishing deletes the package row, which cascades into the accepted version rows and allows a previously published version to be accepted again.

## Fix Focus Areas
- pnpr/crates/storage/src/metadata/sqlite/commit.rs[270-282]
- pnpr/crates/storage/src/metadata/sqlite/schema.rs[37-65]
- pnpr/crates/storage/src/metadata/sqlite/versions.rs[12-40]

## Recommended Fix
Retain tombstone records for unpublished versions, or introduce a dedicated tombstone table that is not removed with the package row. Make version insertion reject any previously tombstoned version, and add a regression test that unpublishes a version and verifies republishing that same version returns `version_already_published`.

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools



Remediation recommended

3. Release notes hide who moved tags ✓ Resolved
Description
The changeset describes tag authorship passively as moves being recorded with who made them instead
of naming the registry or caller as the actor. This wording makes the actor responsible for the
observable audit behavior less direct for release-note readers.
Code

.changeset/sqlite-package-metadata.md[5]

+pnpr can keep hosted package metadata in an embedded SQLite database with `metadata: { backend: sqlite }`. A published npm version's manifest then cannot change, dist-tag moves are recorded with who made them, and hosted npm package responses carry a `pnpr-generation` header.
Relevance

●●● Strong

Recent changeset precedent accepts naming pnpm explicitly as the actor for clearer direct language.

PR-#17514

ⓘ Recommendations generated based on similar findings in past PRs

Evidence
The changed sentence says dist-tag moves are recorded with who made them, which describes the
actor passively and without an explicit subject.

Rule 3058332: Use plain, direct, and quantifiable language in changeset entries
.changeset/sqlite-package-metadata.md[5-5]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
The changeset uses passive wording for dist-tag authorship even though the actor is relevant to the user-visible behavior.

## Fix Focus Areas
- .changeset/sqlite-package-metadata.md[5-5]

## Recommended Fix
Rewrite the authorship clause with an explicit active subject, such as stating that pnpr records which user moved each dist-tag.

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


4. Tag history records no actor for publish-driven moves ✓ Resolved
Description
apply_tags records every dist-tag move that a document commit makes with principal: None,
because write_if_current carries no identity. Publishing a version moves latest (or the tag the
publisher names), and full-packument PUTs and journal roll-forward all go through this path, so the
most common tag moves have no recorded actor. This contradicts the documented promise that pnpr
records who moved a tag. A release-age or downgrade policy, or an investigator, reading
tag_history cannot tell who pointed latest at a version.
Code

pnpr/crates/storage/src/metadata/sqlite/commit.rs[R250-262]

+    for (tag, target) in incoming {
+        let previous = stored.get(tag).map(String::as_str);
+        if previous != Some(target.as_str()) {
+            let change = TagMove { tag, previous, target: Some(target), principal: None };
+            record_tag_move(commit, &change)?;
+            changed = true;
+        }
+    }
+    for (tag, previous) in &stored {
+        if !incoming.contains_key(tag) {
+            let change = TagMove { tag, previous: Some(previous), target: None, principal: None };
+            record_tag_move(commit, &change)?;
+            changed = true;
Relevance

●●● Strong

The implementation visibly records null actors for publish-driven tag changes despite documentation
promising authorship.

PR-#17267

ⓘ Recommendations generated based on similar findings in past PRs

Evidence
Both branches of apply_tags build TagMove { principal: None, .. }. The
PackageMetadata::write_if_current signature has no principal parameter, so publish, PUT and
journal commits cannot provide one. Only change_tag, the dist-tag endpoint, passes
identity.username(). The PR's own test shows the first move of latest, made by the publish
write, recorded with principal None. storage.md says pnpr records every tag move, including who
moved it.

pnpr/crates/storage/src/metadata/sqlite/commit.rs[246-266]
pnpr/crates/storage/src/metadata.rs[91-99]
pnpr/crates/storage/src/metadata/sqlite/tests.rs[273-280]
pnpr/docs/storage.md[79-81]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
Dist-tag moves made by a document commit (publish, full-packument PUT, journal roll-forward) are written to `tag_history` with `principal = NULL`. Only the dist-tag endpoint records who moved a tag, but the docs promise that every move is recorded with its actor.

## Fix Focus Areas
- pnpr/crates/storage/src/metadata/sqlite/commit.rs[246-266]
- pnpr/crates/storage/src/metadata.rs[91-99]
- pnpr/crates/storage/src/metadata/sqlite.rs[235-248]

## Recommended Fix
Add an optional `principal: Option<&str>` to `PackageMetadata::write_if_current` and to the `Storage::write_hosted_document_if_current` and `update_hosted_document_with_retry` callers. Pass it through `commit::write_document` into `apply_packument`/`apply_tags`, so each `TagMove` records the authenticated publisher. Pass `None` only for system-driven paths such as journal recovery, and change the docs to say which moves have no actor.

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


5. Release notes combine four changes ✓ Resolved
Description
The changeset puts SQLite storage, immutable manifests, dist-tag history, and generation headers
into one release-note sentence. Because these are separate user-visible behaviors, readers cannot
identify each change independently when scanning the release notes.
Code

.changeset/sqlite-package-metadata.md[5]

+pnpr can keep hosted package metadata in an embedded SQLite database with `metadata: { backend: sqlite }`. A published npm version's manifest then cannot change, dist-tag moves are recorded with who made them, and hosted npm package responses carry a `pnpr-generation` header.
Relevance

●●● Strong

Recent changeset precedents consistently accept splitting multiple user-visible behaviors into
separate sentences.

PR-#17561
PR-#17520

ⓘ Recommendations generated based on similar findings in past PRs

Evidence
The changed changeset sentence lists four distinct behaviors in a single sentence, while the rule
requires separate descriptions for separate logical changes.

Rule 3058304: Avoid compound sentences in individual changeset entries
.changeset/sqlite-package-metadata.md[5-5]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
The changeset combines four distinct user-visible behavior changes in one sentence, making the release note harder to scan and violating the requirement that each sentence describe one logical change.

## Fix Focus Areas
- .changeset/sqlite-package-metadata.md[5-5]

## Recommended Fix
Rewrite the entry as separate sentences, with each sentence covering only one logical behavior change: SQLite metadata storage, immutable published manifests, dist-tag history, and generation headers.

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


View medium (2)
6. Source overrides can migrate wrong metadata ✓ Resolved
Description
init_source_and_target_storage applies the already-resolved config.storage.metadata path to a
source whose archive directory may instead come from --from. When SQLite uses its default path and
--from selects another directory, migration enumerates documents from the configured database but
blobs from the override directory, omitting source packages or pairing metadata with another store’s
artifacts.
Code

pnpr/crates/pnpr/src/migrate_storage.rs[80]

+        .and_then(|source| source.with_metadata(&config.storage.metadata))
Relevance

●● Moderate

Specific migration-path mismatch is plausible, but no close historical precedent confirms
acceptance.

ⓘ Recommendations generated based on similar findings in past PRs

Evidence
Configuration resolves the default database beneath the configured storage directory, while
migration can independently replace its filesystem source root. The changed source construction
attaches the configured database; package names and documents then come from metadata, but blob
listing uses the source hosted backend.

pnpr/crates/config/src/storage_config.rs[69-74]
pnpr/crates/config/src/storage_config.rs[93-100]
pnpr/crates/pnpr/src/migrate_storage.rs[64-80]
pnpr/crates/pnpr/src/migrate_storage.rs[128-147]
pnpr/crates/storage/src/lib.rs[272-294]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
Migration's `--from` override changes the source archive directory without changing the default SQLite metadata path used for that source.

## Fix Focus Areas
- pnpr/crates/pnpr/src/migrate_storage.rs[70-80]
- pnpr/crates/config/src/storage_config.rs[69-74]

## Recommended Fix
When the metadata path was defaulted, derive the source SQLite path from the effective `source_dir`; preserve an explicitly configured metadata path. Test migration with `--from` pointing to a different store.

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


7. One slow metadata commit stalls every hosted read ✓ Resolved
Description
SqliteMetadata::run sends every operation to the blocking pool and holds a single
Mutex<DatabaseState> around reads, packument rendering, and commits that decompose and hash every
incoming version; even a view-cache hit reads the full state blob before checking its generation.
When a cold view renders a long version history or a publish or deprecate reconciles one, unrelated
hosted-package requests across orgs and ecosystems queue behind the lock, with blocked requests also
occupying blocking-pool threads.
Code

pnpr/crates/storage/src/metadata/sqlite.rs[R159-165]

+    async fn run<Output, Operation>(self: &Arc<Self>, operation: Operation) -> Result<Output>
+    where
+        Output: Send + 'static,
+        Operation: FnOnce(&mut DatabaseState) -> Result<Output> + Send + 'static,
+    {
+        let database = Arc::clone(self);
+        tokio::task::spawn_blocking(move || operation(&mut database.lock())).await?
Relevance

●● Moderate

The lock contention concern is technically plausible but requires architectural performance judgment
without close precedent.

ⓘ Recommendations generated based on similar findings in past PRs

Evidence
run acquires the shared database mutex for every operation, including read_view,
write_if_current, and change_tag. write_document performs decompose(bytes) and applies
versions whose input_digest values are computed while that lock is held; on a read,
render::read_view selects generation, state before checking the view cache, and a cache miss
fetches uncached version fragments through separate queries while assembling the view under the same
lock.

pnpr/crates/storage/src/metadata/sqlite.rs[154-166]
pnpr/crates/storage/src/metadata/sqlite.rs[218-248]
pnpr/crates/storage/src/metadata/sqlite/commit.rs[24-36]
pnpr/crates/storage/src/metadata/sqlite/commit.rs[78-101]
pnpr/crates/storage/src/metadata/sqlite/commit.rs[178-201]
pnpr/crates/storage/src/metadata/sqlite/render.rs[26-45]
pnpr/crates/storage/src/metadata/sqlite.rs[39-47]
pnpr/crates/storage/src/metadata/sqlite.rs[158-166]
pnpr/crates/storage/src/metadata/sqlite.rs[216-220]
pnpr/crates/storage/src/metadata/sqlite/render.rs[26-44]
pnpr/crates/storage/src/metadata/sqlite/render.rs[132-151]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
Every SQLite metadata operation, including reads, is serialized on one database-state mutex. Commits decompose documents and hash incoming versions while holding it; cache hits load the full `state` blob before checking generations, and cold views query and assemble versions under the lock. Unrelated hosted-package requests therefore wait behind a long commit or render.

## Fix Focus Areas
- pnpr/crates/storage/src/metadata/sqlite.rs[39-47]
- pnpr/crates/storage/src/metadata/sqlite.rs[154-166]
- pnpr/crates/storage/src/metadata/sqlite.rs[235-248]
- pnpr/crates/storage/src/metadata/sqlite/commit.rs[78-101]
- pnpr/crates/storage/src/metadata/sqlite/render.rs[26-45]
- pnpr/crates/storage/src/metadata/sqlite/render.rs[132-151]

## Recommended Fix
Open a small pool of read-only connections so WAL readers can run while the single writer connection commits behind its own mutex. Coordinate the render cache with a separate lock held only to look up or store entries, and retain generation revalidation. In `write_if_current`, decompose the document and compute each incoming version's `input_digest` before taking the writer lock, then pass the precomputed rows to `commit::write_document`. In `read_view`, select only `generation` to check the cache and load `state` only when assembling a view. Measure concurrent warm and cold reads, including a package with a long version history.

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools



Informational

8. SQLite cache gains lack measurements 📜 Skill insight ➹ Performance
Description
RenderCache adds fragment and assembled-view caching with fixed memory budgets, but the PR
supplies no numeric before-and-after measurement. Because the optimization affects SQLite package
reads and tag or deprecation paths, reviewers cannot establish its gain or its request-path cost.
Code

pnpr/crates/storage/src/metadata/sqlite/cache.rs[R10-13]

+/// Bytes of rendered version fragments kept in memory.
+const FRAGMENT_BUDGET: usize = 64 * 1024 * 1024;
+/// Bytes of assembled package views kept in memory.
+const VIEW_BUDGET: usize = 64 * 1024 * 1024;
Relevance

● Weak

Recent performance-review precedent rejected demands for before-and-after benchmarks for
optimization claims.

PR-#17375
PR-#17169

ⓘ Recommendations generated based on similar findings in past PRs

Evidence
The changed implementation introduces bounded fragment and view caches and uses them when rendering
package responses, which is a claimed performance optimization. No benchmark or numeric before/after
result is present in the changed benchmark-related code or tests.

pnpr/crates/storage/src/metadata/sqlite/cache.rs[10-17]
pnpr/crates/storage/src/metadata/sqlite/render.rs[26-45]
Skill: review-code

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
The PR introduces fragment and assembled-view caching as a performance optimization but provides no quantitative evidence showing its benefit or overhead.

## Fix Focus Areas
- pnpr/crates/storage/src/metadata/sqlite/cache.rs[10-17]
- pnpr/crates/storage/src/metadata/sqlite/render.rs[26-45]

## Recommended Fix
Add a benchmark covering cold and warm SQLite reads, tag changes, and deprecations across realistic package and version counts. Report multiple-run before-and-after timings with variance, along with memory usage or cache-budget impact, in the PR description or benchmark documentation.

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools

Dismiss ↗ | View ↗


Grey Divider

Context sources
✅ Compliance rules (platform): 61 rules
Review mode: Auto: ⏭️ Skipped: Changeset contains release-note prose only, with no behavioral code changes.

Grey Divider

Tip of the day
💡 Did you know, you can copy the agent prompt from any finding and feed it to your IDE agent

More tips ↗ | Customize Qodo ↗ | Qodo docs ↗

Grey Divider

Previous reviews

Review updated until commit 09b4f59

Results up to commit a4db6ff 🧠 Deep


🐞 Bugs (0) 📘 Rule violations (0) 📎 Requirement gaps (0) 🎨 UX issues (0) 🔗 Cross-repo conflicts (0) 📜 Skill insights (1)


Action required
1. Failed deletion can expose a package name ✓ Resolved
Description
Storage::remove_package commits SQLite metadata deletion before attempting filesystem archive
removal. If archive removal fails, the delete handler returns before writing its tombstone, so a
subsequent publisher encounters neither the former maintainers nor the unpublished-version record
and can claim the package under a rule that permits initial publication.
Code

pnpr/crates/storage/src/lib.rs[R380-381]

+        let had_metadata = self.metadata.remove_package(name).await?;
+        let had_files = self.hosted.remove_package(name).await?;
Relevance

●●● Strong

The finding identifies a concrete partial-failure security issue across metadata and archive
deletion.

PR-#14665

ⓘ Recommendations generated based on similar findings in past PRs

Evidence
SQLite removal commits the row deletion, whereas a local directory deletion can return an error. The
handler exits on that error before writing the tombstone; both the reclaim check and the
owner-context authorization then treat a document-free, tombstone-free name as eligible for initial
publication.

pnpr/crates/storage/src/metadata/sqlite/commit.rs[268-282]
pnpr/crates/storage/src/local_store.rs[190-201]
pnpr/crates/pnpr/src/server/package_mutation/unpublish.rs[28-56]
pnpr/crates/pnpr/src/server/publishing/tombstones.rs[13-26]
pnpr/crates/pnpr/src/server/authentication.rs[402-419]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
A filesystem archive-removal failure can occur after SQLite metadata has been deleted but before the server writes the package tombstone, leaving the name and its versions unprotected.

## Fix Focus Areas
- pnpr/crates/storage/src/lib.rs[378-382]
- pnpr/crates/pnpr/src/server/package_mutation/unpublish.rs[28-56]

## Recommended Fix
Make the ownership and unpublished-version tombstone durable before deleting metadata, or otherwise ensure an archive-removal failure leaves the metadata intact. Preserve retry behavior and test a filesystem deletion failure after metadata is available.

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


2. Removed versions can be republished ✓ Resolved
Description
remove_package deletes the package row, and the schema's cascading foreign keys delete its
accepted version rows, so no tombstone remains. After an unpublish, publishing the same version
finds no existing row and insert_version accepts it again, contradicting the
insert-only/version-tombstone behavior.
Code

pnpr/crates/storage/src/metadata/sqlite/commit.rs[R273-276]

+    let removed = commit.transaction.execute(
+        "DELETE FROM packages WHERE catalog = ?1 AND ecosystem = ?2 AND name = ?3",
+        params![catalog, ecosystem, name],
+    )?;
Relevance

●● Moderate

The schema behavior raises a real concern, but server tombstones may intentionally preserve
republish protection.

ⓘ Recommendations generated based on similar findings in past PRs

Evidence
The SQLite removal path deletes the package row, while the version tables declare cascading foreign
keys from the package. Version insertion then accepts any version absent from those tables, so the
changed backend has no mechanism to reject a republished version.

SQL metadata storage and backend conformance
pnpr/crates/storage/src/metadata/sqlite/commit.rs[270-282]
pnpr/crates/storage/src/metadata/sqlite/schema.rs[37-65]
pnpr/crates/storage/src/metadata/sqlite/versions.rs[12-40]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
Unpublishing deletes the package row, which cascades into the accepted version rows and allows a previously published version to be accepted again.

## Fix Focus Areas
- pnpr/crates/storage/src/metadata/sqlite/commit.rs[270-282]
- pnpr/crates/storage/src/metadata/sqlite/schema.rs[37-65]
- pnpr/crates/storage/src/metadata/sqlite/versions.rs[12-40]

## Recommended Fix
Retain tombstone records for unpublished versions, or introduce a dedicated tombstone table that is not removed with the package row. Make version insertion reject any previously tombstoned version, and add a regression test that unpublishes a version and verifies republishing that same version returns `version_already_published`.

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools



Remediation recommended
3. Tag history records no actor for publish-driven moves ✓ Resolved
Description
apply_tags records every dist-tag move that a document commit makes with principal: None,
because write_if_current carries no identity. Publishing a version moves latest (or the tag the
publisher names), and full-packument PUTs and journal roll-forward all go through this path, so the
most common tag moves have no recorded actor. This contradicts the documented promise that pnpr
records who moved a tag. A release-age or downgrade policy, or an investigator, reading
tag_history cannot tell who pointed latest at a version.
Code

pnpr/crates/storage/src/metadata/sqlite/commit.rs[R250-262]

+    for (tag, target) in incoming {
+        let previous = stored.get(tag).map(String::as_str);
+        if previous != Some(target.as_str()) {
+            let change = TagMove { tag, previous, target: Some(target), principal: None };
+            record_tag_move(commit, &change)?;
+            changed = true;
+        }
+    }
+    for (tag, previous) in &stored {
+        if !incoming.contains_key(tag) {
+            let change = TagMove { tag, previous: Some(previous), target: None, principal: None };
+            record_tag_move(commit, &change)?;
+            changed = true;
Relevance

●●● Strong

The implementation visibly records null actors for publish-driven tag changes despite documentation
promising authorship.

PR-#17267

ⓘ Recommendations generated based on similar findings in past PRs

Evidence
Both branches of apply_tags build TagMove { principal: None, .. }. The
PackageMetadata::write_if_current signature has no principal parameter, so publish, PUT and
journal commits cannot provide one. Only change_tag, the dist-tag endpoint, passes
identity.username(). The PR's own test shows the first move of latest, made by the publish
write, recorded with principal None. storage.md says pnpr records every tag move, including who
moved it.

pnpr/crates/storage/src/metadata/sqlite/commit.rs[246-266]
pnpr/crates/storage/src/metadata.rs[91-99]
pnpr/crates/storage/src/metadata/sqlite/tests.rs[273-280]
pnpr/docs/storage.md[79-81]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
Dist-tag moves made by a document commit (publish, full-packument PUT, journal roll-forward) are written to `tag_history` with `principal = NULL`. Only the dist-tag endpoint records who moved a tag, but the docs promise that every move is recorded with its actor.

## Fix Focus Areas
- pnpr/crates/storage/src/metadata/sqlite/commit.rs[246-266]
- pnpr/crates/storage/src/metadata.rs[91-99]
- pnpr/crates/storage/src/metadata/sqlite.rs[235-248]

## Recommended Fix
Add an optional `principal: Option<&str>` to `PackageMetadata::write_if_current` and to the `Storage::write_hosted_document_if_current` and `update_hosted_document_with_retry` callers. Pass it through `commit::write_document` into `apply_packument`/`apply_tags`, so each `TagMove` records the authenticated publisher. Pass `None` only for system-driven paths such as journal recovery, and change the docs to say which moves have no actor.

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


4. Release notes hide who moved tags ✓ Resolved
Description
The changeset describes tag authorship passively as moves being recorded with who made them instead
of naming the registry or caller as the actor. This wording makes the actor responsible for the
observable audit behavior less direct for release-note readers.
Code

.changeset/sqlite-package-metadata.md[5]

+pnpr can keep hosted package metadata in an embedded SQLite database with `metadata: { backend: sqlite }`. A published npm version's manifest then cannot change, dist-tag moves are recorded with who made them, and hosted npm package responses carry a `pnpr-generation` header.
Relevance

●●● Strong

Recent changeset precedent accepts naming pnpm explicitly as the actor for clearer direct language.

PR-#17514

ⓘ Recommendations generated based on similar findings in past PRs

Evidence
The changed sentence says dist-tag moves are recorded with who made them, which describes the
actor passively and without an explicit subject.

Rule 3058332: Use plain, direct, and quantifiable language in changeset entries
.changeset/sqlite-package-metadata.md[5-5]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
The changeset uses passive wording for dist-tag authorship even though the actor is relevant to the user-visible behavior.

## Fix Focus Areas
- .changeset/sqlite-package-metadata.md[5-5]

## Recommended Fix
Rewrite the authorship clause with an explicit active subject, such as stating that pnpr records which user moved each dist-tag.

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


5. Release notes combine four changes ✓ Resolved
Description
The changeset puts SQLite storage, immutable manifests, dist-tag history, and generation headers
into one release-note sentence. Because these are separate user-visible behaviors, readers cannot
identify each change independently when scanning the release notes.
Code

.changeset/sqlite-package-metadata.md[5]

+pnpr can keep hosted package metadata in an embedded SQLite database with `metadata: { backend: sqlite }`. A published npm version's manifest then cannot change, dist-tag moves are recorded with who made them, and hosted npm package responses carry a `pnpr-generation` header.
Relevance

●●● Strong

Recent changeset precedents consistently accept splitting multiple user-visible behaviors into
separate sentences.

PR-#17561
PR-#17520

ⓘ Recommendations generated based on similar findings in past PRs

Evidence
The changed changeset sentence lists four distinct behaviors in a single sentence, while the rule
requires separate descriptions for separate logical changes.

Rule 3058304: Avoid compound sentences in individual changeset entries
.changeset/sqlite-package-metadata.md[5-5]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
The changeset combines four distinct user-visible behavior changes in one sentence, making the release note harder to scan and violating the requirement that each sentence describe one logical change.

## Fix Focus Areas
- .changeset/sqlite-package-metadata.md[5-5]

## Recommended Fix
Rewrite the entry as separate sentences, with each sentence covering only one logical behavior change: SQLite metadata storage, immutable published manifests, dist-tag history, and generation headers.

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


View medium (2)
6. Source overrides can migrate wrong metadata ✓ Resolved
Description
init_source_and_target_storage applies the already-resolved config.storage.metadata path to a
source whose archive directory may instead come from --from. When SQLite uses its default path and
--from selects another directory, migration enumerates documents from the configured database but
blobs from the override directory, omitting source packages or pairing metadata with another store’s
artifacts.
Code

pnpr/crates/pnpr/src/migrate_storage.rs[80]

+        .and_then(|source| source.with_metadata(&config.storage.metadata))
Relevance

●● Moderate

Specific migration-path mismatch is plausible, but no close historical precedent confirms
acceptance.

ⓘ Recommendations generated based on similar findings in past PRs

Evidence
Configuration resolves the default database beneath the configured storage directory, while
migration can independently replace its filesystem source root. The changed source construction
attaches the configured database; package names and documents then come from metadata, but blob
listing uses the source hosted backend.

pnpr/crates/config/src/storage_config.rs[69-74]
pnpr/crates/config/src/storage_config.rs[93-100]
pnpr/crates/pnpr/src/migrate_storage.rs[64-80]
pnpr/crates/pnpr/src/migrate_storage.rs[128-147]
pnpr/crates/storage/src/lib.rs[272-294]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
Migration's `--from` override changes the source archive directory without changing the default SQLite metadata path used for that source.

## Fix Focus Areas
- pnpr/crates/pnpr/src/migrate_storage.rs[70-80]
- pnpr/crates/config/src/storage_config.rs[69-74]

## Recommended Fix
When the metadata path was defaulted, derive the source SQLite path from the effective `source_dir`; preserve an explicitly configured metadata path. Test migration with `--from` pointing to a different store.

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


7. One slow metadata commit stalls every hosted read ✓ Resolved
Description
SqliteMetadata::run sends every operation to the blocking pool and holds a single
Mutex<DatabaseState> around reads, packument rendering, and commits that decompose and hash every
incoming version; even a view-cache hit reads the full state blob before checking its generation.
When a cold view renders a long version history or a publish or deprecate reconciles one, unrelated
hosted-package requests across orgs and ecosystems queue behind the lock, with blocked requests also
occupying blocking-pool threads.
Code

pnpr/crates/storage/src/metadata/sqlite.rs[R159-165]

+    async fn run<Output, Operation>(self: &Arc<Self>, operation: Operation) -> Result<Output>
+    where
+        Output: Send + 'static,
+        Operation: FnOnce(&mut DatabaseState) -> Result<Output> + Send + 'static,
+    {
+        let database = Arc::clone(self);
+        tokio::task::spawn_blocking(move || operation(&mut database.lock())).await?
Relevance

●● Moderate

The lock contention concern is technically plausible but requires architectural performance judgment
without close precedent.

ⓘ Recommendations generated based on similar findings in past PRs

Evidence
run acquires the shared database mutex for every operation, including read_view,
write_if_current, and change_tag. write_document performs decompose(bytes) and applies
versions whose input_digest values are computed while that lock is held; on a read,
render::read_view selects generation, state before checking the view cache, and a cache miss
fetches uncached version fragments through separate queries while assembling the view under the same
lock.

pnpr/crates/storage/src/metadata/sqlite.rs[154-166]
pnpr/crates/storage/src/metadata/sqlite.rs[218-248]
pnpr/crates/storage/src/metadata/sqlite/commit.rs[24-36]
pnpr/crates/storage/src/metadata/sqlite/commit.rs[78-101]
pnpr/crates/storage/src/metadata/sqlite/commit.rs[178-201]
pnpr/crates/storage/src/metadata/sqlite/render.rs[26-45]
pnpr/crates/storage/src/metadata/sqlite.rs[39-47]
pnpr/crates/storage/src/metadata/sqlite.rs[158-166]
pnpr/crates/storage/src/metadata/sqlite.rs[216-220]
pnpr/crates/storage/src/metadata/sqlite/render.rs[26-44]
pnpr/crates/storage/src/metadata/sqlite/render.rs[132-151]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
Every SQLite metadata operation, including reads, is serialized on one database-state mutex. Commits decompose documents and hash incoming versions while holding it; cache hits load the full `state` blob before checking generations, and cold views query and assemble versions under the lock. Unrelated hosted-package requests therefore wait behind a long commit or render.

## Fix Focus Areas
- pnpr/crates/storage/src/metadata/sqlite.rs[39-47]
- pnpr/crates/storage/src/metadata/sqlite.rs[154-166]
- pnpr/crates/storage/src/metadata/sqlite.rs[235-248]
- pnpr/crates/storage/src/metadata/sqlite/commit.rs[78-101]
- pnpr/crates/storage/src/metadata/sqlite/render.rs[26-45]
- pnpr/crates/storage/src/metadata/sqlite/render.rs[132-151]

## Recommended Fix
Open a small pool of read-only connections so WAL readers can run while the single writer connection commits behind its own mutex. Coordinate the render cache with a separate lock held only to look up or store entries, and retain generation revalidation. In `write_if_current`, decompose the document and compute each incoming version's `input_digest` before taking the writer lock, then pass the precomputed rows to `commit::write_document`. In `read_view`, select only `generation` to check the cache and load `state` only when assembling a view. Measure concurrent warm and cold reads, including a package with a long version history.

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools



Informational
8. SQLite cache gains lack measurements 📜 Skill insight ➹ Performance
Description
RenderCache adds fragment and assembled-view caching with fixed memory budgets, but the PR
supplies no numeric before-and-after measurement. Because the optimization affects SQLite package
reads and tag or deprecation paths, reviewers cannot establish its gain or its request-path cost.
Code

pnpr/crates/storage/src/metadata/sqlite/cache.rs[R10-13]

+/// Bytes of rendered version fragments kept in memory.
+const FRAGMENT_BUDGET: usize = 64 * 1024 * 1024;
+/// Bytes of assembled package views kept in memory.
+const VIEW_BUDGET: usize = 64 * 1024 * 1024;
Relevance

● Weak

Recent performance-review precedent rejected demands for before-and-after benchmarks for
optimization claims.

PR-#17375
PR-#17169

ⓘ Recommendations generated based on similar findings in past PRs

Evidence
The changed implementation introduces bounded fragment and view caches and uses them when rendering
package responses, which is a claimed performance optimization. No benchmark or numeric before/after
result is present in the changed benchmark-related code or tests.

pnpr/crates/storage/src/metadata/sqlite/cache.rs[10-17]
pnpr/crates/storage/src/metadata/sqlite/render.rs[26-45]
Skill: review-code

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
The PR introduces fragment and assembled-view caching as a performance optimization but provides no quantitative evidence showing its benefit or overhead.

## Fix Focus Areas
- pnpr/crates/storage/src/metadata/sqlite/cache.rs[10-17]
- pnpr/crates/storage/src/metadata/sqlite/render.rs[26-45]

## Recommended Fix
Add a benchmark covering cold and warm SQLite reads, tag changes, and deprecations across realistic package and version counts. Report multiple-run before-and-after timings with variance, along with memory usage or cache-budget impact, in the PR description or benchmark documentation.

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools

Dismiss ↗ | View ↗


Grey Divider

Qodo Logo

Comment thread pnpr/crates/storage/src/lib.rs Resolved
@qodo-code-review

Copy link
Copy Markdown

PR Code Suggestions ✨

Warning

/improve is deprecated. Use /agentic_review instead (removal date not yet scheduled).

No code suggestions found for the PR.

@coderabbitai coderabbitai Bot left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • Fix comments: Fix CodeRabbit comments on this PR

zkochan and others added 2 commits November 2, 2026 13:44
Address review findings on the SQLite metadata store:

- The SQLite store keeps the identity of every removed version in an
  insert-only table that survives package removal, and refuses to accept
  one again. Unpublishing a version and removing a package both record
  it, so no write path, startup recovery of a sealed publish included,
  can bring a removed version back. The documents backend refuses a
  version its tombstone lists as removed in the same way.
- Unpublishing a package writes its tombstone before it removes anything,
  and a packument rewrite records removed versions in the tombstone
  before it writes, so a failure partway never leaves a name claimable.
  The rewrite no longer needs a rollback.
- Document writes carry the principal that asked for them, so a publish,
  a full-document update, and a journal roll-forward record who moved a
  tag. The journal keeps each package's publisher for recovery.
- `migrate-storage --from` reads another store's metadata from that
  store's own default database, or from its documents, instead of the
  configured database.
- Reads use their own WAL connections, so they never queue behind a
  commit or another read's render on the write connection. The render
  caches are shared by every read connection.
- The changeset states each user-visible change in its own sentence.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Copilot AI balanced review requested due to automatic review settings November 2, 2026 12:53

@greptile-apps greptile-apps Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Your trial has ended. Reactivate Greptile to resume code reviews.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.

@qodo-code-review

Copy link
Copy Markdown

Code review by qodo was updated up to the latest commit 5aafdb7

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

product: pnpr reviewed: coderabbit CodeRabbit submitted an approving review

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants