Repository navigation
refactor(proxy): migrate the Gemini deadline onto the shared RequestDeadline (after #10054) - #10056
aryanorastar wants to merge 5 commits into
Conversation
|
Thanks for keeping this stacked behind #10054 and narrowing the last commit to the proxy deadline migration. I reviewed the last commit only. The direction looks coherent: moving the proxy's ad hoc deadline/race helpers into Because this is still a draft, stacked on #10054, touches timeout/security-sensitive proxy/auth behavior plus CI check coverage, and has no passing check summary yet, I’m not approving it. Before merge, a human maintainer should verify the final unstacked diff and CI, especially the Rust compile/test result for the desktop backend and the new deadline/static-check coverage. One small cleanup to consider while it is still draft: the proxy-local deadline helpers moved out of Validation I could run here:
by AI on behalf of David — if you need David’s attention urgently, please @Git-on-my-level and escalate with |
3731caa to
cb0e6be
Compare
|
Good catch @Git-on-my-level — Staying draft until #10054 lands; I'll rebase onto main then so the diff collapses to the single |
cb0e6be to
b33fee9
Compare
|
Thanks for keeping this as a draft/stacked follow-up while #10054 settles. I re-checked the current head I’m still not approving because this is draft/stacked on #10054 and touches timeout/auth/proxy behavior plus CI guardrails. Before this is flipped ready/merged, a human maintainer should review the final unstacked diff and explicitly confirm the extractor-timeout response semantics: auth/BYOK/paywall budget exhaustion now returns through the auth extractor’s by AI on behalf of David — if you need David’s attention urgently, please @Git-on-my-level and escalate with |
…nded deadline (#10101) # Summary - Four desktop-backend call sites built reqwest clients with **no connect timeout and no total-request deadline** — screen-activity Pinecone upserts, both Sentry fetches (webhook enrichment + feedback poll), and 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. - `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.rs` keeps 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 to `bounded_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 a `harden:` 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 - New hermetic regression test drives the primitive against a **stalled local upstream** (TCP listener that accepts, reads the request, and never responds — the exact shape a bare client hangs on forever) and asserts the client-side deadline fires, as a timeout error, within budget. No network, no sleeps on the assert path. - `cargo test` → **377 passed** (full crate, includes the new test). - `cargo clippy` clean on the crate; the `--all-targets` `unwrap()` lints in `src/routes/chat/tests/all.rs` are pre-existing on main (from the #9851 module split), untouched here. - `rustfmt --edition 2021` applied to all changed files. - Behavior at the four migrated sites is unchanged on the success path; the only new behavior is that a hung upstream now errors at its budget instead of hanging forever — exercised directly by the test above. # 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-targets` clippy lints in `routes/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) — #10054/#10056 own that for the chat/proxy paths. <!-- This is an auto-generated description by cubic. --> <a href="https://cubic.dev/pr/BasedHardware/omi/pull/10101?utm_source=github" target="_blank" rel="noopener noreferrer" data-no-image-dialog="true"><picture><source media="(prefers-color-scheme: dark)" srcset="https://www.cubic.dev/buttons/review-in-cubic-dark.svg"><source media="(prefers-color-scheme: light)" srcset="https://www.cubic.dev/buttons/review-in-cubic-light.svg"><img alt="Review in cubic" src="https://www.cubic.dev/buttons/review-in-cubic-dark.svg"></picture></a> <!-- End of auto-generated description by cubic. -->
b33fee9 to
09a5bbf
Compare
|
Resolved the Re-verified on the rebased head: |
|
Thanks for the rebase update. I re-checked the current head The current CI failure is a concrete blocker: both Still not approving because this remains draft/stacked on #10054 and touches timeout/auth/proxy behavior plus CI guardrails. Once unstacked, a human maintainer should still review the final diff and sign off on the externally visible extractor-timeout semantics called out earlier. Validation I ran here:
by AI on behalf of David — if you need David’s attention urgently, please @Git-on-my-level and escalate with |
09a5bbf to
2d256cd
Compare
|
Fixed — the baseline is now committed. My earlier update left the 2780 value in the working tree but never got folded into the commit (so the pushed head still pinned 2806, exactly as you saw). Amended: That should clear the Hygiene + Desktop Swift Static Contracts ratchet failures. Still draft/stacked on #10054 as before. |
|
Thanks, the ratchet fix is now present on the current head I also re-ran the lightweight local guards here:
I’m not approving because this is still a draft/stacked PR behind #10054 and it touches timeout/auth/proxy behavior plus CI guardrails. Before merge, a human maintainer should still review the final unstacked diff and sign off on the externally visible extractor-timeout semantics noted earlier: auth/BYOK/paywall budget exhaustion now returns via the auth extractor’s by AI on behalf of David — if you need David’s attention urgently, please @Git-on-my-level and escalate with |
The provider-timeout class (FC-per-hop-timeout: BasedHardware#8640, BasedHardware#8911, BasedHardware#9135, chat path now owns one admission budget instead: - RequestDeadline (240s inside the 300s platform bound, mirroring the Gemini proxy) is created in route middleware before extractors and body extraction; auth, BYOK, and paywall waits are bounded by it and budget exhaustion returns a typed 504 instead of a 401. - All provider sends go through send_with_deadline; the retry loop is a budget-aware policy: attempts never start on an expired budget, a retry or pause_turn continuation starts only above a 10s floor, and backoff sleeps truncate at the budget edge. A transient status on the final available attempt still passes through unchanged. - The budget governs everything before the first client-visible semantic SSE event. The stream idle timer now measures SEMANTIC progress: raw bytes and Anthropic ping events no longer reset it, closing the live gap where a ping-only upstream could hold a client forever with nothing visible. Streaming still has no total response timeout by design (BasedHardware#9135): a visible-delta stream survives budget expiry. - The detached Firestore usage write runs through a spawn seam that never inherits the request deadline. Behavioral tests drive the policy and the real stream translator with tokio::time::pause: budget-floor retry stop, backoff truncation at the edge, long visible streams surviving expiry, ping-only turns ending in a typed terminal SSE error, semantic-idle stalls independent of budget, and detached-write completion after expiry. Fixes BasedHardware#9835. Co-Authored-By: Claude Fable 5 <[email protected]>
Static tripwire (labeled as such): raw reqwest builders are not covered by signatures alone, so new direct .send() calls in routes/chat/ fail the manifest lanes. Behavioral coverage lives in the paused-time deadline tests. Caught class: BasedHardware#8640/BasedHardware#8911/BasedHardware#9135/BasedHardware#9644 (BasedHardware#9835). Co-Authored-By: Claude Fable 5 <[email protected]>
ThinkingDelta chunks reach the client as `reasoning_content`, but they did not refresh the semantic idle timer — only text deltas did. So after the initial role chunk, a Claude reasoning phase that kept emitting visible reasoning for longer than STREAM_IDLE_TIMEOUT was ended as "no semantic progress" while the client was actively receiving output, regressing the "a long visible stream is not an error" contract (BasedHardware#9135) for reasoning streams. Refresh the timer when a reasoning chunk is yielded, matching the text-delta path. Regression test drives a reasoning-only stream 200s past the 60s idle bound on the paused clock: it fails on the old code (1 of 4 reasoning deltas delivered, turn killed at the bound) and passes with the fix. Co-Authored-By: Claude Opus 4.8 <[email protected]>
…eadline Named follow-up from BasedHardware#9835: proxy.rs kept a working ad hoc deadline; the budget type now exists, so the migration is mechanical. - The shared race/within helpers and DeadlineElapsed move to request_deadline.rs; the proxy-local copies are deleted (no aliases, all call sites and tests migrate in this change). - The budget is admitted by the shared route middleware before extractors on both proxy routes, so auth/BYOK/paywall waits are inside it. The handler consumes the same RequestDeadline the chat path uses; the phase-aware timeout telemetry mapping is unchanged. - CHAT_REQUEST_BUDGET generalizes to REQUEST_BUDGET (same 240s value both route classes already derived from the platform contract); the proxy's platform constants collapse into the shared module. Per-attempt Gemini defenses (connect bound, attempt cap) stay proxy-owned policy. - The streaming proxy keeps no total response timeout by design; it gains only budgeted extractor waits. - New behavioral test: the middleware-admitted budget is the one the handler consumes, on the paused tokio clock. Existing proxy deadline tests (hanging-upstream cancellation, downstream disconnect propagation, one-budget-includes-pre-dispatch-work) migrate to the shared helpers with assertions unchanged. Refs BasedHardware#9835. Co-Authored-By: Claude Fable 5 <[email protected]>
2d256cd to
04850c5
Compare
|
Re-stacked onto the rebased #10054 (head One real migration was needed here: #10054 now creates a fresh budget for the mid-stream pause-turn continuation (see the design note I left on #10054 — the request budget must not leak past the first visible event, or streaming would gain a total-response cap). That call site used Verified on the re-stacked tip: Both PRs are MERGEABLE again. Still draft/stacked as before; the extractor-timeout semantics you flagged remain the item for maintainer sign-off, now joined by the mid-stream continuation budget decision on #10054. |
Git-on-my-level
left a comment
There was a problem hiding this comment.
Thanks for the re-stack update. I checked the current head 04850c547f4b924da5dd07289793840130f1aed2 and the proxy/request-deadline refactor still looks coherent, including the decision to give post-first-visible-event pause-turn continuations their own budget rather than reusing the original request deadline.
There is one current merge blocker from CI: Hygiene is failing at failure-class-guard-artifact-ratchet because FC-per-hop-timeout has reached the recurrence threshold but .github/failure-classes/FC-per-hop-timeout.json does not record a canonical_prevention_artifact. This PR appears to add the reusable guard surface (.github/scripts/check_chat_send_deadline.py, plus its test and manifest entry), so please wire that artifact into the failure-class definition (or otherwise satisfy the ratchet) and let Hygiene go green.
Still not approving because this remains a draft/stacked PR behind #10054, touches timeout/auth/proxy behavior plus CI guardrails, and currently has a failing Hygiene check. Before merge, a human maintainer should review the final unstacked diff and sign off on the externally visible timeout semantics already called out: extractor/auth/BYOK/paywall budget exhaustion returns through the auth extractor’s request_deadline_exceeded 504 path, and streaming continuations after visible output get a fresh bounded budget rather than the original admission deadline.
Validation checked here:
- GitHub
Hygienefailure log points to missingcanonical_prevention_artifactforFC-per-hop-timeout. - The chat-send-deadline checker and checker tests pass inside that same Hygiene run.
- Rust/backend-related checks on the current head are otherwise passing in GitHub CI.
by AI on behalf of David — if you need David’s attention urgently, please @Git-on-my-level and escalate with need human response.
Failure-Class: FC-per-hop-timeout
Dismissed by current automation review: this review only blocked on FC-per-hop-timeout missing canonical_prevention_artifact; current head a367f72 adds the artifact and Hygiene is green.
|
Thanks for the update. I re-checked the current head I dismissed my stale This is a positive signal rather than approval: the refactor remains draft/stacked behind #10054 and still touches timeout/auth/proxy behavior plus CI guardrails. Before merge, a human maintainer should review the final unstacked diff and sign off on the externally visible timeout semantics already discussed, especially extractor/auth/BYOK/paywall budget exhaustion returning through Validation checked here:
by AI on behalf of David — if you need David’s attention urgently, please @Git-on-my-level and escalate with |
|
Closing as superseded/obsolete — the code this refactor targets no longer exists on main. Investigation before touching it:
There is nothing to rebase onto — resurrecting the Rust modules would fight the intentional Python cutover. If any specific logic from this refactor (e.g. the shared-budget admission before extractors, per-attempt Gemini defenses) is still wanted, it belongs as a focused change in the current Python implementation, not as a Rust rebase. Closing as obsolete; the branch can be deleted. |
|
Hey @aryanorastar 👋 Thank you so much for taking the time to contribute to Omi! We truly appreciate you putting in the effort to submit this pull request. After careful review, we've decided not to merge this particular PR. Please don't take this personally — we genuinely try to merge as many contributions as possible, but sometimes we have to make tough calls based on:
Before your next PR, please skim:
If this was declined for direction or taste, maintainers should cite an invariant ID or open a proposed one — ask if that citation is missing. Your contribution is still valuable to us, and we'd love to see you contribute again in the future! If you'd like feedback on how to improve this PR or want to discuss alternative approaches, please don't hesitate to reach out. Thank you for being part of the Omi community! |
Summary
Named follow-up from #9835 (kept out of that PR to stay reviewable): the Gemini proxy's working ad hoc deadline migrates onto the shared
RequestDeadline, so both provider route classes consume one platform-derived admission budget.race/withinhelpers andDeadlineElapsedmove intorequest_deadline.rs; the proxy-local copies are deleted. Per the in-repo-consumers rule, no aliases: every call site and test migrates in this change.upstream_timeoutresponse are unchanged.CHAT_REQUEST_BUDGETgeneralizes toREQUEST_BUDGET— both route classes already derived the same 240s from the same Cloud Run contract; the proxy's platform constants collapse into the shared module. Per-attempt Gemini defenses (connect bound, attempt cap, no post-dispatch retries) stay proxy-owned policy.Depends on #10054 (introduces
RequestDeadline); stacked on that branch, so this PR's diff shows both until #10054 merges (regular merge collapses it to the singlerefactor(proxy)commit). Review the last commit only.Failure class
Failure-Class: FC-per-hop-timeout
(The declaration covers the stacked
fix(chat)commit from #10054 while it is in this PR's range; this PR's own commit is a behavior-preserving refactor.)Behavior notes
Product invariants affected
none (verified with
scripts/pr-preflight --suggest)Validation
cargo test --locked→ 382 passed (all existing proxy deadline tests — hanging-upstream cancellation at an injected deadline, drop-cancels-upstream-socket, downstream-disconnect propagation, one-budget-includes-pre-dispatch-work — migrated to the shared helpers with assertions unchanged).middleware_admits_the_shared_budget_before_the_handler: on the paused tokio clock, the budget the middleware admits is the budget the handler consumes.cargo check --lockedclean,cargo fmt --checkclean.make preflight(local lane, this PR body) → all selected checks pass.