Skip to main content

Module workspace

Module workspace 

Source
Expand description

Workspace filesystem abstraction for explicit path resolution.

This module provides the Workspace trait and implementations that eliminate CWD dependencies by making all path operations explicit relative to the repository root.

§Problem

The codebase previously relied on std::env::set_current_dir() to set the process CWD to the repository root, then used relative paths (.agent/, PROMPT.md, etc.) throughout. This caused:

  • Test flakiness when tests ran in parallel (CWD is process-global)
  • Background thread bugs when CWD changed after thread started
  • Poor testability without complex CWD manipulation

§Solution

The Workspace trait defines the interface for file operations, with two implementations:

  • WorkspaceFs - Production implementation using the real filesystem
  • [MemoryWorkspace] - Test implementation with in-memory storage (available with test-utils feature)

§Example

use ralph_workflow::workspace::WorkspaceFs;
use std::path::PathBuf;

let ws = WorkspaceFs::new(PathBuf::from("/path/to/repo"));

// Get paths to well-known files
let plan = ws.plan_md();  // /path/to/repo/.agent/PLAN.md
let prompt = ws.prompt_md();  // /path/to/repo/PROMPT.md

// Perform file operations
ws.write(".agent/test.txt", "content")?;
let content = ws.read(".agent/test.txt")?;

Structs§

DirEntry
A directory entry returned by Workspace::read_dir.
WorkspaceFs
Production workspace implementation using the real filesystem.

Constants§

AGENTS_TOML
Path to the agents registry file.
AGENT_CONFIG_TOML
Path to the agent config file.
AGENT_DIR
The .agent directory where Ralph stores all artifacts.
AGENT_LOGS
The .agent/logs directory for agent logs.
AGENT_TMP
The .agent/tmp directory for temporary files.
CHECKPOINT_JSON
Path to the checkpoint file for resume support.
COMMIT_MESSAGE_TXT
Path to the commit message file.
ISSUES_MD
Path to the issues file from code review.
NOTES_MD
Path to the notes file.
PIPELINE_LOG
Path to the pipeline log file.
PLAN_MD
Path to the implementation plan file.
PROMPT_BACKUP
Path to the prompt backup file.
PROMPT_MD
Path to the prompt file in repository root.
REVIEW_BASELINE_TXT
Path to the review baseline tracking file.
START_COMMIT
Path to the start commit tracking file.
STATUS_MD
Path to the status file.

Traits§

Workspace
Trait defining the workspace filesystem interface.