| 1 | package agent |
| 2 | |
| 3 | import ( |
| 4 | "context" |
| 5 | "testing" |
| 6 | |
| 7 | "reasonix/internal/event" |
| 8 | "reasonix/internal/evidence" |
| 9 | "reasonix/internal/provider" |
| 10 | "reasonix/internal/tool" |
| 11 | ) |
| 12 | |
| 13 | type auditProbe2 struct { |
| 14 | event.Sink |
| 15 | got []evidence.DelegationAudit |
| 16 | } |
| 17 | |
| 18 | func (p *auditProbe2) RecordDelegationAudit(a evidence.DelegationAudit) { p.got = append(p.got, a) } |
| 19 | |
| 20 | func TestZZProbeThroughTaskTool(t *testing.T) { |
| 21 | root := t.TempDir() |
| 22 | probe := &auditProbe2{Sink: event.Discard} |
| 23 | reg := tool.NewRegistry() |
| 24 | reg.Add(fakeReadFileTool{}) |
| 25 | prov := &scriptedProvider{name: "p", turns: [][]provider.Chunk{ |
| 26 | {toolCallChunk("1", "read_file", `{"path":"a.go"}`), {Type: provider.ChunkDone}}, |
| 27 | {{Type: provider.ChunkText, Text: "done"}, {Type: provider.ChunkDone}}, |
| 28 | }} |
| 29 | task := NewTaskTool(prov, nil, reg, 20, 0, 0, 0, 0, 0, 0, 0.0, "", "sys", nil, 0, "", "", nil). |
| 30 | WithTranscripts(mustSubagentStore(t), root, "base", "high"). |
| 31 | WithScheduler(NewSubagentScheduler(4, 4)) |
| 32 | ctx := withCallContext(context.Background(), "call-1", probe, nil, false) |
| 33 | if _, err := task.Execute(ctx, []byte(`{"prompt":"inspect a.go"}`)); err != nil { |
| 34 | t.Fatalf("task: %v", err) |
| 35 | } |
| 36 | t.Logf("audits через TaskTool: %d", len(probe.got)) |
| 37 | if len(probe.got) == 0 { |
| 38 | t.Fatal("no audit through the TaskTool path") |
| 39 | } |
| 40 | } |
| 41 |