From ec7ff61d4d0aa4aa0436b3e56d348c37e35cac35 Mon Sep 17 00:00:00 2001 From: Harry <4210852+harryert@users.noreply.github.com> Date: Wed, 28 Oct 2026 12:57:21 +0800 Subject: [PATCH] test(ecc2): cover long native delegation sender IDs --- ecc2/src/session/store.rs | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/ecc2/src/session/store.rs b/ecc2/src/session/store.rs index 7f262c275..69381691f 100644 --- a/ecc2/src/session/store.rs +++ b/ecc2/src/session/store.rs @@ -4963,7 +4963,7 @@ fn is_assignment_handoff(content: &str, sender: &str) -> bool { }; // The native delegate CLI uses a short sender ID, and does not append a // routing reason. Both forms are internal notifications, not new work. - if context.starts_with(&format!("Delegated from {} [", short_session_ref(sender))) + if context.starts_with(&format!("Delegated from {} [", sender.chars().take(8).collect::())) && context.contains("] | cwd ") { return true; @@ -7067,6 +7067,19 @@ mod tests { Some("lead") ); + // The CLI shortens the source to its first eight characters regardless + // of its actual length; the inbox filter must use the same rule. + let long_sender = "lead-987654321"; + db.insert_session(&build_session(long_sender, SessionState::Running))?; + let long_notice = serde_json::to_string(&comms::MessageType::TaskHandoff { + task: "Implement another item".to_string(), + context: "Delegated from lead-987 [claude] | cwd /repo".to_string(), + priority: comms::TaskPriority::Normal, + })?; + db.send_message(long_sender, "worker", &long_notice, "task_handoff")?; + assert_eq!(db.unread_task_handoff_count("worker")?, 0); + assert!(db.unread_task_handoff_targets(10)?.is_empty()); + // Even a matching routing phrase in a user message is not an internal // assignment when the actual sender differs from the generated context. db.send_message("operator", "worker", &internal, "task_handoff")?; @@ -7084,7 +7097,7 @@ mod tests { // The original notification remains available to the human/agent inbox, // even though it never spawns a recursive grandchild. let all = db.list_messages_for_session("worker", 10)?; - assert_eq!(all.iter().filter(|message| message.msg_type == "task_handoff").count(), 5); + assert_eq!(all.iter().filter(|message| message.msg_type == "task_handoff").count(), 6); Ok(()) }