diff --git a/Cargo.lock b/Cargo.lock index 0bb5c56..20c1c01 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3859,7 +3859,7 @@ checksum = "0c790de23124f9ab44544d7ac05d60440adc586479ce501c1d6d7da3cd8c9cf5" [[package]] name = "slop-broker" -version = "0.2.1" +version = "0.2.2" dependencies = [ "age", "anyhow", diff --git a/Cargo.toml b/Cargo.toml index 3768671..21c43bb 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "slop-broker" -version = "0.2.1" +version = "0.2.2" edition = "2024" description = "Approval broker that runs privileged operations for coding agents" license = "MIT" diff --git a/slop-tools.md b/slop-tools.md index e1541cd..df05d2a 100644 --- a/slop-tools.md +++ b/slop-tools.md @@ -6,9 +6,11 @@ applies a policy, and asks a human to approve most requests. ## How requests behave -- A request that needs approval blocks for up to **five minutes** while a human answers. Run - `slop` with a tool timeout of at least six minutes, or in the background. Don't retry a request - that is waiting, denied or expired in a loop; tell the user instead. +- A request that needs approval blocks while a human answers, for as long as the broker allows: + five minutes by default, but often much longer. `slop` prints how long when it starts waiting + (`approvers have 45m to answer`), and a deploy or build waits that long at each approval. Run + `slop` in the background, or with a tool timeout longer than that. Don't retry a request that + is waiting, denied or expired in a loop; tell the user instead. - Exit status **125** means the broker did not run the operation: it was denied, expired, invalid or failed. Any other status is the operation's own. - Approvers see who sent a request and can see `--label` (or `SLOP_LABEL`). Use it to say briefly diff --git a/src/bin/slop.rs b/src/bin/slop.rs index 358c67c..8c9c5db 100644 --- a/src/bin/slop.rs +++ b/src/bin/slop.rs @@ -28,7 +28,8 @@ const GUIDE: &str = include_str!("../../slop-tools.md"); #[derive(Parser)] #[command( about = "Ask the slop broker to run privileged operations", - after_help = "Requests wait up to five minutes for an approver; don't retry them in a loop.\n\ + after_help = "Requests wait for an approver for as long as the broker allows (it says how long);\n\ + don't retry them in a loop.\n\ Exit status 125 means the broker did not run the operation.\n\ SLOP_BROKER, or broker in ~/.config/slop/config.toml, selects the broker:\n\ vsock::, unix: or ssh:." diff --git a/src/server.rs b/src/server.rs index 5a65672..96df041 100644 --- a/src/server.rs +++ b/src/server.rs @@ -387,6 +387,8 @@ async fn authorize( .submit(id, pending, settings.max_pending) .map_err(|e| ServerMessage::Error(e.to_string()))?; io.out.send(ServerMessage::Pending { id: id.to_owned(), summary: parsed.summary.clone() }).await; + let window = humantime::format_duration(broker.queue.timeout()); + io.out.send(ServerMessage::Info(format!("approvers have {window} to answer"))).await; let outcome = tokio::select! { outcome = reply => outcome.unwrap_or(Outcome::Expired), diff --git a/tests/broker.rs b/tests/broker.rs index 67dc51f..9e24bc6 100644 --- a/tests/broker.rs +++ b/tests/broker.rs @@ -264,6 +264,9 @@ async fn pending_id(client: &mut Client) -> String { match client.next(&mut String::new()).await { ServerMessage::Pending { id, summary } => { assert_eq!(summary, "ssh river"); + // Then how long approvers have, so agents know how long to wait. + let window = client.next(&mut String::new()).await; + assert!(matches!(&window, ServerMessage::Info(m) if m.starts_with("approvers have ")), "{window:?}"); id } other => panic!("expected pending, got {other:?}"), @@ -425,6 +428,9 @@ async fn remote_requesters_and_approvers_use_one_socket() { let request = ClientMessage::Request(Request { version: PROTOCOL_VERSION, label: None, operation: ssh(&["true"]) }); send(&mut requester, &request).await.unwrap(); let Some(ServerMessage::Pending { id, .. }) = receive(&mut requester).await.unwrap() else { panic!("not pending") }; + let Some(ServerMessage::Info(_)) = receive::<_, ServerMessage>(&mut requester).await.unwrap() else { + panic!("no window") + }; // One approver connection carries several requests. let mut approver = remote(&path, Role::Approver, "laptop").await;