Files
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.3 KiB
Go

package tracing
import (
"context"
"encoding/json"
"strings"
"testing"
"github.com/nextlevelbuilder/goclaw/internal/store"
)
func TestTextRedactorSanitizesSpanUpdatesAndEventPayloads(t *testing.T) {
const secret = "/host/tenant/collaboration/delegations/id/outputs"
ctx := WithTextRedactor(context.Background(), func(value string) string {
return strings.ReplaceAll(value, secret, "outputs")
})
span := RedactSpan(ctx, store.SpanData{
InputPreview: `{"path":"` + secret + `/input.txt"}`,
OutputPreview: secret + "/result.txt",
Error: "failed at " + secret,
Metadata: json.RawMessage(`{"root":"` + secret + `"}`),
})
encoded, err := json.Marshal(span)
if err != nil {
t.Fatal(err)
}
if strings.Contains(string(encoded), secret) {
t.Fatalf("redacted span leaked host root: %s", encoded)
}
updates := RedactSpanUpdates(ctx, map[string]any{
"output_preview": secret + "/result.txt",
"metadata": json.RawMessage(`{"root":"` + secret + `"}`),
})
payload := RedactValue(ctx, map[string]any{
"content": secret,
"items": []any{secret + "/child"},
})
combined, err := json.Marshal([]any{updates, payload})
if err != nil {
t.Fatal(err)
}
if strings.Contains(string(combined), secret) {
t.Fatalf("redacted values leaked host root: %s", combined)
}
}