返回 DeepSeek-Reasonix
ablation_test.go
根目录 / internal / agent / ablation_test.go
1 package agent
2
3 import (
4 "testing"
5
6 "reasonix/internal/ablation"
7 "reasonix/internal/evidence"
8 )
9
10 func TestEvidenceAblationStandsDownTheReadinessGate(t *testing.T) {
11 writer := evidence.Receipt{ToolName: "write_file", Success: true, Write: true, Paths: []string{"a.go"}}
12 todo := evidence.Receipt{ToolName: "todo_write", Success: true, Todos: []evidence.TodoItem{{Content: "edit", Status: "in_progress"}}}
13
14 gated := &Agent{evidence: readinessLedger(writer, todo)}
15 if gated.finalReadinessCheckFor().reason == "" {
16 t.Fatal("control arm must still gate an incomplete todo after a write")
17 }
18
19 off := &Agent{evidence: readinessLedger(writer, todo), ablation: ablation.New(ablation.Evidence)}
20 if got := off.finalReadinessCheckFor().reason; got != "" {
21 t.Fatalf("evidence ablation still gated the final answer: %q", got)
22 }
23
24 unrelated := &Agent{evidence: readinessLedger(writer, todo), ablation: ablation.New(ablation.Planner)}
25 if unrelated.finalReadinessCheckFor().reason == "" {
26 t.Fatal("an unrelated ablation must not disable the readiness gate")
27 }
28 }
29
30 func TestCompactionAblationCollapsesTheCachePreservingDeferral(t *testing.T) {
31 full := &Agent{contextWindow: 100_000, softCompactRatio: 0.5, toolResultSnipRatio: 0.7, compactRatio: 0.8}
32 soft, snip, high := full.compactThresholds()
33 if soft != 50_000 || snip != 70_000 || high != 80_000 {
34 t.Fatalf("control thresholds = %d/%d/%d, want 50000/70000/80000", soft, snip, high)
35 }
36
37 off := &Agent{contextWindow: 100_000, softCompactRatio: 0.5, toolResultSnipRatio: 0.7, compactRatio: 0.8,
38 ablation: ablation.New(ablation.Compaction)}
39 soft, snip, high = off.compactThresholds()
40 if soft != 50_000 || snip != soft || high != soft {
41 t.Fatalf("ablated thresholds = %d/%d/%d, want all three at 50000", soft, snip, high)
42 }
43 }
44
44 lines GO