Compare commits
3 Commits
v0.1.0-rc3
...
v0.1.0-rc4
| Author | SHA1 | Date | |
|---|---|---|---|
| ea4fb724d4 | |||
| bd5afd44c9 | |||
| 78388a67b8 |
@ -50,8 +50,12 @@ jobs:
|
||||
cp packaging/arch/PKGBUILD /tmp/coding-bench-$VERSION.tar.gz /home/builder/pkg/
|
||||
chown -R builder:builder /home/builder/pkg
|
||||
su builder -c "cd /home/builder/pkg && makepkg -s --noconfirm -f"
|
||||
cp /home/builder/pkg/*.pkg.tar.zst src/
|
||||
# Eigener Ordner: Im Repo gibt es selbst ein src/ (Frontend), dorthin darf das Paket nicht.
|
||||
mkdir -p "$GITHUB_WORKSPACE/dist"
|
||||
cp /home/builder/pkg/*.pkg.tar.zst "$GITHUB_WORKSPACE/dist/"
|
||||
ls -l "$GITHUB_WORKSPACE/dist/"
|
||||
- uses: actions/upload-artifact@v3
|
||||
with:
|
||||
name: coding-bench-arch
|
||||
path: src/*.pkg.tar.zst
|
||||
path: dist/*.pkg.tar.zst
|
||||
if-no-files-found: error
|
||||
|
||||
@ -60,7 +60,7 @@ Der Nutzer wählt Aufgaben und Modelle. Jedes Modell löst jede Aufgabe mehrfach
|
||||
| **Agent-Loop** | Modell und Tools (`read_file`, `write_file`, `list_dir`, `run_shell`, `done`) mit Fehlerklassen. |
|
||||
| **Sandbox** | Frischer Podman-Container pro Lauf, ohne Netzwerk. |
|
||||
| **Runner** | Wiederholungen, Abbruch und Fortsetzen eines Batches. |
|
||||
| **Ranking** | Gesamtscore mit Intervall, Matrix Modell × Test (geplant für 0.2.0: Kategorien, Export). |
|
||||
| **Ranking** | Bewertung in Prozent je Bereich und als Gesamtnote, Matrix Modell × Aufgabe (geplant für 0.2.0: Konfidenzintervall, Export). |
|
||||
|
||||
## How it works
|
||||
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
|
||||
Stand: 2026-11-07 (12:40) · Projekt-ID: offen · Format: 1 · installiert ist noch nichts (Release 0.1.0 offen); Release-Kandidat v0.1.0-rc2 auf srv01 im Bau. Quellen dieser Liste: `SPEC.md` (Gespräch vom 06.11.2026), Anforderungskatalog F-01 bis F-17.
|
||||
Zeichen: ✓ fertig · ◐ teilweise · ✗ offen · ? nicht geprüft.
|
||||
**IDs:** Jeder Punkt in Stand-Tabelle, Todo, Entscheidungen und Risiken hat eine feste ID `#1xxx` (eine Zählung für alles, nie wiederverwendet, am Anfang der Zeile). „→ #…“ nennt die Anforderung, die ein Todo voranbringt. Erledigtes wandert mit ID in „Erledigt (einzeln)“. Nächste freie ID: #1042.
|
||||
**IDs:** Jeder Punkt in Stand-Tabelle, Todo, Entscheidungen und Risiken hat eine feste ID `#1xxx` (eine Zählung für alles, nie wiederverwendet, am Anfang der Zeile). „→ #…“ nennt die Anforderung, die ein Todo voranbringt. Erledigtes wandert mit ID in „Erledigt (einzeln)“. Nächste freie ID: #1048.
|
||||
|
||||
## 1. Leitplanken (von dir festgelegt, gelten für alles)
|
||||
- **Lokal first:** Nur lokale Modelle (Ollama, ab Phase 2 OpenAI-kompatibler Endpunkt im Netz). Cloud-Modelle werden nicht verglichen (Nicht-Ziel v1).
|
||||
@ -76,6 +76,7 @@ Zeichen: ✓ fertig · ◐ teilweise · ✗ offen · ? nicht geprüft.
|
||||
- [#1036] Entschieden: Lizenz wird vorerst nicht festgelegt, die README sagt das ausdrücklich. → #1001
|
||||
- [#1040] Entschieden: Bewertet wird absolut in Prozent, ohne Referenzmodell. Wert je Bereich (A bis D) und eine Gesamtnote, beides gewichtet nach `weight` aus `task.toml`; Bereiche ohne Läufe bleiben leer. → #1009
|
||||
- [#1041] Entschieden: Modelle werden in der Oberfläche als Liste angelegt, jedes mit Adapter (`ollama` oder `openai`), URL, Modell-ID und Name der Schlüssel-Variable. Die Liste steht in `config.toml`; Schlüssel stehen nie dort. → #1013
|
||||
- [#1042] Entschieden: Die App baut das Container-Image `cb-python` selbst. Das Containerfile ist in die App eingebettet, in den Einstellungen gibt es „Image bauen“ mit Live-Ausgabe. Ein Paket muss kein Image mitliefern. → #1004
|
||||
- [#1039] Entschieden: Podman (rootless) statt Docker für die Sandbox. Die SPEC ist entsprechend angepasst. Docker ist auf diesem Rechner nicht installiert. → #1004
|
||||
|
||||
## 6. Roadmap (Aufwand grob, ohne Kalenderdaten)
|
||||
@ -87,3 +88,8 @@ Zeichen: ✓ fertig · ◐ teilweise · ✗ offen · ? nicht geprüft.
|
||||
## 7. Risiken und Schulden
|
||||
- [#1037] Modelle ohne Tool-Support liefern `endpoint_error` und werden übersprungen (SPEC 13). → #1003
|
||||
- [#1038] Vergleichbarkeit mit veröffentlichten Benchmarkzahlen hängt vom Harness ab (Prompt, Tools, Limits). → #1021
|
||||
- [#1043] Die Sandbox ist nur durch die Standardwerte von rootless Podman gehärtet (kein `--cap-drop=ALL`, kein `no-new-privileges`, Prozess als Root im Container, keine Platten- und Datei-Limits). Aus dem Review vom 07.11.2026. Nach vorn bringt es: Phase 2 oder fremde Aufgaben-Quellen. → #1004
|
||||
- [#1044] `check.sh` läuft im selben Container wie der Agent. Ein Modell könnte Interpreter oder `sh` im Container verändern und so die Bewertung beeinflussen. Gegenmaßnahme: Prüfung in einem frischen Container auf dem exportierten `/work`. → #1004
|
||||
- [#1045] Tauri-CSP ist abgeschaltet (`csp: null`), `api_key_env` und Modell-URL sind frei wählbar. Kein Angriffsweg belegt, die Oberfläche nutzt kein `{@html}`. Eine strenge CSP und eine Prüfung der Variablennamen sind offen. → #1013
|
||||
- [#1046] Abbruch greift spät: Der Abbruch wird nur zwischen Schritten geprüft, eine laufende Modell-Anfrage läuft bis zum Zeitlimit weiter. Beim Timeout eines Befehls endet nur der `podman exec`-Client, nicht der Prozess im Container. → #1022
|
||||
- [#1047] Die Messung ist dünn: je Aufgabe eine Wiederholung, zwei Modelle, kein Modell ohne Tool-Support, keine Streuung. Das Ziel „2 Modelle × 6 Aufgaben × 3 Wiederholungen“ ist nicht erreicht. Vor einem Release 0.1.0 nachholen. → #1024
|
||||
|
||||
@ -37,9 +37,19 @@ pub enum ErrorClass {
|
||||
MaxSteps,
|
||||
Timeout,
|
||||
EndpointError,
|
||||
/// Fehler der Umgebung (Container, Image, Dateien), nicht des Modells.
|
||||
SandboxError,
|
||||
CheckFailed,
|
||||
}
|
||||
|
||||
impl ErrorClass {
|
||||
/// Läufe, die an der Umgebung scheiterten, sagen nichts über das Modell:
|
||||
/// Sie zählen nicht in die Bewertung und werden beim Fortsetzen wiederholt.
|
||||
pub fn is_infrastructure(self) -> bool {
|
||||
matches!(self, ErrorClass::EndpointError | ErrorClass::SandboxError)
|
||||
}
|
||||
}
|
||||
|
||||
/// Eine Nachricht im Verlauf (Ollama-Format).
|
||||
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
|
||||
pub struct Message {
|
||||
|
||||
168
src-tauri/src/images.rs
Normal file
168
src-tauri/src/images.rs
Normal file
@ -0,0 +1,168 @@
|
||||
//! Container-Images, die die App selbst bauen kann.
|
||||
//!
|
||||
//! Die Containerfiles sind in die App eingebettet. So braucht ein installiertes Paket keine
|
||||
//! zusätzlichen Dateien, und die App baut das Image beim ersten Start auf Knopfdruck.
|
||||
|
||||
use std::io::{BufRead, BufReader};
|
||||
use std::path::PathBuf;
|
||||
use std::process::{Command, Stdio};
|
||||
use std::sync::mpsc;
|
||||
use std::thread;
|
||||
|
||||
struct Embedded {
|
||||
/// Name ohne Registry und ohne Tag.
|
||||
name: &'static str,
|
||||
containerfile: &'static str,
|
||||
}
|
||||
|
||||
const EMBEDDED: &[Embedded] = &[Embedded {
|
||||
name: "cb-python",
|
||||
containerfile: include_str!("../../images/cb-python/Containerfile"),
|
||||
}];
|
||||
|
||||
/// Repository-Name eines Images: ohne Registry-Pfad, ohne Tag und ohne Digest.
|
||||
fn repo_name(image: &str) -> &str {
|
||||
let last = image.rsplit('/').next().unwrap_or(image);
|
||||
last.split(['@', ':']).next().unwrap_or(last)
|
||||
}
|
||||
|
||||
/// Eingebettetes Containerfile für ein Image, falls es eines gibt.
|
||||
pub fn embedded_containerfile(image: &str) -> Option<&'static str> {
|
||||
let name = repo_name(image);
|
||||
EMBEDDED.iter().find(|e| e.name == name).map(|e| e.containerfile)
|
||||
}
|
||||
|
||||
/// Prüft, ob ein Image lokal vorhanden ist. `podman image exists` liefert 0 (ja) oder 1 (nein).
|
||||
pub fn exists(runtime: &str, image: &str) -> Result<bool, String> {
|
||||
let out = Command::new(runtime)
|
||||
.args(["image", "exists", "--", image])
|
||||
.output()
|
||||
.map_err(|e| format!("{runtime} nicht startbar: {e}"))?;
|
||||
match out.status.code() {
|
||||
Some(0) => Ok(true),
|
||||
Some(1) => Ok(false),
|
||||
_ => Err(format!(
|
||||
"{runtime} image exists schlug fehl: {}",
|
||||
String::from_utf8_lossy(&out.stderr).trim()
|
||||
)),
|
||||
}
|
||||
}
|
||||
|
||||
/// Baut ein eingebettetes Image. Jede Ausgabezeile geht an `on_line`.
|
||||
pub fn build(runtime: &str, image: &str, on_line: &mut dyn FnMut(&str)) -> Result<(), String> {
|
||||
let containerfile = embedded_containerfile(image).ok_or_else(|| {
|
||||
format!("Für {image} gibt es kein eingebautes Containerfile. Das Image muss selbst bereitgestellt werden.")
|
||||
})?;
|
||||
crate::tasks::validate_image(image)?;
|
||||
|
||||
// Eigener Ordner als Build-Kontext, danach wieder gelöscht.
|
||||
let dir: PathBuf = std::env::temp_dir().join(format!(
|
||||
"coding-bench-image-{}-{}",
|
||||
std::process::id(),
|
||||
std::time::SystemTime::now()
|
||||
.duration_since(std::time::UNIX_EPOCH)
|
||||
.map(|d| d.as_nanos())
|
||||
.unwrap_or(0)
|
||||
));
|
||||
std::fs::create_dir_all(&dir).map_err(|e| format!("Build-Ordner nicht anlegbar: {e}"))?;
|
||||
let result = (|| {
|
||||
std::fs::write(dir.join("Containerfile"), containerfile)
|
||||
.map_err(|e| format!("Containerfile nicht schreibbar: {e}"))?;
|
||||
|
||||
let mut child = Command::new(runtime)
|
||||
.arg("build")
|
||||
.arg("-t")
|
||||
.arg(image)
|
||||
.arg(&dir)
|
||||
.stdin(Stdio::null())
|
||||
.stdout(Stdio::piped())
|
||||
.stderr(Stdio::piped())
|
||||
.spawn()
|
||||
.map_err(|e| format!("{runtime} build nicht startbar: {e}"))?;
|
||||
|
||||
// Beide Ströme in eigenen Threads lesen und über einen Kanal zusammenführen.
|
||||
let (tx, rx) = mpsc::channel::<String>();
|
||||
let mut handles = Vec::new();
|
||||
if let Some(out) = child.stdout.take() {
|
||||
let tx = tx.clone();
|
||||
handles.push(thread::spawn(move || {
|
||||
for line in BufReader::new(out).lines().map_while(Result::ok) {
|
||||
let _ = tx.send(line);
|
||||
}
|
||||
}));
|
||||
}
|
||||
if let Some(err) = child.stderr.take() {
|
||||
let tx = tx.clone();
|
||||
handles.push(thread::spawn(move || {
|
||||
for line in BufReader::new(err).lines().map_while(Result::ok) {
|
||||
let _ = tx.send(line);
|
||||
}
|
||||
}));
|
||||
}
|
||||
drop(tx);
|
||||
for line in rx {
|
||||
on_line(&line);
|
||||
}
|
||||
for h in handles {
|
||||
let _ = h.join();
|
||||
}
|
||||
let status = child.wait().map_err(|e| format!("Warten auf den Build schlug fehl: {e}"))?;
|
||||
if status.success() {
|
||||
Ok(())
|
||||
} else {
|
||||
Err(format!("Der Build von {image} ist fehlgeschlagen (Exit {}).", status.code().map_or("?".into(), |c| c.to_string())))
|
||||
}
|
||||
})();
|
||||
let _ = std::fs::remove_dir_all(&dir);
|
||||
result
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
|
||||
#[test]
|
||||
fn repo_name_ohne_registry_tag_und_digest() {
|
||||
assert_eq!(repo_name("cb-python:latest"), "cb-python");
|
||||
assert_eq!(repo_name("localhost/cb-python:1.2"), "cb-python");
|
||||
assert_eq!(repo_name("docker.io/library/python:3.12-slim"), "python");
|
||||
assert_eq!(repo_name("cb-python@sha256:abc"), "cb-python");
|
||||
assert_eq!(repo_name("cb-python"), "cb-python");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn eingebettetes_containerfile_wird_gefunden() {
|
||||
let cf = embedded_containerfile("cb-python:latest").expect("cb-python eingebettet");
|
||||
assert!(cf.contains("FROM "));
|
||||
assert!(embedded_containerfile("localhost/cb-python:latest").is_some());
|
||||
assert!(embedded_containerfile("python:3.12").is_none());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn build_fremdes_image_wird_abgelehnt() {
|
||||
let mut lines = Vec::new();
|
||||
let err = build("podman", "python:3.12", &mut |l| lines.push(l.to_string())).unwrap_err();
|
||||
assert!(err.contains("kein eingebautes Containerfile"));
|
||||
assert!(lines.is_empty());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn name_mit_optionszeichen_ist_kein_eingebettetes_image() {
|
||||
assert!(embedded_containerfile("--cb-python").is_none());
|
||||
assert!(build("podman", "--cb-python", &mut |_| {}).is_err());
|
||||
}
|
||||
|
||||
/// Echter Build gegen Podman (braucht Netz für das Basis-Image). Ignoriert:
|
||||
/// `cargo test images::tests::echter_build -- --ignored`
|
||||
#[test]
|
||||
#[ignore]
|
||||
fn echter_build() {
|
||||
let tag = format!("cb-python:test-{}", std::process::id());
|
||||
let mut lines = Vec::new();
|
||||
build("podman", &tag, &mut |l| lines.push(l.to_string())).expect("Build");
|
||||
assert!(!lines.is_empty());
|
||||
assert!(exists("podman", &tag).unwrap());
|
||||
let _ = Command::new("podman").args(["rmi", "-f", &tag]).output();
|
||||
assert!(!exists("podman", &tag).unwrap());
|
||||
}
|
||||
}
|
||||
@ -1,5 +1,6 @@
|
||||
mod agent;
|
||||
mod config;
|
||||
mod images;
|
||||
mod ranking;
|
||||
mod runner;
|
||||
mod sandbox;
|
||||
@ -19,6 +20,7 @@ use tauri::{Emitter, Manager, State};
|
||||
|
||||
pub const DB_FILE: &str = "coding-bench.sqlite";
|
||||
pub const EVENT_NAME: &str = "batch-event";
|
||||
pub const IMAGE_EVENT: &str = "image-build";
|
||||
|
||||
/// Aufgelöste Pfade, einmal beim Start ermittelt.
|
||||
pub struct AppPaths(pub Paths);
|
||||
@ -35,6 +37,18 @@ pub struct RunState {
|
||||
pub cancel: Arc<AtomicBool>,
|
||||
/// Gesetzt, solange ein Batch läuft.
|
||||
pub running: Arc<AtomicBool>,
|
||||
/// Gesetzt, solange ein Image gebaut wird.
|
||||
pub building: Arc<AtomicBool>,
|
||||
}
|
||||
|
||||
/// Setzt ein Flag beim Verlassen des Gültigkeitsbereichs zurück, auch nach einem Fehler oder Panic.
|
||||
/// Ohne diesen Wächter bliebe `running` nach einem abgestürzten Batch-Thread dauerhaft gesetzt.
|
||||
struct FlagGuard(Arc<AtomicBool>);
|
||||
|
||||
impl Drop for FlagGuard {
|
||||
fn drop(&mut self) {
|
||||
self.0.store(false, Ordering::SeqCst);
|
||||
}
|
||||
}
|
||||
|
||||
/// Ein Modell für die Oberfläche, mit Hinweis, ob die Schlüssel-Variable gesetzt ist.
|
||||
@ -200,9 +214,24 @@ async fn start_batch(
|
||||
return Err("Mindestens eine gewählte Aufgabe ist nicht gültig geladen.".into());
|
||||
}
|
||||
|
||||
// Fehlt ein Image, scheitert sonst jeder Lauf einzeln. Besser sofort und mit klarer Anleitung.
|
||||
let mut missing: Vec<String> = Vec::new();
|
||||
for image in selected.iter().map(|t| t.meta.image.clone()).collect::<std::collections::BTreeSet<_>>() {
|
||||
if !images::exists(&runtime, &image)? {
|
||||
missing.push(image);
|
||||
}
|
||||
}
|
||||
if !missing.is_empty() {
|
||||
return Err(format!(
|
||||
"Container-Image fehlt: {}. Baue es in den Einstellungen unter „Container-Images“.",
|
||||
missing.join(", ")
|
||||
));
|
||||
}
|
||||
|
||||
if run.running.swap(true, Ordering::SeqCst) {
|
||||
return Err("Ein Batch läuft bereits.".into());
|
||||
}
|
||||
let _running_guard = FlagGuard(run.running.clone());
|
||||
run.cancel.store(false, Ordering::SeqCst);
|
||||
|
||||
let jobs = runner::plan(&models, &selected, repeats);
|
||||
@ -214,27 +243,83 @@ async fn start_batch(
|
||||
};
|
||||
let db_path = paths.0.data_dir.join(DB_FILE);
|
||||
let cancel = run.cancel.clone();
|
||||
let running = run.running.clone();
|
||||
let emitter = app.clone();
|
||||
|
||||
let result = tauri::async_runtime::spawn_blocking(move || {
|
||||
let outcome = (|| -> Result<BatchSummary, String> {
|
||||
let mut store = Store::open(&db_path)?;
|
||||
let on_event = |e: &Event| {
|
||||
let _ = emitter.emit(EVENT_NAME, e);
|
||||
};
|
||||
runner::run_batch(&mut store, &run_cfg, None, ¬e, repeats, &jobs, &cancel, &on_event)
|
||||
})();
|
||||
running.store(false, Ordering::SeqCst);
|
||||
outcome
|
||||
})
|
||||
.await
|
||||
.map_err(|e| format!("Batch-Thread abgebrochen: {e}"))?;
|
||||
|
||||
run.running.store(false, Ordering::SeqCst);
|
||||
result
|
||||
}
|
||||
|
||||
/// Zustand eines Container-Images für die Einstellungen.
|
||||
#[derive(Serialize)]
|
||||
pub struct ImageStatus {
|
||||
pub image: String,
|
||||
pub available: bool,
|
||||
/// Die App kann es selbst bauen.
|
||||
pub buildable: bool,
|
||||
/// Fehlertext, falls die Prüfung selbst scheiterte (z. B. Podman fehlt).
|
||||
pub error: Option<String>,
|
||||
}
|
||||
|
||||
/// Images, die die Aufgaben brauchen, und ihr Zustand.
|
||||
#[tauri::command]
|
||||
fn image_status(paths: State<'_, AppPaths>, cfg: State<'_, ConfigState>) -> Result<Vec<ImageStatus>, String> {
|
||||
let runtime = cfg.config.lock().map_err(|e| e.to_string())?.container_runtime.clone();
|
||||
let mut names: std::collections::BTreeSet<String> = tasks::load_all(&paths.0.tasks_dir)
|
||||
.tasks
|
||||
.into_iter()
|
||||
.map(|t| t.meta.image)
|
||||
.collect();
|
||||
// Das eingebaute Standard-Image zeigen wir auch ohne Aufgaben.
|
||||
names.insert("cb-python:latest".to_string());
|
||||
Ok(names
|
||||
.into_iter()
|
||||
.map(|image| {
|
||||
let buildable = images::embedded_containerfile(&image).is_some();
|
||||
match images::exists(&runtime, &image) {
|
||||
Ok(available) => ImageStatus { image, available, buildable, error: None },
|
||||
Err(e) => ImageStatus { image, available: false, buildable, error: Some(e) },
|
||||
}
|
||||
})
|
||||
.collect())
|
||||
}
|
||||
|
||||
/// Baut ein eingebettetes Image. Die Ausgabe kommt zeilenweise als Ereignis `image-build`.
|
||||
#[tauri::command]
|
||||
async fn build_image(
|
||||
app: tauri::AppHandle,
|
||||
cfg: State<'_, ConfigState>,
|
||||
run: State<'_, RunState>,
|
||||
image: String,
|
||||
) -> Result<(), String> {
|
||||
tasks::validate_image(&image)?;
|
||||
if images::embedded_containerfile(&image).is_none() {
|
||||
return Err(format!("Für {image} gibt es kein eingebautes Containerfile."));
|
||||
}
|
||||
let runtime = cfg.config.lock().map_err(|e| e.to_string())?.container_runtime.clone();
|
||||
if run.building.swap(true, Ordering::SeqCst) {
|
||||
return Err("Es wird bereits ein Image gebaut.".into());
|
||||
}
|
||||
let _guard = FlagGuard(run.building.clone());
|
||||
let emitter = app.clone();
|
||||
tauri::async_runtime::spawn_blocking(move || {
|
||||
let name = image.clone();
|
||||
images::build(&runtime, &image, &mut |line| {
|
||||
let _ = emitter.emit(IMAGE_EVENT, serde_json::json!({ "image": name, "line": line }));
|
||||
})
|
||||
})
|
||||
.await
|
||||
.map_err(|e| format!("Build-Thread abgebrochen: {e}"))?
|
||||
}
|
||||
|
||||
/// Bricht den laufenden Batch ab. Der aktuelle Lauf wird verworfen.
|
||||
/// Gibt `false` zurück, wenn gerade kein Batch läuft.
|
||||
#[tauri::command]
|
||||
@ -347,6 +432,7 @@ pub fn run() {
|
||||
app.manage(RunState {
|
||||
cancel: Arc::new(AtomicBool::new(false)),
|
||||
running: Arc::new(AtomicBool::new(false)),
|
||||
building: Arc::new(AtomicBool::new(false)),
|
||||
});
|
||||
Ok(())
|
||||
})
|
||||
@ -362,7 +448,9 @@ pub fn run() {
|
||||
batch_results,
|
||||
batch_ranking,
|
||||
run_steps,
|
||||
runtime_status
|
||||
runtime_status,
|
||||
image_status,
|
||||
build_image
|
||||
])
|
||||
.run(tauri::generate_context!())
|
||||
.expect("error while running tauri application");
|
||||
|
||||
@ -7,6 +7,8 @@
|
||||
//! - Gewichte kommen aus `weight` in `task.toml`.
|
||||
//! - Bereiche ohne Läufe eines Modells bleiben leer und zählen nicht mit.
|
||||
//! - Reihenfolge: Gesamtnote absteigend, dann Median der Dauer, dann mittlere Completion-Tokens.
|
||||
//! - Läufe, die an Server oder Umgebung scheiterten (`endpoint_error`, `sandbox_error`), sagen
|
||||
//! nichts über das Modell. Sie zählen nicht mit und werden getrennt gezählt (`excluded_runs`).
|
||||
|
||||
use crate::agent::ErrorClass;
|
||||
use crate::store::RunRecord;
|
||||
@ -71,12 +73,22 @@ pub struct Ranking {
|
||||
pub cells: Vec<MatrixCell>,
|
||||
/// Aufgaben des Batches, sortiert nach Bereich und ID.
|
||||
pub tasks: Vec<TaskColumn>,
|
||||
/// Läufe, die wegen Server- oder Umgebungsfehlern nicht in die Bewertung eingehen.
|
||||
pub excluded_runs: usize,
|
||||
}
|
||||
|
||||
const UNKNOWN_GROUP: &str = "?";
|
||||
|
||||
/// Berechnet Bewertung und Matrix. Unbekannte Aufgaben zählen mit Gewicht 1.0 im Bereich `?`.
|
||||
pub fn compute(batch_id: i64, runs: &[RunRecord], tasks: &BTreeMap<String, TaskInfo>) -> Ranking {
|
||||
pub fn compute(batch_id: i64, all_runs: &[RunRecord], tasks: &BTreeMap<String, TaskInfo>) -> Ranking {
|
||||
let valid: Vec<RunRecord> = all_runs
|
||||
.iter()
|
||||
.filter(|r| !r.error_class.is_infrastructure())
|
||||
.cloned()
|
||||
.collect();
|
||||
let excluded_runs = all_runs.len() - valid.len();
|
||||
let runs = valid.as_slice();
|
||||
|
||||
let info_of = |task: &str| -> TaskInfo {
|
||||
tasks.get(task).cloned().unwrap_or(TaskInfo {
|
||||
group: UNKNOWN_GROUP.into(),
|
||||
@ -212,7 +224,7 @@ pub fn compute(batch_id: i64, runs: &[RunRecord], tasks: &BTreeMap<String, TaskI
|
||||
})
|
||||
.collect();
|
||||
|
||||
Ranking { batch_id, groups, models, cells, tasks: task_list }
|
||||
Ranking { batch_id, groups, models, cells, tasks: task_list, excluded_runs }
|
||||
}
|
||||
|
||||
fn median_u128(sorted: &[u128]) -> u128 {
|
||||
@ -337,6 +349,22 @@ mod tests {
|
||||
assert_eq!(r.groups, vec!["?".to_string()]);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn ausfaelle_der_umgebung_zaehlen_nicht_gegen_das_modell() {
|
||||
let tasks = infos(&[("a1", "A", 1.0), ("a2", "A", 1.0)]);
|
||||
let runs = vec![
|
||||
run("m", "a1", 1.0, ErrorClass::Ok, 1, 1),
|
||||
run("m", "a2", 0.0, ErrorClass::SandboxError, 0, 0),
|
||||
run("n", "a1", 0.0, ErrorClass::EndpointError, 0, 0),
|
||||
];
|
||||
let r = compute(1, &runs, &tasks);
|
||||
assert_eq!(r.excluded_runs, 2);
|
||||
// m: nur a1 zählt, 100 %. Modell n hat keine gültigen Läufe und fehlt.
|
||||
assert_eq!(r.models.len(), 1);
|
||||
assert!((r.models[0].total_percent - 100.0).abs() < 1e-9);
|
||||
assert_eq!(r.tasks.len(), 1);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn leerer_batch() {
|
||||
let r = compute(7, &[], &BTreeMap::new());
|
||||
|
||||
@ -166,6 +166,10 @@ pub fn run_batch(
|
||||
}
|
||||
|
||||
'models: for model in &models {
|
||||
if cancel.load(Ordering::SeqCst) {
|
||||
summary.cancelled = true;
|
||||
break 'models;
|
||||
}
|
||||
let client = make_client(cfg, model)?;
|
||||
let warm = client.chat(
|
||||
&[Message::new("user", "ping")],
|
||||
@ -208,31 +212,21 @@ pub fn run_batch(
|
||||
let fin = match &unavailable {
|
||||
// Modell nicht nutzbar: Lauf wird als endpoint_error gespeichert, ohne Container.
|
||||
Some(reason) => Finished {
|
||||
record: RunRecord {
|
||||
batch_id,
|
||||
model: job.model.clone(),
|
||||
task_id: job.task.meta.id.clone(),
|
||||
repeat_idx: job.repeat_idx,
|
||||
error_class: ErrorClass::EndpointError,
|
||||
score: 0.0,
|
||||
steps: 0,
|
||||
prompt_tokens: 0,
|
||||
completion_tokens: 0,
|
||||
duration_ms: 0,
|
||||
tps: None,
|
||||
ttft_tool_ms: None,
|
||||
artifact_path: None,
|
||||
summary: None,
|
||||
check_output: reason.clone(),
|
||||
},
|
||||
record: infra_record(batch_id, job, ErrorClass::EndpointError, reason),
|
||||
transcript: vec![],
|
||||
},
|
||||
None => match execute_job(cfg, batch_id, i, job, &*client, cancel)? {
|
||||
JobResult::Cancelled => {
|
||||
None => match execute_job(cfg, batch_id, i, job, &*client, cancel) {
|
||||
Ok(JobResult::Cancelled) => {
|
||||
summary.cancelled = true;
|
||||
break 'models;
|
||||
}
|
||||
JobResult::Finished(f) => f,
|
||||
Ok(JobResult::Finished(f)) => f,
|
||||
// Ein Fehler der Umgebung beendet nicht den Batch: Der Lauf wird als
|
||||
// sandbox_error gespeichert und beim Fortsetzen wiederholt.
|
||||
Err(message) => Finished {
|
||||
record: infra_record(batch_id, job, ErrorClass::SandboxError, &message),
|
||||
transcript: vec![],
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
@ -256,6 +250,27 @@ pub fn run_batch(
|
||||
Ok(summary)
|
||||
}
|
||||
|
||||
/// Lauf ohne Ergebnis, weil Umgebung oder Server ausfielen. Zählt nicht gegen das Modell.
|
||||
fn infra_record(batch_id: i64, job: &Job, class: ErrorClass, message: &str) -> RunRecord {
|
||||
RunRecord {
|
||||
batch_id,
|
||||
model: job.model.clone(),
|
||||
task_id: job.task.meta.id.clone(),
|
||||
repeat_idx: job.repeat_idx,
|
||||
error_class: class,
|
||||
score: 0.0,
|
||||
steps: 0,
|
||||
prompt_tokens: 0,
|
||||
completion_tokens: 0,
|
||||
duration_ms: 0,
|
||||
tps: None,
|
||||
ttft_tool_ms: None,
|
||||
artifact_path: None,
|
||||
summary: None,
|
||||
check_output: message.to_string(),
|
||||
}
|
||||
}
|
||||
|
||||
struct Finished {
|
||||
record: RunRecord,
|
||||
transcript: Vec<Message>,
|
||||
@ -310,7 +325,9 @@ fn execute_job(
|
||||
.map_err(|e| format!("prompt.md nicht lesbar: {e}"))?;
|
||||
let outcome = run_agent_cancellable(client, &ws, &prompt, &limits, cancel);
|
||||
if outcome.cancelled {
|
||||
sb.remove()?;
|
||||
if let Err(e) = sb.remove() {
|
||||
eprintln!("Container {} nicht entfernt: {e}", name);
|
||||
}
|
||||
return Ok(JobResult::Cancelled);
|
||||
}
|
||||
|
||||
@ -352,7 +369,10 @@ fn execute_job(
|
||||
Ok(()) => Some(artifact.join("work").display().to_string()),
|
||||
Err(_) => None,
|
||||
};
|
||||
sb.remove()?;
|
||||
// Ein fehlschlagendes Aufräumen darf einen fertigen Lauf nicht verwerfen.
|
||||
if let Err(e) = sb.remove() {
|
||||
eprintln!("Container {} nicht entfernt: {e}", name);
|
||||
}
|
||||
|
||||
let class = final_class(outcome.class, &check);
|
||||
let secs = outcome.duration_ms as f64 / 1000.0;
|
||||
@ -562,6 +582,48 @@ mod tests {
|
||||
eprintln!("Datenbank: {}", data.join("db.sqlite").display());
|
||||
}
|
||||
|
||||
/// Ein Modell, dessen Server nicht antwortet, bricht den Batch nicht ab. Die Läufe werden als
|
||||
/// endpoint_error gespeichert, zählen nicht in die Bewertung und werden beim Fortsetzen wiederholt.
|
||||
/// Braucht weder Podman noch einen Server (Port 1 auf localhost ist geschlossen).
|
||||
#[test]
|
||||
fn ausgefallenes_modell_wird_gespeichert_und_beim_fortsetzen_wiederholt() {
|
||||
let cfg = RunConfig {
|
||||
runtime: "podman".into(),
|
||||
models: vec![ModelConn {
|
||||
name: "weg".into(),
|
||||
adapter: "ollama".into(),
|
||||
url: "http://127.0.0.1:1".into(),
|
||||
model_id: "x".into(),
|
||||
api_key: None,
|
||||
}],
|
||||
data_dir: std::env::temp_dir().join("cb-unused"),
|
||||
limits: Limits::default(),
|
||||
};
|
||||
let jobs = plan(&["weg".to_string()], &[task("a-01"), task("a-02")], 1);
|
||||
let mut store = Store::open_in_memory().unwrap();
|
||||
let cancel = AtomicBool::new(false);
|
||||
let events = std::cell::RefCell::new(Vec::new());
|
||||
let on = |e: &Event| events.borrow_mut().push(e.clone());
|
||||
|
||||
let first = run_batch(&mut store, &cfg, None, "t", 1, &jobs, &cancel, &on).unwrap();
|
||||
assert_eq!(first.completed, 2);
|
||||
assert!(events.borrow().iter().any(|e| matches!(e, Event::ModelUnavailable { .. })));
|
||||
let runs = store.runs_for_batch(first.batch_id).unwrap();
|
||||
assert_eq!(runs.len(), 2);
|
||||
assert!(runs.iter().all(|r| r.error_class == ErrorClass::EndpointError));
|
||||
|
||||
// Fortsetzen: Ausfälle gelten nicht als fertig und werden wiederholt.
|
||||
let second = run_batch(&mut store, &cfg, Some(first.batch_id), "", 1, &jobs, &cancel, &on).unwrap();
|
||||
assert_eq!(second.completed, 2);
|
||||
assert_eq!(second.skipped, 0);
|
||||
|
||||
// Die Bewertung ignoriert die Ausfälle.
|
||||
let all = store.runs_for_batch(first.batch_id).unwrap();
|
||||
let r = crate::ranking::compute(first.batch_id, &all, &Default::default());
|
||||
assert_eq!(r.excluded_runs, 4);
|
||||
assert!(r.models.is_empty());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn klasse_agent_vor_pruefung() {
|
||||
let ok = CheckResult { score: 1.0, passed: true };
|
||||
|
||||
@ -12,6 +12,8 @@ use std::thread;
|
||||
use std::time::{Duration, Instant};
|
||||
|
||||
pub const WORK_DIR: &str = "/work";
|
||||
/// Obergrenze je Ausgabestrom eines Befehls. Mehr wird gelesen und verworfen.
|
||||
pub const MAX_CAPTURE_BYTES: u64 = 1 << 20;
|
||||
|
||||
/// Ressourcenlimits eines Containers.
|
||||
#[derive(Debug, Clone, PartialEq)]
|
||||
@ -57,6 +59,8 @@ pub fn run_args(name: &str, image: &str, limits: &Limits) -> Vec<String> {
|
||||
"512".into(),
|
||||
"--label".into(),
|
||||
"coding-bench=lauf".into(),
|
||||
// `--` beendet die Optionen: ein Image-Name wird so nie als Option gelesen.
|
||||
"--".into(),
|
||||
image.into(),
|
||||
"sleep".into(),
|
||||
"infinity".into(),
|
||||
@ -153,16 +157,8 @@ impl Sandbox {
|
||||
// Pipes in eigenen Threads lesen, sonst blockiert ein volles Ausgabepuffer.
|
||||
let mut stdout = child.stdout.take().expect("stdout ist gepiped");
|
||||
let mut stderr = child.stderr.take().expect("stderr ist gepiped");
|
||||
let t_out = thread::spawn(move || {
|
||||
let mut s = String::new();
|
||||
let _ = stdout.read_to_string(&mut s);
|
||||
s
|
||||
});
|
||||
let t_err = thread::spawn(move || {
|
||||
let mut s = String::new();
|
||||
let _ = stderr.read_to_string(&mut s);
|
||||
s
|
||||
});
|
||||
let t_out = thread::spawn(move || read_limited(&mut stdout, MAX_CAPTURE_BYTES));
|
||||
let t_err = thread::spawn(move || read_limited(&mut stderr, MAX_CAPTURE_BYTES));
|
||||
|
||||
let start = Instant::now();
|
||||
let (status, timed_out) = loop {
|
||||
@ -239,6 +235,26 @@ impl Sandbox {
|
||||
}
|
||||
}
|
||||
|
||||
/// Liest höchstens `limit` Bytes, verwirft den Rest (damit der Prozess nicht an einer vollen Pipe
|
||||
/// hängt) und wandelt ungültiges UTF-8 in Ersatzzeichen um.
|
||||
pub fn read_limited<R: Read>(reader: &mut R, limit: u64) -> String {
|
||||
let mut buf = Vec::new();
|
||||
let _ = reader.take(limit).read_to_end(&mut buf);
|
||||
let mut truncated = false;
|
||||
let mut sink = [0u8; 8192];
|
||||
loop {
|
||||
match reader.read(&mut sink) {
|
||||
Ok(0) | Err(_) => break,
|
||||
Ok(_) => truncated = true,
|
||||
}
|
||||
}
|
||||
let mut text = String::from_utf8_lossy(&buf).into_owned();
|
||||
if truncated {
|
||||
text.push_str("\n[Ausgabe gekürzt]");
|
||||
}
|
||||
text
|
||||
}
|
||||
|
||||
/// Entfernt einen Container nach Name, falls ein früherer Lauf ihn hinterlassen hat.
|
||||
pub fn remove_by_name(runtime: &str, name: &str) {
|
||||
let _ = Command::new(runtime).args(["rm", "-f", name]).output();
|
||||
@ -264,6 +280,28 @@ mod tests {
|
||||
assert!(s.ends_with("img:1 sleep infinity"));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn image_steht_nach_doppeltem_strich() {
|
||||
let args = run_args("cb-x", "img:1", &Limits::default());
|
||||
let pos = args.iter().position(|a| a == "--").expect("-- fehlt");
|
||||
assert_eq!(args[pos + 1], "img:1");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn ausgabe_wird_begrenzt_und_utf8_ersetzt() {
|
||||
let mut data = std::io::Cursor::new(vec![b'a'; 100]);
|
||||
let text = read_limited(&mut data, 10);
|
||||
assert!(text.starts_with("aaaaaaaaaa"));
|
||||
assert!(text.contains("[Ausgabe gekürzt]"));
|
||||
assert!(!text.contains("aaaaaaaaaaa"));
|
||||
|
||||
let mut kurz = std::io::Cursor::new(b"ok".to_vec());
|
||||
assert_eq!(read_limited(&mut kurz, 10), "ok");
|
||||
|
||||
let mut kaputt = std::io::Cursor::new(vec![b'x', 0xff, b'y']);
|
||||
assert_eq!(read_limited(&mut kaputt, 10), "x\u{fffd}y");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn containername_ist_praefixiert() {
|
||||
assert_eq!(container_name("42"), "cb-42");
|
||||
|
||||
@ -132,11 +132,15 @@ impl Store {
|
||||
.map_err(|e| e.to_string())
|
||||
}
|
||||
|
||||
/// Schlüssel (Modell, Aufgabe, Wiederholung) aller bereits gespeicherten Läufe eines Batches.
|
||||
/// Schlüssel (Modell, Aufgabe, Wiederholung) der gültig beendeten Läufe eines Batches.
|
||||
/// Läufe, die an Server oder Umgebung scheiterten, fehlen hier und werden wiederholt.
|
||||
pub fn finished_keys(&self, batch_id: i64) -> Result<HashSet<(String, String, u32)>, String> {
|
||||
let mut stmt = self
|
||||
.conn
|
||||
.prepare("SELECT model, task_id, repeat_idx FROM run WHERE batch_id = ?1")
|
||||
.prepare(
|
||||
"SELECT model, task_id, repeat_idx FROM run
|
||||
WHERE batch_id = ?1 AND error_class NOT IN ('endpoint_error', 'sandbox_error')",
|
||||
)
|
||||
.map_err(|e| e.to_string())?;
|
||||
let rows = stmt
|
||||
.query_map(params![batch_id], |r| {
|
||||
@ -410,6 +414,23 @@ mod tests {
|
||||
assert!(list[1].models.contains("m1") && list[1].models.contains("m2"));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn infrastruktur_laeufe_werden_beim_fortsetzen_wiederholt() {
|
||||
let mut s = Store::open_in_memory().unwrap();
|
||||
let b = s.create_batch("", 1, "{}").unwrap();
|
||||
s.insert_run(&rec(b, "m", "ok-task", 1), &[]).unwrap();
|
||||
let mut ausfall = rec(b, "m", "sandbox-task", 1);
|
||||
ausfall.error_class = ErrorClass::SandboxError;
|
||||
s.insert_run(&ausfall, &[]).unwrap();
|
||||
let mut server = rec(b, "m", "server-task", 1);
|
||||
server.error_class = ErrorClass::EndpointError;
|
||||
s.insert_run(&server, &[]).unwrap();
|
||||
let keys = s.finished_keys(b).unwrap();
|
||||
assert!(keys.contains(&("m".to_string(), "ok-task".to_string(), 1)));
|
||||
assert!(!keys.contains(&("m".to_string(), "sandbox-task".to_string(), 1)));
|
||||
assert!(!keys.contains(&("m".to_string(), "server-task".to_string(), 1)));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn unbekannter_batch_existiert_nicht() {
|
||||
let s = Store::open_in_memory().unwrap();
|
||||
|
||||
@ -61,6 +61,27 @@ pub struct LoadReport {
|
||||
pub errors: Vec<TaskError>,
|
||||
}
|
||||
|
||||
/// Prüft einen Image-Namen. Erlaubt sind Buchstaben, Ziffern und `. _ - / : @`; er darf nicht
|
||||
/// mit `-` beginnen. Sonst könnte ein fremder Aufgaben-Ordner Podman-Optionen einschleusen.
|
||||
pub fn validate_image(image: &str) -> Result<(), String> {
|
||||
if image.is_empty() {
|
||||
return Err("image ist leer".into());
|
||||
}
|
||||
if image.len() > 200 {
|
||||
return Err("image ist zu lang".into());
|
||||
}
|
||||
if image.starts_with('-') {
|
||||
return Err(format!("image {image:?} darf nicht mit - beginnen"));
|
||||
}
|
||||
if let Some(c) = image
|
||||
.chars()
|
||||
.find(|c| !(c.is_ascii_alphanumeric() || matches!(c, '.' | '_' | '-' | '/' | ':' | '@')))
|
||||
{
|
||||
return Err(format!("image {image:?} enthält das unzulässige Zeichen {c:?}"));
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
||||
/// Validiert die Metadaten. Gibt eine Liste aller Verstöße zurück.
|
||||
pub fn validate_meta(meta: &TaskToml) -> Vec<String> {
|
||||
let mut errs = Vec::new();
|
||||
@ -76,8 +97,8 @@ pub fn validate_meta(meta: &TaskToml) -> Vec<String> {
|
||||
if !meta.weight.is_finite() || meta.weight <= 0.0 {
|
||||
errs.push("weight muss größer als 0 sein".into());
|
||||
}
|
||||
if meta.image.trim().is_empty() {
|
||||
errs.push("image ist leer".into());
|
||||
if let Err(e) = validate_image(&meta.image) {
|
||||
errs.push(e);
|
||||
}
|
||||
if meta.max_steps == 0 {
|
||||
errs.push("max_steps muss größer als 0 sein".into());
|
||||
@ -276,6 +297,17 @@ timeout_s = 600
|
||||
let _ = fs::remove_dir_all(&base);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn image_namen_werden_geprueft() {
|
||||
for ok in ["cb-python:latest", "docker.io/library/python:3.12-slim", "localhost/cb-x@sha256:abc"] {
|
||||
assert!(validate_image(ok).is_ok(), "{ok}");
|
||||
}
|
||||
for bad in ["", "--privileged", "-v", "img name", "img;rm", "img\nx", "a$b", "--mount=type=bind,src=/home"] {
|
||||
assert!(validate_image(bad).is_err(), "{bad:?} sollte abgelehnt werden");
|
||||
}
|
||||
assert!(validate_image(&"a".repeat(201)).is_err());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn ungueltige_zahlen_werden_gemeldet() {
|
||||
let meta: TaskToml = toml::from_str(&GUT.replace("max_steps = 25", "max_steps = 0")).unwrap();
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
<script lang="ts">
|
||||
import { onMount, onDestroy } from "svelte";
|
||||
import { listen, type UnlistenFn } from "@tauri-apps/api/event";
|
||||
import { api, groupLabel, type BatchEvent, type LoadReport, type ModelInfo, type TaskInfo } from "$lib/api";
|
||||
import { api, errorLabel, groupLabel, type BatchEvent, type LoadReport, type ModelInfo, type TaskInfo } from "$lib/api";
|
||||
|
||||
let {
|
||||
models,
|
||||
@ -50,7 +50,7 @@
|
||||
} else if (e.kind === "run_finished") {
|
||||
const ok = e.class === "ok";
|
||||
log.push({
|
||||
text: `${ok ? "bestanden" : e.class}: ${label}, ${Math.round(e.score * 100)} %`,
|
||||
text: `${errorLabel(e.class)}: ${label}, ${Math.round(e.score * 100)} %`,
|
||||
cls: ok ? "ok" : "error",
|
||||
});
|
||||
current = "";
|
||||
|
||||
@ -2,8 +2,10 @@
|
||||
import { onMount, untrack } from "svelte";
|
||||
import {
|
||||
api,
|
||||
errorLabel,
|
||||
fmtDuration,
|
||||
fmtPct,
|
||||
isInfrastructure,
|
||||
groupLabel,
|
||||
pctColor,
|
||||
type BatchInfo,
|
||||
@ -146,6 +148,13 @@
|
||||
</table>
|
||||
</div>
|
||||
|
||||
{#if ranking.excluded_runs > 0}
|
||||
<p class="muted">
|
||||
{ranking.excluded_runs} Lauf/Läufe sind nicht gewertet, weil der Modell-Server oder die Umgebung ausfiel. Sie
|
||||
fließen nicht in die Prozentwerte ein. Beim Fortsetzen eines Batches werden sie wiederholt.
|
||||
</p>
|
||||
{/if}
|
||||
|
||||
<details class="how">
|
||||
<summary>So wird bewertet</summary>
|
||||
<ul>
|
||||
@ -222,7 +231,10 @@
|
||||
<td>{r.model}</td>
|
||||
<td>{r.task_id}</td>
|
||||
<td class="num">{r.repeat_idx}</td>
|
||||
<td class={r.error_class === "ok" ? "ok" : "error"}>{r.error_class === "ok" ? "bestanden" : r.error_class}</td>
|
||||
<td class={r.error_class === "ok" ? "ok" : isInfrastructure(r.error_class) ? "muted" : "error"}>
|
||||
{errorLabel(r.error_class)}
|
||||
{#if isInfrastructure(r.error_class)}<span class="chip" title="Zählt nicht in die Bewertung">nicht gewertet</span>{/if}
|
||||
</td>
|
||||
<td class="num">{Math.round(r.score * 100)} %</td>
|
||||
<td class="num">{r.steps}</td>
|
||||
<td class="num">{fmtDuration(r.duration_ms)}</td>
|
||||
|
||||
@ -1,5 +1,15 @@
|
||||
<script lang="ts">
|
||||
import { api, type ModelEntry, type ModelInfo, type ModelTest, type Paths, type RuntimeStatus } from "$lib/api";
|
||||
import { onMount, onDestroy } from "svelte";
|
||||
import { listen, type UnlistenFn } from "@tauri-apps/api/event";
|
||||
import {
|
||||
api,
|
||||
type ImageStatus,
|
||||
type ModelEntry,
|
||||
type ModelInfo,
|
||||
type ModelTest,
|
||||
type Paths,
|
||||
type RuntimeStatus,
|
||||
} from "$lib/api";
|
||||
|
||||
let {
|
||||
models,
|
||||
@ -76,6 +86,46 @@
|
||||
function savedInfo(name: string): ModelInfo | undefined {
|
||||
return models.find((m) => m.name === name);
|
||||
}
|
||||
|
||||
// Container-Images: Zustand, Bauen auf Knopfdruck, Ausgabe live.
|
||||
let images = $state<ImageStatus[]>([]);
|
||||
let imagesError = $state("");
|
||||
let building = $state<string | null>(null);
|
||||
let buildLog = $state<string[]>([]);
|
||||
let buildError = $state("");
|
||||
let unlisten: UnlistenFn | null = null;
|
||||
|
||||
async function loadImages() {
|
||||
try {
|
||||
images = await api.imageStatus();
|
||||
imagesError = "";
|
||||
} catch (e) {
|
||||
imagesError = String(e);
|
||||
}
|
||||
}
|
||||
|
||||
async function build(image: string) {
|
||||
building = image;
|
||||
buildLog = [];
|
||||
buildError = "";
|
||||
try {
|
||||
await api.buildImage(image);
|
||||
} catch (e) {
|
||||
buildError = String(e);
|
||||
} finally {
|
||||
building = null;
|
||||
await loadImages();
|
||||
}
|
||||
}
|
||||
|
||||
onMount(async () => {
|
||||
loadImages();
|
||||
unlisten = await listen<{ image: string; line: string }>("image-build", (ev) => {
|
||||
buildLog.push(ev.payload.line);
|
||||
if (buildLog.length > 300) buildLog.splice(0, buildLog.length - 300);
|
||||
});
|
||||
});
|
||||
onDestroy(() => unlisten?.());
|
||||
</script>
|
||||
|
||||
<section class="card">
|
||||
@ -152,6 +202,39 @@
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<section class="card">
|
||||
<h2>Container-Images</h2>
|
||||
<p class="muted">
|
||||
Jede Aufgabe läuft in einem Container. Das Standard-Image <code>cb-python</code> baut die App selbst. Beim
|
||||
ersten Mal lädt Podman dafür ein Basis-Image und braucht Netz und ein paar Minuten.
|
||||
</p>
|
||||
{#if imagesError}<p class="error">{imagesError}</p>{/if}
|
||||
{#each images as img (img.image)}
|
||||
<div class="image-row">
|
||||
<code>{img.image}</code>
|
||||
{#if img.error}
|
||||
<span class="chip error" title={img.error}>Prüfung fehlgeschlagen</span>
|
||||
{:else if img.available}
|
||||
<span class="chip ok">vorhanden</span>
|
||||
{:else}
|
||||
<span class="chip error">fehlt</span>
|
||||
{/if}
|
||||
<span class="spacer"></span>
|
||||
{#if img.buildable}
|
||||
<button class="primary" disabled={building !== null || img.available} onclick={() => build(img.image)}>
|
||||
{building === img.image ? "baut …" : "Image bauen"}
|
||||
</button>
|
||||
{:else if !img.available}
|
||||
<span class="muted">Muss selbst bereitgestellt werden</span>
|
||||
{/if}
|
||||
</div>
|
||||
{/each}
|
||||
{#if buildError}<p class="error">{buildError}</p>{/if}
|
||||
{#if buildLog.length > 0}
|
||||
<pre class="buildlog">{buildLog.join("\n")}</pre>
|
||||
{/if}
|
||||
</section>
|
||||
|
||||
<section class="card">
|
||||
<h2>System</h2>
|
||||
<dl>
|
||||
@ -216,6 +299,25 @@
|
||||
.spacer {
|
||||
flex: 1;
|
||||
}
|
||||
.image-row {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 0.7rem;
|
||||
padding: 0.4rem 0;
|
||||
border-bottom: 1px solid var(--border);
|
||||
}
|
||||
.buildlog {
|
||||
max-height: 14rem;
|
||||
overflow-y: auto;
|
||||
white-space: pre-wrap;
|
||||
overflow-wrap: anywhere;
|
||||
background: var(--bg);
|
||||
border: 1px solid var(--border);
|
||||
border-radius: 8px;
|
||||
padding: 0.6rem;
|
||||
margin: 0.8rem 0 0;
|
||||
font-size: 0.8rem;
|
||||
}
|
||||
dl {
|
||||
display: grid;
|
||||
grid-template-columns: max-content 1fr;
|
||||
|
||||
@ -18,6 +18,8 @@ export type ModelTest = { ok: boolean; duration_ms: number; message: string };
|
||||
|
||||
export type RuntimeStatus = { program: string; available: boolean; detail: string };
|
||||
|
||||
export type ImageStatus = { image: string; available: boolean; buildable: boolean; error: string | null };
|
||||
|
||||
export type BatchInfo = {
|
||||
id: number;
|
||||
created_at: string;
|
||||
@ -72,6 +74,8 @@ export type Ranking = {
|
||||
models: ModelRank[];
|
||||
cells: MatrixCell[];
|
||||
tasks: TaskColumn[];
|
||||
/** Läufe, die wegen Server- oder Umgebungsfehlern nicht in die Bewertung eingehen. */
|
||||
excluded_runs: number;
|
||||
};
|
||||
|
||||
export type BatchEvent =
|
||||
@ -85,6 +89,8 @@ export const api = {
|
||||
paths: () => invoke<Paths>("get_paths"),
|
||||
tasks: () => invoke<LoadReport>("load_tasks"),
|
||||
runtime: () => invoke<RuntimeStatus>("runtime_status"),
|
||||
imageStatus: () => invoke<ImageStatus[]>("image_status"),
|
||||
buildImage: (image: string) => invoke<void>("build_image", { image }),
|
||||
models: () => invoke<ModelInfo[]>("list_models"),
|
||||
saveModels: (models: ModelEntry[]) => invoke<ModelInfo[]>("save_models", { models }),
|
||||
testModel: (name: string) => invoke<ModelTest>("test_model", { name }),
|
||||
@ -98,6 +104,28 @@ export const api = {
|
||||
invoke<StepRow[]>("run_steps", { batchId, model: r.model, taskId: r.task_id, repeatIdx: r.repeat_idx }),
|
||||
};
|
||||
|
||||
/** Lesbare Bezeichnung einer Fehlerklasse. */
|
||||
export function errorLabel(cls: string): string {
|
||||
const labels: Record<string, string> = {
|
||||
ok: "bestanden",
|
||||
check_failed: "Prüfung fehlgeschlagen",
|
||||
max_steps: "Zu viele Schritte",
|
||||
timeout: "Zeitlimit überschritten",
|
||||
loop_detected: "Schleife erkannt",
|
||||
invalid_tool_json: "Ungültiger Tool-Aufruf",
|
||||
unknown_tool: "Unbekanntes Werkzeug",
|
||||
bad_args: "Falsche Argumente",
|
||||
endpoint_error: "Modell-Server nicht erreichbar",
|
||||
sandbox_error: "Fehler der Umgebung",
|
||||
};
|
||||
return labels[cls] ?? cls;
|
||||
}
|
||||
|
||||
/** Läufe, die nicht am Modell scheiterten und deshalb nicht zählen. */
|
||||
export function isInfrastructure(cls: string): boolean {
|
||||
return cls === "endpoint_error" || cls === "sandbox_error";
|
||||
}
|
||||
|
||||
/** Namen der Bereiche (Gruppen aus SPEC 11). */
|
||||
export const GROUP_LABELS: Record<string, string> = {
|
||||
A: "Tool-Calling",
|
||||
|
||||
Reference in New Issue
Block a user