feat(switchyard-translation): add neutral-IR encode/decode helpers#77
Conversation
f2fc719 to
57c015d
Compare
fcf75d3 to
de9ddbe
Compare
Signed-off-by: Greg Clark <grclark@nvidia.com>
de9ddbe to
bb40d0f
Compare
WalkthroughChangesThe translation crate adds buffered request/response helpers, streaming encode/decode APIs, SSE frame parsing, associated tests, public re-exports, and futures-based runtime dependencies. Translation streaming
Estimated code review effort: 3 (Moderate) | ~25 minutes Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 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.
Inline comments:
In `@crates/switchyard-translation/src/helpers.rs`:
- Around line 146-159: Bound the pending SSE data in the streaming loop around
`buffer` and `sse::drain_next_sse_frame`: after draining all complete frames
from each chunk, reject the request when the remaining incomplete buffer exceeds
the configured maximum frame size. Add a multi-chunk test that omits the frame
delimiter and verifies the oversized pending frame is rejected.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Enterprise
Run ID: c3a2bb39-46ff-4a53-980b-a40929104739
⛔ Files ignored due to path filters (1)
Cargo.lockis excluded by!**/*.lock,!Cargo.lock
📒 Files selected for processing (4)
crates/switchyard-translation/Cargo.tomlcrates/switchyard-translation/src/helpers.rscrates/switchyard-translation/src/lib.rscrates/switchyard-translation/src/sse.rs
Signed-off-by: Greg Clark <grclark@nvidia.com>
|
nothing extra to add apart from Graham, just an additional pass checking if there are more idiomatic or standard ways of doing anything in this PR would be good |
Signed-off-by: Greg Clark <grclark@nvidia.com>
Summary
Adds convenience helpers to
switchyard-translationfor translating between provider wireformats and the neutral IR without threading an engine/policy through every call.
Base:
libsy-lib-proto-cleanupChanges
helpers.rs— free functions over a shared default engine:decode_request,encode_request,decode_buffered_response,encode_buffered_response,encode_stream,and a byte-based
decode_stream(Stream<Item = Result<Vec<u8>, _>>→ IR chunks — no HTTPclient types), plus the
RawEventStreamtype for unframed wire-event streams.sse.rs— a minimal SSE frame parser backingdecode_stream.lib.rs— wires in the two modules and re-exports the helpers from the crate root.Cargo.toml— addsfutures+async-streamfor the streaming helpers.Tests
Unit tests for every helper (request/response round-trips, buffered & stream encode/decode)
and the SSE parser. Full workspace builds clean, clippy at zero.
Checklist
snake_caseof the primary class.switchyard/__init__.py.__all__if intended for downstream use.--helpupdated if customer-facing surface changed.Signed-off-by: Your Name <email>) per the DCO.Notes for reviewers
Anything reviewers should pay extra attention to — risky paths, follow-up tickets, intentional trade-offs.
Summary by CodeRabbit