返回 DeepSeek-Reasonix
completion_receipt_test.go
根目录 / internal / agent / completion_receipt_test.go
1 package agent
2
3 import (
4 "testing"
5
6 "reasonix/internal/completion"
7 "reasonix/internal/evidence"
8 )
9
10 func TestReceiptCarriesWhatProseDoesNot(t *testing.T) {
11 ledger := evidence.NewLedger()
12 for _, r := range []evidence.Receipt{
13 {ToolName: "edit_file", Success: true, Write: true, Mutation: true, Paths: []string{"calc.py"}},
14 {ToolName: "bash", Success: true, Command: "go test ./...", OutputBytes: 64},
15 } {
16 ledger.Record(r)
17 }
18 got := completionReceipt(completion.BuildFacts(ledger, "", nil))
19 if got == nil {
20 t.Fatal("a turn that changed a file must produce a receipt")
21 }
22 if got.Verdict != "unknown" {
23 t.Fatalf("verdict = %q, want unknown", got.Verdict)
24 }
25 if len(got.Changes) != 1 || got.Changes[0].Path != "calc.py" || got.Changes[0].Reviewed {
26 t.Fatalf("changes = %+v, want calc.py recorded as unreviewed", got.Changes)
27 }
28 if len(got.Verifications) != 1 || !got.Verifications[0].Passed {
29 t.Fatalf("verifications = %+v, want the passing command named", got.Verifications)
30 }
31 if len(got.Gaps) != 0 {
32 t.Fatalf("unreviewed path acquired inferred quality gap: %+v", got.Gaps)
33 }
34 }
35
36 // A receipt that says nothing is noise, and noise is what makes people stop
37 // reading receipts.
38 func TestNoReceiptForATurnWithNothingToJudge(t *testing.T) {
39 ledger := evidence.NewLedger()
40 ledger.Record(evidence.Receipt{ToolName: "read_file", Success: true, Read: true, Paths: []string{"calc.py"}, OutputBytes: 64})
41 if got := completionReceipt(completion.BuildFacts(ledger, "", nil)); got != nil {
42 t.Fatalf("read-only answer produced a receipt: %+v", got)
43 }
44 }
45
46 func TestAgentHoldsTheLastTurnsReceipt(t *testing.T) {
47 var a *Agent
48 if a.CompletionReceipt() != nil {
49 t.Fatal("a nil agent must not produce a receipt")
50 }
51 a = &Agent{}
52 if a.CompletionReceipt() != nil {
53 t.Fatal("an agent that has not finished a turn has no receipt")
54 }
55 }
56
56 lines GO