feat(category): implement recategorize backfill engine and fallback mapping (Spec §3.4-3.5 A4-A5)

This commit is contained in:
WeiCHEN
2026-09-13 02:50:20 +00:00
committed by weichen
parent 7d293833bf
commit e8002b2243
11 changed files with 557 additions and 13 deletions
+51
View File
@@ -0,0 +1,51 @@
package main
import (
"context"
"flag"
"fmt"
"os"
"time"
"chat-agent-system/internal/bizdev"
"chat-agent-system/internal/config"
)
func main() {
envPath := flag.String("env", ".env", "环境配置文件路径")
sessionID := flag.String("session", "", "指定处理的会话ID (留空则全量回填)")
flag.Parse()
cfg, err := config.Load(*envPath)
if err != nil {
fmt.Fprintf(os.Stderr, "加载配置失败: %v\n", err)
os.Exit(1)
}
svc := bizdev.NewService(cfg)
ctxMgr := svc.ContextManager()
if ctxMgr == nil {
fmt.Fprintf(os.Stderr, "ContextManager 未初始化\n")
os.Exit(1)
}
ctx, cancel := context.WithTimeout(context.Background(), 5*time.Minute)
defer cancel()
fmt.Println("==================================================================")
fmt.Println(" 🔄 历史消息分类回填与数据对齐工具 (Spec §3.4 A4) ")
fmt.Println("==================================================================")
if *sessionID != "" {
fmt.Printf("处理目标会话: %s\n", *sessionID)
} else {
fmt.Println("处理目标: 全量历史消息")
}
res, err := ctxMgr.RecategorizeMessages(ctx, *sessionID)
if err != nil {
fmt.Fprintf(os.Stderr, "分类回填失败: %v\n", err)
os.Exit(1)
}
fmt.Printf("✅ 分类回填完成!\n已扫描消息数: %d\n已更新分类数: %d\n", res.TotalProcessed, res.TotalUpdated)
}