pub struct LoopHistory { /* private fields */ }Expand description
Loop history manager for a single loop.
Wraps an append-only JSONL file for recording loop events.
Implementations§
Source§impl LoopHistory
impl LoopHistory
Sourcepub fn from_context(context: &LoopContext) -> Self
pub fn from_context(context: &LoopContext) -> Self
Create a loop history from a loop context.
Sourcepub fn append(&self, event: HistoryEvent) -> Result<(), HistoryError>
pub fn append(&self, event: HistoryEvent) -> Result<(), HistoryError>
Append an event to the history file.
This is thread-safe via file locking.
Sourcepub fn read_all(&self) -> Result<Vec<HistoryEvent>, HistoryError>
pub fn read_all(&self) -> Result<Vec<HistoryEvent>, HistoryError>
Read all events from the history file.
Sourcepub fn last_iteration(&self) -> Result<Option<u32>, HistoryError>
pub fn last_iteration(&self) -> Result<Option<u32>, HistoryError>
Find the last completed iteration number.
Returns None if no iterations have been completed.
Sourcepub fn is_completed(&self) -> Result<bool, HistoryError>
pub fn is_completed(&self) -> Result<bool, HistoryError>
Check if the loop completed successfully.
Sourcepub fn get_prompt(&self) -> Result<Option<String>, HistoryError>
pub fn get_prompt(&self) -> Result<Option<String>, HistoryError>
Get the original prompt that started the loop.
Sourcepub fn summary(&self) -> Result<HistorySummary, HistoryError>
pub fn summary(&self) -> Result<HistorySummary, HistoryError>
Get summary statistics about the loop.
Sourcepub fn record_started(&self, prompt: &str) -> Result<(), HistoryError>
pub fn record_started(&self, prompt: &str) -> Result<(), HistoryError>
Record loop started event.
Sourcepub fn record_iteration_started(
&self,
iteration: u32,
) -> Result<(), HistoryError>
pub fn record_iteration_started( &self, iteration: u32, ) -> Result<(), HistoryError>
Record iteration started event.
Sourcepub fn record_event_published(
&self,
topic: &str,
payload: &str,
) -> Result<(), HistoryError>
pub fn record_event_published( &self, topic: &str, payload: &str, ) -> Result<(), HistoryError>
Record event published event.
Sourcepub fn record_iteration_completed(
&self,
iteration: u32,
success: bool,
) -> Result<(), HistoryError>
pub fn record_iteration_completed( &self, iteration: u32, success: bool, ) -> Result<(), HistoryError>
Record iteration completed event.
Sourcepub fn record_completed(&self, reason: &str) -> Result<(), HistoryError>
pub fn record_completed(&self, reason: &str) -> Result<(), HistoryError>
Record loop completed event.
Sourcepub fn record_resumed(&self, from_iteration: u32) -> Result<(), HistoryError>
pub fn record_resumed(&self, from_iteration: u32) -> Result<(), HistoryError>
Record loop resumed event.
Sourcepub fn record_terminated(&self, signal: &str) -> Result<(), HistoryError>
pub fn record_terminated(&self, signal: &str) -> Result<(), HistoryError>
Record loop terminated event.
Sourcepub fn record_merge_queued(&self) -> Result<(), HistoryError>
pub fn record_merge_queued(&self) -> Result<(), HistoryError>
Record merge queued event.
Sourcepub fn record_merge_started(&self, pid: u32) -> Result<(), HistoryError>
pub fn record_merge_started(&self, pid: u32) -> Result<(), HistoryError>
Record merge started event.
Sourcepub fn record_merge_completed(&self, commit: &str) -> Result<(), HistoryError>
pub fn record_merge_completed(&self, commit: &str) -> Result<(), HistoryError>
Record merge completed event.
Sourcepub fn record_merge_failed(&self, reason: &str) -> Result<(), HistoryError>
pub fn record_merge_failed(&self, reason: &str) -> Result<(), HistoryError>
Record merge failed event.
Sourcepub fn record_discarded(&self, reason: &str) -> Result<(), HistoryError>
pub fn record_discarded(&self, reason: &str) -> Result<(), HistoryError>
Record loop discarded event.