bxcore: a turn's speaker, SessionUpdated's turn, the session-state messages

Co-Authored-By: ornith-1.5-35b-a3b <agent@wntrmute.dev>
This commit is contained in:
2026-09-28 10:27:28 -07:00
co-authored by ornith-1.5-35b-a3b
parent 027146f359
commit c798714af1
31 changed files with 238 additions and 13 deletions
+3 -1
View File
@@ -88,7 +88,7 @@ impl Broker {
}
}
/// The snake_case wire name of a message: all twenty-six kinds, none with a leading underscore.
/// The snake_case wire name of a message: all twenty-eight kinds, none with a leading underscore.
pub fn kind(msg: &Message) -> &'static str {
match msg {
Message::ToolRequest(_) => "tool_request",
@@ -117,6 +117,8 @@ pub fn kind(msg: &Message) -> &'static str {
Message::Reindexed(_) => "reindexed",
Message::MemoryAdmin(_) => "memory_admin",
Message::MemoryAdminReply(_) => "memory_admin_reply",
Message::SessionState(_) => "session_state",
Message::SessionStateReply(_) => "session_state_reply",
}
}
+21 -2
View File
@@ -22,8 +22,8 @@ use brokerd::ledger::NOT_RECORDED;
use brokerd::runner::{REFUSING, RunError};
use bxcore::{
ApprovalList, Approve, ApproveResult, AuditEvent, DataClass, DecisionRecord, DenyReason, Empty,
Envelope, ErrorCode, GrantsReport, Message, Refuse, ResultStatus, SessionId, ToolResponse,
Turn, TurnDone, TurnEvent, Usage, WireError,
Envelope, ErrorCode, GrantsReport, Message, Refuse, ResultStatus, SessionId, SessionState,
SessionStateReply, ToolResponse, Turn, TurnDone, TurnEvent, Usage, WireError,
};
use client::{Serve, call, next, open};
use rig::{Rig, grant_text, request};
@@ -158,6 +158,7 @@ fn every_kind_but_tool_request() -> Vec<Message> {
session: SessionId::new("s1").unwrap(),
content: String::new(),
resume: false,
speaker: None,
}),
Message::TurnEvent(TurnEvent::Content {
text: String::new(),
@@ -217,6 +218,24 @@ fn every_other_kind_on_broker_sock_is_forbidden() {
);
}
/// A refused kind is logged by its wire name, the new session-state messages too (M5c spec,
/// section 7).
#[test]
fn the_session_state_kinds_have_their_wire_names() {
for msg in [
Message::SessionState(SessionState {
session: SessionId::new("s1").unwrap(),
}),
Message::SessionStateReply(SessionStateReply {
class: DataClass::Private,
untrusted: false,
}),
] {
let wire = serde_json::to_value(&msg).unwrap();
assert_eq!(Some(broker::kind(&msg)), wire["kind"].as_str(), "{wire}");
}
}
#[test]
fn a_frame_that_is_not_json_is_answered_with_bad_message() {
let rig = Rig::new("broker-badframe");