garage44.eu/jeroen/midas

logclone: git clone https://garage44.eu/jeroen/midas.git

cartopolis-agent · 2026-11-27T17:28:41Z

feat: the fastest free node first, gates off a slow held node, fewer cards

Measured over 371 sessions (s448-s874) and the hub log of 2026-10-28 to 11-27.

Nodes:
- rank_by_speed put GPU nodes last before speed; since the Macs were flagged
  GPU nodes (11-12) every take naming no node went to the CPU node, 4x slower
  (87 of 175 session leases while a Mac was free). Speed now decides; the GPU
  only between equals, and a GPU waiter keeps its node through the line.
- A claim naming one node takes its machine's other node after 5 minutes
  (36 h of named waits, 22 h of them with the sibling free).
- A take whose every matching node is offline or drained for 15 minutes stops
  and says so (s835 waited 9.5 h).
- An idle lease somebody waits for goes after 10 minutes, not 20; its holder
  hears at 5 (leases were in use 54% of the time held).
- The land script asks the hub (`midas faster`, GET /v1/faster) for a free node
  faster at the gate than the one held, and gates there: 40% of Cartopolis
  gates ran on vps-1, median 905 s against 214 s on a Mac.
- project_add takes `name` too (73 sessions called it so).

The person's cards:
- A PreToolUse hook (AskUserQuestion only) refuses a landing card with no
  picture shown since the last answer, unless the evidence says "No picture:"
  (25 of 190 "not yet" answers asked for the picture).
- finish-branch: look as the person will before asking; a series already
  agreed lands part by part without a card (s839 asked 26 times, 26 yes).
- The session brief: order and scope among wanted parts are the agent's
  (~150 cards a month answered with the recommended option or "doe alles");
  a question in an answer is answered in text.
- session-start: no sleep-polling of background output (206 loops a month).

Also docs/git-hosting.md: public repositories are visible, private ones not.
docs/git-hosting.md           |  5 +--
 docs/usage.md                 |  4 +--
 hooks/pre-tool-use            | 10 ++++++
 skills/finish-branch/SKILL.md | 23 ++++++++++--
 skills/finish-branch/land     | 13 +++++--
 src/claude.rs                 | 22 +++++++-----
 src/cli.rs                    | 22 ++++++++++++
 src/collab.rs                 |  2 +-
 src/hook.rs                   | 84 +++++++++++++++++++++++++++++++++++++++++++
 src/hub.rs                    |  3 ++
 src/main.rs                   | 25 +++++++++++++
 src/mcp.rs                    |  4 ++-
 src/registry.rs               | 70 ++++++++++++++++++++++++++++++------
 src/session-start.md          |  4 ++-
 src/sessions.rs               |  8 +++--
 src/tests.rs                  | 41 ++++++++++++++++++---
 16 files changed, 303 insertions(+), 37 deletions(-)

diff --git a/docs/git-hosting.md b/docs/git-hosting.md
index e22d4dc..0395472 100644
--- a/docs/git-hosting.md
+++ b/docs/git-hosting.md
@@ -246,8 +246,9 @@ The steps, each of which can be undone until Forgejo goes:
 
 ## Open questions for the person
 
-1. **A browsable web view of public repositories**: needed (people reading the
-   code of an open-source project), or only clone and archive URLs?
+1. ~~A browsable web view of public repositories~~ — decided 2026-11-27: public
+   repositories are visible (files, README, log); private ones are not, to anyone
+   outside the workspace.
 2. **Where the off-machine backup goes**: another machine of yours (the mini),
    or storage you name.
 3. **Forgejo after the move**: a month read-only and then removed, or kept
diff --git a/docs/usage.md b/docs/usage.md
index 8e85b9c..55a9852 100644
--- a/docs/usage.md
+++ b/docs/usage.md
@@ -130,7 +130,7 @@ The `finish-branch` skill does all of it, the same way for every project: the
 turn, the project's pre-land check, a stop to read what moved on main when it
 changed files the branch changes too, the rebase, the project's gate on a node
 (`midas take any --fastest-for <gate>` when the session holds none: the free
-node fastest at that command, GPU nodes last), the pass recorded at the hub
+node fastest at that command, a GPU node after one as fast), the pass recorded at the hub
 (`midas verified`), the push, and `--deploy`. What is the project's is named in
 hub.conf ([hub.md](hub.md#each-projects-landing)).
 
@@ -305,7 +305,7 @@ session ends (its session-end hook) or after two days, and each sender is told
 once.
 
 The hub adds its own notes: to a holder whose node somebody waits for while it
-sits unused (ten quiet minutes, then at most every quarter hour), and to both
+sits unused (five quiet minutes, then at most every quarter hour; five more and it goes to the line), and to both
 sessions when they change the same files — each flush reports the files the
 branch changes against the warm branch and the functions its hunks are in, the
 tool hook adds each file the first time the session edits it (`midas
diff --git a/hooks/pre-tool-use b/hooks/pre-tool-use
new file mode 100755
index 0000000..4139e99
--- /dev/null
+++ b/hooks/pre-tool-use
@@ -0,0 +1,10 @@
+#!/usr/bin/env bash
+#
+# Claude Code PreToolUse hook, for AskUserQuestion only: a "Shall it land?"
+# card waits for a picture shown since the person last answered, or a line
+# saying why there is none. The work is `midas hook pre-tool-use` (src/hook.rs).
+# FAILS OPEN: a midas too old to know it, or no hub, lets every card through.
+[ -f "$HOME/.config/midas/hub.env" ] || exit 0
+M=$HOME/.local/bin/midas; [ -x "$M" ] || M=$(command -v midas) || exit 0
+"$M" hook pre-tool-use 2>/dev/null
+exit 0
diff --git a/skills/finish-branch/SKILL.md b/skills/finish-branch/SKILL.md
index d8127d1..da4b848 100644
--- a/skills/finish-branch/SKILL.md
+++ b/skills/finish-branch/SKILL.md
@@ -26,7 +26,16 @@ Two things come before the question, because each, found after the person's
 - **A picture, for a change that can be seen.** Shown with `midas show`, and
   for a map or render change the before, after and reference beside each other.
   A visible change with no picture shown is not ready to ask about: the
-  person judges what they see, and "slop" after a landing is a lost day.
+  person judges what they see, and "slop" after a landing is a lost day. A
+  hook refuses the card until one is shown since their last answer, or the
+  evidence says on a line of its own `No picture: <why>` for a change nothing
+  draws. **Look at it yourself first, as they will:** a view from the ground or
+  at an angle for anything standing in the world (floating, sinking, gaps and
+  wrong walls hide in a view from above), a video for motion, the phone's
+  viewport for UI, the mockup or the reference beside it, rendered on a GPU
+  node when colour or light is what changed. Of 190 landing cards answered
+  "not yet" in the month to 2026-11-27, about 65 named what such a look would
+  have shown.
 - **What it builds.** `midas land targets` says which deploy targets this
   landing changes, which it builds after landing (every changed one that is
   not optional, and any optional one whose `required_by` changed, such as the
@@ -69,7 +78,17 @@ a phone shows it as a card, and a long one buries the choices. The options:
 
 There is no "keep working" answer: a session that stayed open after landing
 took the next wish, and the next, and did not end. When the person writes a
-new wish into their answer ("land it, and also …"), weigh it:
+new wish into their answer ("land it, and also …"), weigh it — but first:
+
+- **A series they already said yes to.** When they asked for the work in parts
+  (the steps of a plan, "doe alles"), or answered a landing with "land it and
+  carry on" to the rest of it, each later part lands on its own green gate
+  without a card: land it without `--finish`, say in a line what landed and
+  where it is shown, and go on; ask "Shall it land?" for the last part, and
+  for any part whose result is a matter of taste (a look, a text). s839 asked
+  26 times in one series and heard "land it" 26 times, s834 23 times.
+
+Then:
 
 - **It carries on this session's work** — a follow-up, a fix, the same
   feature in its docs, a slide or another project (add that project here). This
diff --git a/skills/finish-branch/land b/skills/finish-branch/land
index ea1bd53..a0b10d1 100755
--- a/skills/finish-branch/land
+++ b/skills/finish-branch/land
@@ -216,12 +216,19 @@ else
     # none, so a session holding a Mac was gated on whichever node was fastest.
     node=$(midas mine 2>/dev/null | jq -r --arg g "$gate_nodes" \
         'select($g == "" or $g == "any" or .machine == $g or .id == $g or ($g == "gpu" and .gpu == true)) | .id // empty' 2>/dev/null)
+    # The worktree's session: a worktree in a session's folder (one per project) is that session's.
+    if [ -f "$(dirname "$root")/.midas-session" ]; then whose=$(basename "$(dirname "$root")"); else whose=$(basename "$root"); fi
+    gate_owner="gate-$whose"
+    # Unless a free node is faster at the gate: a session holding the CPU node
+    # gated there while a Mac sat free, four times slower (40% of Cartopolis
+    # gates, 2026-10-28 to 11-27). The node held stays the session's.
+    if [ -n "$node" ] && faster=$(midas faster --than "$node" "${gate_nodes:-any}" --fastest-for "$gate" --owner "$gate_owner" 2>/dev/null); then
+        echo "==> $faster is free and faster at the gate than $node, which this worktree holds: gating there"
+        node=""
+    fi
     if [ -n "$node" ]; then
         echo "==> gating on $node (this worktree holds it): $gate"
     else
-        # The worktree's session: a worktree in a session's folder (one per project) is that session's.
-        if [ -f "$(dirname "$root")/.midas-session" ]; then whose=$(basename "$(dirname "$root")"); else whose=$(basename "$root"); fi
-        gate_owner="gate-$whose"
         node=$(midas take "$gate_nodes" --fastest-for "$gate" --owner "$gate_owner" --wait 3600 \
             --purpose "landing gate for $branch") || {
             land_outcome="failed"; echo "no node came free in an hour; not gating" >&2; exit 1; }
diff --git a/src/claude.rs b/src/claude.rs
index 038b1d6..03d236d 100644
--- a/src/claude.rs
+++ b/src/claude.rs
@@ -48,14 +48,17 @@ const FILES: &[File] = &[
     file!("hooks/midas-session-end", "hooks/session-end", true),
     file!("hooks/midas-prompt-submit", "hooks/prompt-submit", true),
     file!("hooks/midas-post-tool-use", "hooks/post-tool-use", true),
+    file!("hooks/midas-pre-tool-use", "hooks/pre-tool-use", true),
 ];
 
-/// Which hook each Claude Code event runs, and its timeout in seconds.
-const EVENTS: &[(&str, &str, u32)] = &[
-    ("SessionStart", "session-start", 15),
-    ("SessionEnd", "session-end", 20),
-    ("UserPromptSubmit", "prompt-submit", 10),
-    ("PostToolUse", "post-tool-use", 5),
+/// Which hook each Claude Code event runs, its timeout in seconds, and the
+/// tools it is for (none: every one).
+const EVENTS: &[(&str, &str, u32, Option<&str>)] = &[
+    ("SessionStart", "session-start", 15, None),
+    ("SessionEnd", "session-end", 20, None),
+    ("UserPromptSubmit", "prompt-submit", 10, None),
+    ("PostToolUse", "post-tool-use", 5, None),
+    ("PreToolUse", "pre-tool-use", 5, Some("AskUserQuestion")),
 ];
 
 const MANIFEST: &str = "midas-installed.json";
@@ -227,7 +230,7 @@ fn add_hooks(s: &mut Value, hooks: &Path) -> Vec<(String, String)> {
     if !s.is_object() {
         return added;
     }
-    for (event, hook, timeout) in EVENTS {
+    for (event, hook, timeout, matcher) in EVENTS {
         let runs = |c: &str| {
             let base = c.trim_matches('"').rsplit('/').next().unwrap_or("");
             base == *hook || base == format!("midas-{hook}")
@@ -247,7 +250,10 @@ fn add_hooks(s: &mut Value, hooks: &Path) -> Vec<(String, String)> {
             s["hooks"][*event] = json!([]);
         }
         s["hooks"][*event].as_array_mut().unwrap()
-            .push(json!({"hooks": [{"type": "command", "command": cmd, "timeout": timeout}]}));
+            .push(match matcher {
+                Some(m) => json!({"matcher": m, "hooks": [{"type": "command", "command": cmd, "timeout": timeout}]}),
+                None => json!({"hooks": [{"type": "command", "command": cmd, "timeout": timeout}]}),
+            });
         added.push((event.to_string(), cmd));
     }
     added
diff --git a/src/cli.rs b/src/cli.rs
index 334c9d7..bc4e5d5 100644
--- a/src/cli.rs
+++ b/src/cli.rs
@@ -120,6 +120,9 @@ pub fn take(t: &Take) -> Result<i32> {
     }
 }
 
+/// How long a take waits while every node it could have is offline or drained.
+const DEAD_WAIT: Duration = Duration::from_secs(15 * 60);
+
 /// `take` without its answer on stdout: the node's name is returned, and
 /// everything said along the way goes to stderr (`midas bot start` builds on it).
 pub fn take_node(t: &Take) -> Result<Taken> {
@@ -151,6 +154,7 @@ pub fn take_node(t: &Take) -> Result<Taken> {
     let deadline = Instant::now() + Duration::from_secs(t.wait);
     let mut asked = 0u32;
     let mut outage = Outage::default();
+    let mut dead_since: Option<Instant> = None;
     let node = loop {
         let Some((code, v)) = outage.ask(|| client::post_raw("/v1/claim", &body))? else { continue };
         if code == 200 {
@@ -167,6 +171,20 @@ pub fn take_node(t: &Take) -> Result<Taken> {
             let _ = client::post("/v1/unqueue", &json!({"owner": t.owner}));
             bail!("no node matches {:?}. `midas status` lists them.", t.node.as_deref().unwrap_or(&t.machine));
         }
+        // Every node that matches offline or drained: none frees by being given
+        // back. A drain for an update lasts minutes, so give it [`DEAD_WAIT`];
+        // a session waited 9.5 h from 2026-11-23 for a GPU while the Macs were
+        // drained and the deck was off.
+        let dead = v["passed_over"].as_array().into_iter().flatten()
+            .all(|p| matches!(p["why"].as_str(), Some("offline" | "drained")));
+        if !dead {
+            dead_since = None;
+        } else if dead_since.get_or_insert_with(Instant::now).elapsed() >= DEAD_WAIT {
+            let _ = client::post("/v1/unqueue", &json!({"owner": t.owner}));
+            bail!("every node that matches {:?} has been offline or drained for {} minutes ({}): none will come free \
+                   by waiting. Ask for another kind (`midas take any`), or `midas check` for why they are out.",
+                t.node.as_deref().unwrap_or(&t.machine), DEAD_WAIT.as_secs() / 60, why.join(", "));
+        }
         if Instant::now() >= deadline {
             // Out of time, but still in line: whoever runs `midas wait` next
             // (in the background, for an agent) keeps the place.
@@ -184,6 +202,10 @@ pub fn take_node(t: &Take) -> Result<Taken> {
         std::thread::sleep(Duration::from_secs(5));
     };
     let id = node["id"].as_str().unwrap_or("?").to_string();
+    if let Some(named) = t.node.as_deref().filter(|n| *n != id) {
+        eprintln!("took {id} instead of {named}: {named} was not free for {} minutes, and {id} is on its machine",
+            registry::NAMED_FALLBACK_S / 60);
+    }
     if quiet {
         // A run's own ssh brings the node to this worktree.
         return Ok(Taken::Node(id));
diff --git a/src/collab.rs b/src/collab.rs
index 362a21d..e45983f 100644
--- a/src/collab.rs
+++ b/src/collab.rs
@@ -1321,7 +1321,7 @@ fn names_of() -> Value {
 /// Every few minutes from the hub: a session holding a node somebody waits
 /// for, and not using it, hears so. Once a quarter of an hour at most.
 pub fn nudge_idle_holders() {
-    const QUIET_S: i64 = 10 * 60;
+    const QUIET_S: i64 = 5 * 60;
     const AGAIN_S: i64 = 15 * 60;
     let Ok(mut reg) = registry::Locked::open() else { return };
     let t = now();
diff --git a/src/hook.rs b/src/hook.rs
index 897222d..ae48f9b 100644
--- a/src/hook.rs
+++ b/src/hook.rs
@@ -373,10 +373,94 @@ fn session_start_text(state: &Value, held: Option<&str>, check: &str, installed:
         .replace("@NODES@", &list.join("\n"))
 }
 
+/// `midas hook pre-tool-use`: before a "Shall it land?" card, a picture shown
+/// since the person last answered (`midas show`, the `show` tool), or a line in
+/// the evidence saying why there is none ("No picture: …", "Geen beeld: …").
+/// The skill asked for one and 25 of 190 landing cards answered "not yet" in the
+/// month to 2026-11-27 were the person asking for it ("shots", "geen shot
+/// gezien"). Every other call passes, and so does anything it cannot read.
+pub fn pre_tool_use() -> Result<i32> {
+    let mut text = String::new();
+    let _ = std::io::stdin().read_to_string(&mut text);
+    let input: Value = serde_json::from_str(&text).unwrap_or(Value::Null);
+    if input["tool_name"] != "AskUserQuestion" || subagent(&input) {
+        return Ok(0);
+    }
+    let asked = input["tool_input"]["questions"].to_string();
+    let Some(transcript) = input["transcript_path"].as_str().and_then(|p| std::fs::read_to_string(p).ok()) else { return Ok(0) };
+    if !landing_question(&asked) || pictured(&transcript) {
+        return Ok(0);
+    }
+    println!("{}", json!({"hookSpecificOutput": {"hookEventName": "PreToolUse", "permissionDecision": "deny",
+        "permissionDecisionReason": "A landing question needs a picture shown first (finish-branch: `midas show`, before / after / \
+            reference side by side; a ground-level or oblique view for anything in the world, the phone's viewport for UI). Look at \
+            it yourself before showing it. When nothing in the change can be seen, say so in the evidence on a line of its own — \
+            \"No picture: <why>\" — and ask again."}}));
+    Ok(0)
+}
+
+fn landing_question(asked: &str) -> bool {
+    let a = asked.to_lowercase();
+    a.contains("shall it land") || a.contains("land it") || a.contains("landen") || a.contains("zal het landen")
+}
+
+/// Since the person last spoke (a prompt, or an answer to a card): was a
+/// picture shown, or its absence said?
+fn pictured(transcript: &str) -> bool {
+    for line in transcript.lines().rev() {
+        let Ok(o) = serde_json::from_str::<Value>(line) else { continue };
+        let content = &o["message"]["content"];
+        match o["type"].as_str() {
+            Some("assistant") => for c in content.as_array().into_iter().flatten() {
+                let shown = c["type"] == "tool_use" && (c["name"].as_str().is_some_and(|n| n.ends_with("__show"))
+                    || c["input"]["command"].as_str().is_some_and(|s| s.contains("midas show")));
+                let said = c["type"] == "text" && c["text"].as_str().is_some_and(|t| t.lines().any(|l| {
+                    let l = l.trim_start_matches(['*', '-', ' ', '_']).to_lowercase();
+                    l.starts_with("no picture:") || l.starts_with("geen beeld:")
+                }));
+                if shown || said {
+                    return true;
+                }
+            },
+            Some("user") if o["isMeta"] != true => {
+                let prompt = content.is_string() && !content.as_str().unwrap_or("").starts_with('<')
+                    || content.as_array().is_some_and(|a| a.iter().any(|c| c["type"] == "text"));
+                let answer = content.as_array().is_some_and(|a| a.iter().any(|c| c["type"] == "tool_result"
+                    && { let s = c["content"].to_string(); s.contains("answered your questions") || s.contains("user answered") }));
+                if prompt || answer {
+                    return false;
+                }
+            }
+            _ => {}
+        }
+    }
+    false
+}
+
 #[cfg(test)]
 mod tests {
     use super::*;
 
+    #[test]
+    fn a_landing_card_waits_for_a_picture_since_the_last_answer() {
+        let prompt = json!({"type": "user", "message": {"content": "make the roofs red"}}).to_string();
+        let show = json!({"type": "assistant", "message": {"content": [{"type": "tool_use", "name": "mcp__midas__show", "input": {"path": "/tmp/a.png"}}]}}).to_string();
+        let bash_show = json!({"type": "assistant", "message": {"content": [{"type": "tool_use", "name": "Bash", "input": {"command": "midas show x.png --caption after"}}]}}).to_string();
+        let none = json!({"type": "assistant", "message": {"content": [{"type": "text", "text": "Evidence:\n- **No picture:** a server fix, nothing drawn"}]}}).to_string();
+        let edit = json!({"type": "assistant", "message": {"content": [{"type": "tool_use", "name": "Edit", "input": {}}]}}).to_string();
+        let result = json!({"type": "user", "message": {"content": [{"type": "tool_result", "content": "ok"}]}}).to_string();
+        let answer = json!({"type": "user", "message": {"content": [{"type": "tool_result", "content": "The user answered: \"Shall it land?\"=\"not yet, greener\""}]}}).to_string();
+        let t = |l: &[&str]| l.join("\n");
+        assert!(!pictured(&t(&[&prompt, &edit, &result])), "nothing shown");
+        assert!(pictured(&t(&[&prompt, &show, &result, &edit, &result])));
+        assert!(pictured(&t(&[&prompt, &bash_show, &result])));
+        assert!(pictured(&t(&[&prompt, &none])), "its absence said");
+        assert!(!pictured(&t(&[&prompt, &show, &result, &answer, &edit, &result])), "shown before the person's last answer");
+        assert!(landing_question(r#"[{"question":"Shall it land? cartopolis, session/s1"}]"#));
+        assert!(landing_question(r#"[{"header":"Landen","question":"Zal het landen?"}]"#));
+        assert!(!landing_question(r#"[{"header":"Logo","question":"Which logo?"}]"#));
+    }
+
     #[test]
     fn a_shell_command_touches_memory_only_at_a_word_end() {
         assert!(touches_memory("rm ~/.claude/projects/x/memory/a.md"));
diff --git a/src/hub.rs b/src/hub.rs
index bf7cd59..b780fe8 100644
--- a/src/hub.rs
+++ b/src/hub.rs
@@ -527,6 +527,9 @@ fn api(method: &str, path: &str, query: &str, body: &Value, who: &Who, peer: &st
         }),
         ("GET", "events") => return Ok((200, json!(events::read_at(&registry::root(), &events::Filter::from_query(query))))),
         ("GET", "position") => return Ok((200, json!(registry::position(&q("owner").unwrap_or_default())?))),
+        ("GET", "faster") => return Ok((200, json!({"node": registry::faster_free(&pct_decode(&q("owner").unwrap_or_default()),
+            &pct_decode(&q("machine").unwrap_or_else(|| "any".into())), &pct_decode(&q("than").unwrap_or_default()),
+            q("rank").map(|r| pct_decode(&r)).as_deref())?}))),
         ("GET", p) if p.starts_with("lease/") => return Ok((200, lease(&p["lease/".len()..])?)),
         // Notifications (push.rs): the key a browser subscribes with, and what waits now, for its service worker.
         ("GET", "push/key") => return Ok((200, json!({"key": crate::push::public_key()?}))),
diff --git a/src/main.rs b/src/main.rs
index 5c357b8..804b671 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -411,6 +411,19 @@ enum Cmd {
     /// The node this worktree holds, as JSON (exit 1 if none).
     #[command(hide = true)]
     Mine,
+    /// A free node faster at a command than one you hold: its name, or exit 1
+    /// when none is (the landing gate asks before gating on a held node).
+    #[command(hide = true)]
+    Faster {
+        /// The node held.
+        #[arg(long)]
+        than: String,
+        /// The kind of node: any, gpu, a machine.
+        #[arg(default_value = "any")]
+        machine: String,
+        #[arg(long)]
+        fastest_for: Option<String>,
+    },
     /// Who holds each node, for what, until when, doing what; each node's
     /// heartbeat; the queue and where you stand in it; who is landing.
     Status {
@@ -1169,6 +1182,8 @@ enum SessionsCmd {
 
 #[derive(Subcommand)]
 enum HookCmd {
+    /// Before a question card: a landing card waits for a picture.
+    PreToolUse,
     /// After every tool call: report a first edit of a file, hand over notes.
     PostToolUse,
     /// Before every prompt: name the session, sync memory, hand over notes.
@@ -1380,6 +1395,7 @@ fn run(cmd: Cmd, owner: Option<String>) -> anyhow::Result<i32> {
             eprintln!("{id}: {} — told to the sessions involved", d["answer"].as_str().unwrap_or("?"));
             Ok(0)
         }
+        Cmd::Hook(HookCmd::PreToolUse) => hook::pre_tool_use(),
         Cmd::Hook(HookCmd::PostToolUse) => hook::post_tool_use(owner.clone()),
         Cmd::Hook(HookCmd::UserPromptSubmit) => hook::user_prompt_submit(owner.clone()),
         Cmd::Hook(HookCmd::SessionStart) => hook::session_start(),
@@ -1453,6 +1469,15 @@ fn run(cmd: Cmd, owner: Option<String>) -> anyhow::Result<i32> {
         }
         Cmd::Renew { command } => cli::renew(&who(), command.as_deref()),
         Cmd::Mine => cli::mine(&who()),
+        Cmd::Faster { than, machine, fastest_for } => {
+            let enc = crate::hub::pct_encode;
+            let v = client::get(&format!("/v1/faster?owner={}&machine={}&than={}{}", enc(&who()), enc(&machine), enc(&than),
+                fastest_for.map(|f| format!("&rank={}", enc(&f))).unwrap_or_default()))?;
+            match v["node"].as_str() {
+                Some(n) => { println!("{n}"); Ok(0) }
+                None => Ok(1),
+            }
+        }
         Cmd::Status { json, recent } => cli::status(json, recent, &who()),
         Cmd::Position => {
             println!("{}", client::get(&format!("/v1/position?owner={}", who()))?.as_str().unwrap_or("?"));
diff --git a/src/mcp.rs b/src/mcp.rs
index 9c8386e..97f453e 100644
--- a/src/mcp.rs
+++ b/src/mcp.rs
@@ -254,7 +254,9 @@ fn call(name: &str, a: &Value) -> Result<String> {
         "session_title" => crate::sessions::rename_self(arg(a, "title").context("title is required")?),
         "session_later" => crate::sessions::later_self(arg(a, "at"), arg(a, "in"), arg(a, "text"), a["cancel"] == true),
         "session_await" => crate::sessions::await_self(arg(a, "text"), arg(a, "steps"), arg(a, "secret"), arg(a, "url"), a["done"] == true),
-        "project_add" => crate::sessions::add_project(arg(a, "project").context("project is required")?),
+        // `name` too: the tool's text said ./<name> and the CLI's argument is
+        // <name>, so 73 sessions called it so before they saw the schema.
+        "project_add" => crate::sessions::add_project(arg(a, "project").or_else(|| arg(a, "name")).context("project is required")?),
         "devices" => {
             let v = crate::client::get("/v1/devices")?;
             Ok(serde_json::to_string_pretty(&v["devices"])?)
diff --git a/src/registry.rs b/src/registry.rs
index bbb58a5..c59a44f 100644
--- a/src/registry.rs
+++ b/src/registry.rs
@@ -36,9 +36,13 @@ pub const DEFAULT_TTL: i64 = 7200;
 pub const IDLE_S: i64 = 1800;
 /// The same, when somebody waits for the node: a third of the leases in the
 /// week to 2026-10-25 ended only by sitting idle for [`IDLE_S`], while takes
-/// gave up waiting. Its holder was nudged at ten quiet minutes
-/// (`collab::nudge_idle_holders`); ten more and the node goes to the line.
-pub const WAITED_IDLE_S: i64 = 1200;
+/// gave up waiting. Its holder is nudged at five quiet minutes
+/// (`collab::nudge_idle_holders`); five more and the node goes to the line.
+/// Twenty until 2026-11-27: session leases were in use 54% of the time held,
+/// and others waited 14 h in a month behind ones sitting idle (s647 held deck-1
+/// 12 h with nothing running). The tree stays on the node, and `prefer_last`
+/// sends its holder back there when it is free again.
+pub const WAITED_IDLE_S: i64 = 600;
 /// The same, when a deploy or a landing gate waits for the node: what waits has
 /// landed, or holds the one turn to land that every session shares. sim and
 /// atlas waited 14 minutes for a vps node a session held with nothing running
@@ -57,6 +61,11 @@ pub const JOB_IDLE_S: i64 = 600;
 pub const JOB_WAITED_IDLE_S: i64 = 60;
 /// How long a session's last node is remembered, to send its next run there.
 pub const AFFINITY_S: i64 = 24 * 3600;
+/// A claim naming one node that has waited this long takes another node on the
+/// same machine when one is free: a second Mac VM is as fast and as able as the
+/// first. Sessions waited 36 h for a named node in the month to 2026-11-27, 22 h
+/// of it while its sibling was free ("Waarom wachten op mac-2; mac-1 is vrij").
+pub const NAMED_FALLBACK_S: i64 = 300;
 
 /// The hub's deploy builder (`deploy.rs`): first in every line for a node.
 pub fn is_deploy(owner: &str) -> bool {
@@ -558,9 +567,14 @@ fn ahead_of(reg: &Locked, owner: &str, node: &Value) -> Vec<String> {
 /// that never ran it, by the median over all nodes scaled by its general build
 /// speed — or a fast node new to a command would lose to every slow one that
 /// ran it once. For a claim naming no command, by general build speed alone.
-/// Nodes with a GPU go last — they are few, and kept for what needs one — and
-/// nodes with no measurement after those with one. The sort is stable, so ties
-/// keep the listed order.
+/// Nodes with no measurement go after those with one, and a GPU node after a
+/// node as fast without one. Until 2026-11-27 the GPU went first in the key,
+/// before speed: once the Macs were flagged GPU nodes (11-12) every take naming
+/// no node went to the CPU node four times slower — 87 of 175 session leases
+/// while a Mac was free, and Cartopolis gates of 905 s there against 214 s. What
+/// needs a GPU is kept its node by the line instead: a free node somebody waits
+/// for is "queued behind" them (`ahead_of`). The sort is stable, so ties keep
+/// the listed order.
 pub fn rank_by_speed(free: &mut [Value], command: Option<&str>) {
     let m = command.map(|c| crate::builds::medians(&crate::builds::shape(c), 30 * 86400)).unwrap_or_default();
     // Without a kind of command, or with one never run on these nodes: how
@@ -577,12 +591,13 @@ pub fn rank_by_speed(free: &mut [Value], command: Option<&str>) {
             .or_else(|| Some(m.all? as f64 * general(n)?))
     };
     free.sort_by(|a, b| {
-        let key = |n: &Value| (n["gpu"] == true, estimate(n).is_none(), general(n).is_none());
+        let key = |n: &Value| (estimate(n).is_none(), general(n).is_none(), n["gpu"] == true);
         let (ka, kb) = (key(a), key(b));
-        ka.0.cmp(&kb.0).then(ka.1.cmp(&kb.1))
+        ka.0.cmp(&kb.0)
             .then_with(|| estimate(a).unwrap_or(0.0).total_cmp(&estimate(b).unwrap_or(0.0)))
-            .then(ka.2.cmp(&kb.2))
+            .then(ka.1.cmp(&kb.1))
             .then_with(|| general(a).unwrap_or(1.0).total_cmp(&general(b).unwrap_or(1.0)))
+            .then(ka.2.cmp(&kb.2))
     });
 }
 
@@ -605,6 +620,24 @@ pub fn prefer_last(free: &mut [Value], owner: &str, last: &Map<String, Value>, t
     }
 }
 
+/// A free node of `machine` faster at `command` than `than` (a node the asker
+/// holds), when one is: the landing gate's question before it gates on the
+/// node its session holds. 40% of Cartopolis gates ran on the CPU node, a
+/// median 905 s against 214 s on a Mac, because the session held it while a
+/// Mac sat free (2026-10-28 to 11-27). Nobody waiting for a node ahead of
+/// `owner` is passed over.
+pub fn faster_free(owner: &str, machine: &str, than: &str, command: Option<&str>) -> Result<Option<String>> {
+    let reg = Locked::open()?;
+    let Some(held) = reg.node(than).cloned() else { return Ok(None) };
+    let mut v: Vec<Value> = reg.nodes().iter()
+        .filter(|s| machine_matches(machine, s) && s["enabled"].as_bool().unwrap_or(false) && !s["drained"].is_object()
+            && !reg.leases().contains_key(s["id"].as_str().unwrap_or("?")) && ahead_of(&reg, owner, s).is_empty())
+        .cloned().collect();
+    v.push(held);
+    rank_by_speed(&mut v, command);
+    Ok(v.first().and_then(|n| n["id"].as_str()).filter(|id| *id != than).map(str::to_string))
+}
+
 /// A request for a node.
 pub struct Claim {
     pub owner: String,
@@ -654,9 +687,19 @@ pub fn claim(c: &Claim) -> Result<std::result::Result<Value, Value>> {
     }
     let mut passed: Vec<Value> = Vec::new();
     let mut free: Vec<Value> = Vec::new();
+    // A named node waited for long enough: its machine's other nodes too
+    // ([`NAMED_FALLBACK_S`]). Not for a bot, which is set up on the node it
+    // names, nor while a node is drained for this claimant's next turn.
+    let waited = reg.waiters().get(&c.owner).and_then(|w| w["since"].as_i64()).map_or(0, |s| now() - s);
+    let next_turn_kept = reg.nodes().iter().any(|s| s["drained"]["for"] == c.owner.as_str());
+    let sibling_machine = c.node.as_deref()
+        .filter(|_| c.mode != Mode::Bot && waited >= NAMED_FALLBACK_S && !next_turn_kept)
+        .and_then(|w| reg.node(w)).and_then(|s| s["machine"].as_str()).map(str::to_string);
     for s in reg.nodes().clone() {
         let id = s["id"].as_str().unwrap_or("?").to_string();
-        if !machine_matches(&c.machine, &s) || c.node.as_deref().is_some_and(|w| w != id) {
+        let named = c.node.as_deref().is_none_or(|w| w == id);
+        let sibling = !named && sibling_machine.as_deref().is_some_and(|m| s["machine"] == m);
+        if !machine_matches(&c.machine, &s) || !(named || sibling) {
             continue;
         }
         // Drained for this claimant (`reserve_next`): its turn, ahead of the line.
@@ -674,6 +717,8 @@ pub fn claim(c: &Claim) -> Result<std::result::Result<Value, Value>> {
             (!ahead.is_empty()).then(|| json!({"node": id, "why": "queued behind", "waiters": ahead}))
         };
         match why {
+            // A sibling not free is not what the claim waits for.
+            Some(_) if sibling => {}
             Some(w) => passed.push(w),
             None => free.push(s),
         }
@@ -683,6 +728,10 @@ pub fn claim(c: &Claim) -> Result<std::result::Result<Value, Value>> {
     if free.len() > 1 {
         rank_by_speed(&mut free, c.rank.as_deref());
         prefer_last(&mut free, &c.owner, reg.state["last_node"].as_object().unwrap_or(&Map::new()), now());
+        // The node named, when it came free too.
+        if let Some(i) = c.node.as_deref().and_then(|w| free.iter().position(|n| n["id"] == w)) {
+            free[..=i].rotate_right(1);
+        }
     }
     if let Some(s) = free.into_iter().next() {
         let id = s["id"].as_str().unwrap_or("?").to_string();
@@ -712,6 +761,7 @@ pub fn claim(c: &Claim) -> Result<std::result::Result<Value, Value>> {
             "mode": (c.mode == Mode::Bot).then_some("bot"),
             "waited_s": waited.and_then(|w| w["since"].as_i64()).map(|s| now() - s),
             "ranked_by": c.rank,
+            "instead_of": c.node.as_deref().filter(|w| *w != id),
             "next_turn": next_turn.then_some(true),
         }));
         return Ok(Ok(s));
diff --git a/src/session-start.md b/src/session-start.md
index 65e1f47..e3a6d23 100644
--- a/src/session-start.md
+++ b/src/session-start.md
@@ -9,7 +9,9 @@ scp <node>:/tmp/x.png /tmp/       # fetch what it wrote, within a minute of the
 command, sends your worktree, runs it, exits with its status, and lets the node
 go a minute later if somebody waits. Nobody holds a node while reading and
 editing, so the line is short. It waits in line for as long as it takes: run it
-in the background when it may wait or build long. `midas take` holds a node
+in the background when it may wait or build long, and end your turn or do other
+work: its end comes to you as a notification, so never sleep-poll its output
+file (206 such loops in a month, half of them refused). `midas take` holds a node
 for longer — for a bot, a running client to drive, or a series of commands that
 must share one node — and `ssh <node> …` then runs on it.
 
diff --git a/src/sessions.rs b/src/sessions.rs
index 49721d9..2c7ddd0 100644
--- a/src/sessions.rs
+++ b/src/sessions.rs
@@ -69,7 +69,11 @@ language is `analysis`, which the page draws as a panel: `### Problem` (what goe
 ruled out), `### Options` (each with what it costs and what it leaves) and `### Recommendation` (which, and why). \
 Write it for someone who saw none of your steps: an analysis that fits on one line is not one yet. Ask only for a choice that is theirs and \
 changes what you do: carry on by yourself through the steps the task already settles, and never end a step on an \
-open \"what next?\" — each one is a round trip from their phone, often hours long. When what was asked is done, \
+open \"what next?\" — each one is a round trip from their phone, often hours long. Which part of what they asked \
+comes first, and whether to build the next part of it, is not theirs: take the order you recommend, all of it when \
+the parts stand apart, and say what you chose — 150 such cards in a month were answered with the recommended \
+option or \"doe alles\". Taste (a look, a name, a text), money, data lost and a public service down are theirs. \
+When they answer with a question, answer it in your message and end your turn, with no new card. When what was asked is done, \
 land it and finish (the finish-branch skill), and before asking whether it shall land, tell them what landing it \
 changes, as one fenced block of language `impact`, which the page draws as its own panel: `### What changes` (what \
 they and others will see or do differently, step by step as they will meet it, in their words, not the code's), \
@@ -108,7 +112,7 @@ fn folder_brief(id: &str, dir: &Path, repos: &[String]) -> String {
     let now = if repos.is_empty() { "none of them yet".to_string() } else { format!("{} so far, each at ./<name>", names(repos)) };
     format!("\n\nYou run in {}, this session's own folder, which is not a repository. The workspace's projects are {} ({}); \
         this session works in {now}. When the task needs a project's code — to read it, change it or build it — add the project \
-        with the midas MCP tool `project_add` (or `midas sessions add-project <name>`): it makes a worktree of it at ./<name>, on \
+        with the midas MCP tool `project_add` (`project: \"<name>\"`, or `midas sessions add-project <name>`): it makes a worktree of it at ./<name>, on \
         branch session/{id} off its main, and links its skills here. Add as many as the task spans and no more; a question that \
         needs no code needs none. Work in each worktree as in a checkout of its own: read its CLAUDE.md first, commit there, and \
         run builds (`ssh <node> …`, which sends the node the worktree you run it from) and the finish-branch skill from inside it. \
diff --git a/src/tests.rs b/src/tests.rs
index 7165d55..e5c4d5e 100644
--- a/src/tests.rs
+++ b/src/tests.rs
@@ -691,7 +691,7 @@ fn giving_up_a_place_in_line_lets_the_next_one_land() {
 }
 
 #[test]
-fn a_ranked_take_goes_to_the_fastest_free_node_and_a_gpu_last() {
+fn a_ranked_take_goes_to_the_fastest_free_node() {
     let _g = SERIAL.lock().unwrap();
     scratch("rank");
     for (id, machine, port) in [("slow-1", "vps", 2230), ("fast-1", "mini", 2231), ("fast-2", "mini", 2232)] {
@@ -726,7 +726,7 @@ fn a_ranked_take_goes_to_the_fastest_free_node_and_a_gpu_last() {
 }
 
 #[test]
-fn an_unranked_take_leaves_the_gpu_node_for_last() {
+fn an_unranked_take_between_equals_leaves_the_gpu_node_for_last() {
     let _g = SERIAL.lock().unwrap();
     scratch("unranked");
     // gpu-1 is listed first; with no build history either is as fast, and the
@@ -917,7 +917,7 @@ fn a_take_naming_no_command_gets_the_fastest_free_node() {
     assert!(claim("a", "any", None, false));
     assert_eq!(holder("mac-1").as_deref(), Some("a"), "the fastest free node, not the first listed");
     assert!(claim("b", "any", None, false));
-    assert_eq!(holder("cpu-1").as_deref(), Some("b"), "then the next fastest; the GPU node last");
+    assert_eq!(holder("cpu-1").as_deref(), Some("b"), "then the next fastest; the unmeasured GPU node last");
 }
 
 #[test]
@@ -2036,10 +2036,10 @@ fn an_idle_node_somebody_waits_for_goes_back_sooner_and_its_holder_hears() {
     registry::set_intent("a", None, None).unwrap();
     backdate(registry::WAITED_IDLE_S + 60);
     registry::snapshot().unwrap();
-    assert_eq!(holder("cpu-1"), None, "twenty quiet minutes with b waiting");
+    assert_eq!(holder("cpu-1"), None, "ten quiet minutes with b waiting");
     let notes = notes_for("a");
     assert_eq!(notes.len(), 1, "{notes:?}");
-    assert!(notes[0].starts_with("cpu-1 went back to the pool: nothing ran on it for 20 minutes while somebody waited"), "{}", notes[0]);
+    assert!(notes[0].starts_with("cpu-1 went back to the pool: nothing ran on it for 10 minutes while somebody waited"), "{}", notes[0]);
     assert!(claim("b", "server", None, true), "and b gets it");
 }
 
@@ -2661,3 +2661,34 @@ fn a_held_node_never_sleeps_and_a_machine_gone_quiet_leaves_its_nodes_awake() {
     crate::sleep::tick().unwrap();
     assert!(!asleep());
 }
+
+#[test]
+fn a_fast_gpu_node_goes_before_a_slow_one_without() {
+    let _g = SERIAL.lock().unwrap();
+    scratch("fast-gpu");
+    // The Macs are GPU nodes and four times as fast as the CPU node: speed
+    // decides, the GPU only between nodes as fast.
+    let ts = chrono::Utc::now().to_rfc3339();
+    let mut lines = String::new();
+    for (node, machine, secs) in [("cpu-1", "server", 900), ("cpu-1", "server", 880), ("gpu-1", "laptop", 210), ("gpu-1", "laptop", 220)] {
+        lines += &format!("{}\n", json!({"ts": ts, "node": node, "machine": machine, "actor": "s", "shape": "cargo test",
+            "seconds": secs, "exit": 0, "first_build_in_lease": false}));
+    }
+    std::fs::write(registry::root().join("builds.jsonl"), lines).unwrap();
+    assert!(claim("a", "any", None, false));
+    assert_eq!(holder("gpu-1").as_deref(), Some("a"), "the fastest free node, GPU or not");
+    assert!(claim("b", "any", None, false));
+    assert_eq!(holder("cpu-1").as_deref(), Some("b"));
+}
+
+#[test]
+fn a_free_gpu_node_somebody_waits_for_is_theirs() {
+    let _g = SERIAL.lock().unwrap();
+    scratch("gpu-kept");
+    assert!(claim("x", "any", Some("cpu-1"), false));
+    assert!(claim("x2", "gpu", None, false));
+    assert!(!claim("w", "gpu", None, true), "both taken: w waits for a GPU");
+    registry::release("x2", None, false).unwrap();
+    assert!(!claim("a", "any", None, false), "the freed GPU node is queued behind w");
+    assert!(claim("w", "gpu", None, true));
+}