use crate::reducer::effect::Effect;
use crate::reducer::event::{DevelopmentEvent, PipelineEvent};
use crate::reducer::state::{
DevelopmentStatus, MaterializedPromptInput, PromptInputKind, PromptInputRepresentation,
PromptMaterializationReason,
};
use crate::reducer::ui_event::{UIEvent, XmlOutputContext, XmlOutputType};
use super::super::MockEffectHandler;
impl MockEffectHandler {
pub(super) fn handle_development_effect(
&self,
effect: &Effect,
) -> Option<(PipelineEvent, Vec<UIEvent>)> {
match *effect {
Effect::PrepareDevelopmentContext { iteration } => Some((
PipelineEvent::development_context_prepared(iteration),
vec![],
)),
Effect::MaterializeDevelopmentInputs { iteration } => {
let prompt = MaterializedPromptInput {
kind: PromptInputKind::Prompt,
content_id_sha256: "id".to_string(),
consumer_signature_sha256: self.state.agent_chain.consumer_signature_sha256(),
original_bytes: 1,
final_bytes: 1,
model_budget_bytes: None,
inline_budget_bytes: None,
representation: PromptInputRepresentation::Inline,
reason: PromptMaterializationReason::WithinBudgets,
};
let plan = MaterializedPromptInput {
kind: PromptInputKind::Plan,
content_id_sha256: "id".to_string(),
consumer_signature_sha256: self.state.agent_chain.consumer_signature_sha256(),
original_bytes: 1,
final_bytes: 1,
model_budget_bytes: None,
inline_budget_bytes: None,
representation: PromptInputRepresentation::Inline,
reason: PromptMaterializationReason::WithinBudgets,
};
Some((
PipelineEvent::development_inputs_materialized(iteration, prompt, plan),
vec![],
))
}
Effect::PrepareDevelopmentPrompt {
iteration,
prompt_mode: _,
} => Some((
PipelineEvent::development_prompt_prepared(iteration),
vec![],
)),
Effect::InvokeDevelopmentAgent { iteration } => {
Some((PipelineEvent::development_agent_invoked(iteration), vec![]))
}
Effect::InvokeAnalysisAgent { iteration } => Some((
PipelineEvent::Development(DevelopmentEvent::AnalysisAgentInvoked { iteration }),
vec![],
)),
Effect::ExtractDevelopmentXml { iteration } => {
let mock_dev_result_xml = r"<ralph-development-result>
<ralph-status>completed</ralph-status>
<ralph-summary>Mock development iteration completed successfully</ralph-summary>
<ralph-files-changed>src/test.rs
src/lib.rs</ralph-files-changed>
</ralph-development-result>";
let ui = vec![
UIEvent::IterationProgress {
current: iteration,
total: self.state.total_iterations,
},
UIEvent::XmlOutput {
xml_type: XmlOutputType::DevelopmentResult,
content: mock_dev_result_xml.to_string(),
context: Some(XmlOutputContext {
iteration: Some(iteration),
pass: None,
snippets: Vec::new(),
}),
},
];
Some((PipelineEvent::development_xml_extracted(iteration), ui))
}
Effect::ValidateDevelopmentXml { iteration } => Some((
PipelineEvent::development_xml_validated(
iteration,
DevelopmentStatus::Completed,
"Mock development iteration completed successfully".to_string(),
Some(vec!["src/test.rs".to_string(), "src/lib.rs".to_string()]),
None,
),
vec![],
)),
Effect::ArchiveDevelopmentXml { iteration } => {
Some((PipelineEvent::development_xml_archived(iteration), vec![]))
}
Effect::ApplyDevelopmentOutcome { iteration } => Some((
PipelineEvent::development_outcome_applied(iteration),
vec![],
)),
_ => None,
}
}
}