|
1 | | -import type { EvalSuiteOverviewEntry, EvalSuiteRun, CommitGroup } from "./types"; |
| 1 | +import type { EvalSuiteRun, CommitGroup } from "./types"; |
2 | 2 |
|
3 | 3 | // --------------------------------------------------------------------------- |
4 | 4 | // Failure Classification |
@@ -110,132 +110,3 @@ export function classifyAllFailures( |
110 | 110 | }); |
111 | 111 | } |
112 | 112 |
|
113 | | -// --------------------------------------------------------------------------- |
114 | | -// AI Triage Data Preparation |
115 | | -// --------------------------------------------------------------------------- |
116 | | - |
117 | | -export interface TriageContext { |
118 | | - commitSha: string; |
119 | | - branch: string | null; |
120 | | - totalSuites: number; |
121 | | - totalCases: { total: number; passed: number; failed: number }; |
122 | | - failures: Array<{ |
123 | | - suiteName: string; |
124 | | - tags: FailureTag[]; |
125 | | - failedCases: number; |
126 | | - totalCases: number; |
127 | | - passRate: number; |
128 | | - testNames: string[]; |
129 | | - }>; |
130 | | - passedSuites: string[]; |
131 | | - notRunSuites: string[]; |
132 | | -} |
133 | | - |
134 | | -/** |
135 | | - * Build context object for the LLM triage prompt. |
136 | | - */ |
137 | | -export function buildTriageContext( |
138 | | - commitGroup: CommitGroup, |
139 | | - classifiedFailures: ClassifiedFailure[], |
140 | | - passedRuns: EvalSuiteRun[], |
141 | | - notRunRuns: EvalSuiteRun[], |
142 | | -): TriageContext { |
143 | | - const totalCases = { total: 0, passed: 0, failed: 0 }; |
144 | | - for (const run of commitGroup.runs) { |
145 | | - if (run.summary) { |
146 | | - totalCases.total += run.summary.total; |
147 | | - totalCases.passed += run.summary.passed; |
148 | | - totalCases.failed += run.summary.failed; |
149 | | - } |
150 | | - } |
151 | | - |
152 | | - return { |
153 | | - commitSha: commitGroup.shortSha, |
154 | | - branch: commitGroup.branch, |
155 | | - totalSuites: commitGroup.runs.length, |
156 | | - totalCases, |
157 | | - failures: classifiedFailures.map((cf) => ({ |
158 | | - suiteName: cf.suiteName, |
159 | | - tags: cf.tags, |
160 | | - failedCases: cf.run.summary?.failed ?? 0, |
161 | | - totalCases: cf.run.summary?.total ?? 0, |
162 | | - passRate: cf.run.summary |
163 | | - ? Math.round( |
164 | | - (cf.run.summary.passed / Math.max(cf.run.summary.total, 1)) * 100, |
165 | | - ) |
166 | | - : 0, |
167 | | - testNames: |
168 | | - cf.run.configSnapshot?.tests?.map((t) => t.title).filter(Boolean) ?? [], |
169 | | - })), |
170 | | - passedSuites: passedRuns.map( |
171 | | - (r) => commitGroup.suiteMap.get(r.suiteId) || "Unknown", |
172 | | - ), |
173 | | - notRunSuites: notRunRuns.map( |
174 | | - (r) => commitGroup.suiteMap.get(r.suiteId) || "Unknown", |
175 | | - ), |
176 | | - }; |
177 | | -} |
178 | | - |
179 | | -/** |
180 | | - * Build context for overview-level AI insights from all suites. |
181 | | - */ |
182 | | -export interface OverviewTriageContext { |
183 | | - totalSuites: number; |
184 | | - failingSuites: Array<{ |
185 | | - name: string; |
186 | | - tags: FailureTag[]; |
187 | | - passRate: string; |
188 | | - failedCases: number; |
189 | | - totalCases: number; |
190 | | - }>; |
191 | | - passingSuites: number; |
192 | | - neverRunSuites: number; |
193 | | -} |
194 | | - |
195 | | -export function buildOverviewTriageContext( |
196 | | - suites: EvalSuiteOverviewEntry[], |
197 | | - allCommitGroups: CommitGroup[], |
198 | | -): OverviewTriageContext { |
199 | | - const failingSuites: OverviewTriageContext["failingSuites"] = []; |
200 | | - let passingSuites = 0; |
201 | | - let neverRunSuites = 0; |
202 | | - |
203 | | - for (const entry of suites) { |
204 | | - if (!entry.latestRun) { |
205 | | - neverRunSuites++; |
206 | | - continue; |
207 | | - } |
208 | | - // Include suites that have any failed cases — even if the suite-level |
209 | | - // result is "passed" due to pass rate thresholds being met |
210 | | - const hasFailedCases = entry.totals.failed > 0; |
211 | | - const suiteResultFailed = entry.latestRun.result === "failed"; |
212 | | - |
213 | | - if (hasFailedCases || suiteResultFailed) { |
214 | | - const classified = classifyFailure( |
215 | | - entry.latestRun, |
216 | | - entry.suite.name, |
217 | | - allCommitGroups, |
218 | | - ); |
219 | | - const total = entry.totals.passed + entry.totals.failed; |
220 | | - failingSuites.push({ |
221 | | - name: entry.suite.name, |
222 | | - tags: classified.tags, |
223 | | - passRate: |
224 | | - total > 0 |
225 | | - ? `${Math.round((entry.totals.passed / total) * 100)}%` |
226 | | - : "--", |
227 | | - failedCases: entry.totals.failed, |
228 | | - totalCases: total, |
229 | | - }); |
230 | | - } else { |
231 | | - passingSuites++; |
232 | | - } |
233 | | - } |
234 | | - |
235 | | - return { |
236 | | - totalSuites: suites.length, |
237 | | - failingSuites, |
238 | | - passingSuites, |
239 | | - neverRunSuites, |
240 | | - }; |
241 | | -} |
0 commit comments