Skip to content

refactor(pnpr): move libSQL connection code into pnpr-libsql - #17580

Merged
zkochan merged 4 commits into
mainfrom
pnpr/libsql-crate
Nov 3, 2026
Merged

zkochan merged 4 commits into
mainfrom
pnpr/libsql-crate

Conversation

@zkochan

@zkochan zkochan commented Nov 2, 2026 •

Copy link
Copy Markdown
Member

Summary

Third of the SQL metadata adapter stack (pnpm/tasks#244, design in pnpm/rfcs#66). Builds on #17577 and #17578, now merged.

The libSQL metadata adapter (next PR) needs the connection code the auth backend already has. pnpm/rfcs#66 says metadata reuses it. This PR moves that code out of pnpr-auth into a new pnpr-libsql crate, mostly as file moves (git log --follow keeps the history):

  • connector.rs: LibsqlConnector, plus connector(settings, section), which refuses an auth token over plain HTTP off loopback and names <section>.authToken.
  • pool.rs: ConnectionPool, first_row.
  • lib.rs: open (embedded replica when replicaPath is set, else the remote primary), open_primary, is_transaction_conflict, is_unique_violation.
  • testing.rs (feature testing): the local primary that serves libsql's sync protocol, taken from the auth tests, and the canned plain-HTTP server.

LibsqlAuth opens its database through pnpr-libsql and keeps its schema, retries and records. The TLS tests that need pnpm-testing-utils stay in pnpr-auth.

Linking note, for reviewers: a unified test build links two SQLite copies, libsql's and rusqlite's. rusqlite comes in through pnpr-error's server feature. The build fails on duplicate symbols unless libsql's copy comes first on the link line. pnpr-libsql loads pnpr-error ahead of libsql (an extern crate with a comment). pnpr-auth and pnpr already link in that order. A real fix (one SQLite) is out of scope here; draft #17591 explores it.

Squash Commit Body

The libSQL metadata adapter needs the same connection code the auth
backend has: the TLS connector, the connection pool that discards a stream
whose baton was lost, and the embedded replica of a Turso primary. Move it
out of `pnpr-auth` into a new `pnpr-libsql` crate so both use one copy, as
pnpm/rfcs#66 asks.

`pnpr-libsql` holds `LibsqlConnector` and `connector(settings, section)`,
`open` and `open_primary`, `ConnectionPool` and `first_row`, the conflict
and uniqueness classifiers, and, behind a `testing` feature, the local
primary that serves libsql's sync protocol. `LibsqlAuth` opens its
database through it. The auth tests that need the TLS test server stay in
`pnpr-auth`.

Each owner keeps what is specific to it. `connector` names
`<section>.authToken` when it refuses a token, so the auth backend's error
still names `backend.libsql.authToken`. `ConnectionPool::new` takes the
error a timed-out operation fails with; the auth backend passes
`AuthDatabaseTimeout`. `open` and `open_primary` set the connector's token
flag from the settings they open, so a connector built for no token still
refuses to send the settings' token over plain HTTP off loopback.

A unified test build links two SQLite copies, libsql's and rusqlite's, and
fails on duplicate symbols unless libsql's comes first on the link line.
`pnpr-libsql` loads `pnpr-error` (and with it rusqlite) ahead of libsql,
the order `pnpr-auth` and `pnpr` already link in.

No behavior changes for the auth backend.

Related to pnpm/tasks#244.

Checklist

  • I checked the referenced issue and verified that none of the PRs
    already linked to it solves it.
  • Added or updated tests.

Tests: pnpm test:rust over every pnpr-* crate (now including pnpr-libsql) plus pnpm-registry-mock (1812 passed: the same tests as before, relocated, plus one for the token flag that open sets). cargo check -p pnpr --no-default-features builds. cargo deny check licenses passes with the new crate's entries. just test-pnpr and the pacquet exclusion list include pnpr-libsql. No changeset: no user-visible change.

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

🤖 Generated with Claude Code

Summary by CodeRabbit

  • Improvements
    • LibSQL connections now use consistent handling for HTTPS, certificate trust, and retries after timed-out connection attempts.
    • Embedded replicas retain configured sync behavior, including an initial sync when periodic syncing is disabled.
    • Connection pools continue to respect configured limits and deadlines, with timeout errors reported in the appropriate storage context.

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

Walkthrough

The PR adds pnpr-libsql for shared libSQL connector, database-opening, error-classification, and pool APIs. The auth backend uses these APIs. The crate adds connector and replica test support.

Changes: Shared libSQL integration

Layer / File(s) Summary
Shared crate and database APIs
Cargo.toml, deny.toml, justfile, pnpr/AGENTS.md, pnpr/crates/libsql/Cargo.toml, pnpr/crates/libsql/src/lib.rs, pnpr/crates/libsql/src/connector.rs, pnpr/crates/libsql/src/connector/tests.rs
The workspace adds pnpr-libsql with connector creation, database opening, replica setup, deadlines, and error classifiers. Connector APIs become public, and connector tests cover HTTP handling and dial retries.
Deadline-aware connection pool
pnpr/crates/libsql/src/pool.rs, pnpr/crates/libsql/src/pool/tests.rs
The shared pool exposes connection and row APIs. Reads and sync use configured deadlines; writes apply the deadline to connection checkout. Tests cover timeout errors and reads during stalled replica sync.
Connector and replica test support
pnpr/crates/libsql/src/testing.rs
The crate adds local HTTP and Hrana test servers. Its primary server exposes info, export, sync, and pipeline routes.
Auth backend integration
pnpr/crates/auth/Cargo.toml, pnpr/crates/auth/src/libsql_backend.rs, pnpr/crates/auth/src/libsql_backend/schema.rs, pnpr/crates/auth/src/libsql_backend/tests.rs, pnpr/crates/auth/src/libsql_backend/tests/*
The auth backend delegates connector creation and database opening to pnpr-libsql and uses its error classifiers. Auth tests use shared test support, remove the local connector and primary-server test helpers, and add TLS coverage.

Estimated code review effort: 3 (Moderate) | ~30 minutes

Change: Refactor

Possibly related PRs

  • pnpm/pnpm#17237: Adds the bounded auth connection pool that this PR moves into pnpr-libsql.
  • pnpm/pnpm#17225: Adds embedded-replica behavior that this PR moves into pnpr-libsql.
  • pnpm/pnpm#17278: Adds connector dial timeouts and retries that this PR moves into pnpr-libsql.

Suggested labels: product: pnpr

Suggested reviewers: qodo-code-review

Merge Risk: Minimal · up to f30ea

The change extracts shared libSQL support. No merge-blocking regression was established; the reported test results were not independently verified.

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

Warning

Some tools did not complete. Review the errors below.

ast-grep (0.51.1)

ast-grep could not parse rule config: /ast-grep-rules/ast-grep-essentials/rules/python/security/langchain-pal-chain-python.yml

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

CodeRabbit Verify

  • Run CodeRabbit Verify to test the changes in this pull request.
Recent review info
Run configuration
Commits

Reviewing files that changed from the base of the PR and between 6d5c9a7 and f30eac2.

Files selected for processing: 7
  • pnpr/crates/auth/src/libsql_backend.rs
  • pnpr/crates/auth/src/libsql_backend/tests/tls.rs
  • pnpr/crates/libsql/src/connector.rs
  • pnpr/crates/libsql/src/connector/tests.rs
  • pnpr/crates/libsql/src/lib.rs
  • pnpr/crates/libsql/src/pool.rs
  • pnpr/crates/libsql/src/pool/tests.rs

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

@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.00     12.2±1.02ms    30.8 MB/sec    1.23     15.0±1.52ms    25.0 MB/sec
packument/parse                                  1.00     40.2±0.31µs  1650.9 MB/sec    1.05     42.1±1.76µs  1577.3 MB/sec
tarball/download_dependency                      1.00   791.0±88.67µs     5.4 MB/sec    1.12   889.5±90.19µs     4.8 MB/sec
tarball_batch/cold_store_many_medium_tarballs    1.00   205.7±25.19ms 77.8 KElem/sec    1.09   223.3±11.59ms 71.7 KElem/sec
version_pick/repeated_ranges_file                1.00      4.3±0.09ms  7.2 KElem/sec    1.06      4.6±0.22ms  6.8 KElem/sec
version_pick/repeated_ranges_raw                 1.00      4.4±0.09ms  7.1 KElem/sec    1.03      4.5±0.11ms  6.9 KElem/sec
workspace_resolution/hoist_heavy                 1.00   241.1±20.91ms        ? ?/sec    1.40   336.9±14.47ms        ? ?/sec
workspace_sort/chained_projects                  1.00     12.5±1.01ms        ? ?/sec    1.02     12.8±0.95ms        ? ?/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 2382.95 ms 2484.61 ms 4.3% 119.15 ms Within tolerance
isolated-fresh-restore-cold-cache-cold-store pnpr 1405.53 ms 1333.79 ms -5.1% 70.28 ms Within tolerance
isolated-fresh-restore-hot-cache-hot-store pacquet 255.61 ms 254.85 ms -0.3% 12.78 ms Within tolerance
isolated-fresh-restore-hot-cache-hot-store pnpr 259.33 ms 278.48 ms 7.4% 12.97 ms Inconclusive (overlapping samples)
isolated-repeat-install-hot-cache-hot-store pacquet 9.83 ms 9.91 ms 0.8% 2.00 ms Within tolerance
isolated-repeat-install-hot-cache-hot-store pnpr 9.73 ms 9.66 ms -0.8% 2.00 ms Within tolerance
isolated-repeat-install-cold-cache-hot-store pacquet 9.11 ms 10.04 ms 10.3% 2.00 ms Within tolerance
isolated-repeat-install-cold-cache-hot-store pnpr 9.53 ms 9.74 ms 2.1% 2.00 ms Within tolerance
isolated-fresh-install-cold-cache-cold-store pacquet 2622.45 ms 2628.19 ms 0.2% 131.12 ms Within tolerance
isolated-fresh-install-cold-cache-cold-store pnpr 1512.00 ms 1502.55 ms -0.6% 75.60 ms Within tolerance
isolated-fresh-install-hot-cache-hot-store pacquet 522.32 ms 537.38 ms 2.9% 26.12 ms Within tolerance
isolated-fresh-install-hot-cache-hot-store pnpr 335.94 ms 342.95 ms 2.1% 16.80 ms Within tolerance
isolated-fresh-install-cold-cache-hot-store pacquet 1785.13 ms 1788.15 ms 0.2% 89.26 ms Within tolerance
isolated-fresh-install-cold-cache-hot-store pnpr 371.57 ms 359.23 ms -3.3% 18.58 ms Within tolerance
isolated-fresh-resolve-hot-cache-offline pacquet 266.52 ms 258.79 ms -2.9% 13.33 ms Within tolerance
isolated-fresh-resolve-hot-cache-offline pnpr 93.04 ms 92.10 ms -1.0% 4.65 ms Within tolerance
isolated-peer-heavy-resolve-hot-cache-offline pacquet 222.35 ms 214.88 ms -3.4% 11.12 ms Within tolerance
isolated-linked-workspace-resolve-hot-cache-offline pacquet 91.19 ms 85.30 ms -6.5% 4.56 ms Within tolerance
isolated-injected-workspace-repeat-install-hot-cache-hot-store pacquet 97.41 ms 100.51 ms 3.2% 4.87 ms Within tolerance
isolated-fresh-restore-cold-cache-cold-store-cold-pnpr pacquet 4525.54 ms 4526.11 ms 0.0% 226.28 ms Within tolerance
isolated-fresh-restore-cold-cache-cold-store-cold-pnpr pnpr 3472.57 ms 3506.80 ms 1.0% 173.63 ms Within tolerance
gvs-fresh-restore-hot-cache-hot-store pacquet 132.01 ms 122.69 ms -7.1% 6.60 ms Within tolerance
gvs-fresh-restore-hot-cache-hot-store pnpr 140.90 ms 143.62 ms 1.9% 7.04 ms Within tolerance
store-only-unlocked-direct-deps-cold-cache-hot-store pacquet 1211.05 ms 1219.72 ms 0.7% 60.55 ms Within tolerance
cargo-repeat-install-hot-cache-hot-store pacquet 53.79 ms 52.85 ms -1.7% 2.69 ms Within tolerance

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 symlink 3894 3899 +0.1% 77 2 Within tolerance
isolated-fresh-restore-cold-cache-cold-store pnpr access 11 11 +0.0% 50 0 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 readlink 15290 15291 +0.0% 305 14 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 readlink 16102 16191 +0.6% 322 649 Unstable (identical runs differ by 649, 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 access 11 11 +0.0% 50 0 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 access 11 11 +0.0% 50 0 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 access 11 11 +0.0% 50 0 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: f30eac2507b2

Compared against main at: cb8817f84b49

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.479 ± 0.087 2.375 2.670 1.80 ± 0.15
pacquet@main 2.434 ± 0.151 2.245 2.710 1.77 ± 0.17
pnpr@HEAD 1.376 ± 0.101 1.291 1.577 1.00
pnpr@main 1.440 ± 0.108 1.301 1.580 1.05 ± 0.11
BENCHMARK_REPORT.json
{
  "results": [
    {
      "command": "pacquet@HEAD",
      "mean": 2.4789304034200006,
      "stddev": 0.08695649318993201,
      "median": 2.48461022632,
      "user": 2.3582602,
      "system": 1.7729181999999999,
      "min": 2.37485958032,
      "max": 2.66959341432
    },
    {
      "command": "pacquet@main",
      "mean": 2.43440514442,
      "stddev": 0.15109697117707874,
      "median": 2.38295092632,
      "user": 2.3091559000000004,
      "system": 1.7646463000000001,
      "min": 2.24473414332,
      "max": 2.70972926932
    },
    {
      "command": "pnpr@HEAD",
      "mean": 1.3760882203199998,
      "stddev": 0.10117361650106912,
      "median": 1.33378938032,
      "user": 1.8147031999999998,
      "system": 1.4420022,
      "min": 1.2912155483199999,
      "max": 1.57690312432
    },
    {
      "command": "pnpr@main",
      "mean": 1.4401167894199998,
      "stddev": 0.10839869217292657,
      "median": 1.4055323603199998,
      "user": 1.9547965999999999,
      "system": 1.5053962,
      "min": 1.30070354332,
      "max": 1.58019268032
    }
  ]
}

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

Command Mean [ms] Min [ms] Max [ms] Relative
pacquet@HEAD 258.9 ± 15.2 239.3 286.4 1.01 ± 0.07
pacquet@main 256.2 ± 9.4 244.9 278.3 1.00
pnpr@HEAD 277.5 ± 10.8 259.0 291.1 1.08 ± 0.06
pnpr@main 259.2 ± 10.5 235.5 273.2 1.01 ± 0.06
BENCHMARK_REPORT.json
{
  "results": [
    {
      "command": "pacquet@HEAD",
      "mean": 0.25886077956000003,
      "stddev": 0.01521204225447872,
      "median": 0.25484521336,
      "user": 0.32471943999999997,
      "system": 0.60224032,
      "min": 0.23932414886000003,
      "max": 0.28637541286
    },
    {
      "command": "pacquet@main",
      "mean": 0.25622070366000005,
      "stddev": 0.00943950768643294,
      "median": 0.25560701836,
      "user": 0.30614443999999996,
      "system": 0.62632732,
      "min": 0.24489558086000002,
      "max": 0.27831471986
    },
    {
      "command": "pnpr@HEAD",
      "mean": 0.27750785886000007,
      "stddev": 0.01082965275363489,
      "median": 0.27848181486,
      "user": 0.32004424,
      "system": 0.61613592,
      "min": 0.25898921486000004,
      "max": 0.29106652886
    },
    {
      "command": "pnpr@main",
      "mean": 0.25917220826000004,
      "stddev": 0.010546756352110333,
      "median": 0.25932663436000003,
      "user": 0.30614933999999994,
      "system": 0.57358522,
      "min": 0.23545957386000002,
      "max": 0.27321128186000004
    }
  ]
}

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

Command Mean [ms] Min [ms] Max [ms] Relative
pacquet@HEAD 10.0 ± 0.9 7.9 13.3 1.03 ± 0.12
pacquet@main 9.9 ± 1.0 7.6 15.7 1.03 ± 0.13
pnpr@HEAD 9.7 ± 0.8 7.9 13.6 1.00
pnpr@main 9.9 ± 0.8 8.1 13.2 1.03 ± 0.11
BENCHMARK_REPORT.json
{
  "results": [
    {
      "command": "pacquet@HEAD",
      "mean": 0.009984244518181824,
      "stddev": 0.0008751753164439428,
      "median": 0.0099052107,
      "user": 0.005677483636363634,
      "system": 0.0051552168727272765,
      "min": 0.007871727700000001,
      "max": 0.013341857700000001
    },
    {
      "command": "pacquet@main",
      "mean": 0.009935349231598514,
      "stddev": 0.0010346710394705365,
      "median": 0.0098258007,
      "user": 0.005807226617100374,
      "system": 0.004993457546468403,
      "min": 0.007605947700000001,
      "max": 0.0157495647
    },
    {
      "command": "pnpr@HEAD",
      "mean": 0.009692620652218433,
      "stddev": 0.0007715998324807579,
      "median": 0.009658124700000001,
      "user": 0.005808635221843003,
      "system": 0.004660912491467579,
      "min": 0.0078611277,
      "max": 0.013596075700000002
    },
    {
      "command": "pnpr@main",
      "mean": 0.009947068297938151,
      "stddev": 0.0007550673669185214,
      "median": 0.0097331767,
      "user": 0.006037644123711346,
      "system": 0.00473042405498282,
      "min": 0.0081195157,
      "max": 0.0132437417
    }
  ]
}

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

Command Mean [ms] Min [ms] Max [ms] Relative
pacquet@HEAD 10.1 ± 0.7 8.4 12.5 1.08 ± 0.14
pacquet@main 9.4 ± 1.1 7.8 12.5 1.00
pnpr@HEAD 10.0 ± 1.1 8.2 15.2 1.06 ± 0.17
pnpr@main 9.7 ± 0.7 8.5 12.2 1.03 ± 0.14
BENCHMARK_REPORT.json
{
  "results": [
    {
      "command": "pacquet@HEAD",
      "mean": 0.010118909453388428,
      "stddev": 0.0006844705489459336,
      "median": 0.010043724160000001,
      "user": 0.005852677851239669,
      "system": 0.005201282231404958,
      "min": 0.00842547266,
      "max": 0.012513846660000001
    },
    {
      "command": "pacquet@main",
      "mean": 0.009391126592000002,
      "stddev": 0.0010666510824239236,
      "median": 0.00910661366,
      "user": 0.005343359999999999,
      "system": 0.0048598604000000024,
      "min": 0.007799492660000001,
      "max": 0.01251656766
    },
    {
      "command": "pnpr@HEAD",
      "mean": 0.00996905456909091,
      "stddev": 0.001078349044672339,
      "median": 0.00973760366,
      "user": 0.005930309090909093,
      "system": 0.004900639272727276,
      "min": 0.008168223660000001,
      "max": 0.015188158660000001
    },
    {
      "command": "pnpr@main",
      "mean": 0.009716351592773117,
      "stddev": 0.0007231076693915223,
      "median": 0.00953404866,
      "user": 0.005932704033613442,
      "system": 0.004623878151260504,
      "min": 0.00849887266,
      "max": 0.012212036660000002
    }
  ]
}

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

Command Mean [s] Min [s] Max [s] Relative
pacquet@HEAD 2.625 ± 0.030 2.574 2.667 1.70 ± 0.12
pacquet@main 2.625 ± 0.036 2.576 2.692 1.70 ± 0.12
pnpr@HEAD 1.541 ± 0.103 1.445 1.728 1.00
pnpr@main 1.554 ± 0.113 1.451 1.774 1.01 ± 0.10
BENCHMARK_REPORT.json
{
  "results": [
    {
      "command": "pacquet@HEAD",
      "mean": 2.62504240212,
      "stddev": 0.029504937128343994,
      "median": 2.62819246732,
      "user": 2.751837879999999,
      "system": 1.72293572,
      "min": 2.57392743782,
      "max": 2.66697198882
    },
    {
      "command": "pacquet@main",
      "mean": 2.6245388800200002,
      "stddev": 0.03643015695314347,
      "median": 2.6224505353199996,
      "user": 2.74304838,
      "system": 1.6627799199999997,
      "min": 2.57613596782,
      "max": 2.69211628582
    },
    {
      "command": "pnpr@HEAD",
      "mean": 1.5414676477200004,
      "stddev": 0.10344842626189234,
      "median": 1.50254790432,
      "user": 2.16780798,
      "system": 1.58546732,
      "min": 1.44480317082,
      "max": 1.7276952408200001
    },
    {
      "command": "pnpr@main",
      "mean": 1.5537240671199999,
      "stddev": 0.11344881190722447,
      "median": 1.5119951713200002,
      "user": 2.2008900799999997,
      "system": 1.70269832,
      "min": 1.4506923318200002,
      "max": 1.7740512088200002
    }
  ]
}

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

Command Mean [ms] Min [ms] Max [ms] Relative
pacquet@HEAD 541.5 ± 31.8 491.6 600.9 1.60 ± 0.11
pacquet@main 531.1 ± 32.5 491.5 598.0 1.57 ± 0.11
pnpr@HEAD 343.5 ± 20.6 307.2 377.4 1.01 ± 0.07
pnpr@main 338.7 ± 13.1 321.5 361.3 1.00
BENCHMARK_REPORT.json
{
  "results": [
    {
      "command": "pacquet@HEAD",
      "mean": 0.54154196304,
      "stddev": 0.031835708019814994,
      "median": 0.5373806133400001,
      "user": 0.7743365799999999,
      "system": 0.9547158,
      "min": 0.49158137084000003,
      "max": 0.60089588784
    },
    {
      "command": "pacquet@main",
      "mean": 0.5311480527400001,
      "stddev": 0.032458610111434104,
      "median": 0.52232392234,
      "user": 0.78141398,
      "system": 0.9985662000000002,
      "min": 0.49146687284,
      "max": 0.59801113784
    },
    {
      "command": "pnpr@HEAD",
      "mean": 0.34353772904,
      "stddev": 0.020558723232217736,
      "median": 0.34294724034,
      "user": 0.32168267999999994,
      "system": 0.6690748999999999,
      "min": 0.30721335584000004,
      "max": 0.37737603784
    },
    {
      "command": "pnpr@main",
      "mean": 0.33871633413999996,
      "stddev": 0.013147330765645358,
      "median": 0.33593800084000003,
      "user": 0.32566428,
      "system": 0.6294209000000001,
      "min": 0.32154169584000003,
      "max": 0.36128266084
    }
  ]
}

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

Command Mean [s] Min [s] Max [s] Relative
pacquet@HEAD 1.794 ± 0.054 1.716 1.878 4.97 ± 0.30
pacquet@main 1.774 ± 0.025 1.738 1.803 4.91 ± 0.26
pnpr@HEAD 0.361 ± 0.019 0.339 0.401 1.00
pnpr@main 0.368 ± 0.018 0.344 0.396 1.02 ± 0.07
BENCHMARK_REPORT.json
{
  "results": [
    {
      "command": "pacquet@HEAD",
      "mean": 1.79446520652,
      "stddev": 0.05426900113808456,
      "median": 1.78815286122,
      "user": 1.184273,
      "system": 1.0878181,
      "min": 1.71567906122,
      "max": 1.8776319462200002
    },
    {
      "command": "pacquet@main",
      "mean": 1.77356529132,
      "stddev": 0.024522005587918637,
      "median": 1.78513419072,
      "user": 1.1539066999999998,
      "system": 1.029447,
      "min": 1.73750580722,
      "max": 1.8025883922200001
    },
    {
      "command": "pnpr@HEAD",
      "mean": 0.36139155572000004,
      "stddev": 0.01881521122742765,
      "median": 0.35922990172,
      "user": 0.35624750000000005,
      "system": 0.6946794,
      "min": 0.33939990922,
      "max": 0.40097655422
    },
    {
      "command": "pnpr@main",
      "mean": 0.36792461892,
      "stddev": 0.018364413209668633,
      "median": 0.37157379822000003,
      "user": 0.3677435,
      "system": 0.6839550000000001,
      "min": 0.34432146622000004,
      "max": 0.39639294722
    }
  ]
}

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

Command Mean [ms] Min [ms] Max [ms] Relative
pacquet@HEAD 263.6 ± 14.0 245.7 289.3 2.86 ± 0.17
pacquet@main 262.0 ± 10.7 239.2 274.6 2.84 ± 0.14
pnpr@HEAD 92.1 ± 2.6 87.2 98.4 1.00
pnpr@main 93.2 ± 3.5 87.2 99.8 1.01 ± 0.05
BENCHMARK_REPORT.json
{
  "results": [
    {
      "command": "pacquet@HEAD",
      "mean": 0.2635687462890909,
      "stddev": 0.013954656280507596,
      "median": 0.25879121038,
      "user": 0.23807582545454545,
      "system": 0.3255730636363636,
      "min": 0.24574678438,
      "max": 0.28934651238000003
    },
    {
      "command": "pacquet@main",
      "mean": 0.2619880764709091,
      "stddev": 0.010731431007098604,
      "median": 0.26652257438,
      "user": 0.25538518909090907,
      "system": 0.28087251818181813,
      "min": 0.23923015138,
      "max": 0.27455387238
    },
    {
      "command": "pnpr@HEAD",
      "mean": 0.09210250770258067,
      "stddev": 0.0026190066517042853,
      "median": 0.09210266138,
      "user": 0.03459031225806451,
      "system": 0.022223732258064517,
      "min": 0.08715703938000001,
      "max": 0.09843860338000002
    },
    {
      "command": "pnpr@main",
      "mean": 0.09316707591125001,
      "stddev": 0.003497789228079618,
      "median": 0.09303942538000001,
      "user": 0.034826029999999994,
      "system": 0.023335918749999997,
      "min": 0.08719053238,
      "max": 0.09984824238000001
    }
  ]
}

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

Command Mean [ms] Min [ms] Max [ms] Relative
pacquet@HEAD 221.0 ± 24.8 189.2 260.6 1.02 ± 0.12
pacquet@main 217.7 ± 9.7 199.4 228.6 1.00
pnpm@HEAD 4227.6 ± 191.2 3924.4 4498.4 19.42 ± 1.23
BENCHMARK_REPORT.json
{
  "results": [
    {
      "command": "pacquet@HEAD",
      "mean": 0.2209705107066667,
      "stddev": 0.02480437027110335,
      "median": 0.21488202404,
      "user": 0.23597095111111108,
      "system": 0.041154368888888876,
      "min": 0.18919376004000002,
      "max": 0.26059178504
    },
    {
      "command": "pacquet@main",
      "mean": 0.2176983464844445,
      "stddev": 0.00969249614697308,
      "median": 0.22235114804,
      "user": 0.23814884000000003,
      "system": 0.04458803555555555,
      "min": 0.19943341704,
      "max": 0.22856300904000001
    },
    {
      "command": "pnpm@HEAD",
      "mean": 4.227623335151112,
      "stddev": 0.1911998190252918,
      "median": 4.18967435704,
      "user": 6.502017617777778,
      "system": 0.3739783688888889,
      "min": 3.92439504304,
      "max": 4.49837413704
    }
  ]
}

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

Command Mean [ms] Min [ms] Max [ms] Relative
pacquet@HEAD 86.7 ± 5.5 79.7 100.4 1.00
pacquet@main 94.6 ± 14.5 79.1 135.3 1.09 ± 0.18
BENCHMARK_REPORT.json
{
  "results": [
    {
      "command": "pacquet@HEAD",
      "mean": 0.08672286694666669,
      "stddev": 0.005512485373264403,
      "median": 0.08530187528,
      "user": 0.08279664484848487,
      "system": 0.051519842424242415,
      "min": 0.07970044428,
      "max": 0.10036722828
    },
    {
      "command": "pacquet@main",
      "mean": 0.09464548637375003,
      "stddev": 0.014505453975122585,
      "median": 0.09119144228,
      "user": 0.09127591,
      "system": 0.055927349999999994,
      "min": 0.07905699828,
      "max": 0.13531273128000001
    }
  ]
}

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

Command Mean [ms] Min [ms] Max [ms] Relative
pacquet@HEAD 103.6 ± 7.5 94.3 124.6 1.05 ± 0.11
pacquet@main 98.9 ± 7.1 90.4 114.1 1.00
BENCHMARK_REPORT.json
{
  "results": [
    {
      "command": "pacquet@HEAD",
      "mean": 0.10363230429379312,
      "stddev": 0.007541741935582355,
      "median": 0.10051400188000001,
      "user": 0.04058519586206896,
      "system": 0.07241282413793103,
      "min": 0.09429928288000002,
      "max": 0.12458207188
    },
    {
      "command": "pacquet@main",
      "mean": 0.09890181898344828,
      "stddev": 0.007148118244845898,
      "median": 0.09741144188,
      "user": 0.038730816551724126,
      "system": 0.0692600655172414,
      "min": 0.09041061488,
      "max": 0.11407201088
    }
  ]
}

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

Command Mean [s] Min [s] Max [s] Relative
pacquet@HEAD 4.594 ± 0.138 4.445 4.787 1.31 ± 0.06
pacquet@main 4.598 ± 0.149 4.467 4.911 1.31 ± 0.06
pnpr@HEAD 3.578 ± 0.159 3.408 3.844 1.02 ± 0.06
pnpr@main 3.499 ± 0.119 3.378 3.718 1.00
BENCHMARK_REPORT.json
{
  "results": [
    {
      "command": "pacquet@HEAD",
      "mean": 4.593792260319999,
      "stddev": 0.13764312498650977,
      "median": 4.52610679472,
      "user": 2.37994546,
      "system": 1.7144396,
      "min": 4.44508859072,
      "max": 4.78733557272
    },
    {
      "command": "pacquet@main",
      "mean": 4.59797812742,
      "stddev": 0.14915589805046603,
      "median": 4.5255368142200005,
      "user": 2.36547056,
      "system": 1.7041718,
      "min": 4.4668026017199995,
      "max": 4.91145016872
    },
    {
      "command": "pnpr@HEAD",
      "mean": 3.5777537309200005,
      "stddev": 0.15896731552263024,
      "median": 3.50680442122,
      "user": 2.10052326,
      "system": 1.556693,
      "min": 3.4077552097200003,
      "max": 3.8438143997200003
    },
    {
      "command": "pnpr@main",
      "mean": 3.498998620820001,
      "stddev": 0.11894965430962505,
      "median": 3.47256957772,
      "user": 1.86993926,
      "system": 1.2771370999999998,
      "min": 3.3784146557200003,
      "max": 3.71842010772
    }
  ]
}

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 127.8 ± 12.3 113.9 165.5 1.00
pacquet@main 131.9 ± 9.5 119.5 151.7 1.03 ± 0.12
pnpr@HEAD 147.0 ± 10.9 136.3 170.0 1.15 ± 0.14
pnpr@main 142.7 ± 9.3 128.4 166.4 1.12 ± 0.13
BENCHMARK_REPORT.json
{
  "results": [
    {
      "command": "pacquet@HEAD",
      "mean": 0.1278426022609524,
      "stddev": 0.012286619264760266,
      "median": 0.12269321188,
      "user": 0.16927121333333328,
      "system": 0.13796865047619047,
      "min": 0.11393272888,
      "max": 0.16547829888
    },
    {
      "command": "pacquet@main",
      "mean": 0.1318784131577778,
      "stddev": 0.009476877477453767,
      "median": 0.13200648537999998,
      "user": 0.17789165777777777,
      "system": 0.13957884888888888,
      "min": 0.11949337288,
      "max": 0.15174248988
    },
    {
      "command": "pnpr@HEAD",
      "mean": 0.14702229647999998,
      "stddev": 0.010899188134722144,
      "median": 0.14362029388,
      "user": 0.18669727999999994,
      "system": 0.14672492666666667,
      "min": 0.13634723888,
      "max": 0.17000627788
    },
    {
      "command": "pnpr@main",
      "mean": 0.1426748056694737,
      "stddev": 0.009348772842520957,
      "median": 0.14089783888000001,
      "user": 0.18632751157894736,
      "system": 0.13625272315789475,
      "min": 0.12837353988,
      "max": 0.16642434288
    }
  ]
}

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.225 ± 0.045 1.173 1.305 1.00
pacquet@main 1.229 ± 0.046 1.182 1.317 1.00 ± 0.05
BENCHMARK_REPORT.json
{
  "results": [
    {
      "command": "pacquet@HEAD",
      "mean": 1.22467206434,
      "stddev": 0.044673605109093226,
      "median": 1.2197218302400001,
      "user": 0.54734176,
      "system": 0.24894469999999996,
      "min": 1.17330282424,
      "max": 1.30472047124
    },
    {
      "command": "pacquet@main",
      "mean": 1.2293748257400001,
      "stddev": 0.04630197998873217,
      "median": 1.21105011024,
      "user": 0.5498527599999999,
      "system": 0.23446029999999998,
      "min": 1.18186149124,
      "max": 1.31724187724
    }
  ]
}

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 52.6 ± 6.4 40.7 65.2 1.00
pacquet@main 53.6 ± 5.7 41.7 75.9 1.02 ± 0.16
BENCHMARK_REPORT.json
{
  "results": [
    {
      "command": "pacquet@HEAD",
      "mean": 0.05263589764679245,
      "stddev": 0.006402118879001358,
      "median": 0.05284617476,
      "user": 0.034274821132075466,
      "system": 0.03487686905660377,
      "min": 0.04070165876,
      "max": 0.06524992976
    },
    {
      "command": "pacquet@main",
      "mean": 0.05364710553192981,
      "stddev": 0.005685207981838742,
      "median": 0.053786745760000004,
      "user": 0.037126822456140345,
      "system": 0.03333366912280702,
      "min": 0.04166285676,
      "max": 0.07594015276
    }
  ]
}

@codecov-commenter

codecov-commenter commented Nov 2, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 94.23077% with 21 lines in your changes missing coverage. Please review.
✅ Project coverage is 92.72%. Comparing base (cb8817f) to head (f30eac2).

Files with missing lines Patch % Lines
pnpr/crates/libsql/src/testing.rs 92.67% 17 Missing ⚠️
pnpr/crates/auth/src/libsql_backend.rs 60.00% 2 Missing ⚠️
pnpr/crates/libsql/src/lib.rs 98.03% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main   #17580      +/-   ##
==========================================
- Coverage   92.72%   92.72%   -0.01%     
==========================================
  Files        2009     2011       +2     
  Lines      259743   260008     +265     
==========================================
+ Hits       240852   241094     +242     
- Misses      18891    18914      +23     

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

@garnet-runtime-review

garnet-runtime-review Bot commented Nov 2, 2026 •

Copy link
Copy Markdown

No runtime changes

Nothing new in your workflow's 1 job
1 job recorded at the kernel (Linux x86_64)

At f30eac2, compared with the PR base cb8817f
Commit Change to this head
head f30eac2
pnpr/libsql-crate · run 41571718075
previous push 6d5c9a7
run 41570198142
nothing new
PR base cb8817f
main · run 41569820743
the job folds above
1 job · nothing new
TS CI / test · only runner activity outside your workflow changed
TS CI / test · runner activity outside your workflow · +7 −6 · not counted
  systemd
    ├─ chronyd
-   │  ├─ ○ 162.159.200[.]123
-   │  ├─ ○ 23.131.76[.]162
-   │  ├─ ○ 72.30.35[.]89
-   │  ├─ ○ 96.19.94[.]82
+   │  ├─ ○ 172.234.25[.]10
+   │  ├─ ○ 192.231.84[.]117
+   │  ├─ ○ 23.168.24[.]210
+   │  └─ ○ 69.89.207[.]99
    ├─ … (1)
    │  └─ nginx
-   │     ├─ ○ 140.82.112[.]22
-   │     ├─ ○ 140.82.113[.]22
+   │     ├─ ○ 140.82.112[.]21
+   │     ├─ ○ 140.82.113[.]21
+   │     └─ ○ results-receiver.actions[.]githubusercontent (github infra)
    ├─ snapd
    │  └─ ○ api.snapcraft[.]io
    └─ systemd-resolve
       └─ ○ 8.8.8[.]8

Full record in Garnet ↗


How to read this
Runner.Worker     ← process on a path
└─ curl           ← process that acted
   └─ ○ example[.]com ← observed action

Read down: what ran, then what it reached. + only in this commit · − only in the compared run. Capture is best-effort. · Docs ↗

Runtime behavior, recorded by Garnet. Add it to your CI ↗

@blacksmith-sh

This comment has been minimized.

@zkochan
zkochan force-pushed the pnpr/sql-metadata-url branch 2 times, most recently from 4a436c7 to 9f67666 Compare November 3, 2026 00:58
@blacksmith-sh

This comment has been minimized.

@zkochan
zkochan force-pushed the pnpr/libsql-crate branch 7 times, most recently from d6ea9a9 to f860860 Compare November 3, 2026 02:28
Base automatically changed from pnpr/sql-metadata-url to main November 3, 2026 03:03
zkochan and others added 2 commits November 3, 2026 04:03
The libSQL metadata adapter needs the same connection code the auth
backend has: the TLS connector, the connection pool that discards a stream
whose baton was lost, and the embedded replica of a Turso primary. Move it
out of `pnpr-auth` into a new `pnpr-libsql` crate so both use one copy, as
pnpm/rfcs#66 asks ("Metadata reuses that connection code").

`pnpr-libsql` holds:
- `LibsqlConnector` and `connector(settings)`, which refuses an auth token
  over plain HTTP to a host other than loopback;
- `open(settings, connector)`, an embedded replica when `replicaPath` is
  set and the remote primary otherwise, and `open_primary`;
- `ConnectionPool` and `first_row`;
- `is_transaction_conflict` and `is_unique_violation`;
- behind a `testing` feature, the local primary that serves libsql's sync
  protocol, and a plain-HTTP canned server, for tests in other crates.

`LibsqlAuth` keeps its schema, retries, and records, and opens its database
through `pnpr-libsql`. The auth tests that need the TLS test server from
`pnpm-testing-utils` stay in `pnpr-auth`. The other connector and pool
tests move with the code.

A unified test build links two SQLite copies, libsql's and rusqlite's, and
fails on duplicate symbols unless libsql's comes first on the link line.
`pnpr-libsql` loads `pnpr-error` (and with it rusqlite) ahead of libsql, the
order `pnpr-auth` and `pnpr` already link in.

No behavior changes, except that the auth-token refusal no longer names the
`backend.libsql` key, since metadata will reuse it.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@zkochan
zkochan marked this pull request as ready for review November 3, 2026 03:06
Copilot AI balanced review requested due to automatic review settings November 3, 2026 03:06

@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

Extract shared libSQL connectivity into pnpr-libsql

✨ Enhancement 🧪 Tests ⚙️ Configuration changes 🕐 40+ Minutes

Grey Divider

AI Description

• Move libSQL connectivity into a shared crate for auth and the planned metadata adapter.
• Keep auth-specific schema and retries in pnpr-auth while preserving connector and pool behavior.
• Relocate reusable test servers and retain TLS tests with their existing test dependencies.
Diagram

graph TD
  A["Auth backend"] --> B["Shared libSQL"] --> C["TLS connector"] --> D["Remote primary"]
  B --> E["Connection pool"] --> F["Embedded replica"] --> D
  E --> D
  G["Test fixtures"] --> F
Loading
High-Level Assessment

The following are alternative approaches to this PR:

1. Export connectivity from pnpr-auth
  • ➕ Avoids introducing another crate.
  • ➖ Makes the metadata adapter depend on auth-specific code and features.
  • ➖ Obscures ownership of shared connection behavior.

Recommendation: Keep the dedicated pnpr-libsql crate. It gives both adapters a shared, auth-independent connection layer while leaving schema and retry policy with auth; exporting these helpers from pnpr-auth would couple metadata to the wrong layer.

Files changed (18) +979 / -513

Refactor (6) +230 / -169
Cargo.tomlDepend on shared libSQL connectivity +5/-16

Depend on shared libSQL connectivity

• Replaces connector-specific production dependencies with the optional pnpr-libsql dependency. Enables its testing feature for auth tests and keeps TLS test dependencies locally.

pnpr/crates/auth/Cargo.toml

libsql_backend.rsOpen auth databases through pnpr-libsql +12/-75

Open auth databases through pnpr-libsql

• Uses the shared connector, database opener, pool, row helper, and uniqueness classifier. Auth retains its startup deadline, schema initialization, and backend-specific behavior.

pnpr/crates/auth/src/libsql_backend.rs

schema.rsReuse shared libSQL error classifiers +3/-46

Reuse shared libSQL error classifiers

• Removes local transaction-conflict and uniqueness classifiers in favor of pnpr-libsql exports.

pnpr/crates/auth/src/libsql_backend/schema.rs

connector.rsExpose the reusable libSQL connector +11/-9

Expose the reusable libSQL connector

• Moves the TLS/plain-HTTP connector and timed-out-dial retry guard out of auth. Makes the required types and constructors public and generalizes the retry log message.

pnpr/crates/libsql/src/connector.rs

lib.rsExpose database opening and error classification +182/-0

Expose database opening and error classification

• Provides connector validation, remote-primary and embedded-replica opening, pool exports, and SQLite error classifiers. Loads pnpr-error before libsql to preserve the required SQLite link order in unified test builds.

pnpr/crates/libsql/src/lib.rs

pool.rsMake connection pooling reusable +17/-23

Make connection pooling reusable

• Moves the connection pool and first-row helper from auth. Preserves deadline handling and the rule that failed or interrupted streams are not returned to the pool.

pnpr/crates/libsql/src/pool.rs

Tests (6) +671 / -338
tests.rsRewire auth tests to shared helpers +6/-4

Rewire auth tests to shared helpers

• Imports the shared conflict classifier and adds the auth-local TLS test module.

pnpr/crates/auth/src/libsql_backend/tests.rs

sync_server.rsUse the shared replica test primary +5/-332

Use the shared replica test primary

• Keeps auth-specific replica assertions while replacing the inline sync-protocol server with the pnpr-libsql fixture. Moves the stalled-sync pool test to the pool’s own tests.

pnpr/crates/auth/src/libsql_backend/tests/sync_server.rs

tls.rsKeep TLS integration coverage in pnpr-auth +115/-0

Keep TLS integration coverage in pnpr-auth

• Retains trusted-server, untrusted-certificate, and HTTP-without-trust-store tests where pnpm-testing-utils is available.

pnpr/crates/auth/src/libsql_backend/tests/tls.rs

tests.rsTest shared connector security and dial behavior +143/-0

Test shared connector security and dial behavior

• Moves coverage for token transport, URI schemes, unreachable endpoints, and dial retries alongside the connector.

pnpr/crates/libsql/src/connector/tests.rs

tests.rsCover stalled replica connection opens in pool tests +47/-2

Cover stalled replica connection opens in pool tests

• Adds the relocated test verifying that stalled background syncs respect read deadlines without accumulating unbounded connection opens.

pnpr/crates/libsql/src/pool/tests.rs

testing.rsProvide reusable libSQL test servers +355/-0

Provide reusable libSQL test servers

• Moves the local primary serving sync, export, and Hrana routes into a feature-gated fixture. Also exposes the canned plain-HTTP server for connector and TLS tests.

pnpr/crates/libsql/src/testing.rs

Documentation (1) +1 / -0
AGENTS.mdDocument the pnpr-libsql crate +1/-0

Document the pnpr-libsql crate

• Lists the new crate and its responsibility for the connector, pool, and replica.

pnpr/AGENTS.md

Other (5) +77 / -6
Cargo.tomlRegister pnpr-libsql as a workspace dependency +1/-0

Register pnpr-libsql as a workspace dependency

• Adds the new crate to workspace dependency declarations so other pnpr crates can reference it.

Cargo.toml

Cargo.lockRecord the new crate and redistributed dependencies +23/-4

Record the new crate and redistributed dependencies

• Adds pnpr-libsql and reflects dependencies moved out of pnpr-auth.

Cargo.lock

deny.tomlAllow and clarify the new crate’s license +6/-0

Allow and clarify the new crate’s license

• Adds pnpr-libsql to the license exception and clarification entries.

deny.toml

justfileInclude pnpr-libsql in pnpr test selection +2/-2

Include pnpr-libsql in pnpr test selection

• Includes the new crate in pnpr-only tests and excludes it from pacquet-only tests.

justfile

Cargo.tomlDefine the shared libSQL crate +45/-0

Define the shared libSQL crate

• Declares connectivity dependencies and a testing feature for reusable HTTP and sync-protocol fixtures.

pnpr/crates/libsql/Cargo.toml

@qodo-code-review

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

Copy link
Copy Markdown

Code Review by Qodo

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

Grey Divider


Remediation recommended

1. Database tokens can cross cleartext links ✓ Resolved
Description
open_primary passes settings.auth_token to libsql while accepting a caller-supplied connector
whose token-protection flag may be false. If a caller constructs that connector with
LibsqlConnector::for_url(&settings.url, false) for a remote HTTP URL, neither the separate
connector(settings) check nor the connector's cleartext refusal applies, so the token can be sent
to that host.
Code

pnpr/crates/libsql/src/lib.rs[R77-79]

+    let auth_token = settings.auth_token.clone().unwrap_or_default();
+    let database = Box::pin(
+        Builder::new_remote(settings.url.clone(), auth_token).connector(connector).build(),
Relevance

●●● Strong

Recent libSQL security precedents accepted enforcing token restrictions across all caller-supplied
connection paths.

PR-#16835

ⓘ Recommendations generated based on similar findings in past PRs

Evidence
The token/URL validation resides only in the optional factory call. The newly public constructor
accepts a caller-selected carries_token value, and the dial-time refusal checks that value; the
newly public opening function does not reconcile it with the token it supplies to libsql. The
existing auth caller uses the safe factory, so this affects callers of the new shared API rather
than the current auth call path.

pnpr/crates/libsql/src/lib.rs[34-45]
pnpr/crates/libsql/src/lib.rs[61-81]
pnpr/crates/libsql/src/connector.rs[65-72]
pnpr/crates/libsql/src/connector.rs[108-121]
pnpr/crates/auth/src/libsql_backend.rs[86-91]
PR-#16835

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 public database-opening functions can pair an auth token with a connector configured as though no token is present, bypassing the cleartext safeguard.

## Fix Focus Areas
- pnpr/crates/libsql/src/lib.rs[61-83]
- pnpr/crates/libsql/src/connector.rs[65-72]
- pnpr/crates/libsql/src/connector.rs[108-121]

## Recommended Fix
Make `open` and `open_primary` validate the URL/token combination and ensure the connector's token-protection state is derived from those settings rather than a caller-provided boolean. Preserve support for custom TLS connectors without permitting them to disable the token policy.

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


2. Shared pool reports every timeout as an auth timeout ✓ Resolved
Description
The new pnpr_libsql::with_deadline, used by ConnectionPool::read, write and sync, turns
every elapsed deadline into RegistryError::AuthDatabaseTimeout, whose message is "Auth database
timeout" and whose error code is auth_database_timeout. The point of this crate is to let the
upcoming metadata adapter share this pool, and once it does, a stalled metadata query will reach
clients and logs as an auth-database failure and send operators to the wrong backend.
Code

pnpr/crates/libsql/src/lib.rs[R129-132]

+    match tokio::time::timeout(deadline, future).await {
+        Ok(result) => result.map_err(RegistryError::from),
+        Err(_) => Err(RegistryError::AuthDatabaseTimeout),
+    }
Relevance

●●● Strong

Shared timeout extraction was accepted; metadata reuse makes an auth-specific timeout classification
misleading.

PR-#12645
PR-#17237

ⓘ Recommendations generated based on similar findings in past PRs

Evidence
with_deadline hard-codes the auth-specific variant. The error crate documents that variant as "SQL
auth backend operation timed out", shows it as "Auth database timeout" and maps it to code
auth_database_timeout. The PR description says the libSQL metadata adapter in the next PR will
reuse ConnectionPool.

pnpr/crates/libsql/src/lib.rs[118-133]
pnpr/crates/error/src/lib.rs[416-423]
pnpr/crates/error/src/response.rs[98-128]

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

## Issue description
`pnpr_libsql::with_deadline` always returns `RegistryError::AuthDatabaseTimeout`, so any user of the shared `ConnectionPool` reports its timeouts as auth-database timeouts.

## Fix Focus Areas
- pnpr/crates/libsql/src/lib.rs[118-133]
- pnpr/crates/libsql/src/pool.rs[58-101]

## Recommended Fix
Have `ConnectionPool::new` take the timeout error to return. This can be a `fn() -> RegistryError` or a `RegistryError` kind. `LibsqlAuth` would pass `AuthDatabaseTimeout`, and the metadata adapter would pass its own variant. Thread that value through `with_deadline` instead of hard-coding the auth variant.

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



Informational

3. Auth token config error no longer names the key ✓ Resolved
Description
pnpr_libsql::connector now rejects a plain-HTTP token with the generic reason "a libSQL authToken
requires…". It replaces the old message, which named backend.libsql.authToken. An operator who
misconfigures the auth backend no longer sees which setting to fix, and the same vague message will
appear when the metadata adapter rejects its own setting.
Code

pnpr/crates/libsql/src/lib.rs[R39-43]

+        return Err(RegistryError::InvalidConfig {
+            reason: "a libSQL authToken requires an https:// or libsql:// url, or http:// on a \
+                     loopback host"
+                .to_string(),
+        });
Relevance

●●● Strong

Recent precedents favor actionable configuration errors that name the offending setting.

PR-#16835
PR-#14207

ⓘ Recommendations generated based on similar findings in past PRs

Evidence
The removed code in libsql_backend.rs named backend.libsql.authToken. The new shared function
cannot know which config section it was called for, so its message names no setting.

pnpr/crates/libsql/src/lib.rs[34-46]

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 config error from `pnpr_libsql::connector` no longer names the setting that is wrong.

## Fix Focus Areas
- pnpr/crates/libsql/src/lib.rs[34-46]
- pnpr/crates/auth/src/libsql_backend.rs[86-88]

## Recommended Fix
Add a `config_key: &str` parameter, such as `"backend.libsql"`, to `connector` and put it in the reason as `{config_key}.authToken requires ...`. Alternatively, let the caller map the error into a message that names its own key.

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


Grey Divider

Context sources
✅ Compliance rules (platform): 61 rules
✅ Cross-repo context — repo relationships
Review mode: Auto: ⚖️ Balanced: Security-sensitive connector and pool behavior changed across several related paths.
✅ Fix-loop round: fix loop

Grey Divider

Tip of the day
💡 Did you know, you can tweak Display settings with a live preview to see your comment before it ships

More tips ↗ | Customize Qodo ↗ | Qodo docs ↗

Grey Divider

Previous reviews

Review updated until commit f30eac2

Results up to commit 6d5c9a7 🧠 Deep


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


Remediation recommended
1. Database tokens can cross cleartext links ✓ Resolved
Description
open_primary passes settings.auth_token to libsql while accepting a caller-supplied connector
whose token-protection flag may be false. If a caller constructs that connector with
LibsqlConnector::for_url(&settings.url, false) for a remote HTTP URL, neither the separate
connector(settings) check nor the connector's cleartext refusal applies, so the token can be sent
to that host.
Code

pnpr/crates/libsql/src/lib.rs[R77-79]

+    let auth_token = settings.auth_token.clone().unwrap_or_default();
+    let database = Box::pin(
+        Builder::new_remote(settings.url.clone(), auth_token).connector(connector).build(),
Relevance

●●● Strong

Recent libSQL security precedents accepted enforcing token restrictions across all caller-supplied
connection paths.

PR-#16835

ⓘ Recommendations generated based on similar findings in past PRs

Evidence
The token/URL validation resides only in the optional factory call. The newly public constructor
accepts a caller-selected carries_token value, and the dial-time refusal checks that value; the
newly public opening function does not reconcile it with the token it supplies to libsql. The
existing auth caller uses the safe factory, so this affects callers of the new shared API rather
than the current auth call path.

pnpr/crates/libsql/src/lib.rs[34-45]
pnpr/crates/libsql/src/lib.rs[61-81]
pnpr/crates/libsql/src/connector.rs[65-72]
pnpr/crates/libsql/src/connector.rs[108-121]
pnpr/crates/auth/src/libsql_backend.rs[86-91]
PR-#16835

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 public database-opening functions can pair an auth token with a connector configured as though no token is present, bypassing the cleartext safeguard.

## Fix Focus Areas
- pnpr/crates/libsql/src/lib.rs[61-83]
- pnpr/crates/libsql/src/connector.rs[65-72]
- pnpr/crates/libsql/src/connector.rs[108-121]

## Recommended Fix
Make `open` and `open_primary` validate the URL/token combination and ensure the connector's token-protection state is derived from those settings rather than a caller-provided boolean. Preserve support for custom TLS connectors without permitting them to disable the token policy.

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


2. Shared pool reports every timeout as an auth timeout ✓ Resolved
Description
The new pnpr_libsql::with_deadline, used by ConnectionPool::read, write and sync, turns
every elapsed deadline into RegistryError::AuthDatabaseTimeout, whose message is "Auth database
timeout" and whose error code is auth_database_timeout. The point of this crate is to let the
upcoming metadata adapter share this pool, and once it does, a stalled metadata query will reach
clients and logs as an auth-database failure and send operators to the wrong backend.
Code

pnpr/crates/libsql/src/lib.rs[R129-132]

+    match tokio::time::timeout(deadline, future).await {
+        Ok(result) => result.map_err(RegistryError::from),
+        Err(_) => Err(RegistryError::AuthDatabaseTimeout),
+    }
Relevance

●●● Strong

Shared timeout extraction was accepted; metadata reuse makes an auth-specific timeout classification
misleading.

PR-#12645
PR-#17237

ⓘ Recommendations generated based on similar findings in past PRs

Evidence
with_deadline hard-codes the auth-specific variant. The error crate documents that variant as "SQL
auth backend operation timed out", shows it as "Auth database timeout" and maps it to code
auth_database_timeout. The PR description says the libSQL metadata adapter in the next PR will
reuse ConnectionPool.

pnpr/crates/libsql/src/lib.rs[118-133]
pnpr/crates/error/src/lib.rs[416-423]
pnpr/crates/error/src/response.rs[98-128]

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

## Issue description
`pnpr_libsql::with_deadline` always returns `RegistryError::AuthDatabaseTimeout`, so any user of the shared `ConnectionPool` reports its timeouts as auth-database timeouts.

## Fix Focus Areas
- pnpr/crates/libsql/src/lib.rs[118-133]
- pnpr/crates/libsql/src/pool.rs[58-101]

## Recommended Fix
Have `ConnectionPool::new` take the timeout error to return. This can be a `fn() -> RegistryError` or a `RegistryError` kind. `LibsqlAuth` would pass `AuthDatabaseTimeout`, and the metadata adapter would pass its own variant. Thread that value through `with_deadline` instead of hard-coding the auth variant.

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



Informational
3. Auth token config error no longer names the key ✓ Resolved
Description
pnpr_libsql::connector now rejects a plain-HTTP token with the generic reason "a libSQL authToken
requires…". It replaces the old message, which named backend.libsql.authToken. An operator who
misconfigures the auth backend no longer sees which setting to fix, and the same vague message will
appear when the metadata adapter rejects its own setting.
Code

pnpr/crates/libsql/src/lib.rs[R39-43]

+        return Err(RegistryError::InvalidConfig {
+            reason: "a libSQL authToken requires an https:// or libsql:// url, or http:// on a \
+                     loopback host"
+                .to_string(),
+        });
Relevance

●●● Strong

Recent precedents favor actionable configuration errors that name the offending setting.

PR-#16835
PR-#14207

ⓘ Recommendations generated based on similar findings in past PRs

Evidence
The removed code in libsql_backend.rs named backend.libsql.authToken. The new shared function
cannot know which config section it was called for, so its message names no setting.

pnpr/crates/libsql/src/lib.rs[34-46]

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 config error from `pnpr_libsql::connector` no longer names the setting that is wrong.

## Fix Focus Areas
- pnpr/crates/libsql/src/lib.rs[34-46]
- pnpr/crates/auth/src/libsql_backend.rs[86-88]

## Recommended Fix
Add a `config_key: &str` parameter, such as `"backend.libsql"`, to `connector` and put it in the reason as `{config_key}.authToken requires ...`. Alternatively, let the caller map the error into a message that names its own key.

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


Grey Divider

Qodo Logo

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

@github-actions github-actions Bot added the reviewed: coderabbit CodeRabbit submitted an approving review label Nov 3, 2026
zkochan and others added 2 commits November 3, 2026 04:17
…wner

`open` and `open_primary` now set the connector's token flag from the
settings they open, so a connector built for no token still refuses to
send the settings' token over plain HTTP to a host other than loopback.

`ConnectionPool::new` takes the error a timed-out operation fails with,
so a pool other than the auth backend's does not report its timeouts as
`AuthDatabaseTimeout`. The auth backend passes `AuthDatabaseTimeout`.

`connector` takes the config section its settings come from and names
`<section>.authToken` when it refuses a token, as the auth backend's
error did before the move.

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

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

@zkochan

zkochan commented Nov 3, 2026

Copy link
Copy Markdown
Member Author

Replies to the Qodo review:

  1. Database tokens can cross cleartext links: fixed in 77fcbb5. open and open_primary now set the connector's token flag from the settings they open, so a connector built for no token still refuses to send the settings' token over plain HTTP to a host other than loopback. open_refuses_the_token_over_plain_http_whatever_the_connector covers it.
  2. Shared pool reports every timeout as an auth timeout: fixed in 77fcbb5. ConnectionPool::new takes the error a timed-out operation fails with. The auth backend passes AuthDatabaseTimeout. The libSQL metadata adapter in feat(pnpr): keep metadata in libSQL, read through an embedded replica #17583 passes a StorageUnavailable that names the metadata database. The pool tests use an error the pool cannot produce otherwise, so they check the owner's error comes back.
  3. Auth token config error no longer names the key: fixed in 77fcbb5. connector takes the config section its settings come from and names <section>.authToken in the refusal, so the auth backend's error names backend.libsql.authToken again and the metadata adapter's names metadata.authToken.

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

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 f30eac2

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

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