pub struct TaskWorkspace { /* private fields */ }Expand description
An isolated workspace for running a benchmark task.
The workspace is created in a temporary directory with:
- Its own
.gitdirectory (isolated from main repo) - A fresh
.ralph/agent/scratchpad.md - Copied setup files from the task definition
Implementations§
Source§impl TaskWorkspace
impl TaskWorkspace
Sourcepub fn create(
task: &TaskDefinition,
base_dir: &Path,
) -> Result<Self, WorkspaceError>
pub fn create( task: &TaskDefinition, base_dir: &Path, ) -> Result<Self, WorkspaceError>
Creates a new isolated workspace for the given task.
The workspace is created at:
{base_dir}/ralph-bench-{task_name}-{timestamp}/
§Arguments
task- The task definition to create a workspace forbase_dir- Base directory for workspaces (e.g.,/tmp)
§Errors
Returns WorkspaceError if directory creation or git init fails.
Sourcepub fn created_at(&self) -> u64
pub fn created_at(&self) -> u64
Returns the creation timestamp.
Sourcepub fn setup(
&self,
task: &TaskDefinition,
tasks_dir: &Path,
) -> Result<(), WorkspaceError>
pub fn setup( &self, task: &TaskDefinition, tasks_dir: &Path, ) -> Result<(), WorkspaceError>
Sets up the workspace with files from the task definition.
This copies:
- The prompt file as
PROMPT.md - Any setup files specified in the task definition
§Arguments
task- The task definition containing setup configurationtasks_dir- Base directory where task files are located
§Errors
Returns WorkspaceError if file copying fails.
Sourcepub fn cleanup(&mut self) -> Result<(), WorkspaceError>
pub fn cleanup(&mut self) -> Result<(), WorkspaceError>
Sourcepub fn is_cleaned_up(&self) -> bool
pub fn is_cleaned_up(&self) -> bool
Returns true if the workspace has been cleaned up.
Source§impl TaskWorkspace
impl TaskWorkspace
Sourcepub fn run_verification(
&self,
verification: &Verification,
) -> Result<VerificationResult, WorkspaceError>
pub fn run_verification( &self, verification: &Verification, ) -> Result<VerificationResult, WorkspaceError>
Runs a verification command in the workspace directory.
The command is executed via bash -c in the workspace’s root directory.
§Arguments
verification- The verification configuration with command and expected exit code
§Returns
A VerificationResult indicating whether the command passed and capturing output.
§Errors
Returns WorkspaceError::Verification if the command fails to execute
(not the same as the command returning a non-zero exit code).