(t *testing.T)
| 150 | } |
| 151 | |
| 152 | func TestReplayExact_RAGSuccess(t *testing.T) { |
| 153 | dir := t.TempDir() |
| 154 | doc := filepath.Join(dir, "doc.txt") |
| 155 | if err := os.WriteFile(doc, []byte("replay rag chunk about InferCore routing.\n"), 0o644); err != nil { |
| 156 | t.Fatal(err) |
| 157 | } |
| 158 | cfg := replayTestConfig() |
| 159 | cfg.KnowledgeBases = []config.KnowledgeBaseConfig{ |
| 160 | {Name: "kb1", Type: "file", Path: dir}, |
| 161 | } |
| 162 | st := requests.NewMemoryStore() |
| 163 | req := types.AIRequest{ |
| 164 | RequestType: types.RequestTypeRAG, |
| 165 | TenantID: "team-a", |
| 166 | TaskType: "chat", |
| 167 | Priority: "high", |
| 168 | Context: map[string]any{ |
| 169 | "knowledge_base": "kb1", |
| 170 | "query": "routing", |
| 171 | }, |
| 172 | Input: map[string]any{"text": "routing"}, |
| 173 | Options: types.RequestOptions{Stream: false, MaxTokens: 64}, |
| 174 | } |
| 175 | full, _ := json.Marshal(req) |
| 176 | snap := types.PolicySnapshot{ |
| 177 | PrimaryBackend: "small-model", |
| 178 | PrimaryRouteReason: "test", |
| 179 | EstimatedCost: 1, |
| 180 | } |
| 181 | snapBytes, _ := json.Marshal(snap) |
| 182 | now := time.Now() |
| 183 | _ = st.CreateRequest(context.Background(), requests.RequestRow{ |
| 184 | RequestID: "rid-exact-rag", |
| 185 | TraceID: "trace-rag", |
| 186 | TenantID: req.TenantID, |
| 187 | TaskType: req.TaskType, |
| 188 | Priority: req.Priority, |
| 189 | RequestType: types.RequestTypeRAG, |
| 190 | PipelineRef: types.DefaultPipelineRAG, |
| 191 | AIRequestJSON: full, |
| 192 | PolicySnapshot: snapBytes, |
| 193 | SelectedBackend: "small-model", |
| 194 | CreatedAt: now, |
| 195 | UpdatedAt: now, |
| 196 | }) |
| 197 | ad := mock.New(cfg.Backends[0]) |
| 198 | retAdapters := retrieval.FromConfig(cfg) |
| 199 | deps := NewDependenciesFromConfig(cfg, map[string]interfaces.BackendAdapter{ |
| 200 | "small-model": ad, |
| 201 | }, retAdapters) |
| 202 | resp, err := Replay(context.Background(), cfg, st, "rid-exact-rag", ModeExact, deps) |
| 203 | if err != nil { |
| 204 | t.Fatalf("replay: %v", err) |
| 205 | } |
| 206 | if resp.Status != "success" { |
| 207 | t.Fatalf("status=%q", resp.Status) |
| 208 | } |
| 209 | if resp.RouteReason != "replay_exact" { |
nothing calls this directly
no test coverage detected