Skip to content

fix(pnpr): bound libsql auth backend reads with a timeout - #12645

Merged
zkochan merged 3 commits into
pnpm:mainfrom
YESHYUNGSEOK:fix/pnpr-libsql-auth-timeout
Jun 25, 2026
Merged

zkochan merged 3 commits into
pnpm:mainfrom
YESHYUNGSEOK:fix/pnpr-libsql-auth-timeout

Conversation

@YESHYUNGSEOK

@YESHYUNGSEOK YESHYUNGSEOK commented Jun 25, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Every request-path database call in the libsql/Turso auth backend (stored_hash, user_count,
lookup, find_by_key, list_for_user) was a bare .await? with no timeout. The sqlx backend,
by contrast, wraps each read in with_auth_timeout and surfaces AuthDatabaseTimeout (HTTP 504)
on expiry. A stalled or hostile libsql endpoint (network partition, overloaded primary,
slow-loris) could therefore hold a Tokio task open indefinitely on every authenticated request,
exhausting the executor and taking the whole registry down — a remote DoS, with no 504 ever
returned.

This wraps the request-path reads and the startup schema setup with a deadline. The
AuthDatabaseTimeout variant (and its log_kind / status_code arms) now compiles under
backend-libsql, not just the sqlx drivers. Writes are intentionally left unwrapped, for the same
reason the sqlx backend documents: a Tokio cancellation mid-write would leave an unknown commit
state, so writes rely on the database's own statement timeout.

The read deadline uses a 30s default to match the sqlx backend. Exposing it as a YAML knob
(backend.libsql.timeout, like the sqlx backends) is a follow-up; this PR fixes the unbounded
hang. with_auth_timeout mirrors the sqlx helper rather than sharing it, because the two backends
are independently feature-gated.

Squash Commit Body

Every request-path database call in the libsql/Turso auth backend was a bare await with no
timeout, while the sqlx backend wraps its reads in with_auth_timeout and returns
AuthDatabaseTimeout (HTTP 504). A stalled or hostile libsql endpoint could hold a Tokio task
open indefinitely on every authenticated request, exhausting the executor and taking the whole
registry down — a remote DoS with no 504 ever returned.

Wrap the request-path reads (stored_hash, user_count, lookup, find_by_key, list_for_user) and
the startup schema setup with a deadline, surfacing AuthDatabaseTimeout on expiry. The
AuthDatabaseTimeout variant and its log_kind / status_code arms now compile under backend-libsql,
not just the sqlx drivers. Writes stay unwrapped for the reason the sqlx backend documents: a
cancelled write would leave an unknown commit state.

Checklist

  • Added or updated tests — deterministic unit tests for the timeout helper (elapse -> 504,
    fast result passes through). LibsqlAuth holds a concrete libsql::Connection rather than an
    injectable trait, so a connection-level stall isn't reproducible in a unit test the way the
    sqlx backend's SlowLookupBackend is; the helper test plus the wrapped call sites cover it.
  • Updated the documentation if needed — n/a.

(No changeset: pnpr is not a published npm package. No pnpm-side port: pnpr-only infrastructure.)


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

Summary by CodeRabbit

  • Bug Fixes
    • Improved authentication reliability by enforcing time limits on libsql auth database operations, including startup/schema setup and request-path user/token lookups.
    • Long-running or stalled auth reads now fail gracefully with an auth database timeout error instead of hanging.
  • Tests
    • Added async coverage for both timeout (slow) and non-timeout (fast) auth read scenarios.
  • Chores
    • Expanded compile-time feature gating so the auth timeout error handling applies consistently across supported SQL backends.

@YESHYUNGSEOK
YESHYUNGSEOK requested a review from zkochan as a code owner June 25, 2026 04:51
@coderabbitai

coderabbitai Bot commented Jun 25, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: 62630718-e637-441e-b5e0-a11afab300bf

📥 Commits

Reviewing files that changed from the base of the PR and between 658bf8e and ab07d06.

📒 Files selected for processing (3)
  • pnpr/crates/pnpr/src/auth.rs
  • pnpr/crates/pnpr/src/auth/libsql_backend.rs
  • pnpr/crates/pnpr/src/auth/sqlx_backend.rs

📝 Walkthrough

Walkthrough

Adds timeout enforcement for libsql auth startup and read operations, stores a per-backend auth timeout, and broadens shared SQLx error gating for libsql builds. Adds tests for timeout success and expiry.

Changes

Libsql auth timeout handling

Layer / File(s) Summary
Shared timeout helper
pnpr/crates/pnpr/src/auth.rs, pnpr/crates/pnpr/src/auth/sqlx_backend.rs
Adds with_auth_timeout in the auth module and switches sqlx_backend to use the shared helper.
Startup timeout wiring
pnpr/crates/pnpr/src/auth/libsql_backend.rs
Adds timeout constants, stores a timeout field on LibsqlAuth, and runs build() and init_schema under the startup timeout.
Bounded read paths
pnpr/crates/pnpr/src/auth/libsql_backend.rs
Wraps stored_hash, user_count, lookup, find_by_key, and list_for_user database reads in with_auth_timeout(self.timeout, ...).
Timeout checks and error gating
pnpr/crates/pnpr/src/auth/libsql_backend/tests.rs, pnpr/crates/pnpr/src/error.rs
Adds timeout behavior tests and includes backend-libsql in the RegistryError::AuthDatabaseTimeout and RegistryError::Sqlx feature gates.

Sequence Diagram(s)

sequenceDiagram
  participant LibsqlAuth
  participant with_auth_timeout
  participant tokio_time_timeout
  LibsqlAuth->>with_auth_timeout: wrap startup or read future
  with_auth_timeout->>tokio_time_timeout: enforce duration
  tokio_time_timeout-->>with_auth_timeout: value or timeout
  with_auth_timeout-->>LibsqlAuth: result or AuthDatabaseTimeout
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~30 minutes

Possibly related PRs

  • pnpm/pnpm#12206: Introduces LibsqlAuth and the read paths this PR wraps in with_auth_timeout.

Suggested labels

product: pnpr

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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

Comment @coderabbitai help to get the list of available commands.

@qodo-free-for-open-source-projects

Copy link
Copy Markdown

PR Summary by Qodo

Bound libsql/Turso auth reads with tokio timeouts (surface 504 on stall)
🐞 Bug fix 🧪 Tests 🕐 20-40 Minutes

Grey Divider

Description

• Add a bounded timeout wrapper for libsql auth reads to prevent indefinite task hangs.
• Apply deadlines to request-path lookups and startup schema init, returning HTTP 504 on expiry.
• Extend tests to validate timeout behavior and fast-path passthrough.
Diagram

graph TD
  C(["Client"]) --> H["Auth handler"] --> A["LibsqlAuth"] --> T["with_auth_timeout"] --> K["libsql::Connection"] --> D[("Libsql/Turso")]
  T --> E{{"AuthDatabaseTimeout"}} --> R["HTTP 504"]

  subgraph Legend
    direction LR
    _c(["Caller"]) ~~~ _s["Component"] ~~~ _db[("Database")] ~~~ _e{{"Error"}}
  end
Loading
High-Level Assessment

The following are alternative approaches to this PR:

1. Share a single timeout helper across backends
  • ➕ Avoids duplicated timeout logic between sqlx and libsql implementations
  • ➕ Ensures consistent behavior and future tweaks (e.g., jitter, metrics) apply everywhere
  • ➖ Needs careful module/feature layout so the helper compiles without pulling in sqlx/libsql-specific types
  • ➖ May be more churn than desired for a targeted DoS fix
2. Expose libsql timeout as configuration now (YAML knob)
  • ➕ Operators can tune deadline for latency/availability tradeoffs per deployment
  • ➕ Matches the configurability of existing sqlx backends
  • ➖ Broader surface-area change (config parsing, docs, validation) for an urgent safety fix
  • ➖ Still requires deciding startup vs request-path defaults and override semantics
3. Rely on driver/DB statement timeouts instead of tokio::timeout
  • ➕ Avoids cancellation semantics at the Rust task level
  • ➕ Potentially centralizes timeout enforcement at the database layer
  • ➖ Not always available/portable for all libsql deployment modes
  • ➖ Does not protect against hangs above the statement layer (e.g., connection stalls)

Recommendation: The PR’s approach (tokio deadline around request-path reads + startup init, leaving writes unwrapped) is the right minimal-risk mitigation for an unbounded-hang/DoS class issue. Consider a follow-up to either (a) factor the helper into a feature-neutral module or (b) add a backend.libsql.timeout config knob to match sqlx backends, but those are not required to fix the immediate availability risk.

Files changed (3) +126 / -38

Bug fix (2) +109 / -38
libsql_backend.rsAdd per-read auth deadlines and startup timeout for libsql backend +94/-35

Add per-read auth deadlines and startup timeout for libsql backend

• Introduces 'with_auth_timeout' using 'tokio::time::timeout', with defaults for request-path reads (30s) and startup schema init (5m). Wraps libsql-backed auth read operations ('stored_hash', 'user_count', token 'lookup', 'find_by_key', 'list_for_user') and 'init_schema' so stalled endpoints return 'RegistryError::AuthDatabaseTimeout' instead of hanging indefinitely.

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

error.rsEnable AuthDatabaseTimeout error under backend-libsql feature gate +15/-3

Enable AuthDatabaseTimeout error under backend-libsql feature gate

• Extends the 'AuthDatabaseTimeout' variant and its 'log_kind'/'status_code' mappings to compile when 'backend-libsql' is enabled, ensuring timeouts map to HTTP 504 for the libsql backend as well.

pnpr/crates/pnpr/src/error.rs

Tests (1) +17 / -0
tests.rsAdd deterministic unit tests for the timeout helper +17/-0

Add deterministic unit tests for the timeout helper

• Adds tests verifying that a stalled future yields 'AuthDatabaseTimeout' and that a fast future passes through unchanged.

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

@github-actions github-actions Bot added the reviewed: coderabbit CodeRabbit submitted an approving review label Jun 25, 2026
@qodo-free-for-open-source-projects

qodo-free-for-open-source-projects Bot commented Jun 25, 2026 •

Copy link
Copy Markdown

Code Review by Qodo

🐞 Bugs (3) 📘 Rule violations (3) 📜 Skill insights (0)

Grey Divider


Action required

1. Startup build lacks timeout 🐞 Bug ☼ Reliability
Description
LibsqlAuth::connect still awaits Builder::build().await without any deadline, so a
stalled/blackholed libsql endpoint can hang pnpr startup indefinitely even though the PR introduces
DEFAULT_STARTUP_TIMEOUT for “startup connect + schema setup”. This undermines the intended bounded
startup failure behavior and can block restarts/rollouts under network partitions or hostile
endpoints.
Code

pnpr/crates/pnpr/src/auth/libsql_backend.rs[R51-55]

+/// Deadline for the one-time startup connect + schema setup. More generous
+/// than [`DEFAULT_AUTH_TIMEOUT`] (cold schema DDL against a remote primary can
+/// be slow) but still bounded so an unreachable database fails fast.
+const DEFAULT_STARTUP_TIMEOUT: Duration = Duration::from_mins(5);
+
Evidence
The PR adds a startup timeout constant described as covering “startup connect + schema setup”, but
only applies it to init_schema; the initial remote database build step is still an unbounded
.await. The sqlx backend demonstrates the intended pattern by wrapping its startup connect and
schema initialization in with_auth_timeout.

pnpr/crates/pnpr/src/auth/libsql_backend.rs[51-55]
pnpr/crates/pnpr/src/auth/libsql_backend.rs[111-127]
pnpr/crates/pnpr/src/auth/sqlx_backend.rs[223-238]

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

## Issue description
`LibsqlAuth::connect` still performs `builder.build().await?` without a timeout. Even after adding `DEFAULT_STARTUP_TIMEOUT` and wrapping `init_schema`, startup can still hang indefinitely while creating the `Database` (remote connect / initial sync), which defeats the stated goal of bounding startup failure.
## Issue Context
The sqlx backend wraps both startup connect and startup schema setup in `with_auth_timeout(settings.startup_timeout, ...)`. The libsql backend should mirror this by applying `DEFAULT_STARTUP_TIMEOUT` (or a future config knob) around `Builder::build()` as well.
## Fix Focus Areas
- pnpr/crates/pnpr/src/auth/libsql_backend.rs[111-127]
- pnpr/crates/pnpr/src/auth/libsql_backend.rs[51-75]
## Expected change
Wrap both `Builder::new_remote_replica(...).build()` and `Builder::new_remote(...).build()` in `with_auth_timeout(DEFAULT_STARTUP_TIMEOUT, ...)` so startup cannot hang indefinitely on database creation.

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



Remediation recommended

2. Unbounded reconcile reads 🐞 Bug ⛨ Security
Description
add_or_login() can call reconcile_user_counter_overcount(), which performs SELECT queries
without with_auth_timeout, so that branch can still hang indefinitely if the libsql endpoint
stalls. This leaves a conditional remote-DoS path (registration/cap reconciliation) despite the new
request-path read timeouts.
Code

pnpr/crates/pnpr/src/auth/libsql_backend.rs[R64-75]

+async fn with_auth_timeout<Loaded, DbError>(
+    deadline: Duration,
+    future: impl Future<Output = std::result::Result<Loaded, DbError>>,
+) -> Result<Loaded>
+where
+    RegistryError: From<DbError>,
+{
+    match timeout(deadline, future).await {
+        Ok(result) => result.map_err(RegistryError::from),
+        Err(_) => Err(RegistryError::AuthDatabaseTimeout),
+    }
+}
Evidence
add_or_login() reaches reconcile_user_counter_overcount(&self.conn).await? on the request path
when the auth counter cap update returns 0, and reconcile_user_counter_overcount() issues two
tx.query(...).await? SELECTs; neither is wrapped by with_auth_timeout, so those reads remain
unbounded in that branch.

pnpr/crates/pnpr/src/auth/libsql_backend.rs[176-247]
pnpr/crates/pnpr/src/auth/libsql_backend.rs[379-406]

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 libsql backend added `with_auth_timeout(...)` and wrapped several request-path reads, but the `add_or_login()` reconciliation branch still calls `reconcile_user_counter_overcount()` which performs `SELECT` queries without any timeout. If the libsql endpoint is stalled/blackholed, those reads can hang the Tokio task indefinitely.
## Issue Context
This reconciliation branch is reachable on user-facing requests when the capped counter update fails (`updated == 0`) and `can_retry_after_reconcile` is still true.
## Fix Focus Areas
- pnpr/crates/pnpr/src/auth/libsql_backend.rs[221-247]
- pnpr/crates/pnpr/src/auth/libsql_backend.rs[379-406]
## Suggested fix
Wrap the reconciliation path with a deadline as well (either wrap the call site with `with_auth_timeout(self.timeout, reconcile_user_counter_overcount(&self.conn))`, or refactor `reconcile_user_counter_overcount` so its read portions are bounded). Ensure the chosen approach matches the project’s cancellation/commit-state expectations for this internal counter-repair operation.

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


3. Timeout comments reference PR 📘 Rule violation ⚙ Maintainability
Description
New doc comments describe implementation history and point readers to the PR description rather than
focusing on the code’s contract/invariant. This adds redundant/historical commentary and increases
maintenance burden when the implementation or config knobs change.
Code

pnpr/crates/pnpr/src/auth/libsql_backend.rs[R44-63]

+/// Deadline applied to every request-path auth database read. Mirrors the
+/// sqlx backend's `backend.<driver>.timeout` default so a stalled or hostile
+/// libsql/Turso endpoint cannot hold a Tokio task open indefinitely and
+/// exhaust the executor — a registry-wide `DoS`. (Not yet a separate YAML knob
+/// like the sqlx backend exposes; see the PR description.)
+const DEFAULT_AUTH_TIMEOUT: Duration = Duration::from_secs(30);
+
+/// Deadline for the one-time startup connect + schema setup. More generous
+/// than [`DEFAULT_AUTH_TIMEOUT`] (cold schema DDL against a remote primary can
+/// be slow) but still bounded so an unreachable database fails fast.
+const DEFAULT_STARTUP_TIMEOUT: Duration = Duration::from_mins(5);
+
+/// Bound a read-only request-path (or startup) database future with
+/// [`DEFAULT_AUTH_TIMEOUT`]-style deadline, surfacing
+/// [`RegistryError::AuthDatabaseTimeout`] (HTTP 504) on expiry instead of
+/// awaiting forever. Mirror of `with_auth_timeout` in [`super::sqlx_backend`];
+/// the two backends are independently feature-gated, so the helper is not
+/// shared. Use only around reads and startup: request-path writes must await
+/// the database result so a caller never observes a timeout with an unknown
+/// commit state.
Evidence
PR Compliance ID 7 requires comments to be minimal and contract-focused, avoiding redundant or
historical commentary. The added comment block includes PR-referential and roadmap framing (e.g.,
"see the PR description" / "Not yet a separate YAML knob"), which is not part of the stable contract
of the constants/helper.

AGENTS.md: Keep comments minimal and contract-focused; avoid redundant or historical commentary: AGENTS.md: Keep comments minimal and contract-focused; avoid redundant or historical commentary: AGENTS.md: Keep comments minimal and contract-focused; avoid redundant or historical commentary: AGENTS.md: Keep comments minimal and contract-focused; avoid redundant or historical commentary: AGENTS.md: Keep comments minimal and contract-focused; avoid redundant or historical commentary: AGENTS.md: Keep comments minimal and contract-focused; avoid redundant or historical commentary: AGENTS.md: Keep comments minimal and contract-focused; avoid redundant or historical commentary: AGENTS.md: Keep comments minimal and contract-focused; avoid redundant or historical commentary: AGENTS.md: Keep comments minimal and contract-focused; avoid redundant or historical commentary: AGENTS.md: Keep comments minimal and contract-focused; avoid redundant or historical commentary: AGENTS.md: Keep comments minimal and contract-focused; avoid redundant or historical commentary: AGENTS.md: Keep comments minimal and contract-focused; avoid redundant or historical commentary: AGENTS.md: Keep comments minimal and contract-focused; avoid redundant or historical commentary: AGENTS.md: Keep comments minimal and contract-focused; avoid redundant or historical commentary: AGENTS.md: Keep comments minimal and contract-focused; avoid redundant or historical commentary: AGENTS.md: Keep comments minimal and contract-focused; avoid redundant or historical commentary: AGENTS.md: Keep comments minimal and contract-focused; avoid redundant or historical commentary: AGENTS.md: Keep comments minimal and contract-focused; avoid redundant or historical commentary: AGENTS.md: Keep comments minimal and contract-focused; avoid redundant or historical commentary: AGENTS.md: Keep comments minimal and contract-focused; avoid redundant or historical commentary: AGENTS.md: Keep comments minimal and contract-focused; avoid redundant or historical commentary: AGENTS.md: Keep comments minimal and contract-focused; avoid redundant or historical commentary: AGENTS.md: Keep comments minimal and contract-focused; avoid redundant or historical commentary: AGENTS.md: Keep comments minimal and contract-focused; avoid redundant or historical commentary: AGENTS.md: Keep comments minimal and contract-focused; avoid redundant or historical commentary: AGENTS.md: Keep comments minimal and contract-focused; avoid redundant or historical commentary: AGENTS.md: Keep comments minimal and contract-focused; avoid redundant or historical commentary: AGENTS.md: Keep comments minimal and contract-focused; avoid redundant or historical commentary: AGENTS.md: Keep comments minimal and contract-focused; avoid redundant or historical commentary: AGENTS.md: Keep comments minimal and contract-focused; avoid redundant or historical commentary: AGENTS.md: Keep comments minimal and contract-focused; avoid redundant or historical commentary: AGENTS.md: Keep comments minimal and contract-focused; avoid redundant or historical commentary: AGENTS.md: Keep comments minimal and contract-focused; avoid redundant or historical commentary: AGENTS.md: Keep comments minimal and contract-focused; avoid redundant or historical commentary: AGENTS.md: Keep comments minimal and contract-focused; avoid redundant or historical commentary: AGENTS.md: Keep comments minimal and contract-focused; avoid redundant or historical commentary: AGENTS.md: Keep comments minimal and contract-focused; avoid redundant or historical commentary: AGENTS.md: Keep comments minimal and contract-focused; avoid redundant or historical commentary: AGENTS.md: Keep comments minimal and contract-focused; avoid redundant or historical commentary: AGENTS.md: Keep comments minimal and contract-focused; avoid redundant or historical commentary: AGENTS.md: Keep comments minimal and contract-focused; avoid redundant or historical commentary: AGENTS.md: Keep comments minimal and contract-focused; avoid redundant or historical commentary: AGENTS.md: Keep comments minimal and contract-focused; avoid redundant or historical commentary: AGENTS.md: Keep comments minimal and contract-focused; avoid redundant or historical commentary: AGENTS.md: Keep comments minimal and contract-focused; avoid redundant or historical commentary: AGENTS.md: Keep comments minimal and contract-focused; avoid redundant or historical commentary: AGENTS.md: Keep comments minimal and contract-focused; avoid redundant or historical commentary: AGENTS.md: Keep comments minimal and contract-focused; avoid redundant or historical commentary: AGENTS.md: Keep comments minimal and contract-focused; avoid redundant or historical commentary: AGENTS.md: Keep comments minimal and contract-focused; avoid redundant or historical commentary: AGENTS.md: Keep comments minimal and contract-focused; avoid redundant or historical commentary: AGENTS.md: Keep comments minimal and contract-focused; avoid redundant or historical commentary: AGENTS.md: Keep comments minimal and contract-focused; avoid redundant or historical commentary: AGENTS.md: Keep comments minimal and contract-focused; avoid redundant or historical commentary: AGENTS.md: Keep comments minimal and contract-focused; avoid redundant or historical commentary: AGENTS.md: Keep comments minimal and contract-focused; avoid redundant or historical commentary: AGENTS.md: Keep comments minimal and contract-focused; avoid redundant or historical commentary: AGENTS.md: Keep comments minimal and contract-focused; avoid redundant or historical commentary: AGENTS.md: Keep comments minimal and contract-focused; avoid redundant or historical commentary: AGENTS.md: Keep comments minimal and contract-focused; avoid redundant or historical commentary: AGENTS.md: Keep comments minimal and contract-focused; avoid redundant or historical commentary: AGENTS.md: Keep comments minimal and contract-focused; avoid redundant or historical commentary: AGENTS.md: Keep comments minimal and contract-focused; avoid redundant or historical commentary: AGENTS.md: Keep comments minimal and contract-focused; avoid redundant or historical commentary: AGENTS.md: Keep comments minimal and contract-focused; avoid redundant or historical commentary: AGENTS.md: Keep comments minimal and contract-focused; avoid redundant or historical commentary: AGENTS.md: Keep comments minimal and contract-focused; avoid redundant or historical commentary: AGENTS.md: Keep comments minimal and contract-focused; avoid redundant or historical commentary: AGENTS.md: Keep comments minimal and contract-focused; avoid redundant or historical commentary: AGENTS.md: Keep comments minimal and contract-focused; avoid redundant or historical commentary: AGENTS.md: Keep comments minimal and contract-focused; avoid redundant or historical commentary: AGENTS.md: Keep comments minimal and contract-focused; avoid redundant or historical commentary: AGENTS.md: Keep comments minimal and contract-focused; avoid redundant or historical commentary: AGENTS.md: Keep comments minimal and contract-focused; avoid redundant or historical commentary: AGENTS.md: Keep comments minimal and contract-focused; avoid redundant or historical commentary: AGENTS.md: Keep comments minimal and contract-focused; avoid redundant or historical commentary: AGENTS.md: Keep comments minimal and contract-focused; avoid redundant or historical commentary: AGENTS.md: Keep comments minimal and contract-focused; avoid redundant or historical commentary: AGENTS.md: Keep comments minimal and contract-focused; avoid redundant or historical commentary: AGENTS.md: Keep comments minimal and contract-focused; avoid redundant or historical commentary: AGENTS.md: Keep comments minimal and contract-focused; avoid redundant or historical commentary: AGENTS.md: Keep comments minimal and contract-focused; avoid redundant or historical commentary: AGENTS.md: Keep comments minimal and contract-focused; avoid redundant or historical commentary: AGENTS.md: Keep comments minimal and contract-focused; avoid redundant or historical commentary: AGENTS.md: Keep comments minimal and contract-focused; avoid redundant or historical commentary: AGENTS.md: Keep comments minimal and contract-focused; avoid redundant or historical commentary: AGENTS.md: Keep comments minimal and contract-focused; avoid redundant or historical commentary: AGENTS.md: Keep comments minimal and contract-focused; avoid redundant or historical commentary: AGENTS.md: Keep comments minimal and contract-focused; avoid redundant or historical commentary: AGENTS.md: Keep comments minimal and contract-focused; avoid redundant or historical commentary: AGENTS.md: Keep comments minimal and contract-focused; avoid redundant or historical commentary: AGENTS.md: Keep comments minimal and contract-focused; avoid redundant or historical commentary: AGENTS.md: Keep comments minimal and contract-focused; avoid redundant or historical commentary: AGENTS.md: Keep comments minimal and contract-focused; avoid redundant or historical commentary: AGENTS.md: Keep comments minimal and contract-focused; avoid redundant or historical commentary: AGENTS.md: Keep comments minimal and contract-focused; avoid redundant or historical commentary: AGENTS.md: Keep comments minimal and contract-focused; avoid redundant or historical commentary: AGENTS.md: Keep comments minimal and contract-focused; avoid redundant or historical commentary: AGENTS.md: Keep comments minimal and contract-focused; avoid redundant or historical commentary: AGENTS.md: Keep comments minimal and contract-focused; avoid redundant or historical commentary: AGENTS.md: Keep comments minimal and contract-focused; avoid redundant or historical commentary: AGENTS.md: Keep comments minimal and contract-focused; avoid redundant or historical commentary: AGENTS.md: Keep comments minimal and contract-focused; avoid redundant or historical commentary: AGENTS.md: Keep comments minimal and contract-focused; avoid redundant or historical commentary: AGENTS.md: Keep comments minimal and contract-focused; avoid redundant or historical commentary: AGENTS.md: Keep comments minimal and contract-focused; avoid redundant or historical commentary: AGENTS.md: Keep comments minimal and contract-focused; avoid redundant or historical commentary: AGENTS.md: Keep comments minimal and contract-focused; avoid redundant or historical commentary: AGENTS.md: Keep comments minimal and contract-focused; avoid redundant or historical commentary: AGENTS.md: Keep comments minimal and contract-focused; avoid redundant or historical commentary: AGENTS.md: Keep comments minimal and contract-focused; avoid redundant or historical commentary: AGENTS.md: Keep comments minimal and contract-focused; avoid redundant or historical commentary: AGENTS.md: Keep comments minimal and contract-focused; avoid redundant or historical commentary: AGENTS.md: Keep comments minimal and contract-focused; avoid redundant or historical commentary: AGENTS.md: Keep comments minimal and contract-focused; avoid redundant or historical commentary: AGENTS.md: Keep comments minimal and contract-focused; avoid redundant or historical commentary: AGENTS.md: Keep comments minimal and contract-focused; avoid redundant or historical commentary: AGENTS.md: Keep comments minimal and contract-focused; avoid redundant or historical commentary: AGENTS.md: Keep comments minimal and contract-focused; avoid redundant or historical commentary: AGENTS.md: Keep comments minimal and contract-focused; avoid redundant or historical commentary: AGENTS.md: Keep comments minimal and contract-focused; avoid redundant or historical commentary: AGENTS.md: Keep comments minimal and contract-focused; avoid redundant or historical commentary: AGENTS.md: Keep comments minimal and contract-focused; avoid redundant or historical commentary: AGENTS.md: Keep comments minimal and contract-focused; avoid redundant or historical commentary: AGENTS.md: Keep comments minimal and contract-focused; avoid redundant or historical commentary: AGENTS.md: Keep comments minimal and contract-focused; avoid redundant or historical commentary: AGENTS.md: Keep comments minimal and contract-focused; avoid redundant or historical commentary: AGENTS.md: Keep comments minimal and contract-focused; avoid redundant or historical commentary
pnpr/crates/pnpr/src/auth/libsql_backend.rs[44-63]

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

## Issue description
Comments added around the libsql auth timeout constants/helper include historical/PR-specific context (e.g., "see the PR description" and roadmap notes about YAML knobs) rather than a minimal contract-focused explanation.
## Issue Context
Per repo guidance, comments should capture the stable *why/contract* and avoid PR-history or duplicated rationale that will drift as the implementation/config evolves.
## Fix Focus Areas
- pnpr/crates/pnpr/src/auth/libsql_backend.rs[44-63]

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


4. Libsql writes still unbounded 🐞 Bug ⛨ Security
Description
The new with_auth_timeout documentation says request-path writes “rely on the database's own
statement timeout”, but the libsql backend does not configure any statement/operation timeout and
still awaits write queries directly. A stalled/blackholed libsql endpoint can therefore still hold
Tokio tasks open indefinitely on write-heavy endpoints (e.g. token issue/revoke, user creation),
leaving a DoS path despite the read timeouts.
Code

pnpr/crates/pnpr/src/auth/libsql_backend.rs[R56-63]

+/// Bound a read-only request-path (or startup) database future with
+/// [`DEFAULT_AUTH_TIMEOUT`]-style deadline, surfacing
+/// [`RegistryError::AuthDatabaseTimeout`] (HTTP 504) on expiry instead of
+/// awaiting forever. Mirror of `with_auth_timeout` in [`super::sqlx_backend`];
+/// the two backends are independently feature-gated, so the helper is not
+/// shared. Use only around reads and startup: request-path writes must await
+/// the database result so a caller never observes a timeout with an unknown
+/// commit state.
Evidence
The PR adds a comment asserting writes rely on a DB statement timeout, but the libsql backend does
not set any such timeout and still awaits write statements directly; meanwhile the sqlx backends
explicitly configure statement_timeout, demonstrating the gap.

pnpr/crates/pnpr/src/auth/libsql_backend.rs[56-63]
pnpr/crates/pnpr/src/auth/libsql_backend.rs[111-126]
pnpr/crates/pnpr/src/auth/libsql_backend.rs[249-269]
pnpr/crates/pnpr/src/auth/libsql_backend.rs[275-290]
pnpr/crates/pnpr/src/config.rs[218-240]
pnpr/crates/pnpr/src/auth/sqlx_backend.rs[247-268]

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

## Issue description
`libsql_backend` now documents that request-path writes are intentionally not wrapped in `with_auth_timeout` because they should rely on the database’s statement timeout. In this repo, the sqlx backends explicitly configure `statement_timeout`, but the libsql backend does not configure an equivalent—so write operations remain unbounded under network partitions / stalled endpoints, which is still an availability/DoS risk.
### Issue Context
This PR bounds libsql reads and startup schema setup with a Tokio timeout. Writes (INSERT/DELETE/transactional work) are intentionally left unwrapped; that’s reasonable for commit-state correctness, but only if there is a *real* backend-side timeout in effect.
### Fix Focus Areas
- pnpr/crates/pnpr/src/auth/libsql_backend.rs[56-63]
- pnpr/crates/pnpr/src/auth/libsql_backend.rs[111-126]
- pnpr/crates/pnpr/src/auth/libsql_backend.rs[249-269]
- pnpr/crates/pnpr/src/auth/libsql_backend.rs[275-290]
- pnpr/crates/pnpr/src/auth/sqlx_backend.rs[247-268]
### What to change
Choose one (or combine):
1. **Make the comment accurate and enforceable**: update the `with_auth_timeout` doc comment to explicitly state that libsql write bounding depends on *external* server-side configuration (and is not set by pnpr), and document the operational requirement.
2. **Add a libsql-side statement/operation timeout configuration** (if the libsql client/server supports it) during `connect`/`from_database`, analogous to sqlx’s `SET statement_timeout`, so write awaits are actually bounded.
3. **If neither is possible**, consider a bounded strategy for write endpoints (e.g., rejecting new work once the backend is deemed unhealthy via a circuit breaker), to prevent executor exhaustion without returning a misleading success/failure signal.

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


View more (2)
5. Duplicated with_auth_timeout helper 📘 Rule violation ⚙ Maintainability
Description
with_auth_timeout is reimplemented in libsql_backend.rs even though an equivalent helper already
exists in sqlx_backend.rs, increasing maintenance cost and the risk of behavioral drift between
backends.
Code

pnpr/crates/pnpr/src/auth/libsql_backend.rs[R56-75]

+/// Bound a read-only request-path (or startup) database future with
+/// [`DEFAULT_AUTH_TIMEOUT`]-style deadline, surfacing
+/// [`RegistryError::AuthDatabaseTimeout`] (HTTP 504) on expiry instead of
+/// awaiting forever. Mirror of `with_auth_timeout` in [`super::sqlx_backend`];
+/// the two backends are independently feature-gated, so the helper is not
+/// shared. Use only around reads and startup: request-path writes must await
+/// the database result so a caller never observes a timeout with an unknown
+/// commit state.
+async fn with_auth_timeout<T, E>(
+    deadline: Duration,
+    future: impl Future<Output = std::result::Result<T, E>>,
+) -> Result<T>
+where
+    RegistryError: From<E>,
+{
+    match timeout(deadline, future).await {
+        Ok(result) => result.map_err(RegistryError::from),
+        Err(_) => Err(RegistryError::AuthDatabaseTimeout),
+    }
+}
Evidence
PR Compliance ID 2 requires avoiding duplicate implementations when existing repo utilities can be
reused. The PR adds a new with_auth_timeout in libsql_backend.rs that matches the existing
sqlx_backend.rs helper, indicating duplication rather than reuse/extraction.

AGENTS.md: Avoid duplicate implementations; reuse existing repo utilities and well-maintained OSS libraries: AGENTS.md: Avoid duplicate implementations; reuse existing repo utilities and well-maintained OSS libraries: AGENTS.md: Avoid duplicate implementations; reuse existing repo utilities and well-maintained OSS libraries: AGENTS.md: Avoid duplicate implementations; reuse existing repo utilities and well-maintained OSS libraries: AGENTS.md: Avoid duplicate implementations; reuse existing repo utilities and well-maintained OSS libraries: AGENTS.md: Avoid duplicate implementations; reuse existing repo utilities and well-maintained OSS libraries: AGENTS.md: Avoid duplicate implementations; reuse existing repo utilities and well-maintained OSS libraries: AGENTS.md: Avoid duplicate implementations; reuse existing repo utilities and well-maintained OSS libraries: AGENTS.md: Avoid duplicate implementations; reuse existing repo utilities and well-maintained OSS libraries: AGENTS.md: Avoid duplicate implementations; reuse existing repo utilities and well-maintained OSS libraries: AGENTS.md: Avoid duplicate implementations; reuse existing repo utilities and well-maintained OSS libraries: AGENTS.md: Avoid duplicate implementations; reuse existing repo utilities and well-maintained OSS libraries: AGENTS.md: Avoid duplicate implementations; reuse existing repo utilities and well-maintained OSS libraries: AGENTS.md: Avoid duplicate implementations; reuse existing repo utilities and well-maintained OSS libraries: AGENTS.md: Avoid duplicate implementations; reuse existing repo utilities and well-maintained OSS libraries: AGENTS.md: Avoid duplicate implementations; reuse existing repo utilities and well-maintained OSS libraries: AGENTS.md: Avoid duplicate implementations; reuse existing repo utilities and well-maintained OSS libraries: AGENTS.md: Avoid duplicate implementations; reuse existing repo utilities and well-maintained OSS libraries: AGENTS.md: Avoid duplicate implementations; reuse existing repo utilities and well-maintained OSS libraries: AGENTS.md: Avoid duplicate implementations; reuse existing repo utilities and well-maintained OSS libraries: AGENTS.md: Avoid duplicate implementations; reuse existing repo utilities and well-maintained OSS libraries: AGENTS.md: Avoid duplicate implementations; reuse existing repo utilities and well-maintained OSS libraries: AGENTS.md: Avoid duplicate implementations; reuse existing repo utilities and well-maintained OSS libraries: AGENTS.md: Avoid duplicate implementations; reuse existing repo utilities and well-maintained OSS libraries: AGENTS.md: Avoid duplicate implementations; reuse existing repo utilities and well-maintained OSS libraries: AGENTS.md: Avoid duplicate implementations; reuse existing repo utilities and well-maintained OSS libraries: AGENTS.md: Avoid duplicate implementations; reuse existing repo utilities and well-maintained OSS libraries: AGENTS.md: Avoid duplicate implementations; reuse existing repo utilities and well-maintained OSS libraries: AGENTS.md: Avoid duplicate implementations; reuse existing repo utilities and well-maintained OSS libraries: AGENTS.md: Avoid duplicate implementations; reuse existing repo utilities and well-maintained OSS libraries: AGENTS.md: Avoid duplicate implementations; reuse existing repo utilities and well-maintained OSS libraries: AGENTS.md: Avoid duplicate implementations; reuse existing repo utilities and well-maintained OSS libraries: AGENTS.md: Avoid duplicate implementations; reuse existing repo utilities and well-maintained OSS libraries: AGENTS.md: Avoid duplicate implementations; reuse existing repo utilities and well-maintained OSS libraries: AGENTS.md: Avoid duplicate implementations; reuse existing repo utilities and well-maintained OSS libraries: AGENTS.md: Avoid duplicate implementations; reuse existing repo utilities and well-maintained OSS libraries: AGENTS.md: Avoid duplicate implementations; reuse existing repo utilities and well-maintained OSS libraries: AGENTS.md: Avoid duplicate implementations; reuse existing repo utilities and well-maintained OSS libraries: AGENTS.md: Avoid duplicate implementations; reuse existing repo utilities and well-maintained OSS libraries: AGENTS.md: Avoid duplicate implementations; reuse existing repo utilities and well-maintained OSS libraries: AGENTS.md: Avoid duplicate implementations; reuse existing repo utilities and well-maintained OSS libraries: AGENTS.md: Avoid duplicate implementations; reuse existing repo utilities and well-maintained OSS libraries: AGENTS.md: Avoid duplicate implementations; reuse existing repo utilities and well-maintained OSS libraries: AGENTS.md: Avoid duplicate implementations; reuse existing repo utilities and well-maintained OSS libraries: AGENTS.md: Avoid duplicate implementations; reuse existing repo utilities and well-maintained OSS libraries: AGENTS.md: Avoid duplicate implementations; reuse existing repo utilities and well-maintained OSS libraries: AGENTS.md: Avoid duplicate implementations; reuse existing repo utilities and well-maintained OSS libraries: AGENTS.md: Avoid duplicate implementations; reuse existing repo utilities and well-maintained OSS libraries: AGENTS.md: Avoid duplicate implementations; reuse existing repo utilities and well-maintained OSS libraries: AGENTS.md: Avoid duplicate implementations; reuse existing repo utilities and well-maintained OSS libraries: AGENTS.md: Avoid duplicate implementations; reuse existing repo utilities and well-maintained OSS libraries: AGENTS.md: Avoid duplicate implementations; reuse existing repo utilities and well-maintained OSS libraries: AGENTS.md: Avoid duplicate implementations; reuse existing repo utilities and well-maintained OSS libraries: AGENTS.md: Avoid duplicate implementations; reuse existing repo utilities and well-maintained OSS libraries: AGENTS.md: Avoid duplicate implementations; reuse existing repo utilities and well-maintained OSS libraries: AGENTS.md: Avoid duplicate implementations; reuse existing repo utilities and well-maintained OSS libraries: AGENTS.md: Avoid duplicate implementations; reuse existing repo utilities and well-maintained OSS libraries: AGENTS.md: Avoid duplicate implementations; reuse existing repo utilities and well-maintained OSS libraries: AGENTS.md: Avoid duplicate implementations; reuse existing repo utilities and well-maintained OSS libraries: AGENTS.md: Avoid duplicate implementations; reuse existing repo utilities and well-maintained OSS libraries: AGENTS.md: Avoid duplicate implementations; reuse existing repo utilities and well-maintained OSS libraries: AGENTS.md: Avoid duplicate implementations; reuse existing repo utilities and well-maintained OSS libraries: AGENTS.md: Avoid duplicate implementations; reuse existing repo utilities and well-maintained OSS libraries: AGENTS.md: Avoid duplicate implementations; reuse existing repo utilities and well-maintained OSS libraries: AGENTS.md: Avoid duplicate implementations; reuse existing repo utilities and well-maintained OSS libraries: AGENTS.md: Avoid duplicate implementations; reuse existing repo utilities and well-maintained OSS libraries: AGENTS.md: Avoid duplicate implementations; reuse existing repo utilities and well-maintained OSS libraries: AGENTS.md: Avoid duplicate implementations; reuse existing repo utilities and well-maintained OSS libraries: AGENTS.md: Avoid duplicate implementations; reuse existing repo utilities and well-maintained OSS libraries: AGENTS.md: Avoid duplicate implementations; reuse existing repo utilities and well-maintained OSS libraries: AGENTS.md: Avoid duplicate implementations; reuse existing repo utilities and well-maintained OSS libraries: AGENTS.md: Avoid duplicate implementations; reuse existing repo utilities and well-maintained OSS libraries: AGENTS.md: Avoid duplicate implementations; reuse existing repo utilities and well-maintained OSS libraries: AGENTS.md: Avoid duplicate implementations; reuse existing repo utilities and well-maintained OSS libraries: AGENTS.md: Avoid duplicate implementations; reuse existing repo utilities and well-maintained OSS libraries: AGENTS.md: Avoid duplicate implementations; reuse existing repo utilities and well-maintained OSS libraries: AGENTS.md: Avoid duplicate implementations; reuse existing repo utilities and well-maintained OSS libraries: AGENTS.md: Avoid duplicate implementations; reuse existing repo utilities and well-maintained OSS libraries: AGENTS.md: Avoid duplicate implementations; reuse existing repo utilities and well-maintained OSS libraries: AGENTS.md: Avoid duplicate implementations; reuse existing repo utilities and well-maintained OSS libraries: AGENTS.md: Avoid duplicate implementations; reuse existing repo utilities and well-maintained OSS libraries: AGENTS.md: Avoid duplicate implementations; reuse existing repo utilities and well-maintained OSS libraries: AGENTS.md: Avoid duplicate implementations; reuse existing repo utilities and well-maintained OSS libraries: AGENTS.md: Avoid duplicate implementations; reuse existing repo utilities and well-maintained OSS libraries: AGENTS.md: Avoid duplicate implementations; reuse existing repo utilities and well-maintained OSS libraries: AGENTS.md: Avoid duplicate implementations; reuse existing repo utilities and well-maintained OSS libraries: AGENTS.md: Avoid duplicate implementations; reuse existing repo utilities and well-maintained OSS libraries: AGENTS.md: Avoid duplicate implementations; reuse existing repo utilities and well-maintained OSS libraries: AGENTS.md: Avoid duplicate implementations; reuse existing repo utilities and well-maintained OSS libraries: AGENTS.md: Avoid duplicate implementations; reuse existing repo utilities and well-maintained OSS libraries: AGENTS.md: Avoid duplicate implementations; reuse existing repo utilities and well-maintained OSS libraries: AGENTS.md: Avoid duplicate implementations; reuse existing repo utilities and well-maintained OSS libraries: AGENTS.md: Avoid duplicate implementations; reuse existing repo utilities and well-maintained OSS libraries: AGENTS.md: Avoid duplicate implementations; reuse existing repo utilities and well-maintained OSS libraries: AGENTS.md: Avoid duplicate implementations; reuse existing repo utilities and well-maintained OSS libraries: AGENTS.md: Avoid duplicate implementations; reuse existing repo utilities and well-maintained OSS libraries: AGENTS.md: Avoid duplicate implementations; reuse existing repo utilities and well-maintained OSS libraries: AGENTS.md: Avoid duplicate implementations; reuse existing repo utilities and well-maintained OSS libraries: AGENTS.md: Avoid duplicate implementations; reuse existing repo utilities and well-maintained OSS libraries: AGENTS.md: Avoid duplicate implementations; reuse existing repo utilities and well-maintained OSS libraries: AGENTS.md: Avoid duplicate implementations; reuse existing repo utilities and well-maintained OSS libraries: AGENTS.md: Avoid duplicate implementations; reuse existing repo utilities and well-maintained OSS libraries: AGENTS.md: Avoid duplicate implementations; reuse existing repo utilities and well-maintained OSS libraries: AGENTS.md: Avoid duplicate implementations; reuse existing repo utilities and well-maintained OSS libraries: AGENTS.md: Avoid duplicate implementations; reuse existing repo utilities and well-maintained OSS libraries: AGENTS.md: Avoid duplicate implementations; reuse existing repo utilities and well-maintained OSS libraries: AGENTS.md: Avoid duplicate implementations; reuse existing repo utilities and well-maintained OSS libraries: AGENTS.md: Avoid duplicate implementations; reuse existing repo utilities and well-maintained OSS libraries: AGENTS.md: Avoid duplicate implementations; reuse existing repo utilities and well-maintained OSS libraries: AGENTS.md: Avoid duplicate implementations; reuse existing repo utilities and well-maintained OSS libraries: AGENTS.md: Avoid duplicate implementations; reuse existing repo utilities and well-maintained OSS libraries: AGENTS.md: Avoid duplicate implementations; reuse existing repo utilities and well-maintained OSS libraries: AGENTS.md: Avoid duplicate implementations; reuse existing repo utilities and well-maintained OSS libraries: AGENTS.md: Avoid duplicate implementations; reuse existing repo utilities and well-maintained OSS libraries: AGENTS.md: Avoid duplicate implementations; reuse existing repo utilities and well-maintained OSS libraries: AGENTS.md: Avoid duplicate implementations; reuse existing repo utilities and well-maintained OSS libraries: AGENTS.md: Avoid duplicate implementations; reuse existing repo utilities and well-maintained OSS libraries: AGENTS.md: Avoid duplicate implementations; reuse existing repo utilities and well-maintained OSS libraries: AGENTS.md: Avoid duplicate implementations; reuse existing repo utilities and well-maintained OSS libraries: AGENTS.md: Avoid duplicate implementations; reuse existing repo utilities and well-maintained OSS libraries: AGENTS.md: Avoid duplicate implementations; reuse existing repo utilities and well-maintained OSS libraries: AGENTS.md: Avoid duplicate implementations; reuse existing repo utilities and well-maintained OSS libraries: AGENTS.md: Avoid duplicate implementations; reuse existing repo utilities and well-maintained OSS libraries: AGENTS.md: Avoid duplicate implementations; reuse existing repo utilities and well-maintained OSS libraries: AGENTS.md: Avoid duplicate implementations; reuse existing repo utilities and well-maintained OSS libraries: AGENTS.md: Avoid duplicate implementations; reuse existing repo utilities and well-maintained OSS libraries: AGENTS.md: Avoid duplicate implementations; reuse existing repo utilities and well-maintained OSS libraries: AGENTS.md: Avoid duplicate implementations; reuse existing repo utilities and well-maintained OSS libraries: AGENTS.md: Avoid duplicate implementations; reuse existing repo utilities and well-maintained OSS libraries: AGENTS.md: Avoid duplicate implementations; reuse existing repo utilities and well-maintained OSS libraries: AGENTS.md: Avoid duplicate implementations; reuse existing repo utilities and well-maintained OSS libraries: AGENTS.md: Avoid duplicate implementations; reuse existing repo utilities and well-maintained OSS libraries: AGENTS.md: Avoid duplicate implementations; reuse existing repo utilities and well-maintained OSS libraries: AGENTS.md: Avoid duplicate implementations; reuse existing repo utilities and well-maintained OSS libraries: AGENTS.md: Avoid duplicate implementations; reuse existing repo utilities and well-maintained OSS libraries: AGENTS.md: Avoid duplicate implementations; reuse existing repo utilities and well-maintained OSS libraries: AGENTS.md: Avoid duplicate implementations; reuse existing repo utilities and well-maintained OSS libraries: AGENTS.md: Avoid duplicate implementations; reuse existing repo utilities and well-maintained OSS libraries: AGENTS.md: Avoid duplicate implementations; reuse existing repo utilities and well-maintained OSS libraries: AGENTS.md: Avoid duplicate implementations; reuse existing repo utilities and well-maintained OSS libraries: AGENTS.md: Avoid duplicate implementations; reuse existing repo utilities and well-maintained OSS libraries: AGENTS.md: Avoid duplicate implementations; reuse existing repo utilities and well-maintained OSS libraries: AGENTS.md: Avoid duplicate implementations; reuse existing repo utilities and well-maintained OSS libraries: AGENTS.md: Avoid duplicate implementations; reuse existing repo utilities and well-maintained OSS libraries: AGENTS.md: Avoid duplicate implementations; reuse existing repo utilities and well-maintained OSS libraries: AGENTS.md: Avoid duplicate implementations; reuse existing repo utilities and well-maintained OSS libraries: AGENTS.md: Avoid duplicate implementations; reuse existing repo utilities and well-maintained OSS libraries: AGENTS.md: Avoid duplicate implementations; reuse existing repo utilities and well-maintained OSS libraries: AGENTS.md: Avoid duplicate implementations; reuse existing repo utilities and well-maintained OSS libraries: AGENTS.md: Avoid duplicate implementations; reuse existing repo utilities and well-maintained OSS libraries: AGENTS.md: Avoid duplicate implementations; reuse existing repo utilities and well-maintained OSS libraries: AGENTS.md: Avoid duplicate implementations; reuse existing repo utilities and well-maintained OSS libraries: AGENTS.md: Avoid duplicate implementations; reuse existing repo utilities and well-maintained OSS libraries: AGENTS.md: Avoid duplicate implementations; reuse existing repo utilities and well-maintained OSS libraries: AGENTS.md: Avoid duplicate implementations; reuse existing repo utilities and well-maintained OSS libraries: AGENTS.md: Avoid duplicate implementations; reuse existing repo utilities and well-maintained OSS libraries: AGENTS.md: Avoid duplicate implementations; reuse existing repo utilities and well-maintained OSS libraries: AGENTS.md: Avoid duplicate implementations; reuse existing repo utilities and well-maintained OSS libraries: AGENTS.md: Avoid duplicate implementations; reuse existing repo utilities and well-maintained OSS libraries: AGENTS.md: Avoid duplicate implementations; reuse existing repo utilities and well-maintained OSS libraries: AGENTS.md: Avoid duplicate implementations; reuse existing repo utilities and well-maintained OSS libraries: AGENTS.md: Avoid duplicate implementations; reuse existing repo utilities and well-maintained OSS libraries: AGENTS.md: Avoid duplicate implementations; reuse existing repo utilities and well-maintained OSS libraries: AGENTS.md: Avoid duplicate implementations; reuse existing repo utilities and well-maintained OSS libraries: AGENTS.md: Avoid duplicate implementations; reuse existing repo utilities and well-maintained OSS libraries: AGENTS.md: Avoid duplicate implementations; reuse existing repo utilities and well-maintained OSS libraries: AGENTS.md: Avoid duplicate implementations; reuse existing repo utilities and well-maintained OSS libraries: AGENTS.md: Avoid duplicate implementations; reuse existing repo utilities and well-maintained OSS libraries: AGENTS.md: Avoid duplicate implementations; reuse existing repo utilities and well-maintained OSS libraries: AGENTS.md: Avoid duplicate implementations; reuse existing repo utilities and well-maintained OSS libraries: AGENTS.md: Avoid duplicate implementations; reuse existing repo utilities and well-maintained OSS libraries: AGENTS.md: Avoid duplicate implementations; reuse existing repo utilities and well-maintained OSS libraries: AGENTS.md: Avoid duplicate implementations; reuse existing repo utilities and well-maintained OSS libraries: AGENTS.md: Avoid duplicate implementations; reuse existing repo utilities and well-maintained OSS libraries: AGENTS.md: Avoid duplicate implementations; reuse existing repo utilities and well-maintained OSS libraries: AGENTS.md: Avoid duplicate implementations; reuse existing repo utilities and well-maintained OSS libraries: AGENTS.md: Avoid duplicate implementations; reuse existing repo utilities and well-maintained OSS libraries: AGENTS.md: Avoid duplicate implementations; reuse existing repo utilities and well-maintained OSS libraries: AGENTS.md: Avoid duplicate implementations; reuse existing repo utilities and well-maintained OSS libraries: AGENTS.md: Avoid duplicate implementations; reuse existing repo utilities and well-maintained OSS libraries: AGENTS.md: Avoid duplicate implementations; reuse existing repo utilities and well-maintained OSS libraries: AGENTS.md: Avoid duplicate implementations; reuse existing repo utilities and well-maintained OSS libraries: AGENTS.md: Avoid duplicate implementations; reuse existing repo utilities and well-maintained OSS libraries: AGENTS.md: Avoid duplicate implementations; reuse existing repo utilities and well-maintained OSS libraries: AGENTS.md: Avoid duplicate implementations; reuse existing repo utilities and well-maintained OSS libraries: AGENTS.md: Avoid duplicate implementations; reuse existing repo utilities and well-maintained OSS libraries: AGENTS.md: Avoid duplicate implementations; reuse existing repo utilities and well-maintained OSS libraries: AGENTS.md: Avoid duplicate implementations; reuse existing repo utilities and well-maintained OSS libraries: AGENTS.md: Avoid duplicate implementations; reuse existing repo utilities and well-maintained OSS libraries: AGENTS.md: Avoid duplicate implementations; reuse existing repo utilities and well-maintained OSS libraries: AGENTS.md: Avoid duplicate implementations; reuse existing repo utilities and well-maintained OSS libraries: AGENTS.md: Avoid duplicate implementations; reuse existing repo utilities and well-maintained OSS libraries: AGENTS.md: Avoid duplicate implementations; reuse existing repo utilities and well-maintained OSS libraries: AGENTS.md: Avoid duplicate implementations; reuse existing repo utilities and well-maintained OSS libraries: AGENTS.md: Avoid duplicate implementations; reuse existing repo utilities and well-maintained OSS libraries: AGENTS.md: Avoid duplicate implementations; reuse existing repo utilities and well-maintained OSS libraries: AGENTS.md: Avoid duplicate implementations; reuse existing repo utilities and well-maintained OSS libraries: AGENTS.md: Avoid duplicate implementations; reuse existing repo utilities and well-maintained OSS libraries: AGENTS.md: Avoid duplicate implementations; reuse existing repo utilities and well-maintained OSS libraries: AGENTS.md: Avoid duplicate implementations; reuse existing repo utilities and well-maintained OSS libraries: AGENTS.md: Avoid duplicate implementations; reuse existing repo utilities and well-maintained OSS libraries: AGENTS.md: Avoid duplicate implementations; reuse existing repo utilities and well-maintained OSS libraries: AGENTS.md: Avoid duplicate implementations; reuse existing repo utilities and well-maintained OSS libraries: AGENTS.md: Avoid duplicate implementations; reuse existing repo utilities and well-maintained OSS libraries: AGENTS.md: Avoid duplicate implementations; reuse existing repo utilities and well-maintained OSS libraries: AGENTS.md: Avoid duplicate implementations; reuse existing repo utilities and well-maintained OSS libraries: AGENTS.md: Avoid duplicate implementations; reuse existing repo utilities and well-maintained OSS libraries: AGENTS.md: Avoid duplicate implementations; reuse existing repo utilities and well-maintained OSS libraries: AGENTS.md: Avoid duplicate implementations; reuse existing repo utilities and well-maintained OSS libraries: AGENTS.md: Avoid duplicate implementations; reuse existing repo utilities and well-maintained OSS libraries: AGENTS.md: Avoid duplicate implementations; reuse existing repo utilities and well-maintained OSS libraries: AGENTS.md: Avoid duplicate implementations; reuse existing repo utilities and well-maintained OSS libraries: AGENTS.md: Avoid duplicate implementations; reuse existing repo utilities and well-maintained OSS libraries: AGENTS.md: Avoid duplicate implementations; reuse existing repo utilities and well-maintained OSS libraries: AGENTS.md: Avoid duplicate implementations; reuse existing repo utilities and well-maintained OSS libraries: AGENTS.md: Avoid duplicate implementations; reuse existing repo utilities and well-maintained OSS libraries: AGENTS.md: Avoid duplicate implementations; reuse existing repo utilities and well-maintained OSS libraries: AGENTS.md: Avoid duplicate implementations; reuse existing repo utilities and well-maintained OSS libraries: AGENTS.md: Avoid duplicate implementations; reuse existing repo utilities and well-maintained OSS libraries: AGENTS.md: Avoid duplicate implementations; reuse existing repo utilities and well-maintained OSS libraries: AGENTS.md: Avoid duplicate implementations; reuse existing repo utilities and well-maintained OSS libraries: AGENTS.md: Avoid duplicate implementations; reuse existing repo utilities and well-maintained OSS libraries: AGENTS.md: Avoid duplicate implementations; reuse existing repo utilities and well-maintained OSS libraries: AGENTS.md: Avoid duplicate implementations; reuse existing repo utilities and well-maintained OSS libraries: AGENTS.md: Avoid duplicate implementations; reuse existing repo utilities and well-maintained OSS libraries: AGENTS.md: Avoid duplicate implementations; reuse existing repo utilities and well-maintained OSS libraries: AGENTS.md: Avoid duplicate implementations; reuse existing repo utilities and well-maintained OSS libraries: AGENTS.md: Avoid duplicate implementations; reuse existing repo utilities and well-maintained OSS libraries: AGENTS.md: Avoid duplicate implementations; reuse existing repo utilities and well-maintained OSS libraries: AGENTS.md: Avoid duplicate implementations; reuse existing repo utilities and well-maintained OSS libraries: AGENTS.md: Avoid duplicate implementations; reuse existing repo utilities and well-maintained OSS libraries: AGENTS.md: Avoid duplicate implementations; reuse existing repo utilities and well-maintained OSS libraries: AGENTS.md: Avoid duplicate implementations; reuse existing repo utilities and well-maintained OSS libraries: AGENTS.md: Avoid duplicate implementations; reuse existing repo utilities and well-maintained OSS libraries: AGENTS.md: Avoid duplicate implementations; reuse existing repo utilities and well-maintained OSS libraries: AGENTS.md: Avoid duplicate implementations; reuse existing repo utilities and well-maintained OSS libraries: AGENTS.md: Avoid duplicate implementations; reuse existing repo utilities and well-maintained OSS libraries: AGENTS.md: Avoid duplicate implementations; reuse existing repo utilities and well-maintained OSS libraries: AGENTS.md: Avoid duplicate implementations; reuse existing repo utilities and well-maintained OSS libraries: AGENTS.md: Avoid duplicate implementations; reuse existing repo utilities and well-maintained OSS libraries: AGENTS.md: Avoid duplicate implementations; reuse existing repo utilities and well-maintained OSS libraries: AGENTS.md: Avoid duplicate implementations; reuse existing repo utilities and well-maintained OSS libraries: AGENTS.md: Avoid duplicate implementations; reuse existing repo utilities and well-maintained OSS libraries: AGENTS.md: Avoid duplicate implementations; reuse existing repo utilities and well-maintained OSS libraries: AGENTS.md: Avoid duplicate implementations; reuse existing repo utilities and well-maintained OSS libraries: AGENTS.md: Avoid duplicate implementations; reuse existing repo utilities and well-maintained OSS libraries: AGENTS.md: Avoid duplicate implementations; reuse existing repo utilities and well-maintained OSS libraries: AGENTS.md: Avoid duplicate implementations; reuse existing repo utilities and well-maintained OSS libraries: AGENTS.md: Avoid duplicate implementations; reuse existing repo utilities and well-maintained OSS libraries: AGENTS.md: Avoid duplicate implementations; reuse existing repo utilities and well-maintained OSS libraries: AGENTS.md: Avoid duplicate implementations; reuse existing repo utilities and well-maintained OSS libraries: AGENTS.md: Avoid duplicate implementations; reuse existing repo utilities and well-maintained OSS libraries: AGENTS.md: Avoid duplicate implementations; reuse existing repo utilities and well-maintained OSS libraries: AGENTS.md: Avoid duplicate implementations; reuse existing repo utilities and well-maintained OSS libraries: AGENTS.md: Avoid duplicate implementations; reuse existing repo utilities and well-maintained OSS libraries: AGENTS.md: Avoid duplicate implementations; reuse existing repo utilities and well-maintained OSS libraries
pnpr/crates/pnpr/src/auth/libsql_backend.rs[56-75]
pnpr/crates/pnpr/src/auth/sqlx_backend.rs[64-78]

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

## Issue description
`with_auth_timeout` is duplicated between the libsql and sqlx auth backends. This violates the repo’s preference to reuse existing utilities and creates drift risk if one helper’s behavior or documentation changes.
## Issue Context
The libsql backend comment notes it is a “Mirror of `with_auth_timeout` in [`super::sqlx_backend`]”, but the function bodies are effectively the same.
## Fix Focus Areas
- pnpr/crates/pnpr/src/auth/libsql_backend.rs[56-75]
- pnpr/crates/pnpr/src/auth/sqlx_backend.rs[64-78]

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


6. Libsql timeout not configurable 📘 Rule violation ⚙ Maintainability
Description
LibsqlAuth hardcodes request-path and startup timeouts (DEFAULT_AUTH_TIMEOUT /
DEFAULT_STARTUP_TIMEOUT) instead of flowing them through configuration, unlike the SQL backends
that already expose timeout and startup_timeout settings.
Code

pnpr/crates/pnpr/src/auth/libsql_backend.rs[R134-142]

+        with_auth_timeout(DEFAULT_STARTUP_TIMEOUT, init_schema(&conn)).await?;
+        Ok(Self {
+            _db: db,
+            conn,
+            secret: fresh_secret(),
+            counter: AtomicU64::new(0),
+            max_users,
+            timeout: DEFAULT_AUTH_TIMEOUT,
+        })
Evidence
PR Compliance ID 12 requires avoiding hardcoded configurable values and routing configuration
through the repo’s config system. The PR hardcodes the libsql backend timeouts and sets
LibsqlAuth.timeout from a constant, while LibsqlSettings provides no configuration fields for
timeouts (in contrast to SqlBackendSettings which includes timeout and startup_timeout).

AGENTS.md: Configuration must flow through @pnpm/config; avoid hardcoding configurable values: AGENTS.md: Configuration must flow through @pnpm/config; avoid hardcoding configurable values: AGENTS.md: Configuration must flow through @pnpm/config; avoid hardcoding configurable values: AGENTS.md: Configuration must flow through @pnpm/config; avoid hardcoding configurable values: AGENTS.md: Configuration must flow through @pnpm/config; avoid hardcoding configurable values: AGENTS.md: Configuration must flow through @pnpm/config; avoid hardcoding configurable values: AGENTS.md: Configuration must flow through @pnpm/config; avoid hardcoding configurable values: AGENTS.md: Configuration must flow through @pnpm/config; avoid hardcoding configurable values: AGENTS.md: Configuration must flow through @pnpm/config; avoid hardcoding configurable values: AGENTS.md: Configuration must flow through @pnpm/config; avoid hardcoding configurable values: AGENTS.md: Configuration must flow through @pnpm/config; avoid hardcoding configurable values: AGENTS.md: Configuration must flow through @pnpm/config; avoid hardcoding configurable values: AGENTS.md: Configuration must flow through @pnpm/config; avoid hardcoding configurable values: AGENTS.md: Configuration must flow through @pnpm/config; avoid hardcoding configurable values: AGENTS.md: Configuration must flow through @pnpm/config; avoid hardcoding configurable values: AGENTS.md: Configuration must flow through @pnpm/config; avoid hardcoding configurable values: AGENTS.md: Configuration must flow through @pnpm/config; avoid hardcoding configurable values: AGENTS.md: Configuration must flow through @pnpm/config; avoid hardcoding configurable values: AGENTS.md: Configuration must flow through @pnpm/config; avoid hardcoding configurable values: AGENTS.md: Configuration must flow through @pnpm/config; avoid hardcoding configurable values: AGENTS.md: Configuration must flow through @pnpm/config; avoid hardcoding configurable values: AGENTS.md: Configuration must flow through @pnpm/config; avoid hardcoding configurable values: AGENTS.md: Configuration must flow through @pnpm/config; avoid hardcoding configurable values: AGENTS.md: Configuration must flow through @pnpm/config; avoid hardcoding configurable values: AGENTS.md: Configuration must flow through @pnpm/config; avoid hardcoding configurable values: AGENTS.md: Configuration must flow through @pnpm/config; avoid hardcoding configurable values: AGENTS.md: Configuration must flow through @pnpm/config; avoid hardcoding configurable values: AGENTS.md: Configuration must flow through @pnpm/config; avoid hardcoding configurable values: AGENTS.md: Configuration must flow through @pnpm/config; avoid hardcoding configurable values: AGENTS.md: Configuration must flow through @pnpm/config; avoid hardcoding configurable values: AGENTS.md: Configuration must flow through @pnpm/config; avoid hardcoding configurable values: AGENTS.md: Configuration must flow through @pnpm/config; avoid hardcoding configurable values: AGENTS.md: Configuration must flow through @pnpm/config; avoid hardcoding configurable values: AGENTS.md: Configuration must flow through @pnpm/config; avoid hardcoding configurable values: AGENTS.md: Configuration must flow through @pnpm/config; avoid hardcoding configurable values: AGENTS.md: Configuration must flow through @pnpm/config; avoid hardcoding configurable values: AGENTS.md: Co...

Comment on lines +51 to +55
/// Deadline for the one-time startup connect + schema setup. More generous
/// than [`DEFAULT_AUTH_TIMEOUT`] (cold schema DDL against a remote primary can
/// be slow) but still bounded so an unreachable database fails fast.
const DEFAULT_STARTUP_TIMEOUT: Duration = Duration::from_mins(5);

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Action required

3. Startup build lacks timeout 🐞 Bug ☼ Reliability

LibsqlAuth::connect still awaits Builder::build().await without any deadline, so a
stalled/blackholed libsql endpoint can hang pnpr startup indefinitely even though the PR introduces
DEFAULT_STARTUP_TIMEOUT for “startup connect + schema setup”. This undermines the intended bounded
startup failure behavior and can block restarts/rollouts under network partitions or hostile
endpoints.
Agent Prompt
## Issue description
`LibsqlAuth::connect` still performs `builder.build().await?` without a timeout. Even after adding `DEFAULT_STARTUP_TIMEOUT` and wrapping `init_schema`, startup can still hang indefinitely while creating the `Database` (remote connect / initial sync), which defeats the stated goal of bounding startup failure.

## Issue Context
The sqlx backend wraps both startup connect and startup schema setup in `with_auth_timeout(settings.startup_timeout, ...)`. The libsql backend should mirror this by applying `DEFAULT_STARTUP_TIMEOUT` (or a future config knob) around `Builder::build()` as well.

## Fix Focus Areas
- pnpr/crates/pnpr/src/auth/libsql_backend.rs[111-127]
- pnpr/crates/pnpr/src/auth/libsql_backend.rs[51-75]

## Expected change
Wrap both `Builder::new_remote_replica(...).build()` and `Builder::new_remote(...).build()` in `with_auth_timeout(DEFAULT_STARTUP_TIMEOUT, ...)` so startup cannot hang indefinitely on database creation.

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

@qodo-free-for-open-source-projects

Copy link
Copy Markdown

Code review by qodo was updated up to the latest commit 6bd255a

@codecov-commenter

codecov-commenter commented Jun 25, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 89.39394% with 7 lines in your changes missing coverage. Please review.
✅ Project coverage is 88.71%. Comparing base (1a96a43) to head (ab07d06).
⚠️ Report is 2 commits behind head on main.

Files with missing lines Patch % Lines
pnpr/crates/pnpr/src/auth/libsql_backend.rs 87.27% 7 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main   #12645      +/-   ##
==========================================
- Coverage   88.72%   88.71%   -0.02%     
==========================================
  Files         342      342              
  Lines       50341    50393      +52     
==========================================
+ Hits        44663    44704      +41     
- Misses       5678     5689      +11     

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

@github-actions

github-actions Bot commented Jun 25, 2026 •

Copy link
Copy Markdown
Contributor

Integrated-Benchmark Report (Linux)

Commit: 28aad49c3344

Each scenario reports direct installs and pnpr installs. Bencher consumes pacquet@HEAD and pnpr@HEAD.

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

Command Mean [s] Min [s] Max [s] Relative
pacquet@HEAD 4.765 ± 0.174 4.624 5.190 1.57 ± 0.08
pacquet@main 4.620 ± 0.098 4.525 4.818 1.52 ± 0.07
pnpr@HEAD 3.033 ± 0.115 2.858 3.217 1.00
pnpr@main 3.080 ± 0.112 2.876 3.217 1.02 ± 0.05
BENCHMARK_REPORT.json
{
  "results": [
    {
      "command": "pacquet@HEAD",
      "mean": 4.76494954246,
      "stddev": 0.174107483376719,
      "median": 4.690031983960001,
      "user": 3.92291798,
      "system": 3.4260922400000005,
      "min": 4.62412614496,
      "max": 5.19035288496,
      "times": [
        4.67877407096,
        4.63944324996,
        5.19035288496,
        4.87530600996,
        4.6799447369600005,
        4.76335913596,
        4.86022638096,
        4.63784357896,
        4.70011923096,
        4.62412614496
      ]
    },
    {
      "command": "pacquet@main",
      "mean": 4.61975506936,
      "stddev": 0.09815071540922704,
      "median": 4.5919099154600005,
      "user": 3.858616279999999,
      "system": 3.4132455399999997,
      "min": 4.52467647596,
      "max": 4.81824156496,
      "times": [
        4.81824156496,
        4.70415627196,
        4.59475645196,
        4.72569174396,
        4.52936586496,
        4.58906337896,
        4.52467647596,
        4.52846114996,
        4.58020058396,
        4.60293720696
      ]
    },
    {
      "command": "pnpr@HEAD",
      "mean": 3.03334543406,
      "stddev": 0.11537524498188478,
      "median": 3.01598103296,
      "user": 2.850984779999999,
      "system": 3.00950314,
      "min": 2.85839867996,
      "max": 3.21735255896,
      "times": [
        3.15484343296,
        2.94498660896,
        3.02481568796,
        3.21735255896,
        3.06955966296,
        3.15794575996,
        2.9717101239600003,
        2.92669544696,
        3.00714637796,
        2.85839867996
      ]
    },
    {
      "command": "pnpr@main",
      "mean": 3.0802449896599997,
      "stddev": 0.1122416977806664,
      "median": 3.08419864096,
      "user": 2.8265410799999993,
      "system": 2.9977298399999994,
      "min": 2.87625523196,
      "max": 3.21707376496,
      "times": [
        3.00191590596,
        3.21707376496,
        3.21216246996,
        3.01555995796,
        2.87625523196,
        3.18582481796,
        3.13236250396,
        3.04058710696,
        2.9928979619600002,
        3.12781017496
      ]
    }
  ]
}

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

Command Mean [ms] Min [ms] Max [ms] Relative
pacquet@HEAD 666.2 ± 11.2 651.9 686.7 1.00
pacquet@main 701.0 ± 73.0 648.8 899.6 1.05 ± 0.11
pnpr@HEAD 746.9 ± 69.9 697.1 936.4 1.12 ± 0.11
pnpr@main 742.7 ± 56.0 699.5 897.7 1.11 ± 0.09
BENCHMARK_REPORT.json
{
  "results": [
    {
      "command": "pacquet@HEAD",
      "mean": 0.6661620120800001,
      "stddev": 0.011247657474878714,
      "median": 0.66629462538,
      "user": 0.39522794,
      "system": 1.3589209599999996,
      "min": 0.6519065228800001,
      "max": 0.68665315788,
      "times": [
        0.65730957388,
        0.67262755088,
        0.66633397488,
        0.65230172888,
        0.66625527588,
        0.67965183188,
        0.66162704188,
        0.68665315788,
        0.66695346188,
        0.6519065228800001
      ]
    },
    {
      "command": "pacquet@main",
      "mean": 0.7010200801800001,
      "stddev": 0.07300926782467239,
      "median": 0.68156136638,
      "user": 0.40507934,
      "system": 1.3494001599999998,
      "min": 0.64884775788,
      "max": 0.89957585488,
      "times": [
        0.70842788188,
        0.64884775788,
        0.6682489338800001,
        0.65638463288,
        0.6770682678800001,
        0.69259298488,
        0.65989789288,
        0.68605446488,
        0.89957585488,
        0.71310212988
      ]
    },
    {
      "command": "pnpr@HEAD",
      "mean": 0.7468846388799999,
      "stddev": 0.06994094860555247,
      "median": 0.72559146988,
      "user": 0.40856493999999993,
      "system": 1.3862586599999998,
      "min": 0.6971292558800001,
      "max": 0.93638027788,
      "times": [
        0.74512408488,
        0.71537111988,
        0.6971292558800001,
        0.71937060188,
        0.7105404308800001,
        0.73181233788,
        0.93638027788,
        0.75443798388,
        0.7582145358800001,
        0.70046575988
      ]
    },
    {
      "command": "pnpr@main",
      "mean": 0.7426993267800002,
      "stddev": 0.05597877698568244,
      "median": 0.73021428588,
      "user": 0.40872274,
      "system": 1.38600766,
      "min": 0.69945145588,
      "max": 0.89767294988,
      "times": [
        0.7447096228800001,
        0.7302457598800001,
        0.72561804488,
        0.69945145588,
        0.70903093588,
        0.7319508408800001,
        0.73018281188,
        0.72247050288,
        0.89767294988,
        0.73566034288
      ]
    }
  ]
}

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

Command Mean [s] Min [s] Max [s] Relative
pacquet@HEAD 4.933 ± 0.025 4.893 4.973 1.48 ± 0.06
pacquet@main 4.951 ± 0.053 4.870 5.025 1.49 ± 0.06
pnpr@HEAD 3.331 ± 0.130 3.194 3.579 1.00
pnpr@main 3.358 ± 0.112 3.206 3.522 1.01 ± 0.05
BENCHMARK_REPORT.json
{
  "results": [
    {
      "command": "pacquet@HEAD",
      "mean": 4.933072570539999,
      "stddev": 0.025202289246051238,
      "median": 4.93637563094,
      "user": 4.006467379999999,
      "system": 3.409645059999999,
      "min": 4.89260087194,
      "max": 4.97302453294,
      "times": [
        4.92997318594,
        4.90613432694,
        4.92373049394,
        4.9470030849399995,
        4.97302453294,
        4.94277807594,
        4.95758875494,
        4.9097579399399995,
        4.94813443794,
        4.89260087194
      ]
    },
    {
      "command": "pacquet@main",
      "mean": 4.951284499039999,
      "stddev": 0.05253339071423558,
      "median": 4.95430161444,
      "user": 4.00188688,
      "system": 3.40659176,
      "min": 4.86996206094,
      "max": 5.02537882594,
      "times": [
        4.98151093394,
        5.02537882594,
        4.91153438594,
        4.88280331394,
        5.02173807394,
        4.94642126894,
        4.86996206094,
        4.94139570894,
        4.9699184579399995,
        4.96218195994
      ]
    },
    {
      "command": "pnpr@HEAD",
      "mean": 3.331371114739999,
      "stddev": 0.13013208281772717,
      "median": 3.28237660744,
      "user": 2.91743708,
      "system": 3.21577376,
      "min": 3.1941000539399997,
      "max": 3.57862933094,
      "times": [
        3.57862933094,
        3.2600336199399997,
        3.19688991094,
        3.41374612594,
        3.51058538194,
        3.1941000539399997,
        3.2731077159399997,
        3.29164549894,
        3.25822745694,
        3.33674605194
      ]
    },
    {
      "command": "pnpr@main",
      "mean": 3.3584371984399994,
      "stddev": 0.11237954829582242,
      "median": 3.37761725294,
      "user": 2.93128238,
      "system": 3.1980211599999997,
      "min": 3.20592908094,
      "max": 3.52175163194,
      "times": [
        3.47277484594,
        3.33739189694,
        3.2500564809399997,
        3.20592908094,
        3.44660529594,
        3.42380011994,
        3.52175163194,
        3.41784260894,
        3.27784291994,
        3.23037710294
      ]
    }
  ]
}

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

Command Mean [s] Min [s] Max [s] Relative
pacquet@HEAD 1.472 ± 0.015 1.439 1.489 1.00
pacquet@main 1.484 ± 0.036 1.433 1.546 1.01 ± 0.03
pnpr@HEAD 1.519 ± 0.021 1.484 1.554 1.03 ± 0.02
pnpr@main 1.514 ± 0.017 1.497 1.540 1.03 ± 0.02
BENCHMARK_REPORT.json
{
  "results": [
    {
      "command": "pacquet@HEAD",
      "mean": 1.4715768210800002,
      "stddev": 0.01494393420244026,
      "median": 1.47538700818,
      "user": 1.4276041000000002,
      "system": 1.7720040999999997,
      "min": 1.4389762291800001,
      "max": 1.48887397718,
      "times": [
        1.45842115118,
        1.4743755971799999,
        1.48793242418,
        1.46494216318,
        1.4389762291800001,
        1.4763984191800001,
        1.48887397718,
        1.47920220618,
        1.46749299818,
        1.47915304518
      ]
    },
    {
      "command": "pacquet@main",
      "mean": 1.4842432544800002,
      "stddev": 0.03593729234023176,
      "median": 1.4813457571800002,
      "user": 1.4404784000000004,
      "system": 1.7732291999999998,
      "min": 1.43322365818,
      "max": 1.54584427118,
      "times": [
        1.54584427118,
        1.47317384818,
        1.53097401418,
        1.50377278518,
        1.48951766618,
        1.47075454018,
        1.4930351961800001,
        1.4460784151800001,
        1.45605815018,
        1.43322365818
      ]
    },
    {
      "command": "pnpr@HEAD",
      "mean": 1.51927847958,
      "stddev": 0.02103590315886905,
      "median": 1.5164120566800001,
      "user": 0.6090048000000001,
      "system": 1.6019444999999997,
      "min": 1.48379112618,
      "max": 1.55447945418,
      "times": [
        1.53351154718,
        1.5174830941800002,
        1.50657758018,
        1.53179272618,
        1.49755731918,
        1.48379112618,
        1.5398972561800002,
        1.55447945418,
        1.51235367318,
        1.51534101918
      ]
    },
    {
      "command": "pnpr@main",
      "mean": 1.51411517398,
      "stddev": 0.017374969009024195,
      "median": 1.50712248718,
      "user": 0.5912331,
      "system": 1.6145133999999999,
      "min": 1.49749506018,
      "max": 1.54013650518,
      "times": [
        1.53659606518,
        1.5033005401800001,
        1.54013650518,
        1.51007347518,
        1.5108870191800001,
        1.49924262618,
        1.50417149918,
        1.53877898918,
        1.50046996018,
        1.49749506018
      ]
    }
  ]
}

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

Command Mean [s] Min [s] Max [s] Relative
pacquet@HEAD 3.209 ± 0.031 3.168 3.283 2.13 ± 0.05
pacquet@main 3.230 ± 0.058 3.165 3.383 2.14 ± 0.06
pnpr@HEAD 1.509 ± 0.029 1.465 1.551 1.00
pnpr@main 1.519 ± 0.032 1.469 1.570 1.01 ± 0.03
BENCHMARK_REPORT.json
{
  "results": [
    {
      "command": "pacquet@HEAD",
      "mean": 3.2093676777800004,
      "stddev": 0.03128966674063475,
      "median": 3.2061243110800004,
      "user": 1.8905392799999998,
      "system": 2.04688178,
      "min": 3.16791140108,
      "max": 3.28304088508,
      "times": [
        3.2299312180800004,
        3.21045347508,
        3.21873986908,
        3.18502085308,
        3.16791140108,
        3.1922233290800004,
        3.2036214280800004,
        3.28304088508,
        3.1941071250800004,
        3.2086271940800004
      ]
    },
    {
      "command": "pacquet@main",
      "mean": 3.22951517098,
      "stddev": 0.058214253247579714,
      "median": 3.22239002208,
      "user": 1.8978529800000001,
      "system": 2.0370574799999996,
      "min": 3.16488538408,
      "max": 3.38277540308,
      "times": [
        3.19969322108,
        3.2163106950800002,
        3.16488538408,
        3.22922844708,
        3.2426053980800003,
        3.2213927620800002,
        3.38277540308,
        3.1912998380800004,
        3.22357327908,
        3.22338728208
      ]
    },
    {
      "command": "pnpr@HEAD",
      "mean": 1.5093009170800002,
      "stddev": 0.02889628144306855,
      "median": 1.51236830658,
      "user": 0.5996594799999999,
      "system": 1.5994675799999998,
      "min": 1.46477836408,
      "max": 1.5507187850800002,
      "times": [
        1.5251397530800002,
        1.48864438808,
        1.5423715680799999,
        1.5507187850800002,
        1.48407743908,
        1.52202378508,
        1.48191777308,
        1.50271282808,
        1.53062448708,
        1.46477836408
      ]
    },
    {
      "command": "pnpr@main",
      "mean": 1.5190700184800003,
      "stddev": 0.032102359581574307,
      "median": 1.52569980808,
      "user": 0.60444498,
      "system": 1.6038243799999996,
      "min": 1.46916259508,
      "max": 1.57009651908,
      "times": [
        1.53593581008,
        1.57009651908,
        1.52066516708,
        1.54589638208,
        1.5376588260800002,
        1.53073444908,
        1.51559136508,
        1.46916259508,
        1.4836009000800001,
        1.48135817108
      ]
    }
  ]
}

@github-actions

github-actions Bot commented Jun 25, 2026 •

Copy link
Copy Markdown
Contributor

🐰 Bencher Report

Branchpr/12645
Testbedpacquet
Click to view all benchmark results
BenchmarkLatencyBenchmark Result
milliseconds (ms)
(Result Δ%)
Upper Boundary
milliseconds (ms)
(Limit %)
isolated-linker.fresh-install.cold-cache.cold-store📈 view plot
🚷 view threshold
4,933.07 ms
(+3.48%)Baseline: 4,767.28 ms
5,720.74 ms
(86.23%)
isolated-linker.fresh-install.cold-cache.hot-store📈 view plot
🚷 view threshold
3,209.37 ms
(+5.53%)Baseline: 3,041.08 ms
3,649.30 ms
(87.94%)
isolated-linker.fresh-install.hot-cache.hot-store📈 view plot
🚷 view threshold
1,471.58 ms
(+9.09%)Baseline: 1,348.95 ms
1,618.74 ms
(90.91%)
isolated-linker.fresh-restore.cold-cache.cold-store📈 view plot
🚷 view threshold
4,764.95 ms
(+1.97%)Baseline: 4,672.86 ms
5,607.43 ms
(84.98%)
isolated-linker.fresh-restore.hot-cache.hot-store📈 view plot
🚷 view threshold
666.16 ms
(+6.14%)Baseline: 627.61 ms
753.14 ms
(88.45%)
🐰 View full continuous benchmarking report in Bencher

@github-actions

github-actions Bot commented Jun 25, 2026 •

Copy link
Copy Markdown
Contributor

🐰 Bencher Report

Branchpr/12645
Testbedpnpr

⚠️ WARNING: No Threshold found!

Without a Threshold, no Alerts will ever be generated.

Click here to create a new Threshold
For more information, see the Threshold documentation.
To only post results if a Threshold exists, set the --ci-only-thresholds flag.

Click to view all benchmark results
BenchmarkLatencymilliseconds (ms)
isolated-linker.fresh-install.cold-cache.cold-store📈 view plot
⚠️ NO THRESHOLD
3,331.37 ms
isolated-linker.fresh-install.cold-cache.hot-store📈 view plot
⚠️ NO THRESHOLD
1,509.30 ms
isolated-linker.fresh-install.hot-cache.hot-store📈 view plot
⚠️ NO THRESHOLD
1,519.28 ms
isolated-linker.fresh-restore.cold-cache.cold-store📈 view plot
⚠️ NO THRESHOLD
3,033.35 ms
isolated-linker.fresh-restore.hot-cache.hot-store📈 view plot
⚠️ NO THRESHOLD
746.88 ms
🐰 View full continuous benchmarking report in Bencher

@qodo-free-for-open-source-projects

Copy link
Copy Markdown

Code review by qodo was updated up to the latest commit 28aad49

1 similar comment
@qodo-free-for-open-source-projects

Copy link
Copy Markdown

Code review by qodo was updated up to the latest commit 28aad49

@YESHYUNGSEOK

Copy link
Copy Markdown
Contributor Author

Thanks @qodo — dispositions:

  • Libsql writes still unbounded: intentional, and it mirrors the sqlx backend. A Tokio-level timeout on a write would race the commit acknowledgement and leave the caller observing a timeout with an unknown commit state; writes therefore rely on the database's own statement timeout. This matches the documented rationale in sqlx_backend (the comment there explains the same).
  • Startup build lacks timeout: init_schema is wrapped with the startup deadline; the one not wrapped is the Builder::build() connect, which is the one-time, fail-fast startup connection (not a per-request hot path). Wrapping the builder connect is a reasonable follow-up.
  • Rule violations (3): these read as style/convention suggestions — happy to apply specific ones on request; the security-relevant change (bounding request-path reads) is the focus here.

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

@qodo-free-for-open-source-projects

Copy link
Copy Markdown

Thanks @qodo — dispositions:

  • Libsql writes still unbounded: intentional, and it mirrors the sqlx backend. A Tokio-level timeout on a write would race the commit acknowledgement and leave the caller observing a timeout with an unknown commit state; writes therefore rely on the database's own statement timeout. This matches the documented rationale in sqlx_backend (the comment there explains the same).
  • Startup build lacks timeout: init_schema is wrapped with the startup deadline; the one not wrapped is the Builder::build() connect, which is the one-time, fail-fast startup connection (not a per-request hot path). Wrapping the builder connect is a reasonable follow-up.
  • Rule violations (3): these read as style/convention suggestions — happy to apply specific ones on request; the security-relevant change (bounding request-path reads) is the focus here.

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

Thanks — that all makes sense.

  • Libsql writes: agreed, keeping writes unbounded at the Tokio layer is the safer choice because commit state must remain unambiguous.
  • Startup timeout: understood; init_schema is already covered, and wrapping Builder::build() can be handled as a follow-up.
  • Rule violations: acknowledged as non-blocking style/convention items.

So the main security-relevant change here is the bounded timeout on request-path reads, which looks appropriately targeted.

YESHYUNGSEOK and others added 2 commits June 25, 2026 13:39
Every request-path database call in the libsql/Turso auth backend was a bare await with no
timeout, while the sqlx backend wraps its reads in with_auth_timeout and returns
AuthDatabaseTimeout (HTTP 504). A stalled or hostile libsql endpoint could hold a Tokio task
open indefinitely on every authenticated request, exhausting the executor and taking the whole
registry down — a remote DoS with no 504 ever returned.

Wrap the request-path reads (stored_hash, user_count, lookup, find_by_key, list_for_user) and
the startup schema setup with a deadline, surfacing AuthDatabaseTimeout on expiry. The
AuthDatabaseTimeout variant and its log_kind / status_code arms now compile under backend-libsql,
not just the sqlx drivers. Writes stay unwrapped for the reason the sqlx backend documents: a
cancelled write would leave an unknown commit state.

The read deadline uses a 30s default to match the sqlx backend; exposing it as a YAML knob is a
follow-up. with_auth_timeout mirrors the sqlx helper, kept separate because the two backends are
independently feature-gated.

Co-authored-by: Claude <[email protected]>
CI Rust Doc runs with default features, where the sqlx_backend module is not compiled, so the
[`super::sqlx_backend`] intra-doc link was unresolvable (broken-intra-doc-links). The Perfectionist
dylint also rejects single-letter generics. Use a plain code span for the cross-module reference
and rename the generics to Loaded/DbError.

Co-authored-by: Claude <[email protected]>
@zkochan
zkochan force-pushed the fix/pnpr-libsql-auth-timeout branch from 28aad49 to 658bf8e Compare June 25, 2026 11:46
@qodo-free-for-open-source-projects

Copy link
Copy Markdown

Code review by qodo was updated up to the latest commit 658bf8e

1 similar comment
@qodo-free-for-open-source-projects

Copy link
Copy Markdown

Code review by qodo was updated up to the latest commit 658bf8e

…lper

Wrap both Builder::build() paths (remote replica and remote) in
with_auth_timeout(DEFAULT_STARTUP_TIMEOUT, ...) so a stalled or
blackholed libsql endpoint cannot hang pnpr startup indefinitely,
matching the bounded-startup behavior the sqlx backend already has. The
build futures are Box::pin'd so the one-time startup connect does not
enlarge the serve future past the large_futures threshold.

Deduplicate with_auth_timeout: move it into the shared auth module so
both the libsql and sqlx backends use one helper instead of two copies.
Its doc no longer claims libsql writes rely on a statement timeout
(libsql configures none); it states the real invariant that writes must
await directly to avoid an unknown commit state.

Trim the timeout constant doc comments to a contract-focused line each,
dropping the DoS narrative and PR-history references.
@qodo-free-for-open-source-projects

Copy link
Copy Markdown

Code review by qodo was updated up to the latest commit ab07d06

1 similar comment
@qodo-free-for-open-source-projects

Copy link
Copy Markdown

Code review by qodo was updated up to the latest commit ab07d06

@zkochan
zkochan enabled auto-merge June 25, 2026 12:29
@zkochan
zkochan disabled auto-merge June 25, 2026 13:22
@zkochan
zkochan merged commit fff9043 into pnpm:main Jun 25, 2026
28 checks passed
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 state: automerge

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants