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:
+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,
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user