Add error codes + details to SeqError - #28
Conversation
📝 WalkthroughWalkthroughThe protocol now supports optional structured remote error codes and details. Model socket opening, command handling, sequence failures, and pending request propagation preserve those fields, with tests covering backward compatibility and structured error delivery. The crate version advances to 0.5.1. ChangesRemote error propagation
Estimated code review effort: 3 (Moderate) | ~20 minutes Sequence Diagram(s)sequenceDiagram
participant Remote
participant MSEvent
participant ModelSocket
participant Seq
participant PendingRequests
Remote->>MSEvent: Emit error with message, code, and details
MSEvent->>ModelSocket: Route opening-seq error
ModelSocket->>PendingRequests: Fail open request with ModelSocketError::Remote
MSEvent->>Seq: Route command or sequence error
Seq->>PendingRequests: Fail pending commands, streams, and embeddings with remote details
Suggested reviewers: 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
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 `@Cargo.toml`:
- Line 3: Update the package version declaration in Cargo.toml from 0.5.1 to
0.6.0 to reflect the breaking public ModelSocketError contract changes.
🪄 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: defaults
Review profile: CHILL
Plan: Pro
Run ID: 7ca354e2-14fb-42b8-bded-cf4c4a0ca615
⛔ Files ignored due to path filters (1)
Cargo.lockis excluded by!**/*.lock
📒 Files selected for processing (4)
Cargo.tomlsrc/client/mod.rssrc/client/seq.rssrc/protocol.rs
| [package] | ||
| name = "modelsocket" | ||
| version = "0.5.0" | ||
| version = "0.5.1" |
There was a problem hiding this comment.
🗄️ Data Integrity & Integration | 🟠 Major | ⚡ Quick win
🧩 Analysis chain
🏁 Script executed:
#!/usr/bin/env bash
set -euo pipefail
sed -n '1,70p' src/client/mod.rs
sed -n '35,145p' src/protocol.rs
rg -nP --glob '*.rs' 'ModelSocketError::(Open|Command|Remote)|MSEvent::Error\s*\{' .Repository: mixlayer/modelsocket-rs
Length of output: 6011
🏁 Script executed:
#!/usr/bin/env bash
set -euo pipefail
rg -n --hidden --glob '!target' --glob '!**/Cargo.lock' -i 'semver|versioning|breaking change|major release|minor release|patch release' .Repository: mixlayer/modelsocket-rs
Length of output: 161
🏁 Script executed:
#!/usr/bin/env bash
set -euo pipefail
sed -n '1,90p' src/client/mod.rs
printf '\n---\n'
sed -n '240,320p' src/client/mod.rs
printf '\n---\n'
sed -n '520,580p' src/client/mod.rs
printf '\n---\n'
sed -n '700,820p' src/client/seq.rsRepository: mixlayer/modelsocket-rs
Length of output: 9753
Bump this to 0.6.0
Cargo.toml:3 is still a patch release, but this PR changes the public error contract (ModelSocketError adds Remote, and some failures now return it instead of Open/Command). That can break downstream exhaustive matches, so this should ship as 0.6.0.
🤖 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 `@Cargo.toml` at line 3, Update the package version declaration in Cargo.toml
from 0.5.1 to 0.6.0 to reflect the breaking public ModelSocketError contract
changes.
Right now
SeqErrorjust returns an error message - we should have something more strictly structured/reliable. We also want to be able to pass additional detail about an error - such as for a rate limiting error, how many RPM/TPM have been consumed and what's remaining. Here, wecodeanddetails, which are generic but for now are specifically designed to handle the rate limiting case.Backwards compatibility is retained - both fields are optional and omitted when absent.
Example error payload:
{ "event": "error", "cid": "gen_01JABC123", "seq_id": "seq_01JXYZ789", "message": "Rate limit exceeded", "code": "rate_limit_exceeded", "details": { "rpm_limit": 60, "rpm_remaining": 0, "tpm_limit": 100000, "tpm_remaining": 42000, "retry_after_ms": 1000 } }Summary by CodeRabbit
New Features
Bug Fixes
Release