summaryrefslogtreecommitdiffstats
path: root/src/sandbox
diff options
context:
space:
mode:
authordev <dev@localhost>2026-11-20 18:04:59 +0000
committerdev <dev@localhost>2026-11-20 18:04:59 +0000
commita97e5dc40069b0dc13c28fa9ab3202c8e5012038 (patch)
treed218f1d5463bca338cdee2d41a41de0f3cbd9c72 /src/sandbox
parent466f6f7e223f56670feabb0737cf97f708aa45f2 (diff)
downloadaur-build-a97e5dc40069b0dc13c28fa9ab3202c8e5012038.tar.gz
aur-build-a97e5dc40069b0dc13c28fa9ab3202c8e5012038.zip
sandbox, pipeline: close what only your own module was ever meant to name
Sandbox exported 35 items and 8 of them were named by nobody at all — not by a caller, not by a test. `Frame`, `read_frame`, `write_frame`, `hex_bytes`, `unhex` and `MAX_FRAME_BYTES` are the wire protocol, and the protocol is sandbox's: the agent, the remote client and the loopback all speak it from inside. Exporting it advertised a second way in that nothing used and everything would have had to keep compatible. `LoopbackSandbox` and `RemoteSandbox` are the same story — handles handed out by a constructor nobody calls by name. Pipeline exported its step machine. `run_step`, `log_line`, `sweep_render_dirs`, `from_candidate`, `from_release` and the four types they pass around (`Collect`, `CollectedPkg`, `SourceIdentity`, `StepResult`) were all internal plumbing reachable from `main`, which only ever wanted `run`, `Outcome`, `enqueue_for_candidate`, `enqueue_manual_rebuild`, `publish::reconcile` and `dispatch::Pool::spawn`. sandbox.pub 35->27, pipeline.pub 30->21, and both modules now have zero items named by nobody: what is left public is public because a test names it, which is the allowlist the budget records rather than a hole in it. Clippy caught what the tests did not: `Ctx::src` was a `pub` field of the newly private `SourceIdentity`, a public face on a private type. The field narrowed with the type. Re-widening `SourceIdentity` to silence it would have undone the point. The diff is visibility keywords only — no step id literal, no frame variant, no wire byte changed. 277 passed / 0 failed across 36 binaries, including remote_agent, failure_modes and the kata tier; clippy -D warnings clean.
Diffstat (limited to 'src/sandbox')
-rw-r--r--src/sandbox/loopback.rs2
-rw-r--r--src/sandbox/remote.rs2
-rw-r--r--src/sandbox/wire.rs12
3 files changed, 8 insertions, 8 deletions
diff --git a/src/sandbox/loopback.rs b/src/sandbox/loopback.rs
index 1173562..7847fdc 100644
--- a/src/sandbox/loopback.rs
+++ b/src/sandbox/loopback.rs
@@ -37,7 +37,7 @@ impl SandboxBackend for LoopbackBackend {
}
}
-pub struct LoopbackSandbox {
+pub(crate) struct LoopbackSandbox {
id: String,
blobs: PathBuf,
cfg: Config,
diff --git a/src/sandbox/remote.rs b/src/sandbox/remote.rs
index 51ec047..2f5a1b7 100644
--- a/src/sandbox/remote.rs
+++ b/src/sandbox/remote.rs
@@ -71,7 +71,7 @@ impl SandboxBackend for RemoteBackend {
}
}
-pub struct RemoteSandbox {
+pub(crate) struct RemoteSandbox {
cfg: Config,
id: String,
ttl: std::time::Duration,
diff --git a/src/sandbox/wire.rs b/src/sandbox/wire.rs
index a0d06ca..ae89d6d 100644
--- a/src/sandbox/wire.rs
+++ b/src/sandbox/wire.rs
@@ -2,11 +2,11 @@ use std::io::{self, BufRead, Write};
use serde::{Deserialize, Serialize};
-pub const MAX_FRAME_BYTES: u32 = 2 * 1024 * 1024 * 1024;
+pub(crate) const MAX_FRAME_BYTES: u32 = 2 * 1024 * 1024 * 1024;
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(tag = "t", rename_all = "snake_case")]
-pub enum Frame {
+pub(crate) enum Frame {
/// agent → hub, first frame on every connection: the outbound rendezvous.
Hello { token: String, agent_id: String, profiles: Vec<String> },
/// hub → agent: rendezvous accepted; `ttl_secs` arms the agent's watchdog.
@@ -35,7 +35,7 @@ pub enum Frame {
Destroy {},
}
-pub fn write_frame(w: &mut impl Write, f: &Frame) -> io::Result<()> {
+pub(crate) fn write_frame(w: &mut impl Write, f: &Frame) -> io::Result<()> {
let body = serde_json::to_vec(f)
.map_err(|e| io::Error::new(io::ErrorKind::InvalidData, e))?;
if body.len() as u64 > MAX_FRAME_BYTES as u64 {
@@ -46,7 +46,7 @@ pub fn write_frame(w: &mut impl Write, f: &Frame) -> io::Result<()> {
w.flush()
}
-pub fn read_frame(r: &mut impl BufRead) -> io::Result<Option<Frame>> {
+pub(crate) fn read_frame(r: &mut impl BufRead) -> io::Result<Option<Frame>> {
let mut len = [0u8; 4];
match r.read_exact(&mut len) {
Ok(()) => {}
@@ -64,11 +64,11 @@ pub fn read_frame(r: &mut impl BufRead) -> io::Result<Option<Frame>> {
Ok(Some(f))
}
-pub fn hex_bytes(b: &[u8]) -> String {
+pub(crate) fn hex_bytes(b: &[u8]) -> String {
hex::encode(b)
}
-pub fn unhex(s: &str) -> io::Result<Vec<u8>> {
+pub(crate) fn unhex(s: &str) -> io::Result<Vec<u8>> {
hex::decode(s).map_err(|e| io::Error::new(io::ErrorKind::InvalidData, e))
}