This commit is contained in:
Alex Emmet 2026-05-21 13:55:49 +02:00
commit 49a436da7f
3 changed files with 80 additions and 1 deletions

View file

@ -17,6 +17,7 @@ pub struct Task {
pub logs: Vec<String>,
pub started_at: Option<DateTime<Utc>>,
pub completed_at: Option<DateTime<Utc>>,
pub payload: Option<serde_json::Value>,
}
impl Default for Task {
@ -32,6 +33,7 @@ impl Default for Task {
logs: Vec::new(),
started_at: None,
completed_at: None,
payload: None,
}
}
}
@ -49,9 +51,15 @@ impl Task {
logs: Vec::new(),
started_at: None,
completed_at: None,
payload: None,
}
}
pub fn with_payload<T: Serialize>(mut self, payload: &T) -> Self {
self.payload = serde_json::to_value(payload).ok();
self
}
pub fn start(&mut self) -> Result<(), String> {
match self.status {
TaskStatus::Pending => {
@ -133,6 +141,68 @@ impl TaskResult {
}
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct TestCase {
pub name: String,
pub command: String,
pub expected_output: Option<String>,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct ResourceLimits {
pub cpu_cores: f32,
pub memory_mb: u64,
pub gpu_memory_mb: Option<u64>,
pub timeout_seconds: u64,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct FileRange {
pub path: String,
pub line_start: u32,
pub line_end: u32,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct AgentTaskSpec {
pub task_id: Uuid,
pub title: String,
pub description: String,
pub board_snapshot: serde_json::Value,
pub assembled_context_id: Uuid,
pub selected_files: Vec<FileRange>,
pub entry_points: Vec<String>,
pub tests: Option<Vec<TestCase>>,
pub success_criteria: Option<String>,
pub token_budget: usize,
pub resource_limits: ResourceLimits,
pub parent_task_id: Option<Uuid>,
}
impl AgentTaskSpec {
pub fn new(task_id: Uuid, title: String, assembled_context_id: Uuid) -> Self {
Self {
task_id,
title,
description: String::new(),
board_snapshot: serde_json::json!({}),
assembled_context_id,
selected_files: Vec::new(),
entry_points: Vec::new(),
tests: None,
success_criteria: None,
token_budget: 1000000, // Default 1M tokens
resource_limits: ResourceLimits {
cpu_cores: 1.0,
memory_mb: 2048,
gpu_memory_mb: None,
timeout_seconds: 3600, // 1 hour
},
parent_task_id: None,
}
}
}
#[cfg(test)]
mod tests {
use super::*;