garage44.eu/jeroen/midas

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

cartopolis-agent · 2026-11-27T19:40:47Z

fix(hook): a landing card says itself why it has no picture

The text of the message that makes a call reaches the transcript only after
the call, so the 'No picture:' line in the evidence above a card was never
seen and every landing without a picture was refused (found on its first use,
s874). The card's own question or option description now carries it.
skills/finish-branch/SKILL.md |  7 ++++---
 src/hook.rs                   | 28 +++++++++++++++++++++++-----
 2 files changed, 27 insertions(+), 8 deletions(-)

diff --git a/skills/finish-branch/SKILL.md b/skills/finish-branch/SKILL.md
index da4b848..a568bc5 100644
--- a/skills/finish-branch/SKILL.md
+++ b/skills/finish-branch/SKILL.md
@@ -27,9 +27,10 @@ Two things come before the question, because each, found after the person's
   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. 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
+  hook refuses the card until one is shown since their last answer, or — for a
+  change nothing draws — the card itself says `No picture: <why>` (in the
+  question or the recommended option's description; the hook cannot see the
+  message text sent with the card). **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
diff --git a/src/hook.rs b/src/hook.rs
index ae48f9b..b5afd49 100644
--- a/src/hook.rs
+++ b/src/hook.rs
@@ -374,8 +374,13 @@ fn session_start_text(state: &Value, held: Option<&str>, check: &str, installed:
 }
 
 /// `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: …").
+/// since the person last answered (`midas show`, the `show` tool), or the card
+/// itself saying why there is none ("No picture: …", "Geen beeld: …", in the
+/// question or an option's description). Not the evidence above it: the text of
+/// the message that makes the call reaches the transcript only after the call,
+/// so a hook never sees it (found the day it landed, 2026-11-27). Also a line in
+/// an earlier message of the turn.
+///
 /// 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.
@@ -388,17 +393,26 @@ pub fn pre_tool_use() -> Result<i32> {
     }
     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) {
+
+    if may_ask(&asked, &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."}}));
+            it yourself before showing it. When nothing in the change can be seen, say so in the card itself — the question or the \
+            recommended option's description — as \
+            \"No picture: <why>\", and ask again."}}));
     Ok(0)
 }
 
+/// Is this card let through: not a landing card, or one that says why it has
+/// no picture, or one with a picture shown since the person last answered.
+fn may_ask(asked: &str, transcript: &str) -> bool {
+    let a = asked.to_lowercase();
+    !landing_question(asked) || a.contains("no picture:") || a.contains("geen beeld:") || pictured(transcript)
+}
+
 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")
@@ -459,6 +473,10 @@ mod tests {
         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?"}]"#));
+        // The card says why it has none: the evidence above it is not in the transcript yet.
+        let card = r#"[{"question":"Shall it land? x","options":[{"label":"Land it","description":"No picture: a build script"}]}]"#;
+        assert!(may_ask(card, &t(&[&prompt, &edit, &result])));
+        assert!(!may_ask(r#"[{"question":"Shall it land? x"}]"#, &t(&[&prompt, &edit, &result])));
     }
 
     #[test]