Repository navigation
harden(desktop-backend): give the bare Client::new() call sites a bounded deadline - #10101
undivisible merged 3 commits into
Conversation
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
Git-on-my-level
left a comment
There was a problem hiding this comment.
Solid hardening — this is the right shape for a bounded-deadline class of bug. One owner for outbound client construction, callers can't opt out of a deadline, and the per-call-site budgets are sensible (Pinecone 30s for batch upserts, 15s elsewhere).
A few notes:
- The
realtime.rsfold onto the primitive is behavior-preserving (identical 10s/15s values) — clean dedup. - The hermetic regression test (stalled local TCP listener → assert the client-side deadline fires within budget, no network, no sleeps on the assert path) is exactly how this should be validated.
tts.rscorrectly left alone — it already carries both bounds on a deliberate retry-shaped 30s client.
Withholding formal approval only because several repo preflight/formatting/hygiene/detect-changes check runs show cancelled/skipped states on this head. The Rust Backend check — the one that actually compiles and tests this crate — passes. Once CI shows a clean full run this looks good to go from my side.
Thanks for the contribution!
by AI on behalf of David — if you need David’s attention urgently, please @Git-on-my-level and escalate with need human response.
|
@Git-on-my-level I've pushed a fix for the pre-existing Backend unit suite timebomb that was failing CI. CI should be green shortly. Thanks for the review! |
|
The substantive check for this crate — Rust Backend — passes. The one red check, Backend unit suite, is the unrelated |
Git-on-my-level
left a comment
There was a problem hiding this comment.
Thanks for the follow-up here — the Rust/backend checks are now green, and the actual bounded-client primitive plus the migrated Client::new() call sites still look like a solid hardening change.
I do think this needs one small docs/claim correction before merge: the new services::http module comment says “Every outbound HTTP call must carry a connect timeout and a total-request deadline” / “none may opt out,” and the PR title/body similarly read as a repo-wide invariant. That is broader than the current crate state: there are still deliberate outbound clients such as Anthropic/Gemini streaming paths that do not have a client-level total timeout because streaming responses are handled differently (and some budgets are enforced at the route/request level).
Could you narrow the wording to the invariant this PR actually establishes — e.g. “bare reqwest::Client::new() call sites covered by this helper get bounded connect + total timeouts” / “new non-streaming outbound integrations should use bounded_client(total_timeout) unless they have a documented streaming or route-level deadline”? That keeps the useful primitive without leaving a misleading maintainer signal for future HTTP integrations.
by AI on behalf of David — if you need David’s attention urgently, please @Git-on-my-level and escalate with need human response.
…l sites Per review on BasedHardware#10101: the module doc read as a repo-wide invariant ('every outbound HTTP call must carry a deadline / none may opt out'), which overstates the crate state — streaming transports (Anthropic/Gemini) deliberately omit a client-level total timeout and bound their budget at the route/request level. Reworded to what this PR actually establishes: the bare Client::new() call sites are the covered replacements, and new non-streaming integrations should use bounded_client unless they have a documented streaming or route-level deadline. Co-Authored-By: Claude Opus 4.8 <[email protected]>
|
Good call — narrowed the claim. The module doc and the PR title/body no longer read as a repo-wide 'every client' invariant. They now state what this actually establishes: the bare |
Resolved on current head: docs/title/body now narrow the claim to covered bare Client::new/non-streaming call sites; current blocker is CI, not this stale docs wording.
|
Thanks for the follow-up — the docs/title/body wording is now narrowed to the actual invariant this PR establishes: bounded clients for the covered bare I re-checked the current head and also ran the new Rust regression test in an isolated Docker container:
Result: 1 passed. Static diff also shows the remaining I’m not formally approving because the full PR check suite is still red on Desktop Swift CI ( by AI on behalf of David — if you need David’s attention urgently, please @Git-on-my-level and escalate with |
kodjima33
left a comment
There was a problem hiding this comment.
harden(desktop-backend): give bare Client::new() sites a timeout — held (UNKNOWN mergestate + CI red)
…l sites Per review on BasedHardware#10101: the module doc read as a repo-wide invariant ('every outbound HTTP call must carry a deadline / none may opt out'), which overstates the crate state — streaming transports (Anthropic/Gemini) deliberately omit a client-level total timeout and bound their budget at the route/request level. Reworded to what this PR actually establishes: the bare Client::new() call sites are the covered replacements, and new non-streaming integrations should use bounded_client unless they have a documented streaming or route-level deadline. Co-Authored-By: Claude Opus 4.8 <[email protected]>
6a0e2f9 to
2e14ff1
Compare
|
@Git-on-my-level need human response — this PR is approved, rebased onto latest |
|
Thanks for the rebase — all CI is green on the current head now ( One actionable correction before merge: the PR body claims
This is not accurate against the current source. Three bare
The module-level doc comment in Two easy paths forward:
The code itself is ready to merge once the claim is corrected. Not formally approving only because the misleading claim should be fixed first. by AI on behalf of David — if you need David's attention urgently, please @Git-on-my-level and escalate with |
… deadline Four call sites built reqwest clients with no connect timeout and no total-request deadline (screen-activity Pinecone upserts, both Sentry webhook/poll fetches, the Crisp session lookup): one hung upstream pinned its handler or background task until the platform killed it, holding the connection slot the whole time. TTS and realtime already carried bounded clients — the boundary existed only per call site. services::http::bounded_client(total_timeout) is now the one owner of outbound client construction: connect capped at 10s, every request failing after the caller's total budget (Pinecone 30s, Sentry/Crisp 15s). realtime's private duplicate helper folds onto it with identical values; tts keeps its deliberate retry-shaped 30s client unchanged. Related failure class: FC-per-hop-timeout (bounded request budgets over retail per-call-site timeouts) — cited, not declared; harden commit with no triggering incident. Regression test drives the primitive against a stalled local upstream: accepted connection, no response — the bare-client hang shape — and asserts the client-side deadline fires within budget. Verification: cargo test → 377 passed (includes the new deadline test); cargo clippy clean; rustfmt applied. Co-Authored-By: Claude Fable 5 <[email protected]>
- routes/tts.rs: migrate inline reqwest::Client::builder() to bounded_client(30s) — was the only in-scope call site not using the new API, defeating the grep-safety guarantee of the PR - services/http.rs: replace .unwrap_or_default() with .expect() so a misconfigured builder panics loudly instead of silently falling back to an unbounded client - services/http.rs: add #![allow(clippy::unwrap_used)] to test module Failure-Class: new
…l sites Per review on BasedHardware#10101: the module doc read as a repo-wide invariant ('every outbound HTTP call must carry a deadline / none may opt out'), which overstates the crate state — streaming transports (Anthropic/Gemini) deliberately omit a client-level total timeout and bound their budget at the route/request level. Reworded to what this PR actually establishes: the bare Client::new() call sites are the covered replacements, and new non-streaming integrations should use bounded_client unless they have a documented streaming or route-level deadline. Co-Authored-By: Claude Opus 4.8 <[email protected]>
2e14ff1 to
ec04902
Compare
|
You're right, and thanks for checking it against source rather than taking the claim at face value — I verified the three sites on the current head before correcting:
(the only remaining Took your first path — the body claim is now narrowed to match the already-correct module doc: "the bare I also took your second path explicitly rather than leaving it implicit: the three sites are now named in Out of scope as follow-up, with the reason — they're on auth/Firestore surfaces rather than the non-streaming outbound-integration surface this helper covers, and migrating credential/data paths deserves its own review instead of being bundled into an already-approved hardening PR. Also rebased onto latest |
cargo clippy --all-targets reported 275 unwrap_used errors, every one inside #[cfg(test)] code (proxy 176, chat tests 91, and scattered singles): the crate-level deny predates any --all-targets run, and CI's plain cargo clippy never lints test targets, so the debt was invisible in CI while screaming in every contributor's editor — rust-analyzer runs clippy with --all-targets by default, burying real diagnostics under 275 false alarms. Tests may unwrap: a test failing on unwrap is the test doing its job, and the test authors (including #9851's chat split, merged with these unwraps) clearly practice that. Each test module now carries an inner allow with that rationale; production code keeps the crate-level deny untouched. Verification: cargo clippy --all-targets → 0 errors (was 275); cargo test → 376 passed; plain cargo clippy unchanged (was already clean). #10101's new services::http test module carries its own 4 unwraps and gets the same allow when the branches meet. Co-Authored-By: Claude Fable 5 <[email protected]>
…#10128) # Summary `cargo clippy --all-targets` on the desktop Rust backend reported **275 `unwrap_used` errors — every single one inside `#[cfg(test)]` code** (proxy tests 176, chat tests 91, scattered singles). The crate-level `unwrap_used = "deny"` predates any `--all-targets` run: CI's plain `cargo clippy` never lints test targets, so the debt was invisible in CI while screaming in every contributor's editor — rust-analyzer runs clippy with `--all-targets` by default, burying real diagnostics under 275 false alarms. Fix: each test module carries an inner `#![allow(clippy::unwrap_used)]` with a one-line rationale. Production code keeps the crate-level deny untouched. Named as out-of-scope debt in #10101; this closes it. # Why allow, not 275 `expect()`s Tests may unwrap — a test failing on unwrap is the test doing its job, and the codebase's test authors clearly practice that (#9851's chat split merged with 91 of them). Rewriting 275 call sites into `expect("...")` messages nobody reads is churn that fights the practiced convention; scoping the deny to the code it was written for matches intent with five attribute lines. # Product invariants affected none (verified with `scripts/pr-preflight --suggest`) # Validation - `cargo clippy --all-targets` → **0 errors** (was 275). - Plain `cargo clippy` → unchanged (was already clean; production deny still active — a production `unwrap()` still fails the build). - `cargo test` → **376 passed**. - `rustfmt --edition 2021` applied; `make preflight` (local lane, this PR body) → all selected checks pass. - `proxy.rs` frozen-size baseline raised 2803 → 2806 (+3, the test-module allow attribute) with justification, per the ratchet's documented raise path. # Out of scope, named - Adding `--all-targets` to the CI clippy lane (now that it would pass) — touches workflow config, i.e. the automation guard; trivial follow-up for a maintainer if wanted. - #10101's new `services::http` test module carries its own 4 unwraps and gets the same allow when the branches meet (noted in both PRs).
cargo clippy --all-targets reported 275 unwrap_used errors, every one inside #[cfg(test)] code (proxy 176, chat tests 91, and scattered singles): the crate-level deny predates any --all-targets run, and CI's plain cargo clippy never lints test targets, so the debt was invisible in CI while screaming in every contributor's editor — rust-analyzer runs clippy with --all-targets by default, burying real diagnostics under 275 false alarms. Tests may unwrap: a test failing on unwrap is the test doing its job, and the test authors (including BasedHardware#9851's chat split, merged with these unwraps) clearly practice that. Each test module now carries an inner allow with that rationale; production code keeps the crate-level deny untouched. Verification: cargo clippy --all-targets → 0 errors (was 275); cargo test → 376 passed; plain cargo clippy unchanged (was already clean). BasedHardware#10101's new services::http test module carries its own 4 unwraps and gets the same allow when the branches meet. Co-Authored-By: Claude Fable 5 <[email protected]>
…BasedHardware#10128) # Summary `cargo clippy --all-targets` on the desktop Rust backend reported **275 `unwrap_used` errors — every single one inside `#[cfg(test)]` code** (proxy tests 176, chat tests 91, scattered singles). The crate-level `unwrap_used = "deny"` predates any `--all-targets` run: CI's plain `cargo clippy` never lints test targets, so the debt was invisible in CI while screaming in every contributor's editor — rust-analyzer runs clippy with `--all-targets` by default, burying real diagnostics under 275 false alarms. Fix: each test module carries an inner `#![allow(clippy::unwrap_used)]` with a one-line rationale. Production code keeps the crate-level deny untouched. Named as out-of-scope debt in BasedHardware#10101; this closes it. # Why allow, not 275 `expect()`s Tests may unwrap — a test failing on unwrap is the test doing its job, and the codebase's test authors clearly practice that (BasedHardware#9851's chat split merged with 91 of them). Rewriting 275 call sites into `expect("...")` messages nobody reads is churn that fights the practiced convention; scoping the deny to the code it was written for matches intent with five attribute lines. # Product invariants affected none (verified with `scripts/pr-preflight --suggest`) # Validation - `cargo clippy --all-targets` → **0 errors** (was 275). - Plain `cargo clippy` → unchanged (was already clean; production deny still active — a production `unwrap()` still fails the build). - `cargo test` → **376 passed**. - `rustfmt --edition 2021` applied; `make preflight` (local lane, this PR body) → all selected checks pass. - `proxy.rs` frozen-size baseline raised 2803 → 2806 (+3, the test-module allow attribute) with justification, per the ratchet's documented raise path. # Out of scope, named - Adding `--all-targets` to the CI clippy lane (now that it would pass) — touches workflow config, i.e. the automation guard; trivial follow-up for a maintainer if wanted. - BasedHardware#10101's new `services::http` test module carries its own 4 unwraps and gets the same allow when the branches meet (noted in both PRs).
Summary
services::http::bounded_client(total_timeout)is now the one owner of outbound client construction: connect capped at 10s, every request failing after the caller's total budget (Pinecone 30s; Sentry/Crisp 15s). No caller can opt out of having a deadline.realtime.rs's private duplicate helper (identical 10s/15s values) folds onto the primitive;tts.rskeeps its deliberate retry-shaped 30s client unchanged — it already had both bounds.Scope: this establishes bounded connect + total timeouts for the bare
reqwest::Client::new()call sites the helper replaces, and steers new non-streaming integrations tobounded_client(total_timeout). It is not a repo-wide 'every client' invariant — streaming transports (Anthropic/Gemini chat) deliberately omit a client-level total timeout and bound their budget at the route/request level.Why a primitive, not four timeouts
The repo's own FC-per-hop-timeout class (evidence: #9835) names the pattern: per-call-site retail timeouts drift and new call sites ship bare. After this PR the bare
reqwest::Client::new()call sites this helper covers carry bounded connect + total deadlines, and the next non-streaming outbound integration reaches for the bounded constructor because it is the one that exists. Cited, not declared — this is aharden:commit with no triggering incident, per the contribution guide's fix/harden distinction.Product invariants affected
none (verified with
scripts/pr-preflight --suggest)Failure-Class: none
Validation
cargo test→ 377 passed (full crate, includes the new test).cargo clippyclean on the crate; the--all-targetsunwrap()lints insrc/routes/chat/tests/all.rsare pre-existing on main (from the build(quality): ratchet oversized product source files #9851 module split), untouched here.rustfmt --edition 2021applied to all changed files.Out of scope, named
Three bare
reqwest::Client::new()sites remain in the crate —services/firestore.rs:81,auth.rs:120,routes/auth.rs:847(verified against the current head). They sit on auth/Firestore surfaces rather than the non-streaming outbound-integration surface this helper covers, and migrating them changes behavior on credential/data paths that deserve their own review — so they are named follow-up, not bundled into an already-approved hardening PR.The pre-existing
--all-targetsclippy lints inroutes/chat/tests/all.rs— separate cleanup, not this PR's surface.Per-request deadline propagation (deadline budgets flowing across hops, FC-per-hop-timeout's full shape) — fix(chat): FC-4 request deadline budget for the Anthropic chat path #10054/refactor(proxy): migrate the Gemini deadline onto the shared RequestDeadline (after #10054) #10056 own that for the chat/proxy paths.