refactor(mcp-go): 拆除 search.Hybrid 残骸(T4.F)
- search.Hybrid 空转(NewHybrid 返空、Query 返 nil TODO)、构造后存进 Gateway 却从不被调用(真实 RAG 走 rag.Engine)→ 纯误导性死重量 - 删 internal/search 包 + gateway.go 字段/构造参数 + main.go 接线 - build/vet 干净;wiki_search 不受影响(本就用 g.rag) Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
+1
-1
@@ -200,7 +200,7 @@ RBAC 未做,暂以单管理员账号代理;概览口径必须是**系统级*
|
|||||||
- [ ] 性能:ListModels 去 O(N²)(admin.go:48)、KB/Agent 列表分页、报告分章检索缓存、Milvus 批量 ensure | S~M
|
- [ ] 性能:ListModels 去 O(N²)(admin.go:48)、KB/Agent 列表分页、报告分章检索缓存、Milvus 批量 ensure | S~M
|
||||||
- [ ] 可观测:panic 进 trace span + 回写通知、TTFT/token-s/各路检索耗时指标 | M
|
- [ ] 可观测:panic 进 trace span + 回写通知、TTFT/token-s/各路检索耗时指标 | M
|
||||||
- [ ] 配置化:切块大小 / history 轮数 / 各并发度 收口为统一可配 | S
|
- [ ] 配置化:切块大小 / history 轮数 / 各并发度 收口为统一可配 | S
|
||||||
- [ ] 删死代码 `mcp-go/internal/search/hybrid.go`(空壳,真实 RAG 在 rag.go)| S
|
- [x] 拆除 `search.Hybrid` 残骸 ✅ —— 该包空转(NewHybrid 返空、Query 返 nil)、构造后存进 Gateway 却从不调用(真 RAG 走 rag.Engine)。删整个 internal/search 包 + gateway/main.go 接线。build/vet 干净。(审计原说"死代码删文件"不准:它是接了线的残骸,需拆接线)
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
|
|||||||
@@ -15,7 +15,6 @@ import (
|
|||||||
"github.com/sundynix/sundynix-mcp-go/internal/mcp"
|
"github.com/sundynix/sundynix-mcp-go/internal/mcp"
|
||||||
"github.com/sundynix/sundynix-mcp-go/internal/memory"
|
"github.com/sundynix/sundynix-mcp-go/internal/memory"
|
||||||
"github.com/sundynix/sundynix-mcp-go/internal/rag"
|
"github.com/sundynix/sundynix-mcp-go/internal/rag"
|
||||||
"github.com/sundynix/sundynix-mcp-go/internal/search"
|
|
||||||
|
|
||||||
"github.com/sundynix/sundynix-shared/otelx"
|
"github.com/sundynix/sundynix-shared/otelx"
|
||||||
"github.com/sundynix/sundynix-shared/prompts"
|
"github.com/sundynix/sundynix-shared/prompts"
|
||||||
@@ -58,8 +57,7 @@ func main() {
|
|||||||
defer b.Close()
|
defer b.Close()
|
||||||
log.Printf("[mcp_go] connected %s", natsURL)
|
log.Printf("[mcp_go] connected %s", natsURL)
|
||||||
|
|
||||||
engine := search.NewHybrid() // LLM Wiki 混合检索:Bleve + Milvus + Neo4j
|
mem := memory.Open(pgDSN) // 偏好记忆:sundynix_user_profile(连不上则降级)
|
||||||
mem := memory.Open(pgDSN) // 偏好记忆:sundynix_user_profile(连不上则降级)
|
|
||||||
defer mem.Close()
|
defer mem.Close()
|
||||||
hist := history.Open(redisAddr) // 会话短期历史:Redis(连不上则降级)
|
hist := history.Open(redisAddr) // 会话短期历史:Redis(连不上则降级)
|
||||||
defer hist.Close()
|
defer hist.Close()
|
||||||
@@ -104,7 +102,7 @@ func main() {
|
|||||||
log.Printf("[mcp_go] subscribe prompts: %v", err)
|
log.Printf("[mcp_go] subscribe prompts: %v", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
gw := mcp.NewGateway(b, engine, mem, hist, ragEngine, pgDSN)
|
gw := mcp.NewGateway(b, mem, hist, ragEngine, pgDSN)
|
||||||
|
|
||||||
log.Println("[mcp_go] serving MCP over sundynix.tools.go.* (Ctrl-C to quit)")
|
log.Println("[mcp_go] serving MCP over sundynix.tools.go.* (Ctrl-C to quit)")
|
||||||
if err := gw.Serve(ctx); err != nil && err != context.Canceled {
|
if err := gw.Serve(ctx); err != nil && err != context.Canceled {
|
||||||
|
|||||||
@@ -21,13 +21,11 @@ import (
|
|||||||
"github.com/sundynix/sundynix-mcp-go/internal/memory"
|
"github.com/sundynix/sundynix-mcp-go/internal/memory"
|
||||||
"github.com/sundynix/sundynix-mcp-go/internal/office"
|
"github.com/sundynix/sundynix-mcp-go/internal/office"
|
||||||
"github.com/sundynix/sundynix-mcp-go/internal/rag"
|
"github.com/sundynix/sundynix-mcp-go/internal/rag"
|
||||||
"github.com/sundynix/sundynix-mcp-go/internal/search"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
// Gateway 暴露 MCP 协议端点,经共享 bus 订阅 sundynix.tools.go.* 响应调用。
|
// Gateway 暴露 MCP 协议端点,经共享 bus 订阅 sundynix.tools.go.* 响应调用。
|
||||||
type Gateway struct {
|
type Gateway struct {
|
||||||
bus *sharedbus.Bus
|
bus *sharedbus.Bus
|
||||||
search *search.Hybrid
|
|
||||||
memory *memory.Store
|
memory *memory.Store
|
||||||
history *history.Store
|
history *history.Store
|
||||||
rag *rag.Engine
|
rag *rag.Engine
|
||||||
@@ -60,8 +58,8 @@ type toolDef struct {
|
|||||||
handler func(context.Context, *contract.ToolCall) *contract.ToolResult
|
handler func(context.Context, *contract.ToolCall) *contract.ToolResult
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewGateway(b *sharedbus.Bus, s *search.Hybrid, m *memory.Store, h *history.Store, r *rag.Engine, pgDSN string) *Gateway {
|
func NewGateway(b *sharedbus.Bus, m *memory.Store, h *history.Store, r *rag.Engine, pgDSN string) *Gateway {
|
||||||
g := &Gateway{bus: b, search: s, memory: m, history: h, rag: r, pgDSN: pgDSN}
|
g := &Gateway{bus: b, memory: m, history: h, rag: r, pgDSN: pgDSN}
|
||||||
g.tools = g.buildRegistry()
|
g.tools = g.buildRegistry()
|
||||||
return g
|
return g
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,30 +0,0 @@
|
|||||||
// Package search 实现 LLM Wiki 混合检索引擎。
|
|
||||||
// Hybrid Search = Bleve(全文/BM25) + Milvus(向量) + Neo4j(知识图谱) 融合排序。
|
|
||||||
package search
|
|
||||||
|
|
||||||
import "context"
|
|
||||||
|
|
||||||
// Hybrid 聚合三路检索后端并做 RRF/加权融合。
|
|
||||||
type Hybrid struct {
|
|
||||||
// bleve *bleve.Index // Go 全文检索
|
|
||||||
// milvus client.Client // Vector DB (Milvus Go SDK)
|
|
||||||
// neo4j neo4j.DriverWithContext // Knowledge Graph
|
|
||||||
}
|
|
||||||
|
|
||||||
func NewHybrid() *Hybrid {
|
|
||||||
// TODO: 打开 bleve 索引;连接 Milvus;连接 Neo4j
|
|
||||||
return &Hybrid{}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Result 是融合后的检索结果。
|
|
||||||
type Result struct {
|
|
||||||
ID string
|
|
||||||
Score float64
|
|
||||||
Text string
|
|
||||||
}
|
|
||||||
|
|
||||||
// Query 并行查询三路后端并融合排序。
|
|
||||||
func (h *Hybrid) Query(ctx context.Context, q string, topK int) ([]Result, error) {
|
|
||||||
// TODO: 并发 bleve.Search + milvus.Search + neo4j Cypher,做 RRF 融合
|
|
||||||
return nil, nil
|
|
||||||
}
|
|
||||||
Reference in New Issue
Block a user