Files
goclaw/cmd/gateway_subagent_announce_key_test.go
T
Duc Nguyenandntduc bb7712a9ff fix(collaboration): harden delegated task isolation (#1486)
* feat(collaboration): isolate delegated artifacts and child runs

Isolate delegated inputs and outputs behind secure artifact exchange lifecycles. Scope Agent Link tasks by tenant and root agent, and enforce delegation spawn-tree boundaries. Add process-wide child-run admission and preserve logical media paths across native, MCP, and sandbox execution.

* fix(collaboration): harden delegated task isolation

Enforce tenant and root-agent task scope across migrations and stores. Add exactly-once async completion delivery, delegated sandbox boundaries, and confined artifact and media recovery across runtime surfaces.

* fix(collaboration): recover interrupted async tasks

* fix(collaboration): normalize persisted child-run status

---------

Co-authored-by: ntduc <ntduc@cpp.ai.vn>
2026-07-30 14:17:40 +07:00

48 lines
1.7 KiB
Go

package cmd
import (
"testing"
"github.com/google/uuid"
)
func TestSubagentAnnounceRoutingKeyScopesRoutingAndAuthority(t *testing.T) {
base := subagentAnnounceRouting{
TenantID: uuid.New(),
RootAgentID: uuid.New(),
ParentAgent: "root",
SessionKey: "session",
OrigChannel: "telegram",
OrigChatID: "chat",
OrigPeerKind: "group",
OrigLocalKey: "topic",
UserID: "user",
SenderID: "sender",
Role: "operator",
}
want := subagentAnnounceRoutingKey(base)
cases := map[string]func(*subagentAnnounceRouting){
"tenant": func(v *subagentAnnounceRouting) { v.TenantID = uuid.New() },
"root id": func(v *subagentAnnounceRouting) { v.RootAgentID = uuid.New() },
"parent agent": func(v *subagentAnnounceRouting) { v.ParentAgent += "-other" },
"session": func(v *subagentAnnounceRouting) { v.SessionKey += "-other" },
"channel": func(v *subagentAnnounceRouting) { v.OrigChannel += "-other" },
"chat": func(v *subagentAnnounceRouting) { v.OrigChatID += "-other" },
"peer kind": func(v *subagentAnnounceRouting) { v.OrigPeerKind += "-other" },
"local key": func(v *subagentAnnounceRouting) { v.OrigLocalKey += "-other" },
"user": func(v *subagentAnnounceRouting) { v.UserID += "-other" },
"sender": func(v *subagentAnnounceRouting) { v.SenderID += "-other" },
"role": func(v *subagentAnnounceRouting) { v.Role += "-other" },
}
for name, mutate := range cases {
t.Run(name, func(t *testing.T) {
got := base
mutate(&got)
if key := subagentAnnounceRoutingKey(got); key == want {
t.Fatalf("routing key did not change when %s changed", name)
}
})
}
}