Stream broker responses through and add pytest coverage#126
Merged
Conversation
Detect streaming requests via Accept: text/event-stream or "stream": true and relay the upstream body chunk-by-chunk with per-chunk flushes, closing the connection to delimit the response. Auth, rate-limit, and privacy checks still run before proxying; the smoke test now covers an SSE case against the fake provider and asserts chunks arrive incrementally. Closes #81 Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Cover signed-token expiry and tampering, wrong HMAC key versions, device attestation clock-skew boundaries, rate limiter concurrency and stale-key eviction, admin/static token compare_digest paths, and adversarial count_input_images payloads. Wire the suite into the repo-checks CI job. Closes #87 Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Accept: text/event-streamor"stream": truein the JSON payload) and relays the upstream body chunk-by-chunk with aread1()loop and per-chunk flushes, mirroring the upstreamContent-Typeand closing the connection to delimit the response. Auth, rate-limit, model-allowlist, and privacy checks still run before any bytes are proxied; the non-streaming path is unchanged.services/model-broker/tests/covering signed-token expiry and bit-flipped tampering, wrong HMAC key versions, device-attestation clock-skew boundaries (inside vs outside the accept window), rate limiter concurrency (16 threads hammeringallow(), exactlymax_eventsadmitted) and stale-key eviction, admin/static tokencompare_digestpaths, and adversarialcount_input_imagespayloads.Closes #81
Closes #87
Test plan
./scripts/check.shpasses locally (includes the broker smoke test with the new streaming case)python3 -m pytest services/model-broker/tests -q— 39 passed🤖 Generated with Claude Code