bxctl: escape error details, time out on admin.sock, AdminError::Io

M3a review findings 9, 10, 12, 13. A retrying error and every error detail
can carry the inference server's body, so they are escaped like model text.
Admin requests wait at most 30 s, so a stuck brokerd cannot hang bxctl or a
chat turn. A failed write is AdminError::Io and stops handle_pending instead
of being answered with another write. The usage line says what audit verify
checks.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-09-22 21:09:53 -07:00
co-authored by Claude Opus 5.5
parent 70d582acf5
commit a75a5453e9
5 changed files with 132 additions and 8 deletions
+9 -3
View File
@@ -10,7 +10,7 @@ use proto::{
};
use crate::admin;
use crate::escape::escape_model_text;
use crate::escape::{escape_json_text, escape_model_text};
#[derive(Debug)]
pub enum ChatError {
@@ -25,7 +25,10 @@ impl std::fmt::Display for ChatError {
match self {
ChatError::Connect(e) => write!(f, "{e}"),
ChatError::Frame(e) => write!(f, "{e}"),
ChatError::Refused(w) => write!(f, "{}: {}", code_name(w.code), w.detail),
// The detail may carry the inference server's body: escape it like model text.
ChatError::Refused(w) => {
write!(f, "{}: {}", code_name(w.code), escape_json_text(&w.detail))
}
ChatError::Protocol(s) => write!(f, "{s}"),
}
}
@@ -188,7 +191,8 @@ impl Printer {
self.close_dimmed(out)?;
writeln!(
out,
"[retrying: attempt {attempt} in {after_ms} ms: {error}]"
"[retrying: attempt {attempt} in {after_ms} ms: {}]",
escape_json_text(error)
)?;
}
TurnEvent::ThinkingCapped { tokens } => {
@@ -302,6 +306,8 @@ pub fn handle_pending(
};
match result {
Ok(_) => Ok(()),
// The output itself failed: writing another line to it would fail the same way.
Err(admin::AdminError::Io(e)) => Err(e),
Err(e) => {
writeln!(out, "approval {approval}: {e}")?;
Ok(())