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:
2026-09-26 01:48:38 -07:00
co-authored by Claude Opus 5.5
parent 727e027fcf
commit 2b3ae080b4
311 changed files with 426 additions and 410 deletions
+1 -1
View File
@@ -7,7 +7,7 @@ use crate::approvals::Entry;
use crate::broker::{Broker, forbid, read_request, send};
use crate::grants;
use crate::ledger::{Answer, Answered};
use proto::{
use bxcore::{
ApprovalList, Approve, ApproveResult, DecisionRecord, DenyReason, Empty, ErrorCode,
GrantsReport, Message, Refuse, Timestamp, WireError,
};
+1 -1
View File
@@ -2,7 +2,7 @@
//! gone. In memory only.
use crate::policy::{Ask, Decision};
use proto::{DecisionRecord, DenyReason, PendingApproval, Timestamp};
use bxcore::{DecisionRecord, DenyReason, PendingApproval, Timestamp};
use std::collections::BTreeMap;
use std::sync::mpsc::{Receiver, Sender, channel};
use std::sync::{Mutex, MutexGuard};
+4 -4
View File
@@ -4,8 +4,8 @@
//! path, a host or a URL is well formed. The module is pure: no I/O, no clock. Everything it reads
//! was written by the model, so it is treated as hostile.
use proto::tools::{HttpFetchArgs, ReadFileArgs, ShellArgs, WriteFileArgs};
use proto::{MemoryArgs, RecallArgs};
use bxcore::tools::{HttpFetchArgs, ReadFileArgs, ShellArgs, WriteFileArgs};
use bxcore::{MemoryArgs, RecallArgs};
use std::fmt;
/// Maximum length, in bytes, of a path.
@@ -295,8 +295,8 @@ pub fn inside(grant_path: &str, path: &str) -> bool {
}
}
/// Moved to `proto::hosts` in M3b, so `toolkit` checks hosts with the same rules.
pub use proto::hosts::{host_matches, valid_host, valid_host_pattern};
/// Moved to `bxcore::hosts` in M3b, so `toolkit` checks hosts with the same rules.
pub use bxcore::hosts::{host_matches, valid_host, valid_host_pattern};
/// A character that may appear in a host name.
fn host_char(c: char) -> bool {
+1 -1
View File
@@ -10,7 +10,7 @@ use std::io::Write;
use std::os::unix::fs::{DirBuilderExt, OpenOptionsExt};
use std::path::{Path, PathBuf};
use proto::{
use bxcore::{
AuditEvent, AuditRecord, ChainFailure, ChainReport, ChainVerifier, Hash32, Timestamp,
is_audit_log_name, sha256,
};
+2 -2
View File
@@ -9,7 +9,7 @@ use std::sync::Mutex;
use std::sync::mpsc::{Receiver, RecvTimeoutError};
use std::time::Duration;
use proto::{
use bxcore::{
DenyReason, Envelope, ErrorCode, FrameError, Message, PROTOCOL_VERSION, PendingApproval,
Timestamp, ToolResponse, WireError, read_frame, write_frame,
};
@@ -37,7 +37,7 @@ pub struct Broker {
table: Table,
runtime: Box<dyn Runtime>,
log: Log,
printed: Mutex<Option<Vec<proto::GrantProblem>>>,
printed: Mutex<Option<Vec<bxcore::GrantProblem>>>,
}
impl Broker {
+1 -1
View File
@@ -2,7 +2,7 @@
//! is what an agent is, so no grant file can turn it off or put questions in front of it; the
//! prompt is protected by `memoryd`, which lets only clean sessions edit identity.
use proto::{Grant, GrantProblem, sha256};
use bxcore::{Grant, GrantProblem, sha256};
use crate::grants::LoadedGrant;
+1 -1
View File
@@ -8,7 +8,7 @@ use std::sync::atomic::{AtomicBool, Ordering};
use std::sync::mpsc::{self, Receiver, RecvTimeoutError};
use std::time::{Duration, Instant};
use proto::{
use bxcore::{
ApprovalOutcome, ApprovalReply, ApprovalRequest, DecisionRecord, DenyReason, Envelope,
FrameError, GatewayOutcome, Message, PendingApproval, Timestamp, read_frame,
};
+3 -3
View File
@@ -8,7 +8,7 @@
use std::path::Path;
use crate::args::{ToolName, valid_host_pattern, valid_path};
use proto::{DataClass, Grant, GrantProblem, Mode, sha256};
use bxcore::{DataClass, Grant, GrantProblem, Mode, sha256};
/// Where the owner reads the rules behind a rejected set.
pub const RUNBOOK: &str = "see docs/runbook.md#grants-invalid";
@@ -17,8 +17,8 @@ pub const RUNBOOK: &str = "see docs/runbook.md#grants-invalid";
#[derive(Debug, Clone, PartialEq, Eq)]
pub struct LoadedGrant {
pub id: String, // the file stem
pub grant: proto::Grant,
pub sha256: proto::Hash32, // of the file's bytes as read
pub grant: bxcore::Grant,
pub sha256: bxcore::Hash32, // of the file's bytes as read
}
/// A set that passed every rule, in id order. Its field is private: `from_grants` and `load` are
+6 -6
View File
@@ -2,7 +2,7 @@
use std::sync::MutexGuard;
use proto::{ApprovalAnswer, AuditEvent, DataClass, DenyReason, Timestamp, ToolResponse};
use bxcore::{ApprovalAnswer, AuditEvent, DataClass, DenyReason, Timestamp, ToolResponse};
use super::{Answer, Answered, Call, Grants, Inner, Ledger};
use crate::approvals::Verdict;
@@ -107,16 +107,16 @@ impl Ledger {
guard: &mut MutexGuard<'_, Inner>,
call: &Call,
now: Timestamp,
status: proto::ResultStatus,
status: bxcore::ResultStatus,
taint_after: DataClass,
response: &ToolResponse,
) -> ToolResponse {
let (sha256, bytes) = match response {
ToolResponse::Result { content, .. } => match proto::sha256(content.as_bytes()) {
ToolResponse::Result { content, .. } => match bxcore::sha256(content.as_bytes()) {
Ok(sha) => (sha, u64::try_from(content.len()).unwrap_or(u64::MAX)),
Err(_) => return Self::not_recorded(),
},
ToolResponse::Failed { message } => match proto::sha256(message.as_bytes()) {
ToolResponse::Failed { message } => match bxcore::sha256(message.as_bytes()) {
Ok(sha) => (sha, u64::try_from(message.len()).unwrap_or(u64::MAX)),
Err(_) => return Self::not_recorded(),
},
@@ -182,7 +182,7 @@ impl Ledger {
&mut guard,
call,
now,
proto::ResultStatus::Result,
bxcore::ResultStatus::Result,
raised.taint,
&response,
)
@@ -197,7 +197,7 @@ impl Ledger {
&mut guard,
call,
now,
proto::ResultStatus::Failed,
bxcore::ResultStatus::Failed,
taint_after,
&response,
)
+1 -1
View File
@@ -6,7 +6,7 @@ mod answer;
use std::sync::{Mutex, MutexGuard};
use proto::{
use bxcore::{
AuditEvent, CallId, DataClass, DecisionRecord, DenyReason, GrantProblem, Mode, SessionId,
Timestamp, ToolRequest, ToolResponse,
};
+1 -1
View File
@@ -6,7 +6,7 @@ use std::os::unix::net::UnixStream;
use std::path::PathBuf;
use std::time::Duration;
use proto::{
use bxcore::{
Envelope, MemoryCall, Message, PROTOCOL_VERSION, ToolRequest, ToolResponse, read_frame,
write_frame,
};
+1 -1
View File
@@ -6,7 +6,7 @@
use crate::config::Runner;
use crate::runner::RunSpec;
use proto::{CallId, SessionId};
use bxcore::{CallId, SessionId};
use std::ffi::OsString;
use std::path::Path;
+1 -1
View File
@@ -3,7 +3,7 @@
use super::{Label, Matched, SessionState};
use crate::args::{ToolArgs, host_matches, inside};
use crate::grants::GrantSet;
use proto::{DataClass, Grant, Hash32, Mode, Timestamp};
use bxcore::{DataClass, Grant, Hash32, Mode, Timestamp};
/// The grants left after matching, and the two flags that pick the denial reason when none are
/// left.
+14 -14
View File
@@ -6,9 +6,9 @@
//! constructor is exposed.
//!
//! ```compile_fail
//! let request = proto::ToolRequest {
//! session: proto::SessionId::new("s1").unwrap(),
//! call: proto::CallId(1),
//! let request = bxcore::ToolRequest {
//! session: bxcore::SessionId::new("s1").unwrap(),
//! call: bxcore::CallId(1),
//! tool: "shell".to_string(),
//! arguments: r#"{"command":"ls"}"#.to_string(),
//! };
@@ -33,9 +33,9 @@
//! The same three hold for `Ask`.
//!
//! ```compile_fail
//! let request = proto::ToolRequest {
//! session: proto::SessionId::new("s1").unwrap(),
//! call: proto::CallId(1),
//! let request = bxcore::ToolRequest {
//! session: bxcore::SessionId::new("s1").unwrap(),
//! call: bxcore::CallId(1),
//! tool: "shell".to_string(),
//! arguments: r#"{"command":"ls"}"#.to_string(),
//! };
@@ -60,15 +60,15 @@
//! ```
//! fn needs_clone<T: Clone>() {}
//! fn needs_decoding<T: serde::de::DeserializeOwned>() {}
//! needs_clone::<proto::ToolRequest>();
//! needs_decoding::<proto::ToolRequest>();
//! let request = proto::ToolRequest {
//! session: proto::SessionId::new("s1").unwrap(),
//! call: proto::CallId(1),
//! needs_clone::<bxcore::ToolRequest>();
//! needs_decoding::<bxcore::ToolRequest>();
//! let request = bxcore::ToolRequest {
//! session: bxcore::SessionId::new("s1").unwrap(),
//! call: bxcore::CallId(1),
//! tool: "shell".to_string(),
//! arguments: r#"{"command":"ls"}"#.to_string(),
//! };
//! let now = proto::Timestamp::from_unix_millis(0).unwrap();
//! let now = bxcore::Timestamp::from_unix_millis(0).unwrap();
//! match brokerd::policy::decide(
//! request,
//! &brokerd::grants::GrantSet::default(),
@@ -76,7 +76,7 @@
//! now,
//! ) {
//! brokerd::policy::Outcome::Denied(denial) => {
//! assert_eq!(denial.reason, proto::DenyReason::NoGrant);
//! assert_eq!(denial.reason, bxcore::DenyReason::NoGrant);
//! }
//! other => panic!("expected a denial, got {other:?}"),
//! }
@@ -86,8 +86,8 @@ mod matching;
use crate::args::{self, ToolArgs, ToolName};
use crate::grants::GrantSet;
use bxcore::{DataClass, DenyReason, Hash32, Mode, Timestamp, ToolRequest};
use matching::{MatchResult, build_matched, match_grants, winner};
use proto::{DataClass, DenyReason, Hash32, Mode, Timestamp, ToolRequest};
/// The session's taint, and whether its results are untrusted. Only `taint` shapes a decision.
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
+4 -4
View File
@@ -5,8 +5,8 @@
//!
//! ```compile_fail
//! let _ = brokerd::runner::RunSpec {
//! session: proto::SessionId::new("s1").unwrap(),
//! call: proto::CallId(1),
//! session: bxcore::SessionId::new("s1").unwrap(),
//! call: bxcore::CallId(1),
//! tool: brokerd::args::ToolName::Shell,
//! arguments: todo!(),
//! mounts: Vec::new(),
@@ -22,7 +22,7 @@
use crate::args::{ToolArgs, ToolName};
use crate::policy::{Decision, Label, SessionState};
use proto::{CallId, SessionId, ToolResponse};
use bxcore::{CallId, SessionId, ToolResponse};
/// A directory mounted for one call: a path and whether the runtime may write to it.
#[derive(Debug, Clone, PartialEq, Eq)]
@@ -111,7 +111,7 @@ pub const REFUSING: &str = "no tool runner is configured: brokerd.toml has no [r
/// Turn an allowed call into a `RunSpec`, run it, and answer. A `RunError`'s text reaches the
/// model unchanged, so a runtime may only put a fixed sentence in it.
pub fn run(decision: Decision, runtime: &dyn Runtime) -> proto::ToolResponse {
pub fn run(decision: Decision, runtime: &dyn Runtime) -> bxcore::ToolResponse {
let label = decision.label();
let args = decision.args();
let (mounts, egress) = match args {
+1 -1
View File
@@ -16,7 +16,7 @@ use crate::config::Config;
use crate::ledger::Ledger;
use crate::runner::Runtime;
use crate::state::StateStore;
use proto::{ChainFailure, Timestamp};
use bxcore::{ChainFailure, Timestamp};
/// A failure while `brokerd serve` is starting up.
#[derive(Debug)]
+1 -1
View File
@@ -5,7 +5,7 @@
//! The file's format is private (`StateFile`), so `SessionState` stays free of serde.
use crate::policy::{Label, SessionState};
use proto::{DataClass, SessionId};
use bxcore::{DataClass, SessionId};
use serde::{Deserialize, Serialize};
use std::fs;
use std::io::{self, Write};