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 withtest-utilsfeature)
§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. - Workspace
Fs - 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
.agentdirectory where Ralph stores all artifacts. - AGENT_
LOGS - The
.agent/logsdirectory for agent logs. - AGENT_
TMP - The
.agent/tmpdirectory 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.