Files
plan2code/plan2code-app/src-tauri/src/loop_shared/retry.rs
T

29 lines
1.0 KiB
Rust

//! The retry rule and the strength step-up, called by both the Implementation
//! Loop and the Review Loop.
use std::collections::BTreeMap;
use crate::loop_driver::{LoopSetup, StopCause};
use crate::models::{self, StrengthRow};
/// One fresh retry for a crash, silence or an announce notice that never came
/// (a crash), when the setup allows it and the phase has not used it yet. A
/// failed watcher is never retried.
pub fn should_retry(cause: &StopCause, setup: &LoopSetup, retries_used_this_phase: u32) -> bool {
matches!(
cause,
StopCause::Crash | StopCause::Silence | StopCause::NoSession
) && setup.retry_once
&& retries_used_this_phase == 0
}
/// The strength word one step above `current`, or `None` when there is none
/// (Best stays, an unmapped word stays). A thin wrapper over
/// `models::next_strength`, so a caller without a `RunningRecord` can step up.
pub fn next_strength_word(
resolved: &BTreeMap<String, StrengthRow>,
current: &str,
) -> Option<String> {
models::next_strength(resolved, current)
}