3 Commits
Author SHA1 Message Date
jackos1998andClaude Opus 5.5 ef53a39597 slop: Say how long approvers have to answer
CI / Check (pull_request) Successful in 4m58s
CI / Check (push) Successful in 4m36s
The agent guide said requests wait up to five minutes, the default,
but a broker can allow much longer, so agents gave up on requests that
were still waiting. The broker now says how long approvers have when a
request starts waiting, and the guide tells agents to wait that long.

Bumps to 0.2.2.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-27 19:18:39 +00:00
jackos1998andClaude Opus 5.5 fed05e18d7 release: Bump to 0.2.1
CI / Check (pull_request) Successful in 4m44s
CI / Check (push) Successful in 4m51s
Reads unsigned size changes from newer Nix in deploy approvals.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-27 18:38:31 +00:00
jackos1998andClaude Opus 5.5 3415f9bb38 deploy: Read unsigned size changes
CI / Check (pull_request) Successful in 5m8s
CI / Check (push) Successful in 4m45s
Newer Nix prints a closure growing as a bare size (`129.0 KiB`) without
a sign, and without colour when piped, so the size ended up in the
version column. Recognise a trailing size by its unit and sign it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-27 18:30:59 +00:00
7 changed files with 42 additions and 16 deletions

No files matched your search

Generated
+1 -1
View File
@@ -3859,7 +3859,7 @@ checksum = "0c790de23124f9ab44544d7ac05d60440adc586479ce501c1d6d7da3cd8c9cf5"
[[package]]
name = "slop-broker"
version = "0.2.0"
version = "0.2.2"
dependencies = [
"age",
"anyhow",
+1 -1
View File
@@ -1,6 +1,6 @@
[package]
name = "slop-broker"
version = "0.2.0"
version = "0.2.2"
edition = "2024"
description = "Approval broker that runs privileged operations for coding agents"
license = "MIT"
+5 -3
View File
@@ -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
+2 -1
View File
@@ -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:<cid>:<port>, unix:<path> or ssh:<destination>."
+25 -10
View File
@@ -415,26 +415,35 @@ impl Changes {
/// A line of `nix store diff-closures` (`name: 1.0 → 1.1, +3.4 KiB`) as package, version change
/// and size change.
fn package_cells(line: &str) -> [&str; 3] {
let Some((name, rest)) = line.split_once(": ") else { return [line, "", ""] };
fn package_cells(line: &str) -> [String; 3] {
let Some((name, rest)) = line.split_once(": ") else { return [line.into(), String::new(), String::new()] };
if let Some((version, size)) = rest.rsplit_once(", ")
&& let Some(size) = package_size(size)
{
return [name, version, size];
return [name.into(), version.into(), size];
}
if let Some(size) = package_size(rest) {
return [name, "unchanged", size];
return [name.into(), "unchanged".into(), size];
}
[name, rest, ""]
[name.into(), rest.into(), String::new()]
}
fn package_size(value: &str) -> Option<&str> {
// Some Nix versions indicate the direction with colour even on piped output.
value
/// A size change, signed. Nix versions differ: some sign increases, some only colour them (even
/// on piped output), and some do neither; decreases always have a sign.
fn package_size(value: &str) -> Option<String> {
let plain = value
.strip_prefix("\x1b[31;1m")
.or_else(|| value.strip_prefix("\x1b[32;1m"))
.and_then(|size| size.strip_suffix("\x1b[0m"))
.or_else(|| value.starts_with(['+', '-']).then_some(value))
.unwrap_or(value);
let (sign, size) = match plain.strip_prefix(['+', '-']) {
Some(size) => (&plain[..1], size),
None => ("+", plain),
};
let (number, unit) = size.split_once(' ')?;
let sized = number.parse::<f64>().is_ok() && ["B", "KiB", "MiB", "GiB", "TiB"].contains(&unit);
sized.then(|| format!("{sign}{size}"))
}
#[cfg(test)]
@@ -445,7 +454,13 @@ mod tests {
fn splits_package_lines() {
assert_eq!(package_cells("a: 1.0 → 1.1, +3.4 KiB"), ["a", "1.0 → 1.1", "+3.4 KiB"]);
assert_eq!(package_cells("b: -12.0 KiB"), ["b", "unchanged", "-12.0 KiB"]);
assert_eq!(package_cells("b: \x1b[31;1m12.0 KiB\x1b[0m"), ["b", "unchanged", "12.0 KiB"]);
assert_eq!(package_cells("b: \x1b[31;1m12.0 KiB\x1b[0m"), ["b", "unchanged", "+12.0 KiB"]);
assert_eq!(package_cells("b: 12.0 KiB"), ["b", "unchanged", "+12.0 KiB"]);
assert_eq!(
package_cells("slop: 0.1.0, 0.1.0-fish → 0.2.0, 0.2.0-fish, 129.0 KiB"),
["slop", "0.1.0, 0.1.0-fish → 0.2.0, 0.2.0-fish", "+129.0 KiB"]
);
assert_eq!(package_cells("c: 1.0, 2 KiB → 1.1"), ["c", "1.0, 2 KiB → 1.1", ""]);
assert_eq!(package_cells("b: 1.0 → 1.1, \x1b[32;1m-12.0 KiB\x1b[0m"), ["b", "1.0 → 1.1", "-12.0 KiB"]);
assert_eq!(package_cells("c: ∅ → 2.0"), ["c", "∅ → 2.0", ""]);
assert_eq!(package_cells("odd"), ["odd", "", ""]);
+2
View File
@@ -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),
+6
View File
@@ -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;