feat(shipote): throughput + stats persistente + auth peer (fase P)

- FlowMeter (atomic u64 + rolling window 32 samples) en cada FlowChannel.
  flow_throughput() → (socket, bytes_total, bytes_per_sec). CLI:
  shipote flow throughput. Idle threshold 5s = rate 0.0.
- Snapshot v4 con stats_history persistente por workspace (cap 16).
  PersistedStats separado para evitar Instant. Restore hidrata el VecDeque
  con source="persisted".
- Auth SO_PEERCRED: daemon rechaza peers con uid distinto al propio.
  SHIPOTE_TRUST_ANYONE=1 = escape hatch documentado.

84 tests pasan (ente-incarnate 16, nouser-core 27, shipote-card 8,
shipote-core 25, shipote-discern 5, yahweh-provider-fs 3).

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
sergio
2026-05-11 13:58:41 +00:00
parent 1cce50b290
commit 3486949d24
8 changed files with 273 additions and 12 deletions
+22
View File
@@ -87,6 +87,8 @@ enum Cmd {
enum FlowCmd {
/// Listar pipelines activos con sus sockets de flow.
List,
/// Throughput por flow socket (bytes_total + bytes/s).
Throughput,
/// Cerrar el data plane de un pipeline (drop de todos sus sockets).
Drop { pipeline: String },
/// Suscribirse a un flow socket y volcar bytes a stdout.
@@ -557,6 +559,26 @@ async fn main() -> Result<()> {
}
}
Cmd::Flow(FlowCmd::Throughput) => {
let resp = round_trip(&mut stream, Request::FlowThroughput).await?;
match resp {
Response::FlowThroughput { items } => {
if items.is_empty() {
println!("(no active flows)");
}
for it in items {
let name = it.socket.file_name()
.map(|n| n.to_string_lossy().to_string())
.unwrap_or_else(|| it.socket.display().to_string());
let kib = it.bytes_total as f64 / 1024.0;
let kbs = it.bytes_per_sec / 1024.0;
println!("{:<60} {:>8.1} KiB total {:>8.2} KiB/s", name, kib, kbs);
}
}
other => print_unexpected(&other),
}
}
Cmd::Flow(FlowCmd::Drop { pipeline }) => {
let pid = Ulid::from_string(&pipeline).map_err(|e| anyhow!("invalid pipeline id: {e}"))?;
let resp = round_trip(&mut stream, Request::FlowDrop { pipeline: pid }).await?;