use salvor_core::{ReplayError, RunId};
use salvor_store::StoreError;
use thiserror::Error;
#[derive(Debug, Error)]
pub enum RuntimeError {
#[error("replay: {0}")]
Replay(#[from] ReplayError),
#[error("store: {0}")]
Store(#[from] StoreError),
#[error("model call: {0}")]
Model(#[from] salvor_llm::Error),
#[error("model request did not serialize: {0}")]
RequestEncode(serde_json::Error),
#[error("recorded model response did not decode: {0}")]
RecordedResponseDecode(serde_json::Error),
#[error("run {run_id:?} already has recorded history; use recover or resume")]
RunAlreadyStarted {
run_id: RunId,
},
#[error("run {run_id:?} has no recorded history")]
UnknownRun {
run_id: RunId,
},
#[error("run {run_id:?} is not parked (status: {status}); resume needs a parked run")]
NotParked {
run_id: RunId,
status: String,
},
#[error("resume input rejected: {0}")]
ResumeInputRejected(String),
#[error("invalid labels: {0}")]
InvalidLabels(String),
#[error(
"run {run_id:?} does not need reconciliation (status: {status}); resolve records the completion of a dangling write intent, and this run has none"
)]
NotReconcilable {
run_id: RunId,
status: String,
},
#[error(
"run {run_id:?} is already terminal (status: {status}); there is nothing left to abandon"
)]
AlreadyTerminal {
run_id: RunId,
status: String,
},
}