Skip to content

Update streaming quote docs: only progressively better quotes are emitted#647

Open
fleupold wants to merge 1 commit into
mainfrom
streaming-quote-monotonic-updates
Open

Update streaming quote docs: only progressively better quotes are emitted#647
fleupold wants to merge 1 commit into
mainfrom
streaming-quote-monotonic-updates

Conversation

@fleupold

@fleupold fleupold commented Jul 27, 2026

Copy link
Copy Markdown
Contributor

Description

cowprotocol/services#4648 (merged 2026-07-27) changed the behavior of POST /api/v1/quote/stream: instead of emitting every per-solver quote (including errors and lower-quality updates), the stream now only emits a quote when it ranks better than the best one already sent. Individual solver errors are no longer streamed — a terminal error event is only sent if no solver returned a usable quote. Verified quotes rank above unverified ones regardless of the quoted amount.

This updates the Streaming Quotes section introduced in #638 to match the new behavior.

Changes

  • Key Endpoints entry and section intro now describe progressively improving emissions (first event from the fastest solver, later events only when strictly better)
  • Documented the ranking rule: verified quotes beat unverified ones regardless of amount, so a later event can carry a slightly worse price when it is the first verified quote
  • Documented that priceQuality is ignored and every event carries its own verified flag
  • Corrected the error semantics: solver failures are not streamed; the terminal error event carries a PriceEstimationError body (e.g. NoLiquidity) and is only sent when no usable quote exists
  • Added integrator guidance: the last event received at stream close is always the best quote, so no client-side ranking is needed

🤖 Generated with Claude Code

Summary by CodeRabbit

  • Documentation
    • Clarified when streamed quote events are emitted based on quote ranking.
    • Documented solver verification behavior, including the verified flag and verification priority.
    • Explained how responses are handled when solvers return no usable quotes.
    • Updated timeout guidance to note that the first quote comes from the fastest solver.

cowprotocol/services#4648 changed POST /api/v1/quote/stream to only
emit quotes that rank better than the best one already sent, defer
individual solver errors, and rank verified quotes above unverified
ones regardless of amount. Update the section added in #638 to match.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@vercel

vercel Bot commented Jul 27, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
docs Ready Ready Preview Jul 27, 2026 10:25am

Request Review

@coderabbitai

coderabbitai Bot commented Jul 27, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Walkthrough

The API integration docs now describe progressive best-so-far quote streaming, solver verification and ranking, no-usable-quote errors, and first-quote timing based on the fastest solver.

Changes

Quote stream documentation

Layer / File(s) Summary
Progressive streaming semantics and timing
docs/cow-protocol/integrate/api.mdx
Documents best-so-far SSE events, verified-quote ranking, solver failure handling, final error behavior, and delivery of the first quote from the fastest solver.

Estimated code review effort: 2 (Simple) | ~10 minutes

Suggested reviewers: pretf00d, cowmarketing, marshymarsh

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title is concise and clearly summarizes the main doc change about progressively better streamed quotes.
Description check ✅ Passed The description matches the template with clear Description and Changes sections and provides the needed context.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch streaming-quote-monotonic-updates

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.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🧹 Nitpick comments (2)
docs/cow-protocol/integrate/api.mdx (2)

86-86: 🎯 Functional Correctness | 🔵 Trivial | ⚡ Quick win

"Last event is always the best quote" doesn't hold when the stream ends in an error.

Line 86 says the terminal event can be an error event with a PriceEstimationError body when no usable quote exists. Line 88 then unconditionally states "the last event received when the stream closes is the best available quote." These two statements conflict for the no-usable-quote case — the last event there is an error, not a quote — and a client relying on line 88 literally could mishandle that case.

✏️ Suggested wording tweak
-Because every event improves on the previous one, the last event received when the stream closes is the best available quote — clients do not need to rank events themselves.
+Because every event improves on the previous one, the last *quote* event received before the stream closes is the best available quote — clients do not need to rank events themselves. If the stream closes with a terminal `error` event instead, no usable quote was found.

Also applies to: 88-88

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@docs/cow-protocol/integrate/api.mdx` at line 86, Update the streaming
behavior documentation around the terminal error description and the “last
event” guidance to clarify that the final event is the best quote only when at
least one usable quote was streamed; when no usable quote exists, the stream
ends with the final PriceEstimationError event instead.

79-79: 🎯 Functional Correctness | 🔵 Trivial | ⚡ Quick win

Clarify "improves" means rank, not necessarily price.

Line 79 says "every update improves on the last," but line 84 then says a later (verified) event "may... report a slightly worse price than an earlier one." Without qualifying "improves" as rank (verified > unverified, not raw amount), readers may assume price is monotonically improving, which line 84 contradicts.

✏️ Suggested wording tweak
-The first event arrives as soon as the fastest solver responds, and after that a quote is only emitted when it ranks better than the best one already sent, so the client can show a price immediately and every update improves on the last.
+The first event arrives as soon as the fastest solver responds, and after that a quote is only emitted when it ranks better than the best one already sent, so the client can show a price immediately and every update improves on the last by rank (verification status, then amount) — not necessarily by price.

Also applies to: 84-84

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@docs/cow-protocol/integrate/api.mdx` at line 79, Clarify the event-update
description around “every update improves on the last” to specify that
improvement refers to solver ranking, not necessarily the quoted price amount.
Align the wording with the later verified-event explanation in the same section,
preserving the immediate first event and subsequent better-ranked update
behavior.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Nitpick comments:
In `@docs/cow-protocol/integrate/api.mdx`:
- Line 86: Update the streaming behavior documentation around the terminal error
description and the “last event” guidance to clarify that the final event is the
best quote only when at least one usable quote was streamed; when no usable
quote exists, the stream ends with the final PriceEstimationError event instead.
- Line 79: Clarify the event-update description around “every update improves on
the last” to specify that improvement refers to solver ranking, not necessarily
the quoted price amount. Align the wording with the later verified-event
explanation in the same section, preserving the immediate first event and
subsequent better-ranked update behavior.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 9fd2b361-c040-4e6e-8ac5-e0419688ee06

📥 Commits

Reviewing files that changed from the base of the PR and between c582f1d and ff64b45.

📒 Files selected for processing (1)
  • docs/cow-protocol/integrate/api.mdx

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant