返回 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{task: taskRuntime{ledger: readinessLedger(writer, todo)}, turn: turnRuntime{deliveryScopeActive: true}}
15 if gated.ReadinessResult().Reason != "" {
16 t.Fatal("control arm must still gate an incomplete todo after a write")
17 }
18
19 off := &Agent{task: taskRuntime{ledger: readinessLedger(writer, todo)}, turn: turnRuntime{deliveryScopeActive: true}, ablation: ablation.New(ablation.Evidence)}
20 if got := off.ReadinessResult().Reason; got != "" {
21 t.Fatalf("evidence ablation still gated the final answer: %q", got)
22 }
23
24 unrelated := &Agent{task: taskRuntime{ledger: readinessLedger(writer, todo)}, turn: turnRuntime{deliveryScopeActive: true}, ablation: ablation.New(ablation.Planner)}
25 if unrelated.ReadinessResult().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{agentConfig: agentConfig{contextWindow: 100_000, compactRatio: 0.8}}
32 if got := full.compactTrigger(); got != 80_000 {
33 t.Fatalf("control trigger = %d, want 80000", got)
34 }
35
36 off := &Agent{agentConfig: agentConfig{contextWindow: 100_000, compactRatio: 0.8}, ablation: ablation.New(ablation.Compaction)}
37 // Compaction ablation forces the sole trigger down to 50% so folds fire earlier.
38 if got := off.compactTrigger(); got != 50_000 {
39 t.Fatalf("ablated trigger = %d, want 50000", got)
40 }
41 }
42
42 lines GO