Skip to main content

ralph_core/
lib.rs

1//! # ralph-core
2//!
3//! Core orchestration functionality for the Ralph Orchestrator framework.
4//!
5//! This crate provides:
6//! - The main orchestration loop for coordinating multiple agents
7//! - Configuration loading and management
8//! - State management for agent sessions
9//! - Message routing between agents
10//! - Terminal capture for session recording
11//! - Benchmark task definitions and workspace isolation
12
13#[cfg(feature = "recording")]
14mod cli_capture;
15mod config;
16pub mod diagnostics;
17mod event_logger;
18mod event_loop;
19mod event_parser;
20mod event_reader;
21pub mod file_lock;
22mod git_ops;
23mod handoff;
24mod hat_registry;
25mod hatless_ralph;
26pub mod hooks;
27mod instructions;
28mod landing;
29pub mod loop_completion;
30pub mod loop_context;
31pub mod loop_history;
32pub mod loop_lock;
33mod loop_name;
34pub mod loop_registry;
35mod memory;
36pub mod memory_parser;
37mod memory_store;
38pub mod merge_queue;
39pub mod planning_session;
40pub mod preflight;
41pub mod preset_source;
42#[cfg(feature = "recording")]
43mod session_player;
44#[cfg(feature = "recording")]
45mod session_recorder;
46pub mod skill;
47pub mod skill_registry;
48mod summary_writer;
49pub mod task;
50pub mod task_definition;
51pub mod task_store;
52pub mod testing;
53mod text;
54mod urgent_steer;
55pub mod utils;
56pub mod wave_detection;
57pub mod wave_prompt;
58pub mod wave_tracker;
59pub mod workspace;
60pub mod worktree;
61
62#[cfg(feature = "recording")]
63pub use cli_capture::{CliCapture, CliCapturePair};
64pub use config::{
65    CliConfig, ConfigError, CoreConfig, EventLoopConfig, EventMetadata, FeaturesConfig, HatBackend,
66    HatConfig, InjectMode, MemoriesConfig, MemoriesFilter, RalphConfig, RobotMode,
67    ScratchpadConfig, SkillOverride, SkillsConfig, resolve_context_window,
68    resolve_context_window_for_backend,
69};
70// Re-export loop_name types (also available via FeaturesConfig.loop_naming)
71pub use diagnostics::DiagnosticsCollector;
72pub use event_logger::{EventHistory, EventLogger, EventRecord};
73pub use event_loop::{
74    EventLoop, LoopState, ProcessedEvents, ProcessedEventsWithWaves, TerminationReason, UserPrompt,
75};
76pub use event_parser::EventParser;
77pub use event_reader::{Event, EventReader, MalformedLine, ParseResult};
78pub use file_lock::{FileLock, LockGuard as FileLockGuard, LockedFile};
79pub use git_ops::{
80    AutoCommitResult, GitOpsError, auto_commit_changes, clean_stashes, get_commit_summary,
81    get_current_branch, get_head_sha, get_recent_files, has_uncommitted_changes,
82    is_working_tree_clean, prune_remote_refs,
83};
84pub use handoff::{HandoffError, HandoffResult, HandoffWriter};
85pub use hat_registry::HatRegistry;
86pub use hatless_ralph::{HatInfo, HatTopology, HatlessRalph};
87pub use hooks::{
88    HookDefaults, HookEngine, HookExecutor, HookExecutorContract, HookExecutorError,
89    HookInvocationPayload, HookMutationConfig, HookOnError, HookPayloadBuilderInput,
90    HookPayloadContext, HookPayloadContextInput, HookPayloadIteration, HookPayloadLoop,
91    HookPayloadMetadata, HookPhaseEvent, HookRunRequest, HookRunResult, HookSpec, HookStreamOutput,
92    HookSuspendMode, HooksConfig, ResolvedHookSpec, SUSPEND_STATE_SCHEMA_VERSION,
93    SuspendLifecycleState, SuspendStateRecord, SuspendStateStore, SuspendStateStoreError,
94};
95pub use instructions::InstructionBuilder;
96pub use landing::{LandingConfig, LandingError, LandingHandler, LandingResult};
97pub use loop_completion::{CompletionAction, CompletionError, LoopCompletionHandler};
98pub use loop_context::LoopContext;
99pub use loop_history::{HistoryError, HistoryEvent, HistoryEventType, HistorySummary, LoopHistory};
100pub use loop_lock::{LockError, LockGuard, LockMetadata, LoopLock};
101pub use loop_name::{LoopNameGenerator, LoopNamingConfig};
102pub use loop_registry::{LoopEntry, LoopRegistry, RegistryError};
103pub use memory::{Memory, MemoryType};
104pub use memory_store::{
105    DEFAULT_MEMORIES_PATH, MarkdownMemoryStore, format_memories_as_markdown, truncate_to_budget,
106};
107pub use merge_queue::{
108    MergeButtonState, MergeEntry, MergeEvent, MergeEventType, MergeOption, MergeQueue,
109    MergeQueueError, MergeState, SteeringDecision, merge_button_state, merge_execution_summary,
110    merge_needs_steering, smart_merge_summary,
111};
112pub use planning_session::{
113    ConversationEntry, ConversationType, PlanningSession, PlanningSessionError, SessionMetadata,
114    SessionStatus,
115};
116pub use preflight::{
117    AcceptanceCriterion, CheckResult, CheckStatus, PreflightCheck, PreflightReport,
118    PreflightRunner, extract_acceptance_criteria, extract_all_criteria, extract_criteria_from_file,
119};
120pub use preset_source::{
121    PresetRegistry, PresetSource, PresetSourceError, TomlPresetSource, YamlPresetSource,
122};
123#[cfg(feature = "recording")]
124pub use session_player::{PlayerConfig, ReplayMode, SessionPlayer, TimestampedRecord};
125#[cfg(feature = "recording")]
126pub use session_recorder::{Record, SessionRecorder};
127pub use skill::{SkillEntry, SkillFrontmatter, SkillSource, parse_frontmatter};
128pub use skill_registry::SkillRegistry;
129pub use summary_writer::SummaryWriter;
130pub use task::{Task, TaskStatus};
131pub use task_definition::{
132    TaskDefinition, TaskDefinitionError, TaskSetup, TaskSuite, Verification,
133};
134pub use task_store::TaskStore;
135pub use text::{floor_char_boundary, truncate_with_ellipsis};
136pub use urgent_steer::{UrgentSteerRecord, UrgentSteerStore};
137pub use wave_detection::{DetectedWave, detect_wave_events};
138pub use wave_prompt::{WaveWorkerContext, build_wave_worker_prompt};
139pub use wave_tracker::{CompletedWave, WaveFailure, WaveProgress, WaveResult, WaveTracker};
140pub use workspace::{
141    CleanupPolicy, TaskWorkspace, VerificationResult, WorkspaceError, WorkspaceInfo,
142    WorkspaceManager,
143};
144pub use worktree::{
145    SyncStats, Worktree, WorktreeConfig, WorktreeError, create_worktree, ensure_gitignore,
146    list_ralph_worktrees, list_worktrees, remove_worktree, sync_working_directory_to_worktree,
147    worktree_exists,
148};