6 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
jackos1998andClaude Opus 5.5 c516409f9a release: Bump to 0.2.0
CI / Check (pull_request) Successful in 5m4s
CI / Check (push) Successful in 4m49s
Recipients named by their comments in the rules, and the audit history
showing what approvers saw as they saw it. Both are compatible: old
audit records still read, and the builder's new field has a default.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-27 16:36:07 +00:00
jackos1998andClaude Opus 5.5 0b2cdf4155 web: Show history details as approvals show them
CI / Check (push) Successful in 4m44s
The audit log kept a request's detail as text, so the web app's history
showed it as one preformatted block. Keep the structure instead, and
render it with the same fields, tables and coloured diffs as a pending
request. Older records' text still reads, as a text section.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-27 16:34:58 +00:00
jackos1998andClaude Opus 5.5 9d08b5cf8f secret: Name recipients by their comments in the rules
CI / Check (pull_request) Successful in 4m44s
CI / Check (push) Successful in 4m49s
Approvals could only name recipients listed in the broker's config, so
host keys showed abbreviated. The builder already evaluates the main
branch's rules; take names from the SSH keys' comments there too
(`ssh-ed25519 AAAA… shill`), which age ignores. Every path's keys
count, so a key added to a secret is named as well.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-27 14:28:10 +00:00
16 changed files with 196 additions and 45 deletions

No files matched your search

Generated
+1 -1
View File
@@ -3859,7 +3859,7 @@ checksum = "0c790de23124f9ab44544d7ac05d60440adc586479ce501c1d6d7da3cd8c9cf5"
[[package]]
name = "slop-broker"
version = "0.1.1"
version = "0.2.2"
dependencies = [
"age",
"anyhow",
+1 -1
View File
@@ -1,6 +1,6 @@
[package]
name = "slop-broker"
version = "0.1.1"
version = "0.2.2"
edition = "2024"
description = "Approval broker that runs privileged operations for coding agents"
license = "MIT"
+6 -3
View File
@@ -328,8 +328,9 @@ operation, and nothing acts on the structure besides showing it.
Each request, decision, approver, lease use and result is an event with the request's ID. The
broker writes it to the journal as a line of text and to `audit.jsonl` in its state directory as a
line of JSON. `slop-approve log [-n 50] [--json]` shows the recent events through the approve
socket, with each request's full detail. Secret operations record the file and the blob ID of the
line of JSON, keeping what approvers were shown with its structure, so the web app's history shows
it as the request did. `slop-approve log [-n 50] [--json]` shows the recent events through the
approve socket, with each request's full detail. Secret operations record the file and the blob ID of the
ciphertext they were sent, never values.
## Operations
@@ -511,7 +512,9 @@ only people should be able to push to, and the approval shows what that branch s
in the rules, added or removed; or that the path isn't in the rules.
- Only the protected branch's Nix is evaluated, never a requester's commit, so this doesn't need
the builder approval.
- `secrets.names` labels well-known keys (such as people's); other keys are shown abbreviated.
- Keys are labelled by name from `secrets.names` (well-known keys, such as people's), then from
SSH keys' comments anywhere in the branch's rules (`ssh-ed25519 AAAA… shill`, which age
ignores). Other keys are shown abbreviated.
- **The broker's own key.** The broker always adds it to the recipients, and says so, so it can
change the file later.
- **Sensitive requests.** Requests that read a secret, change who can read one or name content as
+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
+53 -6
View File
@@ -10,6 +10,7 @@ use std::time::SystemTime;
use anyhow::Result;
use serde::{Deserialize, Serialize};
use crate::detail::{Detail, Section};
use crate::proto::ApprovedBy;
/// One line of the audit file.
@@ -40,14 +41,14 @@ pub enum Event {
requester: String,
op: String,
summary: String,
detail: String,
detail: Shown,
/// Agent-supplied.
label: Option<String>,
},
/// What approvers are shown once preparing a request (such as building a deploy) finished.
Prepared {
id: String,
detail: String,
detail: Shown,
},
Approved {
id: String,
@@ -100,6 +101,39 @@ impl Event {
}
}
/// What approvers were shown of a request. Records from before the broker kept the structure
/// have its text.
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
#[serde(untagged)]
pub enum Shown {
Detail(Detail),
Text(String),
}
impl Shown {
pub fn to_text(&self) -> String {
match self {
Shown::Detail(detail) => detail.to_text(),
Shown::Text(text) => text.clone(),
}
}
/// The structure, with old records' text as one text section.
pub fn to_detail(&self) -> Detail {
match self {
Shown::Detail(detail) => detail.clone(),
Shown::Text(text) if text.is_empty() => Detail::default(),
Shown::Text(text) => Detail { fields: vec![], sections: vec![Section::text("Text", text)] },
}
}
}
impl From<Detail> for Shown {
fn from(detail: Detail) -> Shown {
Shown::Detail(detail)
}
}
/// Request IDs are long; approvers type a prefix, and logs show the same.
pub fn short(id: &str) -> &str {
&id[..id.len().min(6)]
@@ -115,7 +149,7 @@ impl fmt::Display for Event {
}
Event::Request { id, requester, summary, detail, label, .. } => {
write!(f, "{} {requester} asks: {summary}", short(id))?;
if let Some(line) = detail.lines().next() {
if let Some(line) = detail.to_text().lines().next() {
write!(f, "; {line}")?;
}
if let Some(label) = label {
@@ -125,7 +159,7 @@ impl fmt::Display for Event {
}
Event::Prepared { id, detail } => {
write!(f, "{} ready for approval", short(id))?;
if let Some(line) = detail.lines().next() {
if let Some(line) = detail.to_text().lines().next() {
write!(f, "; {line}")?;
}
Ok(())
@@ -165,7 +199,7 @@ impl Record {
let time = self.time.replace('T', " ").trim_end_matches('Z').to_owned();
let mut text = format!("{time} {}\n", self.event);
if let Event::Request { detail, .. } | Event::Prepared { detail, .. } = &self.event {
for line in detail.lines().skip(1) {
for line in detail.to_text().lines().skip(1) {
text += &format!("{:21}{line}\n", "");
}
}
@@ -248,7 +282,7 @@ mod tests {
requester: "slop-cannon".into(),
op: "ssh".into(),
summary: "ssh river".into(),
detail: "Command: a\nmore".into(),
detail: Shown::Text("Command: a\nmore".into()),
label: Some("why".into()),
},
};
@@ -258,4 +292,17 @@ mod tests {
\x20 more\n"
);
}
#[test]
fn keeps_what_approvers_saw_and_reads_old_text() {
let detail = Detail::code("Command", "uptime");
let event = Event::Prepared { id: "a".into(), detail: detail.clone().into() };
let line = serde_json::to_string(&event).unwrap();
assert_eq!(serde_json::from_str::<Event>(&line).unwrap(), event);
let old: Event = serde_json::from_str(r#"{"event":"prepared","id":"a","detail":"Command: uptime"}"#).unwrap();
let Event::Prepared { detail: old, .. } = old else { panic!("{old:?}") };
assert_eq!(old, Shown::Text("Command: uptime".into()));
assert_eq!(old.to_text(), detail.to_text());
}
}
+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>."
+16 -1
View File
@@ -103,6 +103,9 @@ pub struct SecretContext {
pub paths: Vec<String>,
/// The path's recipients in the branch's rules file, or `None` if it has no entry.
pub recipients: Option<Vec<String>>,
/// Keys by name, from SSH keys' comments anywhere in the rules file.
#[serde(default)]
pub names: BTreeMap<String, String>,
}
/// A commit as approvers see it before anything is built. Everything but `on_branch` is
@@ -524,7 +527,19 @@ async fn secret_context(config: &BuilderConfig, request: &SecretRequest) -> Resu
let rules = rules(config, &commit, &request.rules).await?;
let recipients = rules.get(&*request.path).cloned();
Ok(SecretContext { branch: config.branch.clone(), commit, paths, recipients })
let names = commented(rules.values().flatten());
Ok(SecretContext { branch: config.branch.clone(), commit, paths, recipients, names })
}
/// SSH keys by their comments, like `ssh-ed25519 AAAA… shill`; age ignores the comment.
fn commented<'a>(keys: impl Iterator<Item = &'a String>) -> BTreeMap<String, String> {
keys.filter_map(|key| match key.split_whitespace().collect::<Vec<_>>().as_slice() {
[kind, key, comment @ ..] if kind.starts_with("ssh-") && !comment.is_empty() => {
Some((comment.join(" "), format!("{kind} {key}")))
}
_ => None,
})
.collect()
}
/// Paths in `git ls-tree -r -z` output whose object is `blob`.
+2 -2
View File
@@ -1,6 +1,6 @@
//! What approvers are shown of a request: fields, then tables, lists and text. Operations build
//! it; every surface renders it. The web app shows the structure, the others [`Detail::to_text`],
//! which is also what the audit log keeps and passkey confirmations fingerprint.
//! it; every surface renders it. The web app shows the structure (also in the audit history,
//! which keeps it), the others [`Detail::to_text`], which passkey confirmations fingerprint.
//!
//! The structure is the same for every operation, so surfaces don't need to know any of them.
//! All of it can carry agent-written text, which every surface makes printable when it shows it.
+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", "", ""]);
+22 -1
View File
@@ -152,7 +152,8 @@ fn describe(op: &SecretOp, context: &SecretContext, config: &SecretsConfig, own:
if let Some(requested) = op.recipients() {
let (recipients, added) = with_own(requested, own);
let rules = &config.rules;
let label = |r: &Recipient| label(r, &config.names);
let names = names(config, context);
let label = |r: &Recipient| label(r, &names);
let rows: Vec<Row> = match context.recipients.as_ref().map(|keys| expected(keys)) {
Some(expected) => {
@@ -216,6 +217,17 @@ fn same(a: &[Recipient], b: &[Recipient]) -> bool {
a.iter().all(|r| b.contains(r)) && b.iter().all(|r| a.contains(r))
}
/// The configured names, then the comments on the main branch's keys.
fn names(config: &SecretsConfig, context: &SecretContext) -> BTreeMap<String, Recipient> {
let mut names = config.names.clone();
for (name, key) in &context.names {
if let Ok(key) = Recipient::normalize(key) {
names.entry(name.clone()).or_insert(key);
}
}
names
}
fn label(recipient: &Recipient, names: &BTreeMap<String, Recipient>) -> String {
names.iter().find(|(_, r)| *r == recipient).map_or_else(|| recipient.abbreviated(), |(name, _)| name.clone())
}
@@ -412,6 +424,7 @@ mod tests {
commit: "0123456789abcdef0123456789abcdef01234567".parse().unwrap(),
paths: paths.iter().map(|p| p.to_string()).collect(),
recipients,
names: BTreeMap::new(),
}
}
@@ -528,6 +541,14 @@ mod tests {
let (detail, sensitive) = describe(&set(vec![dev.clone()]), &context(&[], None), &config, &own);
assert!(sensitive && detail.to_text().contains("isn't in secrets.nix"), "{}", detail.to_text());
// The main branch's key comments name recipients, though not over the configured names.
let mut named = context(&[], Some(vec![dev.to_string()]));
named.names = BTreeMap::from([("box".into(), host.to_string()), ("not-dev".into(), dev.to_string())]);
named.names.insert("bad".into(), "nonsense".into());
let (detail, _) = describe(&set(vec![host.clone(), dev.clone()]), &named, &config, &own);
let labels: Vec<_> = statuses(&detail).into_iter().map(|(label, ..)| label).collect();
assert_eq!(labels, ["box".to_owned(), "dev".to_owned(), own.abbreviated()]);
}
/// Each recipient row's key, status and tone.
+5 -3
View File
@@ -195,7 +195,7 @@ async fn process(broker: &Broker, requester: &str, request: Request, io: &mut Io
requester: requester.to_owned(),
op: parsed.op.to_string(),
summary: parsed.summary.clone(),
detail: parsed.detail.to_text(),
detail: parsed.detail.clone().into(),
label: label.clone(),
});
@@ -239,7 +239,7 @@ async fn process(broker: &Broker, requester: &str, request: Request, io: &mut Io
Ok(gate) => gate,
Err(error) => return failed(error),
};
log(Event::Prepared { id: id.clone(), detail: gate.detail.to_text() });
log(Event::Prepared { id: id.clone(), detail: gate.detail.clone().into() });
let (by, approver) = match authorize(broker, &id, requester, &gate, label.clone(), io).await {
Ok(Some(approval)) => approval,
@@ -263,7 +263,7 @@ async fn process(broker: &Broker, requester: &str, request: Request, io: &mut Io
return failed(error);
}
log(Event::Prepared { id: id.clone(), detail: parsed.detail.to_text() });
log(Event::Prepared { id: id.clone(), detail: parsed.detail.clone().into() });
}
let (approved_by, approver) = match authorize(broker, &id, requester, &parsed, label, io).await {
@@ -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),
+11 -8
View File
@@ -1,7 +1,8 @@
//! The audit log gathered by request: what was asked, who approved it and how it ended.
use std::collections::HashMap;
use crate::audit::{Event, Record};
use crate::audit::{Event, Record, Shown};
use crate::detail::Detail;
use crate::proto::ApprovedBy;
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
@@ -165,8 +166,8 @@ fn summarize(id: String, records: Vec<Record>) -> History {
history
}
/// One event in a request's timeline: what happened, and any longer text to show with it.
pub fn describe(event: &Event) -> (String, Option<String>) {
/// One event in a request's timeline: what happened, and what approvers were shown with it.
pub fn describe(event: &Event) -> (String, Option<Detail>) {
match event {
Event::Unknown { peer } => (format!("Refused a connection from {peer}"), None),
Event::Invalid { error, .. } => (format!("Invalid request: {error}"), None),
@@ -175,11 +176,9 @@ pub fn describe(event: &Event) -> (String, Option<String>) {
if let Some(label) = label {
text += &format!(" (label: {label})");
}
(text, Some(detail.clone()).filter(|d| !d.is_empty()))
}
Event::Prepared { detail, .. } => {
("Prepared for approval".into(), Some(detail.clone()).filter(|d| !d.is_empty()))
(text, shown(detail))
}
Event::Prepared { detail, .. } => ("Prepared for approval".into(), shown(detail)),
Event::Approved { by, approver, step, .. } => {
let by = match (by, approver) {
(ApprovedBy::Policy, _) => "policy".to_owned(),
@@ -204,6 +203,10 @@ pub fn describe(event: &Event) -> (String, Option<String>) {
}
}
fn shown(detail: &Shown) -> Option<Detail> {
Some(detail.to_detail()).filter(|d| !d.fields.is_empty() || !d.sections.is_empty())
}
#[cfg(test)]
mod tests {
use super::*;
@@ -218,7 +221,7 @@ mod tests {
requester: "slop-cannon".into(),
op: "ssh".into(),
summary: format!("ssh {id}"),
detail: "Command: uptime".into(),
detail: Detail::code("Command", "uptime").into(),
label: None,
}
}
+32 -1
View File
@@ -67,7 +67,7 @@ fn section_titles(detail: &Detail) -> String {
detail.sections.iter().map(Section::title).collect::<Vec<_>>().join(", ")
}
fn describe(record: &Record) -> (String, Option<String>) {
fn describe(record: &Record) -> (String, Option<Detail>) {
history::describe(&record.event)
}
@@ -270,4 +270,35 @@ mod tests {
assert!(html.contains("needs-passkey"));
assert!(html.contains("Needs passkey"));
}
#[test]
fn history_shows_what_approvers_saw() {
use crate::audit::{Event, Record, Shown};
let mut detail = Detail::code("Command", "uptime");
detail.section(Section::diff("Diff", "@@ -1 +1 @@\n-b\n+a"));
let records = vec![
Record {
time: "2026-11-27T10:00:00Z".into(),
event: Event::Request {
id: "abc".into(),
requester: "slop-cannon".into(),
op: "ssh".into(),
summary: "ssh river".into(),
detail: detail.into(),
label: None,
},
},
Record {
time: "2026-11-27T10:00:01Z".into(),
event: Event::Prepared { id: "abc".into(), detail: Shown::Text("Old: text".into()) },
},
];
let (histories, _) = super::history::gather(records);
let html = request("broker", "token", "abc", None, Some(&histories[0]), 0).0;
assert!(html.contains("<dt>Command</dt><dd class=\"neutral\"><code>uptime</code></dd>"), "{html}");
assert!(html.contains("<span class=\"diff-add\">+a</span>"), "{html}");
assert!(html.contains("Details (Text)") && html.contains("<pre>Old: text</pre>"), "{html}");
}
}
+1 -1
View File
@@ -80,7 +80,7 @@
{% for record in records %}
{% let (text, detail) = self::describe(record) %}
<li>{% call time(record.time) %}{% endcall %} <span>{{ text }}</span>
{%- if let Some(detail) = detail %}<details><summary>Details</summary><pre>{{ detail }}</pre></details>{% endif %}</li>
{%- if let Some(detail) = detail %}{% call detail(detail, false) %}{% endcall %}{% endif %}</li>
{% endfor %}
</ol>
{% endmacro %}
+7 -1
View File
@@ -237,7 +237,7 @@ async fn approvers_see_the_whole_command_and_stdin_that_run() {
// So is the audit log.
let records = broker.audit.tail(10).unwrap();
let slop_broker::audit::Event::Request { detail: logged, .. } = &records[0].event else { panic!("{records:?}") };
assert_eq!(*logged, detail);
assert_eq!(logged.to_text(), detail);
// Multi-line commands are shown as text rather than a one-line field.
let mut client = Client::start(&broker, ssh(&["echo one\necho two"])).await;
@@ -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;
+7 -2
View File
@@ -122,13 +122,16 @@ fn secrets_are_looked_up_on_the_branch() {
git(&work, &["init", "--quiet", "--initial-branch=master"]);
std::fs::write(work.join("secrets/a.age"), "age-encryption.org/v1\nreal\n").unwrap();
std::fs::write(work.join("secrets/copy.age"), "age-encryption.org/v1\nreal\n").unwrap();
std::fs::write(work.join("secrets.nix"), "{ \"secrets/a.age\".publicKeys = [ \"age1dev\" ]; }\n").unwrap();
let rules = |keys: &str| {
format!("{{ \"secrets/a.age\".publicKeys = [ \"age1dev\" ]; \"secrets/b.age\".publicKeys = [ {keys} ]; }}\n")
};
std::fs::write(work.join("secrets.nix"), rules("\"ssh-ed25519 AAAA box\"")).unwrap();
git(&work, &["add", "."]);
git(&work, &["commit", "--quiet", "-m", "Secrets"]);
// An agent's branch can't change what the main branch says.
git(&work, &["checkout", "--quiet", "-b", "agent"]);
std::fs::write(work.join("secrets.nix"), "{ \"secrets/a.age\".publicKeys = [ \"age1agent\" ]; }\n").unwrap();
std::fs::write(work.join("secrets.nix"), rules("\"ssh-ed25519 AAAA box\" \"ssh-ed25519 BBBB box\"")).unwrap();
git(&work, &["commit", "--quiet", "-am", "Change the rules"]);
let state = directory.path().join("state");
@@ -154,6 +157,8 @@ fn secrets_are_looked_up_on_the_branch() {
let context: SecretContext = ask(&config, &BuilderRequest::Secret(request.clone()));
assert_eq!(context.paths, ["secrets/a.age", "secrets/copy.age"]);
assert_eq!(context.recipients, Some(vec!["age1dev".to_owned()]));
// Names come from comments on every path's keys.
assert_eq!(context.names, std::collections::BTreeMap::from([("box".to_owned(), "ssh-ed25519 AAAA".to_owned())]));
assert_eq!(&*context.commit, git(&work, &["rev-parse", "master"]));
let unknown = SecretRequest { blob: None, path: "secrets/new.age".parse().unwrap(), ..request };