fix(bridge): use named MessagePack format for wire compatibility

Client-side Protocol.gd expects rmp_serde::to_vec_named() (maps with
string keys), but LocalBridge was using to_vec() (compact positional
arrays). Fix send_snapshot and update all test serialization calls to
match actual wire format. Also change EOF from Ok(vec![]) to
BridgeError::Transport so bridge systems can detect disconnects.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-02-11 21:01:15 +01:00
co-authored by Claude Opus 4.6
parent af4d0d3f26
commit f6ce7d4046
3 changed files with 16 additions and 14 deletions
+2 -5
View File
@@ -81,7 +81,7 @@ impl LocalBridge {
impl SimBridge for LocalBridge {
fn send_snapshot(&self, snapshot: &ObserverSnapshot) -> Result<(), BridgeError> {
let payload = rmp_serde::to_vec(snapshot)?;
let payload = rmp_serde::to_vec_named(snapshot)?;
let mut writer = self.writer.lock().expect("writer mutex poisoned");
write_framed(writer.get_mut(), &payload)?;
@@ -99,10 +99,7 @@ impl SimBridge for LocalBridge {
tracing::trace!("received {} inputs", inputs.len());
Ok(inputs)
}
None => {
tracing::trace!("received EOF, returning empty input vec");
Ok(Vec::new())
}
None => Err(BridgeError::Transport("client disconnected (EOF)".into())),
}
}
}