2 Commits

Author SHA1 Message Date
91a15baebc feat: Podman-Status im Setup und Schritt-Ansicht je Lauf
Setup zeigt, ob der Container-Befehl läuft (Version). Ergebnistabelle hat
eine Schritte-Ansicht: Nachrichten, Tool-Aufrufe und Tool-Antworten eines
Laufs aus der Datenbank. Store-Test grün, 53 Unit-Tests insgesamt.

Co-Authored-By: Claude Haiku 5.5 <noreply@anthropic.com>
2026-11-07 11:55:56 +01:00
668e690cda feat: Rangliste und Matrix für Batches
ranking.rs: Gesamtscore je Modell (gewichtet nach weight aus task.toml),
Median-Dauer und Completion-Tokens als Tie-Breaker, Matrix Modell × Aufgabe
mit Erfolgen und mittlerem Score. Befehl batch_ranking, Anzeige nach dem
Batch. 5 Unit-Tests grün, 47 insgesamt. Wilson-Intervalle folgen mit F-12.

Co-Authored-By: Claude Haiku 5.5 <noreply@anthropic.com>
2026-11-07 11:54:28 +01:00
5 changed files with 499 additions and 4 deletions

View File

@ -26,7 +26,7 @@ Zeichen: ✓ fertig · ◐ teilweise · ✗ offen · ? nicht geprüft.
| #1006 | F-06 SQLite inkl. Schritt-Log | SPEC 8, 12 | ◐ | `store.rs`: Tabellen `batch`, `run`, `step` nach SPEC 8, Lauf und Schritte in einer Transaktion. Datei `coding-bench.sqlite` im Datenordner, wird beim Start angelegt. Lesen über `batch_results`. Getestet in-memory und im Batch (→ #1023) | | #1006 | F-06 SQLite inkl. Schritt-Log | SPEC 8, 12 | ◐ | `store.rs`: Tabellen `batch`, `run`, `step` nach SPEC 8, Lauf und Schritte in einer Transaktion. Datei `coding-bench.sqlite` im Datenordner, wird beim Start angelegt. Lesen über `batch_results`. Getestet in-memory und im Batch (→ #1023) |
| #1007 | F-07 Tests a-01 bis a-03 und b-04 bis b-06 | SPEC 11, 12 | ◐ | Aufgaben liegen unter `tasks/`, gültig geladen (Test `repo_aufgaben_sind_gueltig`). Musterlösungen bestehen alle Checks, leere Lösung scheitert. Mit `qwen3:0.6b` 0 von 6 bestanden. Mit `qwen3.8-flash-next-q2_0` über strata (OpenAI-Format, LAN) 6 von 6 bestanden, Score 1.00 (Testbericht `testberichte/2026-11-06-strata-lauf.md`) (→ #1024) | | #1007 | F-07 Tests a-01 bis a-03 und b-04 bis b-06 | SPEC 11, 12 | ◐ | Aufgaben liegen unter `tasks/`, gültig geladen (Test `repo_aufgaben_sind_gueltig`). Musterlösungen bestehen alle Checks, leere Lösung scheitert. Mit `qwen3:0.6b` 0 von 6 bestanden. Mit `qwen3.8-flash-next-q2_0` über strata (OpenAI-Format, LAN) 6 von 6 bestanden, Score 1.00 (Testbericht `testberichte/2026-11-06-strata-lauf.md`) (→ #1024) |
| #1008 | F-08 GUI: Setup, Batch starten, Live-Fortschritt | SPEC 10, 12 | ◐ | Setup zeigt Pfade und Aufgaben, Batch-Start mit Modellen, Wiederholungen, Abbrechen, Fortschritt und Ergebnistabelle gebaut. `svelte-check` 0 Fehler. Nicht im Fenster geprüft; Klicktests `batch2fortsetzen.1–.2` offen (→ #1025) | | #1008 | F-08 GUI: Setup, Batch starten, Live-Fortschritt | SPEC 10, 12 | ◐ | Setup zeigt Pfade und Aufgaben, Batch-Start mit Modellen, Wiederholungen, Abbrechen, Fortschritt und Ergebnistabelle gebaut. `svelte-check` 0 Fehler. Nicht im Fenster geprüft; Klicktests `batch2fortsetzen.1–.2` offen (→ #1025) |
| #1009 | F-09 Rangliste und Matrix | SPEC 9, 10, 12 | ✗ | noch nicht begonnen (→ #1026) | | #1009 | F-09 Rangliste und Matrix | SPEC 9, 10, 12 | ◐ | `ranking.rs`: Gesamtscore (gewichtet), Median-Dauer, Tie-Breaker, Matrix Modell × Aufgabe. 5 Unit-Tests grün. Oberfläche zeigt beides nach dem Batch. Ohne Intervall und Kategorie-Ranking (F-12). Klicktest `ergebnis2detail.1` manuell offen (→ #1026) |
| #1010 | F-10 Tests c-07 bis c-09 | SPEC 11, 12 | ✗ | Phase 2 (→ #1027) | | #1010 | F-10 Tests c-07 bis c-09 | SPEC 11, 12 | ✗ | Phase 2 (→ #1027) |
| #1011 | F-11 Adapter Aider-Polyglot-Teilmenge | SPEC 12 | ✗ | Phase 2 (→ #1028) | | #1011 | F-11 Adapter Aider-Polyglot-Teilmenge | SPEC 12 | ✗ | Phase 2 (→ #1028) |
| #1012 | F-12 Kategorie-Ranking, Wilson-Intervalle, Markierung | SPEC 9, 12 | ✗ | Phase 2 (→ #1029) | | #1012 | F-12 Kategorie-Ranking, Wilson-Intervalle, Markierung | SPEC 9, 12 | ✗ | Phase 2 (→ #1029) |
@ -51,8 +51,8 @@ Zeichen: ✓ fertig · ◐ teilweise · ✗ offen · ? nicht geprüft.
- [#1022] **Runner.** Umgesetzt in `src-tauri/src/runner.rs`, über `start_batch` und `cancel_batch` an die Oberfläche angebunden. Offen: Abbruch in der App real prüfen, Modelle mit eigenem Endpunkt in der Config (Phase 1 hat einen gemeinsamen `ollama_url`). Tests `batch2fortsetzen.1–.2`. → #1005 - [#1022] **Runner.** Umgesetzt in `src-tauri/src/runner.rs`, über `start_batch` und `cancel_batch` an die Oberfläche angebunden. Offen: Abbruch in der App real prüfen, Modelle mit eigenem Endpunkt in der Config (Phase 1 hat einen gemeinsamen `ollama_url`). Tests `batch2fortsetzen.1–.2`. → #1005
- [#1023] **SQLite-Speicher.** Umgesetzt in `src-tauri/src/store.rs`, Schema nach SPEC 8. Datei-Datenbank im Datenordner angebunden. Offen: Klicktest `lauf2ergebnis.2` mit Schritt-Ansicht (noch keine Oberfläche dafür). Tests `lauf2ergebnis.2`. → #1006 - [#1023] **SQLite-Speicher.** Umgesetzt in `src-tauri/src/store.rs`, Schema nach SPEC 8. Datei-Datenbank im Datenordner angebunden. Offen: Klicktest `lauf2ergebnis.2` mit Schritt-Ansicht (noch keine Oberfläche dafür). Tests `lauf2ergebnis.2`. → #1006
- [#1024] **Aufgaben a-01 bis a-03, b-04 bis b-06 schreiben.** Geschrieben unter `tasks/`. b-06 mit Mutationstest; ein Fehler im Check (veralteter Bytecode bei Mutanten) ist behoben. Ergebnis: mit `qwen3.8-flash-next-q2_0` über strata 6 von 6 bestanden. Bericht in `testberichte/`. Offen: Zeitlimit von b-04 bei langsamen Modellen prüfen. → #1007 - [#1024] **Aufgaben a-01 bis a-03, b-04 bis b-06 schreiben.** Geschrieben unter `tasks/`. b-06 mit Mutationstest; ein Fehler im Check (veralteter Bytecode bei Mutanten) ist behoben. Ergebnis: mit `qwen3.8-flash-next-q2_0` über strata 6 von 6 bestanden. Bericht in `testberichte/`. Offen: Zeitlimit von b-04 bei langsamen Modellen prüfen. → #1007
- [#1025] **GUI Setup und Batch.** Gebaut: Pfade, Aufgabenauswahl, Modelle, Wiederholungen, Start, Abbrechen, Live-Log, Ergebnistabelle. Offen: Podman-Status im Setup, Schritt-Log in der Oberfläche, Klicktest `batch2fortsetzen.1` manuell. → #1008 - [#1025] **GUI Setup und Batch.** Gebaut: Pfade, Container-Status (Podman-Version im Setup), Aufgabenauswahl, Modelle, Wiederholungen, Start, Abbrechen, Live-Log, Ergebnistabelle, Rangliste und Matrix, Schritt-Ansicht je Lauf. Offen: Klicktests `batch2fortsetzen.1` und `lauf2ergebnis.2` manuell, Oberfläche im Fenster ansehen. → #1008
- [#1026] **Rangliste und Matrix.** Gesamtscore mit Intervall, Matrix Modell × Test nach Erfolgsquote, Lauf-Detail. Tests `ergebnis2detail.1`. → #1009 - [#1026] **Rangliste und Matrix.** Gebaut: Gesamtscore (gewichtet nach `weight`), Median-Dauer als Tie-Breaker, Matrix Modell × Aufgabe mit Erfolgen und Farbe nach Score. Offen: Wilson-Intervall und „nicht unterscheidbar“ (F-12, Phase 2), Lauf-Detail mit Schrittliste, Klicktest `ergebnis2detail.1` manuell. Tests `ergebnis2detail.1`. → #1009
**P2 – danach (Release 0.2.0, Referenz und Tiefe)** **P2 – danach (Release 0.2.0, Referenz und Tiefe)**
- [#1027] **Tests c-07 bis c-09.** Neuer CLI-Parameter, Refactoring, Stacktrace-Fehler. → #1010 - [#1027] **Tests c-07 bis c-09.** Neuer CLI-Parameter, Refactoring, Stacktrace-Fehler. → #1010

View File

@ -1,5 +1,6 @@
mod agent; mod agent;
mod config; mod config;
mod ranking;
mod runner; mod runner;
mod sandbox; mod sandbox;
mod store; mod store;
@ -120,6 +121,62 @@ fn batch_results(paths: State<'_, AppPaths>, batch_id: i64) -> Result<Vec<RunRec
store.runs_for_batch(batch_id) store.runs_for_batch(batch_id)
} }
/// Schritte eines einzelnen Laufs für die Detailansicht.
#[tauri::command]
fn run_steps(
paths: State<'_, AppPaths>,
batch_id: i64,
model: String,
task_id: String,
repeat_idx: u32,
) -> Result<Vec<store::StepRow>, String> {
let store = Store::open(&paths.0.data_dir.join(DB_FILE))?;
store.steps_for_run(batch_id, &model, &task_id, repeat_idx)
}
/// Zustand der Container-Laufzeit (Podman) für das Setup.
#[derive(serde::Serialize)]
pub struct RuntimeStatus {
pub program: String,
pub available: bool,
pub detail: String,
}
#[tauri::command]
fn runtime_status(cfg: State<'_, Config>) -> RuntimeStatus {
let program = cfg.container_runtime.clone();
match std::process::Command::new(&program).args(["version", "--format", "{{.Client.Version}}"]).output() {
Ok(out) if out.status.success() => RuntimeStatus {
program,
available: true,
detail: format!("Version {}", String::from_utf8_lossy(&out.stdout).trim()),
},
Ok(out) => RuntimeStatus {
program,
available: false,
detail: String::from_utf8_lossy(&out.stderr).trim().to_string(),
},
Err(e) => RuntimeStatus {
program,
available: false,
detail: format!("nicht startbar: {e}"),
},
}
}
/// Rangliste und Matrix eines Batches. Gewichte kommen aus den Aufgaben.
#[tauri::command]
fn batch_ranking(paths: State<'_, AppPaths>, batch_id: i64) -> Result<ranking::Ranking, String> {
let store = Store::open(&paths.0.data_dir.join(DB_FILE))?;
let runs = store.runs_for_batch(batch_id)?;
let weights: std::collections::BTreeMap<String, f64> = tasks::load_all(&paths.0.tasks_dir)
.tasks
.into_iter()
.map(|t| (t.meta.id, t.meta.weight))
.collect();
Ok(ranking::compute(batch_id, &runs, &weights))
}
#[cfg_attr(mobile, tauri::mobile_entry_point)] #[cfg_attr(mobile, tauri::mobile_entry_point)]
pub fn run() { pub fn run() {
tauri::Builder::default() tauri::Builder::default()
@ -149,7 +206,10 @@ pub fn run() {
load_tasks, load_tasks,
start_batch, start_batch,
cancel_batch, cancel_batch,
batch_results batch_results,
batch_ranking,
run_steps,
runtime_status
]) ])
.run(tauri::generate_context!()) .run(tauri::generate_context!())
.expect("error while running tauri application"); .expect("error while running tauri application");

225
src-tauri/src/ranking.rs Normal file
View File

@ -0,0 +1,225 @@
//! Rangliste und Matrix aus den Läufen eines Batches (F-09, SPEC Abschnitt 9).
//!
//! Gesamtscore je Modell: gewichteter Mittelwert der Aufgaben-Scores (`weight` aus
//! `task.toml`). Erfolgsquote je (Modell, Aufgabe): Anteil der Läufe mit Klasse `ok`.
//! Tie-Breaker: Median der Dauer, dann mittlere Completion-Tokens. Wilson-Intervalle
//! und Kategorie-Ranking folgen mit F-12 (Phase 2).
use crate::agent::ErrorClass;
use crate::store::RunRecord;
use serde::Serialize;
use std::collections::BTreeMap;
#[derive(Debug, Clone, PartialEq, Serialize)]
pub struct ModelRank {
pub rank: usize,
pub model: String,
/// Gewichteter Mittelwert der Aufgaben-Scores, 0.0 bis 1.0.
pub total_score: f64,
pub runs: usize,
pub successes: usize,
pub median_duration_ms: u128,
pub mean_completion_tokens: f64,
}
#[derive(Debug, Clone, PartialEq, Serialize)]
pub struct MatrixCell {
pub model: String,
pub task_id: String,
pub runs: usize,
pub successes: usize,
/// Mittlerer Score über die Wiederholungen.
pub mean_score: f64,
}
#[derive(Debug, Clone, PartialEq, Serialize)]
pub struct Ranking {
pub batch_id: i64,
pub models: Vec<ModelRank>,
pub cells: Vec<MatrixCell>,
pub tasks: Vec<String>,
}
/// Berechnet Rangliste und Matrix. `weights` ordnet jeder Aufgaben-ID ihr Gewicht zu;
/// fehlt eine ID, zählt das Gewicht 1.0.
pub fn compute(batch_id: i64, runs: &[RunRecord], weights: &BTreeMap<String, f64>) -> Ranking {
let weight_of = |task: &str| weights.get(task).copied().unwrap_or(1.0);
// Pro Modell: Liste der Läufe.
let mut by_model: BTreeMap<&str, Vec<&RunRecord>> = BTreeMap::new();
for r in runs {
by_model.entry(r.model.as_str()).or_default().push(r);
}
let mut models: Vec<ModelRank> = by_model
.iter()
.map(|(model, rs)| {
// Mittelwert je Aufgabe, dann gewichtet über die Aufgaben.
let mut per_task: BTreeMap<&str, (f64, usize)> = BTreeMap::new();
for r in rs {
let e = per_task.entry(r.task_id.as_str()).or_insert((0.0, 0));
e.0 += r.score;
e.1 += 1;
}
let (mut wsum, mut wtotal) = (0.0, 0.0);
for (task, (sum, n)) in &per_task {
let w = weight_of(task);
wsum += w * (sum / *n as f64);
wtotal += w;
}
let total_score = if wtotal > 0.0 { wsum / wtotal } else { 0.0 };
let mut durations: Vec<u128> = rs.iter().map(|r| r.duration_ms).collect();
durations.sort_unstable();
let median = median_u128(&durations);
let mean_tokens = rs.iter().map(|r| r.completion_tokens as f64).sum::<f64>() / rs.len() as f64;
let successes = rs.iter().filter(|r| r.error_class == ErrorClass::Ok).count();
ModelRank {
rank: 0,
model: model.to_string(),
total_score,
runs: rs.len(),
successes,
median_duration_ms: median,
mean_completion_tokens: mean_tokens,
}
})
.collect();
// Absteigend nach Score, dann Median-Dauer, dann mittlere Completion-Tokens.
models.sort_by(|a, b| {
b.total_score
.partial_cmp(&a.total_score)
.unwrap_or(std::cmp::Ordering::Equal)
.then(a.median_duration_ms.cmp(&b.median_duration_ms))
.then(
a.mean_completion_tokens
.partial_cmp(&b.mean_completion_tokens)
.unwrap_or(std::cmp::Ordering::Equal),
)
});
for (i, m) in models.iter_mut().enumerate() {
m.rank = i + 1;
}
// Matrix Modell × Aufgabe.
let mut cell_map: BTreeMap<(&str, &str), Vec<&RunRecord>> = BTreeMap::new();
let mut task_set: BTreeMap<&str, ()> = BTreeMap::new();
for r in runs {
cell_map
.entry((r.model.as_str(), r.task_id.as_str()))
.or_default()
.push(r);
task_set.insert(r.task_id.as_str(), ());
}
let cells = cell_map
.iter()
.map(|((model, task), rs)| MatrixCell {
model: model.to_string(),
task_id: task.to_string(),
runs: rs.len(),
successes: rs.iter().filter(|r| r.error_class == ErrorClass::Ok).count(),
mean_score: rs.iter().map(|r| r.score).sum::<f64>() / rs.len() as f64,
})
.collect();
Ranking {
batch_id,
models,
cells,
tasks: task_set.keys().map(|t| t.to_string()).collect(),
}
}
fn median_u128(sorted: &[u128]) -> u128 {
match sorted.len() {
0 => 0,
n if n % 2 == 1 => sorted[n / 2],
n => (sorted[n / 2 - 1] + sorted[n / 2]) / 2,
}
}
#[cfg(test)]
mod tests {
use super::*;
fn run(model: &str, task: &str, score: f64, class: ErrorClass, dur: u128, tokens: u32) -> RunRecord {
RunRecord {
batch_id: 1,
model: model.into(),
task_id: task.into(),
repeat_idx: 1,
error_class: class,
score,
steps: 3,
prompt_tokens: 0,
completion_tokens: tokens,
duration_ms: dur,
tps: None,
ttft_tool_ms: None,
artifact_path: None,
summary: None,
check_output: String::new(),
}
}
#[test]
fn gewichteter_score_und_rang() {
let runs = vec![
run("A", "t1", 1.0, ErrorClass::Ok, 1000, 10),
run("A", "t2", 0.0, ErrorClass::CheckFailed, 1000, 10),
run("B", "t1", 1.0, ErrorClass::Ok, 1000, 10),
run("B", "t2", 1.0, ErrorClass::Ok, 1000, 10),
];
let mut w = BTreeMap::new();
w.insert("t1".to_string(), 1.0);
w.insert("t2".to_string(), 3.0);
let r = compute(1, &runs, &w);
assert_eq!(r.models[0].model, "B");
assert_eq!(r.models[0].rank, 1);
assert!((r.models[0].total_score - 1.0).abs() < 1e-9);
// A: (1*1 + 3*0) / 4 = 0.25
assert!((r.models[1].total_score - 0.25).abs() < 1e-9);
}
#[test]
fn gleichstand_nach_median_dauer() {
let runs = vec![
run("slow", "t1", 1.0, ErrorClass::Ok, 9000, 10),
run("fast", "t1", 1.0, ErrorClass::Ok, 2000, 10),
];
let r = compute(1, &runs, &BTreeMap::new());
assert_eq!(r.models[0].model, "fast");
}
#[test]
fn matrix_zaehlt_erfolge_und_mittelwert() {
let runs = vec![
run("A", "t1", 1.0, ErrorClass::Ok, 1, 1),
run("A", "t1", 0.5, ErrorClass::CheckFailed, 1, 1),
run("A", "t1", 0.0, ErrorClass::MaxSteps, 1, 1),
];
let r = compute(1, &runs, &BTreeMap::new());
assert_eq!(r.cells.len(), 1);
assert_eq!(r.cells[0].runs, 3);
assert_eq!(r.cells[0].successes, 1);
assert!((r.cells[0].mean_score - 0.5).abs() < 1e-9);
assert_eq!(r.tasks, vec!["t1".to_string()]);
}
#[test]
fn median_gerade_und_ungerade() {
assert_eq!(median_u128(&[1, 2, 3]), 2);
assert_eq!(median_u128(&[1, 2, 3, 4]), 2);
assert_eq!(median_u128(&[]), 0);
}
#[test]
fn leerer_batch_ergibt_leere_rangliste() {
let r = compute(7, &[], &BTreeMap::new());
assert!(r.models.is_empty() && r.cells.is_empty() && r.tasks.is_empty());
assert_eq!(r.batch_id, 7);
}
}

View File

@ -50,6 +50,17 @@ CREATE TABLE IF NOT EXISTS step (
"; ";
/// Ein abgeschlossener Lauf, so wie er gespeichert wird. /// Ein abgeschlossener Lauf, so wie er gespeichert wird.
/// Ein Schritt eines Laufs, für die Anzeige.
#[derive(Debug, Clone, PartialEq, Serialize)]
pub struct StepRow {
pub idx: i64,
pub role: String,
pub content: String,
pub tool_name: Option<String>,
pub tool_args_json: Option<String>,
pub tool_result: Option<String>,
}
#[derive(Debug, Clone, PartialEq, Serialize)] #[derive(Debug, Clone, PartialEq, Serialize)]
pub struct RunRecord { pub struct RunRecord {
pub batch_id: i64, pub batch_id: i64,
@ -217,6 +228,38 @@ impl Store {
rows.collect::<Result<Vec<_>, _>>().map_err(|e| e.to_string()) rows.collect::<Result<Vec<_>, _>>().map_err(|e| e.to_string())
} }
/// Schritte eines Laufs, identifiziert über Batch, Modell, Aufgabe und Wiederholung.
pub fn steps_for_run(
&self,
batch_id: i64,
model: &str,
task_id: &str,
repeat_idx: u32,
) -> Result<Vec<StepRow>, String> {
let mut stmt = self
.conn
.prepare(
"SELECT s.idx, s.role, s.content, s.tool_name, s.tool_args_json, s.tool_result
FROM step s JOIN run r ON s.run_id = r.id
WHERE r.batch_id = ?1 AND r.model = ?2 AND r.task_id = ?3 AND r.repeat_idx = ?4
ORDER BY s.idx",
)
.map_err(|e| e.to_string())?;
let rows = stmt
.query_map(params![batch_id, model, task_id, repeat_idx], |r| {
Ok(StepRow {
idx: r.get(0)?,
role: r.get(1)?,
content: r.get(2)?,
tool_name: r.get(3)?,
tool_args_json: r.get(4)?,
tool_result: r.get(5)?,
})
})
.map_err(|e| e.to_string())?;
rows.collect::<Result<Vec<_>, _>>().map_err(|e| e.to_string())
}
pub fn run_count(&self, batch_id: i64) -> Result<i64, String> { pub fn run_count(&self, batch_id: i64) -> Result<i64, String> {
self.conn self.conn
.query_row("SELECT COUNT(*) FROM run WHERE batch_id = ?1", params![batch_id], |r| r.get(0)) .query_row("SELECT COUNT(*) FROM run WHERE batch_id = ?1", params![batch_id], |r| r.get(0))
@ -301,6 +344,19 @@ mod tests {
assert!(s.runs_for_batch(99).unwrap().is_empty()); assert!(s.runs_for_batch(99).unwrap().is_empty());
} }
#[test]
fn schritte_eines_laufs_werden_gefunden() {
let mut s = Store::open_in_memory().unwrap();
let b = s.create_batch("", 1, "{}").unwrap();
let transcript = vec![Message::new("user", "Aufgabe"), Message::new("assistant", "ok")];
s.insert_run(&rec(b, "m1", "a-01", 1), &transcript).unwrap();
let steps = s.steps_for_run(b, "m1", "a-01", 1).unwrap();
assert_eq!(steps.len(), 2);
assert_eq!(steps[0].role, "user");
assert_eq!(steps[1].content, "ok");
assert!(s.steps_for_run(b, "m1", "a-01", 2).unwrap().is_empty());
}
#[test] #[test]
fn unbekannter_batch_existiert_nicht() { fn unbekannter_batch_existiert_nicht() {
let s = Store::open_in_memory().unwrap(); let s = Store::open_in_memory().unwrap();

View File

@ -44,6 +44,29 @@
let progress = $state<{ done: number; total: number } | null>(null); let progress = $state<{ done: number; total: number } | null>(null);
let batchId = $state<number | null>(null); let batchId = $state<number | null>(null);
let rows = $state<RunRow[]>([]); let rows = $state<RunRow[]>([]);
type ModelRank = {
rank: number;
model: string;
total_score: number;
runs: number;
successes: number;
median_duration_ms: number;
mean_completion_tokens: number;
};
type MatrixCell = { model: string; task_id: string; runs: number; successes: number; mean_score: number };
type Ranking = { batch_id: number; models: ModelRank[]; cells: MatrixCell[]; tasks: string[] };
let ranking = $state<Ranking | null>(null);
type RuntimeStatus = { program: string; available: boolean; detail: string };
type StepRow = {
idx: number;
role: string;
content: string;
tool_name: string | null;
tool_args_json: string | null;
tool_result: string | null;
};
let runtime = $state<RuntimeStatus | null>(null);
let detail = $state<{ model: string; task_id: string; repeat_idx: number; steps: StepRow[] } | null>(null);
let batchError = $state(""); let batchError = $state("");
let unlisten: UnlistenFn | null = null; let unlisten: UnlistenFn | null = null;
@ -54,6 +77,11 @@
} catch (e) { } catch (e) {
error = String(e); error = String(e);
} }
try {
runtime = await invoke<RuntimeStatus>("runtime_status");
} catch (e) {
runtime = { program: "?", available: false, detail: String(e) };
}
try { try {
report = await invoke<LoadReport>("load_tasks"); report = await invoke<LoadReport>("load_tasks");
} catch (e) { } catch (e) {
@ -98,6 +126,7 @@
async function start() { async function start() {
batchError = ""; batchError = "";
rows = []; rows = [];
ranking = null;
log = []; log = [];
progress = null; progress = null;
batchId = null; batchId = null;
@ -111,6 +140,7 @@
}); });
batchId = summary.batch_id; batchId = summary.batch_id;
rows = await invoke<RunRow[]>("batch_results", { batchId: summary.batch_id }); rows = await invoke<RunRow[]>("batch_results", { batchId: summary.batch_id });
ranking = await invoke<Ranking>("batch_ranking", { batchId: summary.batch_id });
if (summary.cancelled) log = [...log, "Batch abgebrochen."]; if (summary.cancelled) log = [...log, "Batch abgebrochen."];
} catch (e) { } catch (e) {
batchError = String(e); batchError = String(e);
@ -119,6 +149,17 @@
} }
} }
async function showSteps(r: RunRow) {
if (batchId === null) return;
const steps = await invoke<StepRow[]>("run_steps", {
batchId,
model: r.model,
taskId: r.task_id,
repeatIdx: r.repeat_idx,
});
detail = { model: r.model, task_id: r.task_id, repeat_idx: r.repeat_idx, steps };
}
async function cancel() { async function cancel() {
await invoke<boolean>("cancel_batch"); await invoke<boolean>("cancel_batch");
} }
@ -139,6 +180,18 @@
<dd><code>{paths.data_dir}</code></dd> <dd><code>{paths.data_dir}</code></dd>
<dt>Aufgabenordner</dt> <dt>Aufgabenordner</dt>
<dd><code>{paths.tasks_dir}</code></dd> <dd><code>{paths.tasks_dir}</code></dd>
<dt>Container</dt>
<dd>
{#if runtime}
{#if runtime.available}
<span class="ok">{runtime.program} verfügbar, {runtime.detail}</span>
{:else}
<span class="fehler">{runtime.program} nicht nutzbar: {runtime.detail}</span>
{/if}
{:else}
Prüfe …
{/if}
</dd>
</dl> </dl>
{:else} {:else}
<p>Lade Pfade …</p> <p>Lade Pfade …</p>
@ -211,6 +264,65 @@
{/if} {/if}
</section> </section>
{#if ranking && ranking.models.length > 0}
<section>
<h2>Rangliste, Batch {ranking.batch_id}</h2>
<table>
<thead>
<tr>
<th>Rang</th>
<th>Modell</th>
<th>Score</th>
<th>Erfolge</th>
<th>Median-Dauer</th>
<th>Ø Completion-Tokens</th>
</tr>
</thead>
<tbody>
{#each ranking.models as m (m.model)}
<tr>
<td>{m.rank}</td>
<td>{m.model}</td>
<td>{m.total_score.toFixed(2)}</td>
<td>{m.successes} / {m.runs}</td>
<td>{(m.median_duration_ms / 1000).toFixed(1)} s</td>
<td>{m.mean_completion_tokens.toFixed(0)}</td>
</tr>
{/each}
</tbody>
</table>
<h3>Matrix: Erfolge je Aufgabe</h3>
<table class="matrix">
<thead>
<tr>
<th>Modell</th>
{#each ranking.tasks as t (t)}
<th>{t}</th>
{/each}
</tr>
</thead>
<tbody>
{#each ranking.models as m (m.model)}
<tr>
<td>{m.model}</td>
{#each ranking.tasks as t (t)}
{@const cell = ranking.cells.find((c) => c.model === m.model && c.task_id === t)}
<td
class="zelle"
style={cell ? `background: color-mix(in srgb, #2e7d32 ${Math.round(cell.mean_score * 100)}%, transparent)` : ""}
title={cell ? `Score ${cell.mean_score.toFixed(2)}` : "keine Läufe"}
>
{cell ? `${cell.successes}/${cell.runs}` : "–"}
</td>
{/each}
</tr>
{/each}
</tbody>
</table>
</section>
{/if}
{#if batchId !== null && rows.length > 0} {#if batchId !== null && rows.length > 0}
<section> <section>
<h2>Ergebnisse, Batch {batchId}</h2> <h2>Ergebnisse, Batch {batchId}</h2>
@ -224,6 +336,7 @@
<th>Score</th> <th>Score</th>
<th>Schritte</th> <th>Schritte</th>
<th>Dauer</th> <th>Dauer</th>
<th></th>
</tr> </tr>
</thead> </thead>
<tbody> <tbody>
@ -236,10 +349,31 @@
<td>{r.score.toFixed(2)}</td> <td>{r.score.toFixed(2)}</td>
<td>{r.steps}</td> <td>{r.steps}</td>
<td>{(r.duration_ms / 1000).toFixed(1)} s</td> <td>{(r.duration_ms / 1000).toFixed(1)} s</td>
<td><button onclick={() => showSteps(r)}>Schritte</button></td>
</tr> </tr>
{/each} {/each}
</tbody> </tbody>
</table> </table>
{#if detail}
<h3>Schritte: {detail.model} · {detail.task_id} · Wdh. {detail.repeat_idx}</h3>
<ol class="schritte">
{#each detail.steps as st (st.idx)}
<li>
<strong>{st.role}</strong>
{#if st.tool_name}
· Tool <code>{st.tool_name}</code> <code>{st.tool_args_json ?? ""}</code>
{/if}
{#if st.content}
<pre>{st.content}</pre>
{/if}
{#if st.tool_result}
<pre class="ergebnis">{st.tool_result}</pre>
{/if}
</li>
{/each}
</ol>
{/if}
</section> </section>
{/if} {/if}
</main> </main>
@ -326,4 +460,24 @@
.fehler { .fehler {
color: #c62828; color: #c62828;
} }
.ok {
color: #2e7d32;
}
.schritte pre {
white-space: pre-wrap;
overflow-wrap: anywhere;
max-height: 12rem;
overflow-y: auto;
background: #8881;
padding: 0.4rem;
margin: 0.3rem 0;
font-size: 0.85rem;
}
.matrix .zelle {
text-align: center;
font-variant-numeric: tabular-nums;
}
</style> </style>