Spaces:
Running
Running
Apply adversarial-review fixes to the merged page and API route
Browse files- Source narrower: 'All sources (merged)' now clears the ?source
pre-highlight instead of being a dead option.
- eval-summary route: merged lookup failures degrade to the per-source
lookup/404 instead of a 500 (connection-reset race on the optional
merged table).
- hasMergedEvalsView: only cache the positive probe, so a transient
init failure of the optional parquet can't pin merged pages to
'absent' for the process lifetime.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
- app/api/eval-summary/route.ts +10 -3
- components/merged-benchmark-view.tsx +8 -1
- lib/view-data.ts +6 -1
app/api/eval-summary/route.ts
CHANGED
|
@@ -20,9 +20,16 @@ export async function GET(request: Request) {
|
|
| 20 |
if (isMergedEvalId(id)) {
|
| 21 |
const metricId = searchParams.get("metric")?.trim() || undefined
|
| 22 |
const sliceId = searchParams.get("slice")?.trim() || undefined
|
| 23 |
-
|
| 24 |
-
|
| 25 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 26 |
}
|
| 27 |
}
|
| 28 |
|
|
|
|
| 20 |
if (isMergedEvalId(id)) {
|
| 21 |
const metricId = searchParams.get("metric")?.trim() || undefined
|
| 22 |
const sliceId = searchParams.get("slice")?.trim() || undefined
|
| 23 |
+
try {
|
| 24 |
+
const merged = await getMergedBenchmarkSummary(routeIdFromSegments(id), metricId, sliceId)
|
| 25 |
+
if (merged) {
|
| 26 |
+
return NextResponse.json(merged)
|
| 27 |
+
}
|
| 28 |
+
} catch (error) {
|
| 29 |
+
// A connection reset can drop the optional merged table between
|
| 30 |
+
// the presence probe and the query — degrade to the per-source
|
| 31 |
+
// lookup/404 instead of a 500.
|
| 32 |
+
console.warn(`[eval-summary] merged lookup failed for ${id}:`, error)
|
| 33 |
}
|
| 34 |
}
|
| 35 |
|
components/merged-benchmark-view.tsx
CHANGED
|
@@ -221,7 +221,14 @@ export function MergedBenchmarkView({ benchmarkId }: { benchmarkId: string }) {
|
|
| 221 |
value={preselectedSource}
|
| 222 |
onChange={(e) => {
|
| 223 |
const slug = e.target.value
|
| 224 |
-
if (!slug)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 225 |
const source = summary.aggregate_sources.find((s) => s.composite_slug === slug)
|
| 226 |
if (source?.evaluation_id) {
|
| 227 |
// Navigate-on-select to the per-source page (spec Q5).
|
|
|
|
| 221 |
value={preselectedSource}
|
| 222 |
onChange={(e) => {
|
| 223 |
const slug = e.target.value
|
| 224 |
+
if (!slug) {
|
| 225 |
+
// Back to "All sources": clear the pre-highlight param.
|
| 226 |
+
const params = new URLSearchParams(searchParams.toString())
|
| 227 |
+
params.delete("source")
|
| 228 |
+
const qs = params.toString()
|
| 229 |
+
router.replace(qs ? `${pathname}?${qs}` : pathname)
|
| 230 |
+
return
|
| 231 |
+
}
|
| 232 |
const source = summary.aggregate_sources.find((s) => s.composite_slug === slug)
|
| 233 |
if (source?.evaluation_id) {
|
| 234 |
// Navigate-on-select to the per-source page (spec Q5).
|
lib/view-data.ts
CHANGED
|
@@ -1144,7 +1144,12 @@ async function hasMergedEvalsView(): Promise<boolean> {
|
|
| 1144 |
const rows = await readRows<{ n: number }>(
|
| 1145 |
"SELECT COUNT(*) AS n FROM information_schema.tables WHERE table_name = 'merged_evals_view'"
|
| 1146 |
)
|
| 1147 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1148 |
} catch {
|
| 1149 |
// Probe failed (connection blip) — don't cache; retry next request.
|
| 1150 |
return false
|
|
|
|
| 1144 |
const rows = await readRows<{ n: number }>(
|
| 1145 |
"SELECT COUNT(*) AS n FROM information_schema.tables WHERE table_name = 'merged_evals_view'"
|
| 1146 |
)
|
| 1147 |
+
const present = asNumber(rows[0]?.n) > 0
|
| 1148 |
+
// Cache only the positive: a transient init failure of the
|
| 1149 |
+
// optional parquet must not pin merged pages to "absent" for the
|
| 1150 |
+
// process lifetime — absent-table probes are trivial to repeat.
|
| 1151 |
+
if (present) mergedEvalsViewPresenceCache = true
|
| 1152 |
+
return present
|
| 1153 |
} catch {
|
| 1154 |
// Probe failed (connection blip) — don't cache; retry next request.
|
| 1155 |
return false
|