From 17c4b3c220add14c43a84a12057d7845a2b57e17 Mon Sep 17 00:00:00 2001 From: PerishCode Date: Tue, 14 Jul 2026 12:47:44 +0800 Subject: [PATCH] vocabulary: enforce the canon on the runtime Co-Authored-By: Claude Fable 5 --- crates/cli/src/update.rs | 4 ++-- crates/cli/tests/inspect.rs | 4 ++-- crates/core/src/inspect.rs | 6 +++--- crates/core/src/runtime/process.rs | 6 +++--- crates/core/src/runtime/tcp.rs | 4 ++-- crates/core/src/socket.rs | 14 +++++++------- 6 files changed, 19 insertions(+), 19 deletions(-) diff --git a/crates/cli/src/update.rs b/crates/cli/src/update.rs index c32a38e..d420117 100644 --- a/crates/cli/src/update.rs +++ b/crates/cli/src/update.rs @@ -55,13 +55,13 @@ pub fn run(build: &str) -> Result<(), String> { let tmpdir = scratch().map_err(|err| format!("failed to create tempdir: {err}"))?; let script = tmpdir.join(name); - let dl = Command::new("curl") + let fetched = Command::new("curl") .args(["-fsSL", "--max-time", &INSTALL.to_string(), "-o"]) .arg(&script) .arg(&url) .status() .map_err(|err| format!("failed to invoke curl: {err}"))?; - if !dl.success() { + if !fetched.success() { let _ = fs::remove_dir_all(&tmpdir); return Err(format!("failed to download manager from {url}")); } diff --git a/crates/cli/tests/inspect.rs b/crates/cli/tests/inspect.rs index 851c699..79d1dca 100644 --- a/crates/cli/tests/inspect.rs +++ b/crates/cli/tests/inspect.rs @@ -22,7 +22,7 @@ fn scratch(name: &str) -> std::path::PathBuf { #[test] fn omitted() { let listener = TcpListener::bind("127.0.0.1:0").expect("tcp listener should bind"); - let address = listener.local_addr().expect("listener address"); + let addr = listener.local_addr().expect("listener address"); let (tx, rx) = mpsc::channel(); let handle = std::thread::spawn(move || { @@ -63,7 +63,7 @@ namespace = "inspect-payload" name = "server" command = "sh" args = ["-c", "sleep 1"] -inspect_socket = "tcp://{address}" +inspect_socket = "tcp://{addr}" "# ), ) diff --git a/crates/core/src/inspect.rs b/crates/core/src/inspect.rs index d6ae78b..a4f75be 100644 --- a/crates/core/src/inspect.rs +++ b/crates/core/src/inspect.rs @@ -35,7 +35,7 @@ pub fn send( let raw = match endpoint { socket::Endpoint::Unix(path) => unix(path, &line, timeout)?, - socket::Endpoint::Tcp(address) => tcp(address, &line, timeout)?, + socket::Endpoint::Tcp(addr) => tcp(addr, &line, timeout)?, }; parse(&raw, &id) } @@ -118,8 +118,8 @@ fn unix( Err("unix inspect transport is not available on this platform".to_string()) } -fn tcp(address: &str, line: &str, timeout: Option) -> Result { - let mut stream = TcpStream::connect(address).map_err(|err| err.to_string())?; +fn tcp(addr: &str, line: &str, timeout: Option) -> Result { + let mut stream = TcpStream::connect(addr).map_err(|err| err.to_string())?; if let Some(timeout) = timeout { let _ = stream.set_read_timeout(Some(timeout)); let _ = stream.set_write_timeout(Some(timeout)); diff --git a/crates/core/src/runtime/process.rs b/crates/core/src/runtime/process.rs index cdf8427..e5fc566 100644 --- a/crates/core/src/runtime/process.rs +++ b/crates/core/src/runtime/process.rs @@ -24,7 +24,7 @@ impl Stamped { #[doc(hidden)] pub fn filter(rows: Vec<(u32, String)>, app: Option<&str>, namespace: &str) -> Vec { - sift(rows, |args| { + filter(rows, |args| { stamp::find(args).is_some_and(|stamp| { app.is_none_or(|name| stamp.app == name) && stamp.namespace == namespace }) @@ -42,7 +42,7 @@ impl Broker { #[doc(hidden)] pub fn filter(rows: Vec<(u32, String)>, project: &str, namespace: &str) -> Vec { - sift(rows, |args| { + filter(rows, |args| { broker::find(args).is_some_and(|identity| { identity.project == project && identity.namespace == namespace }) @@ -53,7 +53,7 @@ impl Broker { } } -fn sift(rows: Vec<(u32, String)>, predicate: F) -> Vec<(u32, String)> +fn filter(rows: Vec<(u32, String)>, predicate: F) -> Vec<(u32, String)> where F: Fn(&[String]) -> bool, { diff --git a/crates/core/src/runtime/tcp.rs b/crates/core/src/runtime/tcp.rs index 630744d..9314b95 100644 --- a/crates/core/src/runtime/tcp.rs +++ b/crates/core/src/runtime/tcp.rs @@ -85,13 +85,13 @@ pub fn table( if columns[3] != "0A" || !inodes.contains(columns[9]) { continue; } - addrs.push(address(columns[1])?); + addrs.push(addr(columns[1])?); } Ok(addrs) } #[cfg(target_os = "linux")] -fn address(value: &str) -> Result { +fn addr(value: &str) -> Result { use std::net::{IpAddr, Ipv4Addr, Ipv6Addr}; let (addr, port) = value diff --git a/crates/core/src/socket.rs b/crates/core/src/socket.rs index a4282b5..dc62ae0 100644 --- a/crates/core/src/socket.rs +++ b/crates/core/src/socket.rs @@ -33,9 +33,9 @@ impl Endpoint { return Ok(Self::Unix(PathBuf::from(path))); } - if let Some(address) = value.strip_prefix(TCP) { - validate(address)?; - return Ok(Self::Tcp(address.to_string())); + if let Some(addr) = value.strip_prefix(TCP) { + validate(addr)?; + return Ok(Self::Tcp(addr.to_string())); } Err(Error::new( @@ -48,7 +48,7 @@ impl std::fmt::Display for Endpoint { fn fmt(&self, formatter: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { match self { Self::Unix(path) => write!(formatter, "unix://{}", path.display()), - Self::Tcp(address) => write!(formatter, "{TCP}{address}"), + Self::Tcp(addr) => write!(formatter, "{TCP}{addr}"), } } } @@ -69,11 +69,11 @@ impl std::fmt::Display for Error { impl std::error::Error for Error {} -fn validate(address: &str) -> Result<(), Error> { - if address.trim().is_empty() { +fn validate(addr: &str) -> Result<(), Error> { + if addr.trim().is_empty() { return Err(Error::new("tcp socket endpoint must include host:port")); } - if !address.contains(':') { + if !addr.contains(':') { return Err(Error::new("tcp socket endpoint must include a port")); } Ok(())