Repository navigation
feat(id): P0-A integration — frame-seam charging, HTTP 429+Retry-After, chat limiter consumer, counter visibility (#3882) #3960
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
759bb46
f437759
2ece4d8
3993ac9
0626642
6e868c6
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -353,6 +353,24 @@ pub(super) fn refusal_status(error: &anyhow::Error) -> StatusCode { | |
| } | ||
|
|
||
| fn refusal_response(error: &anyhow::Error) -> Response { | ||
| // Structured refusal (#2244 P0-A): a rate-limit refusal carries the | ||
| // machine-readable reason and a bounded retry value, in the body | ||
| // and as a `Retry-After` header. The directory limiters behind | ||
| // this surface compute no bucket value of their own, so the abuse | ||
| // contract's floor (`RETRY_FLOOR_MS`) is what is emitted. | ||
| if matches!(error.downcast_ref::<Refusal>(), Some(Refusal::RateLimited(_))) { | ||
| let retry_ms = crate::abuse::RETRY_FLOOR_MS; | ||
| return ( | ||
| StatusCode::TOO_MANY_REQUESTS, | ||
| [(header::RETRY_AFTER, (retry_ms / 1_000).to_string())], | ||
|
Comment on lines
+361
to
+365
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
| Json(serde_json::json!({ | ||
| "error": format!("{error:#}"), | ||
| "reason": "rate_limited", | ||
| "retry_after_ms": retry_ms, | ||
| })), | ||
| ) | ||
| .into_response(); | ||
| } | ||
| ( | ||
| refusal_status(error), | ||
| Json(serde_json::json!({ "error": format!("{error:#}") })), | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Script executed:
Repository: developing-today/code
Length of output: 7480
Script executed:
Repository: developing-today/code
Length of output: 9397
Return the longer delay when both budgets refuse.
When the frame bucket and the byte bucket both refuse, the returned delay covers only the frame bucket. A caller that waits that delay is refused again by the byte bucket. Return
max(frame_retry, byte_retry)when both refuse, and keep the frame-firstRateLimitedreason.Suggested fix