use super::event::PipelineEvent;
use super::state::PipelineState;
#[must_use]
pub fn reduce(state: PipelineState, event: PipelineEvent) -> PipelineState {
match event {
PipelineEvent::Lifecycle(ref e) => lifecycle::reduce_lifecycle_event(state, e),
PipelineEvent::Planning(e) => planning::reduce_planning_event(state, e),
PipelineEvent::Development(e) => development::reduce_development_event(state, e),
PipelineEvent::Review(e) => review::reduce_review_event(state, e),
PipelineEvent::PromptInput(e) => prompt_input::reduce_prompt_input_event(state, e),
PipelineEvent::Agent(e) => agent::reduce_agent_event(state, e),
PipelineEvent::Rebase(e) => rebase::reduce_rebase_event(state, e),
PipelineEvent::Commit(e) => commit::reduce_commit_event(state, e),
PipelineEvent::AwaitingDevFix(e) => {
awaiting_dev_fix::reduce_awaiting_dev_fix_event(state, e)
}
PipelineEvent::ContextCleaned => PipelineState {
context_cleaned: true,
..state
},
PipelineEvent::CheckpointSaved { .. } => {
let checkpoint_saved_count = state.checkpoint_saved_count.saturating_add(1);
PipelineState {
checkpoint_saved_count,
..state
}
}
PipelineEvent::FinalizingStarted => PipelineState {
phase: super::event::PipelinePhase::Finalizing,
..state
},
PipelineEvent::PromptPermissionsRestored => {
let new_phase = match state.phase {
super::event::PipelinePhase::Finalizing => super::event::PipelinePhase::Complete,
_ => state.phase, };
PipelineState {
phase: new_phase,
prompt_permissions: crate::reducer::state::PromptPermissionsState {
locked: false,
restore_needed: false,
restored: true,
last_warning: state.prompt_permissions.last_warning,
},
..state
}
}
PipelineEvent::LoopRecoveryTriggered { .. } => {
let artifact = state
.continuation
.current_artifact
.unwrap_or(super::state::ArtifactType::Plan);
PipelineState {
continuation: state.continuation.reset().with_artifact(artifact),
agent_chain: state.agent_chain.clear_session_id(),
..state
}
}
}
}
#[path = "state_reduction/agent.rs"]
mod agent;
#[path = "state_reduction/awaiting_dev_fix.rs"]
mod awaiting_dev_fix;
#[path = "state_reduction/commit/mod.rs"]
mod commit;
#[path = "state_reduction/development/mod.rs"]
mod development;
#[path = "state_reduction/error.rs"]
mod error;
#[path = "state_reduction/lifecycle.rs"]
mod lifecycle;
#[path = "state_reduction/planning.rs"]
mod planning;
#[path = "state_reduction/prompt_input.rs"]
mod prompt_input;
#[path = "state_reduction/rebase.rs"]
mod rebase;
#[path = "state_reduction/review/mod.rs"]
mod review;
#[cfg(test)]
#[path = "state_reduction/io_tests/mod.rs"]
mod tests;