1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
//! Development events.
use crate::reducer::state::DevelopmentStatus;
use serde::{Deserialize, Serialize};
/// Development phase events.
///
/// Events related to development iterations, including continuation handling
/// for partial/failed completion states. Development iterations involve
/// invoking developer agents to make code changes.
///
/// # State Transitions
///
/// - `PhaseStarted`: Sets phase to Development
/// - `IterationStarted`: Resets agent chain, clears continuation state
/// - `IterationCompleted(output_valid=true)`: Transitions to `CommitMessage`
/// - `IterationCompleted(output_valid=false)`: Stays in Development for retry
/// - `ContinuationTriggered`: Saves context for continuation attempt
/// - `ContinuationSucceeded`: Clears continuation, proceeds to `CommitMessage`
/// - `PhaseCompleted`: Transitions to Review
#[derive(Clone, Serialize, Deserialize, Debug)]
pub enum DevelopmentEvent {
/// Development phase has started.
PhaseStarted,
/// A development iteration has started.
IterationStarted {
/// The iteration number starting.
iteration: u32,
},
/// Development context prepared for an iteration.
///
/// Emitted after `Effect::PrepareDevelopmentContext` completes.
ContextPrepared {
/// The iteration number the context was prepared for.
iteration: u32,
},
/// Development prompt prepared for an iteration.
///
/// Emitted after `Effect::PrepareDevelopmentPrompt` completes.
PromptPrepared {
/// The iteration number the prompt was prepared for.
iteration: u32,
},
/// Developer agent was invoked for an iteration.
///
/// Emitted after `Effect::InvokeDevelopmentAgent` completes.
AgentInvoked {
/// The iteration number the agent was invoked for.
iteration: u32,
},
/// Analysis agent was invoked to verify development results for an iteration.
///
/// Emitted after `Effect::InvokeAnalysisAgent` completes. The analysis agent
/// produces `development_result.xml` by comparing git diff against PLAN.md.
AnalysisAgentInvoked {
/// The iteration number the analysis agent was invoked for.
iteration: u32,
},
/// Development result XML exists and was read successfully for the iteration.
///
/// Emitted after `Effect::ExtractDevelopmentXml` completes.
XmlExtracted {
/// The iteration number the XML was extracted for.
iteration: u32,
},
/// Development result XML missing for an iteration.
///
/// Emitted after `Effect::ExtractDevelopmentXml` when the XML was absent.
XmlMissing {
/// The iteration number the XML was extracted for.
iteration: u32,
/// The invalid output attempt count.
attempt: u32,
},
/// Development result XML validated for an iteration.
///
/// This event captures the parsed development outcome.
XmlValidated {
/// The iteration number the XML was validated for.
iteration: u32,
/// The parsed development status.
status: DevelopmentStatus,
/// Summary of what was accomplished.
summary: String,
/// Files changed in this attempt.
files_changed: Option<Vec<String>>,
/// Agent's recommended next steps.
next_steps: Option<String>,
},
/// Development outcome applied for an iteration.
OutcomeApplied {
/// The iteration number the outcome was applied for.
iteration: u32,
},
/// Development result XML archived for an iteration.
///
/// Emitted after `Effect::ArchiveDevelopmentXml` completes.
XmlArchived {
/// The iteration number the XML was archived for.
iteration: u32,
},
/// Development result XML cleaned before invoking the developer agent.
XmlCleaned {
/// The iteration number the XML was cleaned for.
iteration: u32,
},
/// A development iteration completed with validation result.
IterationCompleted {
/// The iteration number that completed.
iteration: u32,
/// Whether the output passed validation.
output_valid: bool,
},
/// Development phase completed, all iterations done.
PhaseCompleted,
/// Continuation triggered due to partial/failed status.
///
/// Emitted only when development output is valid (parseable) but
/// status is not "completed" (i.e., "partial" or "failed").
ContinuationTriggered {
/// Current iteration number.
iteration: u32,
/// Status from the agent ("partial" or "failed").
status: DevelopmentStatus,
/// Summary of what was accomplished.
summary: String,
/// Files changed in this attempt.
files_changed: Option<Vec<String>>,
/// Agent's recommended next steps.
next_steps: Option<String>,
},
/// Continuation attempt succeeded with status "completed".
ContinuationSucceeded {
/// Current iteration number.
iteration: u32,
/// Number of continuation attempts it took.
total_continuation_attempts: u32,
},
/// Output validation failed (XSD/XML parsing error).
///
/// Emitted when development output cannot be parsed or fails XSD validation.
/// The reducer decides whether to retry (same agent) or switch agents based
/// on the attempt count in state.
OutputValidationFailed {
/// Current iteration number.
iteration: u32,
/// Current invalid output attempt number.
attempt: u32,
},
/// Continuation attempts exhausted without reaching completed status.
///
/// Emitted when development iteration has used all allowed continuation
/// attempts but still hasn't reached status="completed".
ContinuationBudgetExhausted {
/// Current iteration number.
iteration: u32,
/// Total continuation attempts made.
total_attempts: u32,
/// Last status received (Partial or Failed).
last_status: DevelopmentStatus,
},
/// Continuation context file was written successfully.
///
/// Emitted after `WriteContinuationContext` effect completes. The reducer
/// clears the `needs_context_write` flag on this event.
ContinuationContextWritten {
/// Current iteration number.
iteration: u32,
/// Current continuation attempt number.
attempt: u32,
},
/// Continuation context file was cleaned up.
///
/// Emitted after `CleanupContinuationContext` effect completes.
ContinuationContextCleaned,
}