diff --git a/go/integration_test.go b/go/integration_test.go index d3061ee..b72e74f 100644 --- a/go/integration_test.go +++ b/go/integration_test.go @@ -293,7 +293,7 @@ func TestEdge_ConcurrentCommits(t *testing.T) { } func TestEdge_GapDetectionThreshold(t *testing.T) { - gd := selfoptimize.NewGapDetector() + gd := selfoptimize.NewGapDetector(nil, nil) // 2 misses — no gap if gap := gd.RecordMiss("test"); gap != nil { @@ -320,7 +320,7 @@ func TestEdge_GraphEmpty(t *testing.T) { t.Error("empty graph should return all zeros") } - paths, err := g.Navigate("nonexistent", 2, "shared") + paths, err := g.Navigate("nonexistent", 2, "shared", nil) if err != nil { t.Errorf("navigate on empty graph should not error: %v", err) } @@ -336,7 +336,8 @@ func TestEdge_TriggersFired(t *testing.T) { "X-API-Key": "zhiyi-dev-key-2026", } - body := map[string]string{"trigger_id": "t1"} + // 触发器 ID 与 routes.Triggers 一致(t1..t8 是 executor 的内部编号,不是 API ID) + body := map[string]string{"trigger_id": "t_decay"} req := httptest.NewRequest("POST", "/api/v1/triggers/fire", bytesBody(body)) for k, v := range header { req.Header.Set(k, v) diff --git a/go/internal/selfoptimize/bench_test.go b/go/internal/selfoptimize/bench_test.go index 36d633f..485b07e 100644 --- a/go/internal/selfoptimize/bench_test.go +++ b/go/internal/selfoptimize/bench_test.go @@ -52,7 +52,7 @@ func BenchmarkDashboard_RecordFeedback_Parallel(b *testing.B) { // ─── 缺口检测 ──────────────────────────────────────────── func BenchmarkGapDetector_RecordMiss(b *testing.B) { - gd := NewGapDetector() + gd := NewGapDetector(nil, nil) topics := []string{"config", "memory", "system", "docker", "nginx"} b.ResetTimer() for i := 0; i < b.N; i++ { @@ -61,7 +61,7 @@ func BenchmarkGapDetector_RecordMiss(b *testing.B) { } func BenchmarkGapDetector_List(b *testing.B) { - gd := NewGapDetector() + gd := NewGapDetector(nil, nil) // 预填充 100 个缺口 for i := 0; i < 100; i++ { topic := fmt.Sprintf("gap-%d", i) @@ -76,7 +76,7 @@ func BenchmarkGapDetector_List(b *testing.B) { } func BenchmarkGapDetector_Close(b *testing.B) { - gd := NewGapDetector() + gd := NewGapDetector(nil, nil) for i := 0; i < 100; i++ { topic := fmt.Sprintf("close-%d", i) for j := 0; j < 3; j++ { diff --git a/go/internal/selfoptimize/selfoptimize_test.go b/go/internal/selfoptimize/selfoptimize_test.go index 2363b1e..f698475 100644 --- a/go/internal/selfoptimize/selfoptimize_test.go +++ b/go/internal/selfoptimize/selfoptimize_test.go @@ -94,7 +94,7 @@ func TestDashboard_RecordConflictResolved(t *testing.T) { // ─── 知识缺口检测 ──────────────────────────────────────── func TestGapDetector_NotTriggeredBeforeThreshold(t *testing.T) { - gd := NewGapDetector() + gd := NewGapDetector(nil, nil) gap := gd.RecordMiss("kubernetes") if gap != nil { t.Error("should not trigger gap after 1 miss") @@ -106,7 +106,7 @@ func TestGapDetector_NotTriggeredBeforeThreshold(t *testing.T) { } func TestGapDetector_DetectsGapAtThreshold(t *testing.T) { - gd := NewGapDetector() + gd := NewGapDetector(nil, nil) gd.RecordMiss("topicX") gd.RecordMiss("topicX") gap := gd.RecordMiss("topicX") @@ -123,7 +123,7 @@ func TestGapDetector_DetectsGapAtThreshold(t *testing.T) { } func TestGapDetector_CloseGap(t *testing.T) { - gd := NewGapDetector() + gd := NewGapDetector(nil, nil) gd.RecordMiss("topic") gd.RecordMiss("topic") gd.RecordMiss("topic") @@ -136,7 +136,7 @@ func TestGapDetector_CloseGap(t *testing.T) { } func TestGapDetector_ClassifySynonym(t *testing.T) { - gd := NewGapDetector() + gd := NewGapDetector(nil, nil) gd.RecordMiss("API") gd.RecordMiss("API") gd.RecordMiss("API") @@ -277,7 +277,7 @@ func BenchmarkDashboardMetrics(b *testing.B) { } func BenchmarkGapDetection(b *testing.B) { - gd := NewGapDetector() + gd := NewGapDetector(nil, nil) b.ResetTimer() for i := 0; i < b.N; i++ { gd.RecordMiss("benchmark_topic")