proto becomes bxcore, the one shared crate (M5b task 00)
Done the way the owner asked and the spike mapped: the crate and the manifests renamed, then what the build reported fixed. Layers: 138 "proto unresolved" errors across 169 files; cargo fmt reordering imports; six fixture paths built as strings in brokerd's and bxctl's tests, which the compiler cannot see, and comments naming crates/proto/; the crate-dependency check and its self-test. One more the spike did not reach: a `\nproto =` key inside a printf format in the self-test, which a word-boundary replacement skips because `n` and `p` are both word characters. make gate: gate: ok, 944 tests; no new entry in /tmp. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -7,7 +7,7 @@ use std::path::{Path, PathBuf};
|
||||
use crate::config::Config;
|
||||
use crate::llama::{ChatMessage, ToolSchema};
|
||||
use crate::tools::Registry;
|
||||
use proto::{Hash32, LogRecord, sha256};
|
||||
use bxcore::{Hash32, LogRecord, sha256};
|
||||
|
||||
use serde::Deserialize;
|
||||
use serde::Serialize;
|
||||
|
||||
@@ -8,7 +8,7 @@ use std::path::PathBuf;
|
||||
use std::time::{Duration, Instant};
|
||||
|
||||
use crate::tools::{Pending, ToolPort};
|
||||
use proto::{
|
||||
use bxcore::{
|
||||
Envelope, FrameError, Message, PROTOCOL_VERSION, Timestamp, ToolRequest, ToolResponse,
|
||||
read_frame, write_frame,
|
||||
};
|
||||
|
||||
@@ -14,7 +14,7 @@ use crate::memory::MemorySource;
|
||||
use crate::session::{Session, SessionError};
|
||||
use crate::tools::{Registry, ToolPort};
|
||||
use crate::turn::{Runtime, TurnError, run_turn};
|
||||
use proto::{
|
||||
use bxcore::{
|
||||
Envelope, ErrorCode, FrameError, Message, PROTOCOL_VERSION, SessionId, TurnDone, WireError,
|
||||
read_frame, write_frame,
|
||||
};
|
||||
|
||||
@@ -23,7 +23,7 @@ pub struct Slots {
|
||||
#[derive(Debug, Clone, PartialEq, Eq, Deserialize)]
|
||||
#[serde(deny_unknown_fields)]
|
||||
pub struct Expect {
|
||||
pub template_sha256: proto::Hash32,
|
||||
pub template_sha256: bxcore::Hash32,
|
||||
pub n_ctx: u64,
|
||||
pub slots: u32,
|
||||
}
|
||||
|
||||
@@ -201,7 +201,7 @@ impl Assembler {
|
||||
));
|
||||
}
|
||||
};
|
||||
tool_calls.push(proto::ToolCall {
|
||||
tool_calls.push(bxcore::ToolCall {
|
||||
id,
|
||||
name,
|
||||
arguments: call.arguments,
|
||||
|
||||
@@ -18,7 +18,7 @@ pub enum ChatMessage {
|
||||
Assistant {
|
||||
content: Option<String>,
|
||||
reasoning_content: Option<String>,
|
||||
tool_calls: Vec<proto::ToolCall>,
|
||||
tool_calls: Vec<bxcore::ToolCall>,
|
||||
},
|
||||
Tool {
|
||||
tool_call_id: String,
|
||||
@@ -93,7 +93,7 @@ pub struct Completion {
|
||||
pub id: String,
|
||||
pub content: Option<String>,
|
||||
pub reasoning_content: Option<String>,
|
||||
pub tool_calls: Vec<proto::ToolCall>,
|
||||
pub tool_calls: Vec<bxcore::ToolCall>,
|
||||
pub finish_reason: FinishReason,
|
||||
pub timings: Timings,
|
||||
pub reasoning_tokens: u64,
|
||||
|
||||
@@ -73,7 +73,7 @@ fn serialize_message(message: &ChatMessage) -> Result<serde_json::Value, serde_j
|
||||
}
|
||||
}
|
||||
|
||||
fn serialized_call(call: &proto::ToolCall) -> SerializedToolCall {
|
||||
fn serialized_call(call: &bxcore::ToolCall) -> SerializedToolCall {
|
||||
SerializedToolCall {
|
||||
id: call.id.clone(),
|
||||
kind: "function",
|
||||
|
||||
@@ -6,7 +6,7 @@ use std::os::unix::net::UnixStream;
|
||||
use std::path::PathBuf;
|
||||
use std::time::Duration;
|
||||
|
||||
use proto::{
|
||||
use bxcore::{
|
||||
Empty, Envelope, Message, PROTOCOL_VERSION, SessionId, SessionUpdated, read_frame, write_frame,
|
||||
};
|
||||
|
||||
|
||||
@@ -75,7 +75,7 @@ fn server_matches(client: &Client) -> Result<(), SelfTestError> {
|
||||
let expect = &client.config().expect;
|
||||
|
||||
let expected = expect.template_sha256;
|
||||
let got = proto::sha256(props.chat_template.as_bytes()).map_err(|_| SelfTestError::Hash)?;
|
||||
let got = bxcore::sha256(props.chat_template.as_bytes()).map_err(|_| SelfTestError::Hash)?;
|
||||
if expected != got {
|
||||
return Err(SelfTestError::Mismatch {
|
||||
what: "chat template sha256",
|
||||
|
||||
@@ -6,7 +6,7 @@ use std::io::Write;
|
||||
use std::path::{Path, PathBuf};
|
||||
|
||||
use crate::baseline::{Baseline, BaselineError};
|
||||
use proto::{CallId, Epoch, LogRecord, SessionId, Timestamp};
|
||||
use bxcore::{CallId, Epoch, LogRecord, SessionId, Timestamp};
|
||||
|
||||
/// Creating, opening, appending and resuming a session, and the errors each can raise.
|
||||
#[derive(Debug)]
|
||||
@@ -193,7 +193,7 @@ impl Session {
|
||||
id
|
||||
}
|
||||
|
||||
pub fn last_usage(&self) -> Option<proto::Usage> {
|
||||
pub fn last_usage(&self) -> Option<bxcore::Usage> {
|
||||
for record in self.records.iter().rev() {
|
||||
if let LogRecord::Usage {
|
||||
cache_n,
|
||||
@@ -204,7 +204,7 @@ impl Session {
|
||||
..
|
||||
} = record
|
||||
{
|
||||
return Some(proto::Usage {
|
||||
return Some(bxcore::Usage {
|
||||
cache_n: *cache_n,
|
||||
prompt_n: *prompt_n,
|
||||
predicted_n: *predicted_n,
|
||||
|
||||
+27
-25
@@ -11,16 +11,16 @@ pub trait ToolPort: Send + Sync {
|
||||
/// for the owner, the port calls `on_pending` once and goes on waiting.
|
||||
fn call(
|
||||
&self,
|
||||
request: &proto::ToolRequest,
|
||||
request: &bxcore::ToolRequest,
|
||||
on_pending: &mut dyn FnMut(&Pending),
|
||||
) -> proto::ToolResponse;
|
||||
) -> bxcore::ToolResponse;
|
||||
}
|
||||
|
||||
/// One waiting call, as the broker reports it.
|
||||
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
|
||||
pub struct Pending {
|
||||
pub approval: u64,
|
||||
pub expires: proto::Timestamp,
|
||||
pub expires: bxcore::Timestamp,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, PartialEq)]
|
||||
@@ -281,7 +281,7 @@ pub fn dispatch(registry: &Registry, name: &str, arguments: &str) -> Dispatch {
|
||||
return dispatch_call_tool(registry, arguments);
|
||||
}
|
||||
if name == CLOCK {
|
||||
return Dispatch::Local(proto::Timestamp::now().to_rfc3339());
|
||||
return Dispatch::Local(bxcore::Timestamp::now().to_rfc3339());
|
||||
}
|
||||
Dispatch::Port {
|
||||
tool: name.to_string(),
|
||||
@@ -351,33 +351,35 @@ pub fn cap_result(text: &str, cap: usize) -> (String, bool) {
|
||||
}
|
||||
|
||||
/// The one fixed sentence a denial reaches the model as, named by its reason.
|
||||
pub fn denial_text(reason: proto::DenyReason) -> &'static str {
|
||||
pub fn denial_text(reason: bxcore::DenyReason) -> &'static str {
|
||||
match reason {
|
||||
proto::DenyReason::NoGrant => "Denied: no grant allows this call.",
|
||||
proto::DenyReason::GrantExpired => "Denied: the grant for this call has expired.",
|
||||
proto::DenyReason::TaintTooHigh => {
|
||||
bxcore::DenyReason::NoGrant => "Denied: no grant allows this call.",
|
||||
bxcore::DenyReason::GrantExpired => "Denied: the grant for this call has expired.",
|
||||
bxcore::DenyReason::TaintTooHigh => {
|
||||
"Denied: this session has seen data too sensitive for this call."
|
||||
}
|
||||
proto::DenyReason::DeniedByGrant => "Denied: a grant forbids this call.",
|
||||
proto::DenyReason::ApprovalRefused => "Denied: the owner refused this call.",
|
||||
proto::DenyReason::ApprovalExpired => {
|
||||
bxcore::DenyReason::DeniedByGrant => "Denied: a grant forbids this call.",
|
||||
bxcore::DenyReason::ApprovalRefused => "Denied: the owner refused this call.",
|
||||
bxcore::DenyReason::ApprovalExpired => {
|
||||
"Denied: the approval request expired without an answer."
|
||||
}
|
||||
proto::DenyReason::InvalidArguments => "Denied: the arguments are not valid for this tool.",
|
||||
proto::DenyReason::GrantsInvalid => {
|
||||
bxcore::DenyReason::InvalidArguments => {
|
||||
"Denied: the arguments are not valid for this tool."
|
||||
}
|
||||
bxcore::DenyReason::GrantsInvalid => {
|
||||
"Denied: the grant files have an error; the owner has been told."
|
||||
}
|
||||
proto::DenyReason::AuditUnavailable => {
|
||||
bxcore::DenyReason::AuditUnavailable => {
|
||||
"Denied: the audit log cannot be written; the owner has been told."
|
||||
}
|
||||
proto::DenyReason::StateUnreadable => {
|
||||
bxcore::DenyReason::StateUnreadable => {
|
||||
"Denied: this session's broker state is damaged; the owner has been told."
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub struct FakeTools {
|
||||
calls: Mutex<Vec<proto::ToolRequest>>,
|
||||
calls: Mutex<Vec<bxcore::ToolRequest>>,
|
||||
}
|
||||
|
||||
impl Default for FakeTools {
|
||||
@@ -393,7 +395,7 @@ impl FakeTools {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn calls(&self) -> Vec<proto::ToolRequest> {
|
||||
pub fn calls(&self) -> Vec<bxcore::ToolRequest> {
|
||||
self.calls.lock().unwrap_or_else(|p| p.into_inner()).clone()
|
||||
}
|
||||
}
|
||||
@@ -401,9 +403,9 @@ impl FakeTools {
|
||||
impl ToolPort for FakeTools {
|
||||
fn call(
|
||||
&self,
|
||||
request: &proto::ToolRequest,
|
||||
request: &bxcore::ToolRequest,
|
||||
_on_pending: &mut dyn FnMut(&Pending),
|
||||
) -> proto::ToolResponse {
|
||||
) -> bxcore::ToolResponse {
|
||||
self.calls
|
||||
.lock()
|
||||
.unwrap_or_else(|p| p.into_inner())
|
||||
@@ -413,23 +415,23 @@ impl ToolPort for FakeTools {
|
||||
"echo" => match serde_json::from_str::<serde_json::Value>(&request.arguments) {
|
||||
Ok(serde_json::Value::Object(obj)) => {
|
||||
match obj.get("text").and_then(|v| v.as_str()) {
|
||||
Some(text) => proto::ToolResponse::Result {
|
||||
Some(text) => bxcore::ToolResponse::Result {
|
||||
content: text.to_string(),
|
||||
class: proto::DataClass::Public,
|
||||
class: bxcore::DataClass::Public,
|
||||
untrusted: false,
|
||||
truncated: false,
|
||||
},
|
||||
None => proto::ToolResponse::Failed {
|
||||
None => bxcore::ToolResponse::Failed {
|
||||
message: "missing text argument".to_string(),
|
||||
},
|
||||
}
|
||||
}
|
||||
_ => proto::ToolResponse::Failed {
|
||||
_ => bxcore::ToolResponse::Failed {
|
||||
message: "arguments must be a JSON object".to_string(),
|
||||
},
|
||||
},
|
||||
_ => proto::ToolResponse::Denied {
|
||||
reason: proto::DenyReason::NoGrant,
|
||||
_ => bxcore::ToolResponse::Denied {
|
||||
reason: bxcore::DenyReason::NoGrant,
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,7 +8,9 @@ use crate::llama::info::{CacheOutcome, cache_outcome};
|
||||
use crate::llama::{ChatEvent, ChatRequest, Client, InferError};
|
||||
use crate::session::{Session, SessionError};
|
||||
use crate::tools::{Registry, ToolPort, cap_result, denial_text, dispatch};
|
||||
use proto::{CallId, DataClass, LogRecord, Timestamp, ToolRequest, ToolResponse, TurnEvent, Usage};
|
||||
use bxcore::{
|
||||
CallId, DataClass, LogRecord, Timestamp, ToolRequest, ToolResponse, TurnEvent, Usage,
|
||||
};
|
||||
|
||||
/// What one turn can fail with, beyond the inference server.
|
||||
#[derive(Debug)]
|
||||
@@ -258,7 +260,7 @@ pub fn run_turn(
|
||||
fn run_call(
|
||||
rt: &Runtime<'_>,
|
||||
session: &Session,
|
||||
call: &proto::ToolCall,
|
||||
call: &bxcore::ToolCall,
|
||||
call_id: CallId,
|
||||
on_event: &mut dyn FnMut(&TurnEvent),
|
||||
) -> (String, DataClass, bool) {
|
||||
|
||||
Reference in New Issue
Block a user