feat: Sandbox-Limits in config.toml und Image cb-python
Speicher-, CPU- und Runtime-Angabe in config.toml, Standard podman, 2g, 2. Containerfile für cb-python (Python 3.12, pytest). Echter Sandbox-Test mit cb-python:latest grün. Co-Authored-By: Claude Haiku 5.5 <noreply@anthropic.com>
This commit is contained in:
@ -21,7 +21,7 @@ Zeichen: ✓ fertig · ◐ teilweise · ✗ offen · ? nicht geprüft.
|
||||
| #1001 | F-01 Tauri-Grundgerüst, Datenordner, Config | SPEC 12 | ◐ | Umgesetzt: Gerüst, TOML-Config mit Standardanlage, Datenordner, Setup zeigt Pfade. `cargo test` 6/6, `npm run build` grün. Klicktests `start2app.1–.2` manuell noch nicht ✓ (→ #1018) |
|
||||
| #1002 | F-02 Aufgaben laden und validieren | SPEC 4, 12 | ◐ | Umgesetzt: Laden, Validierung (Pflichtdateien, TOML, Werte, `check.sh` ausführbar), Fehler im Setup. `cargo test` 13/13. Klicktests `aufgabe2validierung.1–.2` manuell offen (→ #1019) |
|
||||
| #1003 | F-03 Agent-Loop gegen Ollama mit Tools und Fehlerklassen | SPEC 5, 12 | ✗ | noch nicht begonnen (→ #1021) |
|
||||
| #1004 | F-04 Podman-Sandbox pro Lauf | SPEC 6, 12 | ◐ | Modul `sandbox.rs` steht: Start ohne Netz, Limits, Kopieren nach `/work`, `exec` mit Timeout, Export, Entfernen. Echter Lauf gegen Podman bestanden (Test ignoriert, siehe Anmerkung). Noch nicht an Commands angebunden; Limits nicht aus der Config; Klicktests `lauf2sandbox.1–.2` manuell offen (→ #1020) |
|
||||
| #1004 | F-04 Podman-Sandbox pro Lauf | SPEC 6, 12 | ◐ | Modul `sandbox.rs` steht: Start ohne Netz, Limits, Kopieren nach `/work`, `exec` mit Timeout, Export, Entfernen. Limits und Runtime kommen aus `config.toml`. Echter Lauf gegen Podman mit Image `cb-python:latest` bestanden (ignorierter Test). Noch nicht an den Runner angebunden (#1022); Klicktests `lauf2sandbox.1–.2` manuell offen (→ #1020) |
|
||||
| #1005 | F-05 Runner mit Wiederholungen, Abbruch, Fortsetzen | SPEC 7, 12 | ✗ | noch nicht begonnen (→ #1022) |
|
||||
| #1006 | F-06 SQLite inkl. Schritt-Log | SPEC 8, 12 | ✗ | noch nicht begonnen (→ #1023) |
|
||||
| #1007 | F-07 Tests a-01 bis a-03 und b-04 bis b-06 | SPEC 11, 12 | ✗ | noch nicht begonnen (→ #1024) |
|
||||
@ -46,7 +46,7 @@ Zeichen: ✓ fertig · ◐ teilweise · ✗ offen · ? nicht geprüft.
|
||||
**P1 – als Nächstes (Release 0.1.0, Phase 1 Kern)**
|
||||
- [#1018] **Gerüst anlegen.** Tauri 2 mit Svelte und TypeScript, Rust-Backend, Datenordner, TOML-Config. Gerüst (`create-tauri-app`, svelte-ts) und Config-/Datenordner-Logik (`src-tauri/src/config.rs`) sind gebaut; `cargo test` 6/6 grün. Offen: die Klicktests `start2app.1–.2` vom Menschen manuell ausführen lassen. Erst dann gilt #1018 als fertig. Tests `start2app.1–.2`. → #1001
|
||||
- [#1019] **Aufgaben laden und validieren.** Umgesetzt in `src-tauri/src/tasks.rs`, `cargo test` 13/13. Offen: Klicktests `aufgabe2validierung.1–.2` manuell ausführen lassen. Tests `aufgabe2validierung.1–.2`. → #1002
|
||||
- [#1020] **Podman-Sandbox pro Lauf.** Modul gebaut (`src-tauri/src/sandbox.rs`). Echter Test `CB_TEST_IMAGE=docker.io/library/python:3.12-slim cargo test -- --ignored` grün: Startdatei in `/work`, Netz aus, Timeout erkannt, Export, Container entfernt. Offen: Limits aus der Config (SPEC 6), Anbindung an den Runner (#1022), Klicktests `lauf2sandbox.1–.2` manuell, Image `cb-python` (Containerfile) noch nicht gebaut. Tests `lauf2sandbox.1–.2`. → #1004
|
||||
- [#1020] **Podman-Sandbox pro Lauf.** Modul gebaut (`src-tauri/src/sandbox.rs`). Echter Test `CB_TEST_IMAGE=docker.io/library/python:3.12-slim cargo test -- --ignored` grün: Startdatei in `/work`, Netz aus, Timeout erkannt, Export, Container entfernt. Limits und Runtime aus der Config. Image `cb-python` gebaut (`images/cb-python/Containerfile`, Python 3.12 und pytest). Der Test lief mit `CB_TEST_IMAGE=cb-python:latest` grün. Offen: Anbindung an den Runner (#1022), Klicktests `lauf2sandbox.1–.2` manuell. Tests `lauf2sandbox.1–.2`. → #1004
|
||||
- [#1021] **Agent-Loop gegen Ollama.** Tools `read_file`, `write_file`, `list_dir`, `run_shell`, `done`; Pfade auf `/work`; Fehlerklassen und Metriken. Tests `lauf2ergebnis.1–.3`. → #1003
|
||||
- [#1022] **Runner.** Wiederholungen, sequentiell pro Modell, Aufwärmen, Abbruch und Fortsetzen. Tests `batch2fortsetzen.1–.2`. → #1005
|
||||
- [#1023] **SQLite-Speicher.** Tabellen `batch`, `run`, `step` nach Abschnitt 8. Tests `lauf2ergebnis.2`. → #1006
|
||||
|
||||
8
images/cb-python/Containerfile
Normal file
8
images/cb-python/Containerfile
Normal file
@ -0,0 +1,8 @@
|
||||
# cb-python: Python 3 mit pytest für Aufgaben der Gruppen A bis C.
|
||||
# Bauen: podman build -t cb-python:latest images/cb-python
|
||||
FROM docker.io/library/python:3.12-slim
|
||||
|
||||
RUN pip install --no-cache-dir pytest \
|
||||
&& mkdir -p /work
|
||||
|
||||
WORKDIR /work
|
||||
@ -4,6 +4,7 @@
|
||||
//! mit Standardwerten angelegt. Pfade in der Datei sind optional; ohne Angabe
|
||||
//! gilt der Standardordner der App bzw. `<datenordner>/tasks`.
|
||||
|
||||
use crate::sandbox::Limits;
|
||||
use serde::{Deserialize, Serialize};
|
||||
use std::fs;
|
||||
use std::path::{Path, PathBuf};
|
||||
@ -11,13 +12,32 @@ use std::path::{Path, PathBuf};
|
||||
pub const CONFIG_FILE_NAME: &str = "config.toml";
|
||||
|
||||
/// Rohe Konfiguration, so wie sie in der Datei steht.
|
||||
#[derive(Debug, Default, Clone, PartialEq, Serialize, Deserialize)]
|
||||
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
|
||||
#[serde(default, deny_unknown_fields)]
|
||||
pub struct Config {
|
||||
/// Datenordner (Ergebnisse, Artefakte, Datenbank). Leer = Standard der App.
|
||||
pub data_dir: Option<PathBuf>,
|
||||
/// Aufgabenordner. Leer = `<datenordner>/tasks`.
|
||||
pub tasks_dir: Option<PathBuf>,
|
||||
/// Container-Programm für die Sandbox (Podman-CLI).
|
||||
pub container_runtime: String,
|
||||
/// Speicherlimit pro Lauf, Podman-Schreibweise.
|
||||
pub sandbox_memory: String,
|
||||
/// CPU-Anteil pro Lauf.
|
||||
pub sandbox_cpus: String,
|
||||
}
|
||||
|
||||
impl Default for Config {
|
||||
fn default() -> Self {
|
||||
let limits = Limits::default();
|
||||
Config {
|
||||
data_dir: None,
|
||||
tasks_dir: None,
|
||||
container_runtime: "podman".into(),
|
||||
sandbox_memory: limits.memory,
|
||||
sandbox_cpus: limits.cpus,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Aufgelöste Pfade, die die App tatsächlich verwendet.
|
||||
@ -34,6 +54,14 @@ impl Config {
|
||||
toml::from_str(text).map_err(|e| format!("config.toml ist ungültig: {e}"))
|
||||
}
|
||||
|
||||
/// Ressourcenlimits der Sandbox aus der Konfiguration.
|
||||
pub fn sandbox_limits(&self) -> Limits {
|
||||
Limits {
|
||||
memory: self.sandbox_memory.clone(),
|
||||
cpus: self.sandbox_cpus.clone(),
|
||||
}
|
||||
}
|
||||
|
||||
/// Löst die Pfade auf. `default_data_dir` ist der Standardordner der App.
|
||||
pub fn resolve(&self, config_file: &Path, default_data_dir: &Path) -> Paths {
|
||||
let data_dir = self
|
||||
@ -54,7 +82,7 @@ impl Config {
|
||||
|
||||
/// Lädt die Konfiguration aus `config_dir/config.toml`, legt die Datei bei Bedarf
|
||||
/// mit Standardwerten an und stellt sicher, dass der Datenordner existiert.
|
||||
pub fn load_or_create(config_dir: &Path, default_data_dir: &Path) -> Result<Paths, String> {
|
||||
pub fn load_or_create(config_dir: &Path, default_data_dir: &Path) -> Result<(Paths, Config), String> {
|
||||
fs::create_dir_all(config_dir)
|
||||
.map_err(|e| format!("Konfigurationsordner {} nicht anlegbar: {e}", config_dir.display()))?;
|
||||
|
||||
@ -75,7 +103,7 @@ pub fn load_or_create(config_dir: &Path, default_data_dir: &Path) -> Result<Path
|
||||
let paths = config.resolve(&config_file, default_data_dir);
|
||||
fs::create_dir_all(&paths.data_dir)
|
||||
.map_err(|e| format!("Datenordner {} nicht anlegbar: {e}", paths.data_dir.display()))?;
|
||||
Ok(paths)
|
||||
Ok((paths, config))
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
@ -95,6 +123,13 @@ mod tests {
|
||||
assert_eq!(c.tasks_dir, Some(PathBuf::from("/x/aufgaben")));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn sandbox_limits_werden_gelesen() {
|
||||
let c = Config::parse("sandbox_memory = \"4g\"\nsandbox_cpus = \"1\"\n").unwrap();
|
||||
assert_eq!(c.sandbox_limits(), Limits { memory: "4g".into(), cpus: "1".into() });
|
||||
assert_eq!(c.container_runtime, "podman");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn unbekannter_schluessel_ist_fehler() {
|
||||
assert!(Config::parse("unbekannt = 1\n").is_err());
|
||||
@ -122,7 +157,7 @@ mod tests {
|
||||
let cfg_dir = base.join("cfg");
|
||||
let data_dir = base.join("data");
|
||||
|
||||
let paths = load_or_create(&cfg_dir, &data_dir).unwrap();
|
||||
let (paths, _) = load_or_create(&cfg_dir, &data_dir).unwrap();
|
||||
assert!(cfg_dir.join(CONFIG_FILE_NAME).exists());
|
||||
assert!(data_dir.is_dir());
|
||||
assert_eq!(paths.tasks_dir, data_dir.join("tasks"));
|
||||
|
||||
@ -31,8 +31,9 @@ pub fn run() {
|
||||
.path()
|
||||
.app_data_dir()
|
||||
.map_err(|e| format!("Datenordner nicht ermittelbar: {e}"))?;
|
||||
let paths = config::load_or_create(&config_dir, &default_data_dir)?;
|
||||
let (paths, cfg) = config::load_or_create(&config_dir, &default_data_dir)?;
|
||||
app.manage(AppPaths(paths));
|
||||
app.manage(cfg);
|
||||
Ok(())
|
||||
})
|
||||
.invoke_handler(tauri::generate_handler![get_paths, load_tasks])
|
||||
|
||||
Reference in New Issue
Block a user