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;
41#[cfg(feature = "recording")]
42mod session_player;
43#[cfg(feature = "recording")]
44mod session_recorder;
45pub mod skill;
46pub mod skill_registry;
47mod summary_writer;
48pub mod task;
49pub mod task_definition;
50pub mod task_store;
51pub mod testing;
52mod text;
53mod urgent_steer;
54pub mod utils;
55pub mod wave_detection;
56pub mod wave_prompt;
57pub mod wave_tracker;
58pub mod workspace;
59pub mod worktree;
60
61#[cfg(feature = "recording")]
62pub use cli_capture::{CliCapture, CliCapturePair};
63pub use config::{
64    CliConfig, ConfigError, CoreConfig, EventLoopConfig, EventMetadata, FeaturesConfig, HatBackend,
65    HatConfig, InjectMode, MemoriesConfig, MemoriesFilter, RalphConfig, SkillOverride,
66    SkillsConfig,
67};
68// Re-export loop_name types (also available via FeaturesConfig.loop_naming)
69pub use diagnostics::DiagnosticsCollector;
70pub use event_logger::{EventHistory, EventLogger, EventRecord};
71pub use event_loop::{
72    EventLoop, LoopState, ProcessedEvents, ProcessedEventsWithWaves, TerminationReason, UserPrompt,
73};
74pub use event_parser::EventParser;
75pub use event_reader::{Event, EventReader, MalformedLine, ParseResult};
76pub use file_lock::{FileLock, LockGuard as FileLockGuard, LockedFile};
77pub use git_ops::{
78    AutoCommitResult, GitOpsError, auto_commit_changes, clean_stashes, get_commit_summary,
79    get_current_branch, get_head_sha, get_recent_files, has_uncommitted_changes,
80    is_working_tree_clean, prune_remote_refs,
81};
82pub use handoff::{HandoffError, HandoffResult, HandoffWriter};
83pub use hat_registry::HatRegistry;
84pub use hatless_ralph::{HatInfo, HatTopology, HatlessRalph};
85pub use hooks::{
86    HookDefaults, HookEngine, HookExecutor, HookExecutorContract, HookExecutorError,
87    HookInvocationPayload, HookMutationConfig, HookOnError, HookPayloadBuilderInput,
88    HookPayloadContext, HookPayloadContextInput, HookPayloadIteration, HookPayloadLoop,
89    HookPayloadMetadata, HookPhaseEvent, HookRunRequest, HookRunResult, HookSpec, HookStreamOutput,
90    HookSuspendMode, HooksConfig, ResolvedHookSpec, SUSPEND_STATE_SCHEMA_VERSION,
91    SuspendLifecycleState, SuspendStateRecord, SuspendStateStore, SuspendStateStoreError,
92};
93pub use instructions::InstructionBuilder;
94pub use landing::{LandingConfig, LandingError, LandingHandler, LandingResult};
95pub use loop_completion::{CompletionAction, CompletionError, LoopCompletionHandler};
96pub use loop_context::LoopContext;
97pub use loop_history::{HistoryError, HistoryEvent, HistoryEventType, HistorySummary, LoopHistory};
98pub use loop_lock::{LockError, LockGuard, LockMetadata, LoopLock};
99pub use loop_name::{LoopNameGenerator, LoopNamingConfig};
100pub use loop_registry::{LoopEntry, LoopRegistry, RegistryError};
101pub use memory::{Memory, MemoryType};
102pub use memory_store::{
103    DEFAULT_MEMORIES_PATH, MarkdownMemoryStore, format_memories_as_markdown, truncate_to_budget,
104};
105pub use merge_queue::{
106    MergeButtonState, MergeEntry, MergeEvent, MergeEventType, MergeOption, MergeQueue,
107    MergeQueueError, MergeState, SteeringDecision, merge_button_state, merge_execution_summary,
108    merge_needs_steering, smart_merge_summary,
109};
110pub use planning_session::{
111    ConversationEntry, ConversationType, PlanningSession, PlanningSessionError, SessionMetadata,
112    SessionStatus,
113};
114pub use preflight::{
115    AcceptanceCriterion, CheckResult, CheckStatus, PreflightCheck, PreflightReport,
116    PreflightRunner, extract_acceptance_criteria, extract_all_criteria, extract_criteria_from_file,
117};
118#[cfg(feature = "recording")]
119pub use session_player::{PlayerConfig, ReplayMode, SessionPlayer, TimestampedRecord};
120#[cfg(feature = "recording")]
121pub use session_recorder::{Record, SessionRecorder};
122pub use skill::{SkillEntry, SkillFrontmatter, SkillSource, parse_frontmatter};
123pub use skill_registry::SkillRegistry;
124pub use summary_writer::SummaryWriter;
125pub use task::{Task, TaskStatus};
126pub use task_definition::{
127    TaskDefinition, TaskDefinitionError, TaskSetup, TaskSuite, Verification,
128};
129pub use task_store::TaskStore;
130pub use text::{floor_char_boundary, truncate_with_ellipsis};
131pub use urgent_steer::{UrgentSteerRecord, UrgentSteerStore};
132pub use wave_detection::{DetectedWave, detect_wave_events};
133pub use wave_prompt::{WaveWorkerContext, build_wave_worker_prompt};
134pub use wave_tracker::{CompletedWave, WaveFailure, WaveProgress, WaveResult, WaveTracker};
135pub use workspace::{
136    CleanupPolicy, TaskWorkspace, VerificationResult, WorkspaceError, WorkspaceInfo,
137    WorkspaceManager,
138};
139pub use worktree::{
140    SyncStats, Worktree, WorktreeConfig, WorktreeError, create_worktree, ensure_gitignore,
141    list_ralph_worktrees, list_worktrees, remove_worktree, sync_working_directory_to_worktree,
142    worktree_exists,
143};