git clone https://garage44.eu/jeroen/midas.gitcartopolis-agent · 2026-11-28T12:18:38Z
feat(node): a stopped command is the agent's to solve, and wakes it The person's answer to the first landing card: the agent must then solve the problem by itself, without them stepping in. "Run it again with what it waited for fixed" left that open. - The stop's words (stall::stopped_words) name what was still in the command's process group — s857's two QEMUs would have been the clue — and tell the agent to find the cause with ps/lsof, fix it and run it again, without asking the person. - The hub turns the node's `stalled` stop event (taken only from that node's own address) into a note to the session, of a kind that wakes an idle one: the ssh ending wakes an agent that ran it in the background, not one whose ssh was already gone. It is the only note of midas's own besides a decision's answer that wakes (collab::wakes). - The session-start text says the same. Seen on deck-1: s857's shape under MIDAS_STALL=60s is stopped after 61 s with the group (bash, grep, head, the orphaned sleep 900) and the instruction on stderr; 338 tests pass.
DESIGN.md | 7 +++++--
src/collab.rs | 8 +++++---
src/hub.rs | 10 ++++++++++
src/node.rs | 5 +----
src/session-start.md | 2 ++
src/stall.rs | 37 +++++++++++++++++++++++++++++++++++++
6 files changed, 60 insertions(+), 9 deletions(-)
diff --git a/DESIGN.md b/DESIGN.md
index 65d8cd9..3dc8def 100644
--- a/DESIGN.md
+++ b/DESIGN.md
@@ -91,8 +91,11 @@ midas release # or the session-end hook does it
group is stopped, unless another command on the node is moving; and once
the command ends, what it left holding its output gets two seconds, not
the session. A background command ending is what wakes an idle agent, so
- stopping it is also how the session hears. Terminal sessions, file
- transfers and a bot's relay are not watched.
+ stopping it is also how the session hears; the hub's note from the stop
+ wakes it too, the one note of midas's own that does besides a decision. Both
+ name what was still in the group and leave finding the cause to the agent,
+ not the person. Terminal sessions, file transfers and a bot's relay are not
+ watched.
- **Builds do not run where agents are**: `cargo` there is midas and names the
`ssh` to use instead (`MIDAS_LOCAL_BUILD=1` for a one-off); commands that only
read the manifest (fmt, metadata, tree…) pass through.
diff --git a/src/collab.rs b/src/collab.rs
index e45983f..509d28b 100644
--- a/src/collab.rs
+++ b/src/collab.rs
@@ -188,9 +188,11 @@ fn say_about(from: &str, to: &str, text: &str, kind: &str, about: Value) -> Resu
/// (a deploy that is live, an overlap, a node back in the pool) waits for the
/// next prompt or tool call: woken by it, an agent answered midas in the
/// person's conversation, with nobody there to talk to (session-s497,
-/// 2026-10-29).
-fn wakes(from: &str, kind: &str) -> bool {
- from != "hub" || kind == "decision"
+/// 2026-10-29). Its own command stopped for doing nothing (stall.rs) is not
+/// news but work left to it: s857 sat idle 19 hours on one, until the person
+/// asked.
+pub(crate) fn wakes(from: &str, kind: &str) -> bool {
+ from != "hub" || matches!(kind, "decision" | "stalled")
}
/// A note into `to`'s mailbox, waking nobody: its id.
diff --git a/src/hub.rs b/src/hub.rs
index 6063c14..6700643 100644
--- a/src/hub.rs
+++ b/src/hub.rs
@@ -678,6 +678,16 @@ fn api(method: &str, path: &str, query: &str, body: &Value, who: &Who, peer: &st
}
ev["via_hub_from"] = json!(peer);
events::record(&ev);
+ // A command the node stopped for doing nothing (stall.rs): its
+ // session is told by a note too, which wakes it when idle —
+ // the ssh ending tells an agent that ran it in the background,
+ // but not one whose ssh was gone already. Only from the node.
+ let node = ev["node"].as_str().unwrap_or("");
+ if ev["kind"] == "stalled" && ev["stage"] == "stop" && !node.is_empty() && from_node(node, peer).is_none() {
+ if let Some(actor) = ev["actor"].as_str().filter(|a| !a.is_empty()) {
+ let _ = crate::collab::say("hub", actor, &crate::stall::note_stop(&ev), "stalled");
+ }
+ }
}
return Ok((204, Value::Null));
}
diff --git a/src/node.rs b/src/node.rs
index 19a9813..ec303e5 100644
--- a/src/node.rs
+++ b/src/node.rs
@@ -642,10 +642,7 @@ pub fn session() -> Result<i32> {
emit(&cfg, "stalled", json!({"stage": "warn", "actor": actor, "command": command_for_log, "quiet_s": q.as_secs()}));
}
Said::Stopping(q, left) => {
- eprintln!("midas: stopped `{what}` on {}: nothing printed and no CPU used for {} — \
- it waits for something that will not come (a process it started holding a pipe \
- open, a lock, a prompt). Run it again with what it waited for fixed.",
- cfg.node, mins(q));
+ eprintln!("{}", crate::stall::stopped_words(&what, &cfg.node, &mins(q), &left));
emit(&cfg, "stalled", json!({"stage": "stop", "actor": actor, "command": command_for_log,
"quiet_s": q.as_secs(), "group": left}));
}
diff --git a/src/session-start.md b/src/session-start.md
index bce3d8d..09329b4 100644
--- a/src/session-start.md
+++ b/src/session-start.md
@@ -29,6 +29,8 @@ the session-end hook gives it back too. `midas status` shows who holds what,
CPU for 30 minutes is stopped, which ends your ssh and says why
(`MIDAS_STALL=off` or `=2h` as its first word for one meant to wait), and a
process left behind holding a command's output no longer keeps its ssh open.
+A stopped command is yours to solve at once, without asking the person: find
+what it waited for, fix that, run it again.
**Subagents.** A subagent in this worktree shares its node: it can `ssh` there
too, but every ssh first re-syncs the node, so two agents running commands
diff --git a/src/stall.rs b/src/stall.rs
index acc636e..87ba923 100644
--- a/src/stall.rs
+++ b/src/stall.rs
@@ -87,6 +87,30 @@ pub fn limits_for(command: &str) -> Option<Limits> {
}
}
+/// What a stop says to the agent, on the command's stderr and in the hub's
+/// note (`note_stop`): what ran, what was still in its group — the clue, as
+/// s857's two QEMUs were — and that finding the cause is its own work. "Run it
+/// again with it fixed" alone left the next step to the person, who said the
+/// agent must solve it by itself (2026-11-28).
+pub fn stopped_words(command: &str, node: &str, quiet: &str, group: &[String]) -> String {
+ let left = if group.is_empty() { String::new() } else { format!(" Still in its process group then: {}.", group.join("; ")) };
+ format!(
+ "midas: stopped `{command}` on {node}: it printed nothing and used no CPU for {quiet}, so it was waiting for \
+ something that would never come.{left} This is yours to solve now, without asking the person: find what it \
+ waited for (most often a process it started that kept its output open — a QEMU, a server, a pipe into grep — \
+ or a lock or a prompt; `ps`, `lsof` and its log on {node} show which), fix that cause, and run it again."
+ )
+}
+
+/// The hub's note to the session of a node's `stalled` stop event.
+pub fn note_stop(ev: &serde_json::Value) -> String {
+ let group: Vec<String> = ev["group"].as_array().into_iter().flatten()
+ .filter_map(|g| g.as_str().map(str::to_string)).collect();
+ let quiet = ev["quiet_s"].as_u64().map_or("half an hour".into(), |s| format!("{} minutes", s / 60));
+ stopped_words(&ev["command"].as_str().unwrap_or("").chars().take(120).collect::<String>(),
+ ev["node"].as_str().unwrap_or("its node"), &quiet, &group)
+}
+
/// What the watch has to say, as it happens.
#[derive(Debug, PartialEq, Eq)]
pub enum Said {
@@ -241,6 +265,19 @@ mod tests {
assert_eq!(limits_for("MIDAS_STALL=soon x"), Some(Limits::DEFAULT));
}
+ /// The stop names the clue and leaves the cause to the agent, not the person.
+ #[test]
+ fn a_stop_tells_the_agent_to_solve_it_itself() {
+ let ev = serde_json::json!({"kind": "stalled", "stage": "stop", "node": "mac-2", "quiet_s": 1830,
+ "command": "cargo xtask app Calculator 2>&1 | grep x",
+ "group": ["37664 qemu-system-aarch64 -M virt"]});
+ let w = note_stop(&ev);
+ assert!(w.contains("`cargo xtask app Calculator 2>&1 | grep x` on mac-2"), "{w}");
+ assert!(w.contains("30 minutes") && w.contains("37664 qemu-system-aarch64"), "{w}");
+ assert!(w.contains("without asking the person") && w.contains("run it again"), "{w}");
+ assert!(crate::collab::wakes("hub", "stalled") && !crate::collab::wakes("hub", "overlap"));
+ }
+
/// s857's hang, in small: a process orphaned out of a subshell keeps the
/// pipe into `grep` open, so the pipeline never ends by itself. Under the
/// watch it is stopped once quiet, and the run returns.